Hi Rémi,

> - if you want the bytecode getstatic to access the field, here you need the VM
>   to be changed, it's in the roadmap for the VM but not yet implemented

I wish we could still access the constants with bytecode getstatic, which is 
simple enough for us to use and read, but I do not know which version of Java 
will support the feature. Luckily, no rush to have the native lazy constants 
support, we can wait ;-)

    Thanks for your suggestions and detailed explaination.

Cheers,
Daniel.Sun
On 2020/01/12 15:19:08, Remi Forax <fo...@univ-mlv.fr> wrote: 
> Several things to know:
> - you can rewrite all access to a field marked @Lazy to use a constant 
> dynamic,
>   that part can already be implemented. If you want to keep the compatibility
>   with Java 8, it means that you have to have two translations one for Java 
> 11+
>   and one for Java 10-.
> - if you want the bytecode getstatic to access the field, here you need the VM
>   to be changed, it's in the roadmap for the VM but not yet implemented
> - you don't care about getstatic because you can simulate it with an indy*
>   (which means that even with @CompileStatic you will use indy)
>   in that case you can implement it but it means that all codes that use
>   a combination of @Lazy + @CompileStatic has to be recompiled.
> 
> Rémi
> 
> * there is actually no support of ldc constantdynamic in java.lang.invoke.
> 
> 
> ----- Mail original -----
> > De: "sunlan" <sun...@apache.org>
> > À: "dev" <d...@groovy.incubator.apache.org>
> > Envoyé: Dimanche 12 Janvier 2020 13:34:22
> > Objet: About native support for lazy constants
> 
> > Hi all,
> > 
> >      I read an article[1] about the new features of Java 11 just now, and
> > find "JEP 309: Dynamic Class-File Constants"[2] can help us implement lazy
> > constants elegantly, e.g. `@Lazy static final Object SOME_LAZY_CONST =
> > <heavy lifts>`. The feature is very useful, so I propose to add *native*
> > support for lazy constants in some future version of Groovy.
> > 
> >      Any thoughts?
> > 
> > Cheers,
> > Daniel.Sun
> > [1]
> > https://javabeginnerstutorial.com/core-java-tutorial/java-11-new-features/
> > [2] https://openjdk.java.net/jeps/309
> > 
> > 
> > 
> > -----
> > Apache Groovy committer & PMC member
> > Blog: http://blog.sunlan.me
> > Twitter: @daniel_sun
> > 
> > --
> > Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
> r
> 

Reply via email to