Dynamic Constants adoption IRL

forax at univ-mlv.fr forax at univ-mlv.fr
Thu Apr 15 18:52:34 UTC 2021


----- Mail original -----
> De: "Paul Sandoz" <paul.sandoz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Maxim Degtyarev" <mdegtyarev at gmail.com>, "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Jeudi 15 Avril 2021 20:34:10
> Objet: Re: Dynamic Constants adoption IRL

> A while back we also did experiments in the java source compiler, compiling
> non-capturing method refs or lambda expressions to condy rather than indy. This
> is more efficient for duplicates. It’s still in the condy-folding branch of the
> amber repo, but it never made it into the mainline, not sure why.
> 
> For more details see presentation at JVMLS 2018
> 
>  https://www.youtube.com/watch?v=knPSQyUtM4I&list=PLX8CzqL3ArzVnxC6PYxMlngEMv3W1pIkn&index=10
> 
> As Remi indicated it is anticipated condy will be used more in language
> translation strategies of future platform features.
> 
> I am not aware of any other JVM language runtimes using condy at the moment.

This remember me that they were talks to use condy in Clojure (to lazily initialize builtin functions), the main issue at that time was that most people were still using Java 8 and not Java 11.

> 
> Paul.

Rémi

> 
>> On Apr 15, 2021, at 9:17 AM, forax at univ-mlv.fr wrote:
>> 
>> ----- Mail original -----
>>> De: "Maxim Degtyarev" <mdegtyarev at gmail.com>
>>> À: "Remi Forax" <forax at univ-mlv.fr>
>>> Cc: "amber-dev" <amber-dev at openjdk.java.net>
>>> Envoyé: Jeudi 15 Avril 2021 17:53:05
>>> Objet: Re: Dynamic Constants adoption IRL
>> 
>>> I'm asking about JEP 309: Dynamic Class-File Constants.
>>> 
>>> [1] https://openjdk.java.net/jeps/309
>> 
>> Ok, got it,
>> given that it's not yet supported by Java the language (see [1]), it's not used
>> a lot.
>> 
>> I know, it was used by an early prototype of jextract (Foreign Linker API of
>> Panama) but jextract later switches to use lazy class loading instead because
>> people did not want to use a jar without having a corresponding Java source
>> code.
>> 
>> Now, condy is an integral part of the current strategy to implement generics
>> over primitive class (Project Valhalla, see [2] for more detail).
>> So if it goes as planned, a lot of Java classes that uses a parameterized type
>> over a type variable like List<T> will contain a condy.
>> 
>> regards,
>> Rémi
>> 
>> [1] https://bugs.openjdk.java.net/browse/JDK-8209964
>> [2] http://cr.openjdk.java.net/~jrose/values/parametric-vm.pdf
>> 
>> 
>> 
>>> 
>>> El jue, 15 abr 2021 a las 18:37, Remi Forax (<forax at univ-mlv.fr>) escribió:
>>>> 
>>>> ----- Mail original -----
>>>>> De: "Maxim Degtyarev" <mdegtyarev at gmail.com>
>>>>> À: "amber-dev" <amber-dev at openjdk.java.net>
>>>>> Envoyé: Jeudi 15 Avril 2021 17:04:15
>>>>> Objet: Dynamic Constants adoption IRL
>>>> 
>>>>> Hello,
>>>>> 
>>>>> Is there currently real-life examples of dynamic constants adoption in
>>>>> programming languages targeting JVM or either libraries and
>>>>> frameworks?
>>>>> Or are there currently no projects using dynamic constants? Maybe any
>>>>> planned in the future?
>>>>> Quick googling was unsuccessful.
>>>> 
>>>> It depends what you mean by dynamic constant.
>>>> For the VM, a simple static final field that is not a primitive types or String
>>>> is a dynamic constant.
>>>> 
>>>> A lambda that doesn't capture any variable value is a dynamic constant.
>>>> 
>>>> A VarHandle, used for concurrency or by the Foreign Memory API is a dynamic
>>>> constant, the same goes for the MethodHandles.
>>>> 
>>>> The Vector API relies on the VectorSpecies being a dynamic constant.
>>>> 
>>>> System.out and System.err, the ClassValue for a particular class, or
>>>> Thread.currentThread() can all be seen as dynamic constants (but they are not
>>>> constant for the JIT).
>>>> 
>>>> The classData of an hidden class is also a dynamic constant [1].
>>>> 
>>>> regards,
>>>> Rémi
>>>> 
>>>> [1]
>>>> https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/invoke/MethodHandles.html#classData(java.lang.invoke.MethodHandles.Lookup,java.lang.String,java.lang.Class)


More information about the amber-dev mailing list