You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -235,16 +237,93 @@ Replace `<JREKEY>` with the uppercased `jreKey` value.
235
237
bash scripts/unit.sh
236
238
```
237
239
240
+
## Helper Functions
241
+
242
+
These are available in `src/java/jres/` and called by `BaseJRE` internally. You may need them if you implement a JRE that does not use `BaseJRE` (e.g. Zing).
243
+
244
+
| Function | Purpose |
245
+
|----------|---------|
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 |
cf set-env myapp MEMORY_CALCULATOR_HEADROOM 10 # % headroom to leave
285
+
```
286
+
287
+
### JVMKill Agent
288
+
289
+
Native agent (`.so`) that kills the JVM on `OutOfMemoryError` or memory allocation failure, causing CF to restart the container cleanly instead of hanging.
**`findJavaHome` fails** — the tarball extracted to a directory that matches neither `dirPrefixes` nor `dirExacts`. Check the extraction layout:
304
+
**`findJavaHome` fails** — tarball extracted to directory matching neither `dirPrefixes` nor `dirExacts`. Check layout:
241
305
242
306
```bash
243
307
tar tf my-jre.tar.gz | head -5
244
308
```
245
309
246
310
Add the top-level directory prefix/name to `dirPrefixes`/`dirExacts` accordingly.
247
311
248
-
**Install fails with "No matching dependency"** — check the `jreKey` in `newBaseJRE` matches the `name:` field in `manifest.yml` exactly.
312
+
**Install fails with "No matching dependency"** — `jreKey` in `newBaseJRE` must match the `name:` field in `manifest.yml` exactly.
313
+
314
+
**`extraFinalizeOpts` not applied** — set the function on `b` (the `BaseJRE` value) before wrapping: `b.extraFinalizeOpts = func() string { ... }`. Setting it after `return &MyJRE{b}` has no effect.
315
+
316
+
**JAVA_HOME not set at runtime** — verify `profile.d/java.sh` exists:
**Memory calculator not running** — verify binary exists and `MEMORY_LIMIT` is set:
323
+
324
+
```bash
325
+
cf ssh myapp -- ls /home/vcap/deps/0/jre/bin/java-buildpack-memory-calculator-*
326
+
cf ssh myapp -- echo $MEMORY_LIMIT
327
+
```
249
328
250
-
**`extraFinalizeOpts` not applied** — ensure the function is set on `b` (the `BaseJRE` value) before wrapping it: `b.extraFinalizeOpts = func() string { ... }`. Setting it on the returned struct after `return &MyJRE{b}` has no effect.
0 commit comments