Loosening requirements for super() invocation

Robbe Pincket robbepincket at live.be
Tue Jan 24 23:18:20 UTC 2023


On 2023-01-24 00:42 UTC, Brian Goetz wrote:

> Yes, substitute "normal completion" for "exit".

I think I see what you mean. Still I think the original might be more descriptive?

> * Add the requirement that `super()` and `this()` may not appear
> within any `try { }` block

Additionally, I think it would need to be extended to prevent calling
`super()` or `this()` in lambdas? Or to mirror some other parts of the
spec, a constructor call can’t be enclosed by a try block?


----

On 2023-01-24 20:11 UTC, Archie Cobbs wrote:

> This made me realize there is another missing requirement:
>
> - Upon normal return from a constructor, the `this` reference must be DA
>
> Wouldn't that requirement subsume the one about try blocks? What I mean is,
the normal dataflow analysis already takes care of try blocks, and what we
care about is the DA/DU state when the constructor eventually returns.
>
> Thanks,
> -Archie

I think that only prevents "try catch" and not "try finally"
(or "try with resources").

Actually that made me realize that in "try catch finally" or
"try catch with resources", `this` or `super` calls shouldn't
appear in any of the catch blocks either.

----

On 2023-01-24 20:21 UTC, Brian Goetz wrote:

> You can simplify the rule about try blocks to:
>
>  - if `this` is DU on entry to a try block, it must be DU on normal
completion of the try block.
>
> Can you simplify further, while still preventing `this` calls inside a
try block?  I don't think so, since we might want to allow a try block
before the super/this call.

What about
 - At each point in the program, if `this` is not DA, it must be DU

I think that covers all try cases?

Kind regards
Robbe Pincket
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230124/d9335cd1/attachment-0001.htm>


More information about the amber-dev mailing list