RFR (S): 8019192: StringIndexOutOfBoundsException: in Class.getSimpleName()

Christian Thalinger christian.thalinger at oracle.com
Wed Sep 25 16:27:04 PDT 2013


http://cr.openjdk.java.net/~twisti/8019192/webrev/

8019192: StringIndexOutOfBoundsException: in Class.getSimpleName()
Reviewed-by:

This is a race in MemberName's name and type getters.

MemberName's type field is of type Object so it can hold different objects when it gets filled in from the VM.  These types include String and Object[].  On the first invocation the current type if it's not MethodType gets converted to a MethodType.

There is a tiny window where some instanceof check have already been done on one thread and then another thread stores a MethodType.  The following checkcast then fails.

The fix is to make name and type volatile and do the conversion in a synchronized block.  This is okay because it's only done once.

src/share/classes/java/lang/invoke/MemberName.java



More information about the hotspot-compiler-dev mailing list