On Thu, 12 Jan 2023 15:10:19 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

> Interesting example - I thought you might have been referring to a case where 
> the class being analyzed was itself an exception.

Yes - although that example doesn't compile (oops!). Just replace `catch 
(RuntimeException e)` with `catch (ThrownThis e)` and it should.

> Question - shouldn't we conclude that this leak when we see throw this ? E.g. 
> what if the constructor did not have a catch (or if the catch was of a 
> different type) ?

A thorough analysis would evaluate whether the exception was caught or not. But 
you're right - since we're not doing a thorough analysis, we should immediately 
declare a leak anytime we see `throw x` where `x` is a possible direct or 
indirect reference. Of course, this scenario should be unlikely in normal code.

I will add a check for that.

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

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

Reply via email to