When a named class is not yet loaded, ciEnv::get_klass_by_name_impl() drops the 'Q' prefix and creates an unloaded version of ciInstanceKlass:
http://hg.openjdk.java.net/valhalla/valhalla/file/8f8d2ccfdc40/src/hotspot/share/ci/ciEnv.cpp#l507
if (i > 0 && sym->byte_at(i) == 'Q') {
// An unloaded array class of value types is an ObjArrayKlass, an
// unloaded value type class is an InstanceKlass. For consistency,
// make the signature of the unloaded array of value type use L
// rather than Q.
char *new_name = CURRENT_THREAD_ENV->name_buffer(sym->utf8_length()+1);
strncpy(new_name, (char*)sym->base(), sym->utf8_length());
new_name[i] = 'L';
new_name[sym->utf8_length()] = '\0';
return get_unloaded_klass(accessing_klass, ciSymbol::make(new_name));
}
Later, when "Q"-aware bytecodes such as aaload is compiled by C1, we no longer know that we're dealing with a value klass. Example:
int test() {
V[] a = new V[1]; // V is not yet loaded when this is compiled
return a[0].field;
}
The fix is for ciEnv::get_klass_by_name_impl() to return an unloaded version of ciValueKlass when the 'Q" prefix is specified.
http://hg.openjdk.java.net/valhalla/valhalla/file/8f8d2ccfdc40/src/hotspot/share/ci/ciEnv.cpp#l507
if (i > 0 && sym->byte_at(i) == 'Q') {
// An unloaded array class of value types is an ObjArrayKlass, an
// unloaded value type class is an InstanceKlass. For consistency,
// make the signature of the unloaded array of value type use L
// rather than Q.
char *new_name = CURRENT_THREAD_ENV->name_buffer(sym->utf8_length()+1);
strncpy(new_name, (char*)sym->base(), sym->utf8_length());
new_name[i] = 'L';
new_name[sym->utf8_length()] = '\0';
return get_unloaded_klass(accessing_klass, ciSymbol::make(new_name));
}
Later, when "Q"-aware bytecodes such as aaload is compiled by C1, we no longer know that we're dealing with a value klass. Example:
int test() {
V[] a = new V[1]; // V is not yet loaded when this is compiled
return a[0].field;
}
The fix is for ciEnv::get_klass_by_name_impl() to return an unloaded version of ciValueKlass when the 'Q" prefix is specified.
- duplicates
-
JDK-8214689 [lworld][c1] aaload cannot handle unloaded class
-
- Resolved
-