On 12/08/2014 09:31 PM, Martin Buchholz wrote:
(sorry for missing this message earlier)
On Tue, Dec 2, 2014 at 1:49 AM, Paul Sandoz <paul.san...@oracle.com> wrote:
http://cr.openjdk.java.net/~martin/webrevs/openjdk9/core-reflection-more-safety/
Hi Martin,
I see lots of "changes" in javadocs that appear to have same text. Do
you know why?
I am not convinced about the use of CAS. If we can get away with just volatile
fields I think the code is simpler. Are you concerned there are cases of
identity and mutability?
Yes, I'm trying to write this code in the safest possible way, never
for example returning distinct but equivalent Type objects to a user,
possibly triggering very obscure bugs in non-jdk code. If this code
is not performance crititcal (which I believe to be true), doing it
this way seems best. If it is performance crititcal, we can switch to
Unsafe CAS or even use Unsafe CAS plus risky relaxed reads as Peter
has suggested (which would improve performance on weak-memory-model
platforms as seen on other email threads).
"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