<init> and factories

Dan Smith daniel.smith at oracle.com
Thu Oct 17 22:51:50 UTC 2019


> On Oct 17, 2019, at 2:00 PM, John Rose <john.r.rose at oracle.com> wrote:
> 
> If the translation strategy were adjusted to translate every
> new Foo() expression as invokestatic <new>

One interesting thing we might consider: 'invokestatic Foo.<new>(...)...' could implicitly be rewritten to 'new Foo; dup; invokespecial ...' if there is no declared '<new>' method. This lets us immediately implement the translation strategy you propose, without waiting for classes to be recompiled. It also gives us an atomic "newdupinit" bytecode for free.

(I recognize, however, that most implicit magic like this that we've considered in the past has been dropped because the JVM doesn't like implicit magic.)



More information about the valhalla-spec-experts mailing list