--- old/hotspot/src/share/vm/classfile/systemDictionary.cpp 2017-09-12 11:16:11.779280436 +0200 +++ new/hotspot/src/share/vm/classfile/systemDictionary.cpp 2017-09-12 11:16:11.639277913 +0200 @@ -61,6 +61,7 @@ #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" #include "oops/typeArrayKlass.hpp" +#include "oops/valueKlass.hpp" #include "prims/jvm.h" #include "prims/jvmtiEnvBase.hpp" #include "prims/resolvedMethodTable.hpp" @@ -288,6 +289,34 @@ return k; } +// Temporary Minimal Value Type support code. Attempt to load VCC for DVT descriptor +Klass* SystemDictionary::resolve_dvt_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) { + assert(EnableMVT && FieldType::is_dvt_postfix(class_name), "Invariant"); + + ResourceMark rm(THREAD); + // Given a "Q-type" descriptor and EnableMVT, original exception is not so interesting + CLEAR_PENDING_EXCEPTION; + + TempNewSymbol vcc_name = SymbolTable::new_symbol(FieldType::dvt_unmangle_vcc(class_name), CHECK_NULL); + Klass* vcc = do_resolve_instance_class_or_null(vcc_name, class_loader, protection_domain, CHECK_NULL); + if (vcc == NULL) { + return NULL; + } + Klass* dvt = do_resolve_instance_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL); + if ((dvt !=NULL) && dvt->is_value() && (ValueKlass::cast(dvt)->get_vcc_klass() == vcc)) { + return dvt; + } + if (vcc->is_instance_klass() && (!InstanceKlass::cast(vcc)->has_vcc_annotation())) { + static const char not_vcc_msg[] = + "Failed to resolve %s, found possible ValueCapableClass name mangle match is not ValueCapableClass annotated: %s"; + size_t buflen = strlen(not_vcc_msg) + class_name->utf8_length() + vcc_name->utf8_length(); + char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); + jio_snprintf(buf, buflen, not_vcc_msg, class_name->as_C_string(), vcc_name->as_C_string()); + THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), buf); + } + return NULL; +} + // Must be called for any super-class or super-interface resolution // during class definition to allow class circularity checking @@ -643,11 +672,22 @@ #endif // INCLUDE_TRACE } +Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, + Handle class_loader, + Handle protection_domain, + TRAPS) { + Klass* k = do_resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD); + if (EnableMVT && (k == NULL) && FieldType::is_dvt_postfix(name)) { + k = resolve_dvt_or_null(name, class_loader, protection_domain, THREAD); + } + return k; +} + // Be careful when modifying this code: once you have run // placeholders()->find_and_add(PlaceholderTable::LOAD_INSTANCE), // you need to find_and_remove it before returning. // So be careful to not exit with a CHECK_ macro betweeen these calls. -Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, +Klass* SystemDictionary::do_resolve_instance_class_or_null(Symbol* name, Handle class_loader, Handle protection_domain, TRAPS) {