Always enforce ACC_SUPER

Florian Weimer fweimer at redhat.com
Fri May 18 00:49:14 PDT 2012


It has been observed that the easy way of creating non-cloneable classes 
does not work because classes can opt out of the ACC_SUPER handling:

<http://mail.openjdk.java.net/pipermail/core-libs-dev/2010-August/004742.html>

I don't think this is desirable, so I propose a patch to treat all 
classes as if they have ACC_SUPER set.  A new product flag is 
introduced, ForceAccSuper, which defaults to true.  Disabling it 
preserves the old behavior.  I think that assuming the presence of 
ACC_SUPER rather than rejecting classes without it completely is safer 
because non-javac bytecode generators might forget to set ACC_SUPER.

The patch is against the Hotspot in OpenJDK 7u4, but it should apply to 
other versions as well.  It has been tested only lightly (on 7u4 and 8).

I have got a test case, but it uses ASM because to my knowledge, no 
released javac version has produced classes without ACC_SUPER (and I 
need to replace a type name, too).  Should I include the class file 
contents as a string constant?  Then the ASM dependency can go away.

Florian
-- 
Florian Weimer / Red Hat Product Security Team
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jdk7u4.diff
Type: text/x-patch
Size: 1612 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20120518/88009eca/jdk7u4.diff 


More information about the hotspot-dev mailing list