RFR: 8065172: More core reflection final and volatile annotations

Peter Levart peter.levart at gmail.com
Mon Dec 8 21:52:19 UTC 2014


On 12/08/2014 10:24 PM, Peter Levart wrote:
> "Interned" Types can not be guaranteed, since they are rooted on 
> members of j.l.Class (Method, Field, Constructor), which can be GC-ed 
> because of either:
>
> - class redefinition
> - memory pressure (see j.l.Class.reflectionData field, which points to 
> SoftReference<ReflectionData>)
>
> ...and next time you request them, new instances will be created and 
> new instances of Types with them.
>
> Regards, Peter

Even in the absence of above, the Method, Field, Constructor objects 
obtained from j.l.Class methods are always copied from the "root" 
objects (because they are mutable - setAccessible()) and with copying, 
you always get a "fresh" object that has an uninitialized 'genericInfo' 
field.

Even in the absence of all above, by CAS-ing, you don't actually get 
"interning", since two Type objects from different sources (for example 
generic return types of two different methods) can be equal, but they 
will not be same objects. So I can't see a purpose here. We would have 
to implement Type interning in a global pool to achieve that (like it is 
guaranteed for j.l.Class objects).


Regards, Peter




More information about the core-libs-dev mailing list