RFR (S): 8019192: StringIndexOutOfBoundsException: in Class.getSimpleName()
christian.thalinger at oracle.com
Wed Sep 25 23:27:04 UTC 2013
8019192: StringIndexOutOfBoundsException: in Class.getSimpleName()
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.
More information about the core-libs-dev