[9] RFR(S): 8164612: NoSuchMethodException when method name contains NULL or Latin-1 supplement character
Tobias Hartmann
tobias.hartmann at oracle.com
Tue Oct 18 13:25:02 UTC 2016
Hi,
please review the following patch:
https://bugs.openjdk.java.net/browse/JDK-8164612
http://cr.openjdk.java.net/~thartmann/8164612/webrev.00/
The test executes Java Script code that defines getter methods containing Latin-1 supplement characters (0x80 - 0xFF). Those methods are registered at runtime through anonymous classes via Unsafe_DefineAnonymousClass. When calling a method, the VM fails with a NoSuchMethodException in MethodHandles::resolve_MemberName().
The failure happens while looking up the method name symbol in java_lang_String::as_symbol_or_null() [1]:
544 jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0);
545 const char* base = UNICODE::as_utf8(position, length);
546 return SymbolTable::probe(base, length);
If Compact Strings is enabled, we pass the Latin-1 encoded method name to UNICODE::as_utf8() and probe for the UTF-8 String in the SymbolTable. Since the Latin-1 method name contains non-ASCII characters, the length of the resulting UTF-8 String is larger (characters >= 0x80 are encoded as two bytes in UTF-8). However, we pass the shorter Latin-1 length to SymbolTable::probe() resulting in a lookup failure.
I fixed this by passing the String length by reference to UNICODE::as_utf8(). I also refactored the related code in utf8.cpp, added comments and updated the callers.
Tested with regression test and hs-comp PIT RBT (running).
Thanks,
Tobias,
[1] http://hg.openjdk.java.net/jdk9/hs/hotspot/file/652537a80080/src/share/vm/classfile/javaClasses.cpp#l535
More information about the hotspot-dev
mailing list