Code Review for jdk

Prepared by:twisti on Thu Sep 26 13:10:43 PDT 2013
Workspace:/Users/twisti/ws/jdk8-tl/jdk
Compare against: http://hg.openjdk.java.net/jdk8/tl/jdk
Summary of changes: 76 lines changed: 35 ins; 8 del; 33 mod; 963 unchg
Patch of changes: jdk.patch
Author comments:
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.

Bug id: 8019192
Legend: Modified file
Deleted file
New file

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/classes/java/lang/invoke/MemberName.java

76 lines changed: 35 ins; 8 del; 33 mod; 963 unchg

This code review page was prepared using /Users/twisti/bin/webrev (vers 23.18-hg-never-dev).