RFR: 8372373: Make ResolutionErrorEntry's interface less susceptible to memory leaks

Johan Sjölen jsjolen at openjdk.org
Sat Nov 22 12:14:22 UTC 2025


Hi,

Ioi discovered that the `ResolutionErrorEntry`'s two constructors are working in two different ways: One of them copies the string, and the other one requires the string to already be on the CHeap. This leads to code that's difficult to understand and increases the risk of memory leaks. This PR makes the interface more uniform.

I've done a few style changes as well, hope those are OK.

Here's a list of the callsites I found:

constantPool.cpp:992:
  Strings are Resource-allocated and strdupped
cpCache.cpp:746
  Strings are Resource-allocated and strupped
instanceKlass.cpp:317
  Was manually CHeap allocated and transferred to REE, now wrapped in stringStream and strdupped
instanceKlass.cpp:361
  Was manually CHeap allocated and transferred to REE, now wrapped in stringStream and strdupped
systemDictionary.cpp:1872
  Potential memory leak via set_nest_host_error

-------------

Commit messages:
 - Make ResolutionErrorEntry more uniform

Changes: https://git.openjdk.org/jdk/pull/28466/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28466&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8372373
  Stats: 33 lines in 3 files changed: 2 ins; 17 del; 14 mod
  Patch: https://git.openjdk.org/jdk/pull/28466.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28466/head:pull/28466

PR: https://git.openjdk.org/jdk/pull/28466


More information about the hotspot-dev mailing list