Skip to content

Commit 11837e2

Browse files
committed
docs: correct JRE interface, env var, and example accuracy in IMPLEMENTING_JRES.md
Addresses PR review: - Add missing MemoryCalculatorCommand() to the jres.JRE interface excerpt. - Add the missing `type MinimalJRE` so the no-extra-opts example compiles. - Correct detection/version docs to match DetectJREByEnv/GetJREVersion: the documented JBP_CONFIG_<NAME>_JRE name (recommended) or the auto-generated JBP_CONFIG_<KEY> alias. JBP_CONFIG_COMPONENTS is deprecated and unused for selection; there is no BP_JAVA_<JREKEY> variable.
1 parent 358bb87 commit 11837e2

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

docs/IMPLEMENTING_JRES.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ type JRE interface {
4949
Finalize() error
5050
JavaHome() string
5151
Version() string
52+
// MemoryCalculatorCommand returns the shell snippet prepended to the
53+
// container startup command; "" when the memory calculator is not installed.
54+
MemoryCalculatorCommand() string
5255
}
5356
```
5457

@@ -182,6 +185,8 @@ func NewGraalVMJRE(ctx *common.Context) *GraalVMJRE {
182185
If no JRE-specific opts are needed, omit `extraFinalizeOpts`:
183186

184187
```go
188+
type MinimalJRE struct{ BaseJRE }
189+
185190
func NewMinimalJRE(ctx *common.Context) *MinimalJRE {
186191
b := newBaseJRE(ctx, "Minimal JRE", "minimal", []string{"jre"}, nil, "")
187192
// extraFinalizeOpts left nil — BaseJRE writes only -Djava.io.tmpdir=$TMPDIR
@@ -220,12 +225,13 @@ var _ = Describe("MyJRE", func() {
220225

221226
### Detection
222227

223-
`BaseJRE.Detect()` calls `DetectJREByEnv(jreKey)` which returns `true` when:
224-
- `JBP_CONFIG_<JREKEY>_JRE` is set, or
225-
- `JBP_CONFIG_COMPONENTS` names this JRE, or
226-
- `BP_JAVA_<JREKEY>` is set
228+
`BaseJRE.Detect()` calls `DetectJREByEnv(jreKey)` which returns `true` when **either**:
229+
- the documented `JBP_CONFIG_<NAME>_JRE` name is set (e.g. `JBP_CONFIG_OPEN_JDK_JRE`) — the **recommended** form, defined for each built-in provider in the `jreNameToDocumentedEnvVar` map, or
230+
- the auto-generated `JBP_CONFIG_<KEY>` alias is set — `jreKey` uppercased with `-` → `_` (e.g. `JBP_CONFIG_OPENJDK`).
231+
232+
The documented `_JRE` names originate from the Ruby buildpack and are kept for backward compatibility, but they remain the recommended, fully-supported form: the buildpack points users to them, and (unlike the auto-generated alias) they also drive memory-calculator config. `JBP_CONFIG_COMPONENTS` is **deprecated** and is not used for JRE selection; there is no `BP_JAVA_<JREKEY>` detection variable.
227233

228-
Replace `<JREKEY>` with the uppercased `jreKey` value.
234+
A **new custom JRE** responds only to the auto-generated `JBP_CONFIG_<KEY>` name unless you add an entry to `jreNameToDocumentedEnvVar`.
229235

230236
### Running tests
231237

@@ -243,16 +249,16 @@ These are available in `src/java/jres/` and called by `BaseJRE` internally. You
243249

244250
| Function | Purpose |
245251
|----------|---------|
246-
| `GetJREVersion(ctx, jreKey)` | Resolves version from `BP_JAVA_VERSION`, `JBP_CONFIG_<KEY>_JRE`, then manifest default |
247-
| `DetectJREByEnv(jreKey)` | Returns `true` if `JBP_CONFIG_<KEY>_JRE` or `JBP_CONFIG_COMPONENTS` selects this JRE |
252+
| `GetJREVersion(ctx, jreKey)` | Resolves version from `BP_JAVA_VERSION`, then the documented `JBP_CONFIG_<NAME>_JRE` or auto-generated `JBP_CONFIG_<KEY>` alias, then manifest default |
253+
| `DetectJREByEnv(jreKey)` | Returns `true` if the documented `JBP_CONFIG_<NAME>_JRE` name or the auto-generated `JBP_CONFIG_<KEY>` alias selects this JRE |
248254
| `WriteJavaHomeProfileD(ctx, jreDir, javaHome)` | Writes `profile.d/java.sh` exporting `JAVA_HOME`, `JRE_HOME`, and `PATH` |
249255
| `WriteJavaOpts(ctx, opts)` | Appends opts to the centralized `.opts` file consumed by `profile.d/00_java_opts.sh` |
250256
| `common.DetermineJavaVersion(javaHome)` | Reads `$JAVA_HOME/release` → returns Java major version as int |
251257

252258
### Version resolution priority
253259

254260
1. `BP_JAVA_VERSION` (e.g. `21`, `21.*`, `21.0.5`)
255-
2. `JBP_CONFIG_<JREKEY>_JRE` with `version:` field
261+
2. The documented `JBP_CONFIG_<NAME>_JRE` name, or the auto-generated `JBP_CONFIG_<KEY>` alias, with a `version:` field
256262
3. Manifest `default_versions` entry for this JRE key
257263

258264
### profile.d output

0 commit comments

Comments
 (0)