Dynamic Constants adoption IRL
forax at univ-mlv.fr
forax at univ-mlv.fr
Thu Apr 15 16:17:50 UTC 2021
----- 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