RFR: 8300032: DwarfParser resource leak

Daniel Jeliński djelinski at openjdk.org
Fri Jan 13 07:49:11 UTC 2023


On Thu, 12 Jan 2023 21:26:09 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

> This seems like a pretty serious flaw with using Lambdas and Cleaners that probably should be brought up with the libs and language teams.

They are aware of this issue; it's even mentioned in [this article](https://inside.java/2022/05/25/clean-cleaner/):
> For example, if `chars` is a field, the lambda could refer to `this.chars` inadvertently capturing `this`. [...] One way to ensure that this is not captured is to create the lambda in a static method. Its scope does not have this so it cannot accidentally be captured.

As far as I could tell, the cleaners you pointed out use local variables only. As long as the lambda does not reference any object fields or instance methods, `this` is not captured.

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

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


More information about the serviceability-dev mailing list