On Tue, 28 Sep 2021 09:50:45 GMT, Claes Redestad <redes...@openjdk.org> wrote:

> Does `Reflection::new_method/...` (which are natively implemented 
> constructors) need any special treatment for them to follow the same 
> semantics as a Java-based constructor w.r.t. final field writes? Or could 
> they be rewritten to call the equivalent java constructor in each case?
> 

I don't think they need special treatment currently. The 
Method/Constructor/Field instances created by native code and returned via 
native methods are always the `root` objects that are never handed to user 
code. They are used internally in the caches and are published to other threads 
via volatile field write/read (see `java.lang.Class.ReflectionData`). User code 
only sees copies of those objects which are performed using constructors.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5694

Reply via email to