< prev index next >

hotspot/src/share/vm/classfile/systemDictionary.cpp

Print this page

        

@@ -59,10 +59,11 @@
 #include "oops/objArrayKlass.hpp"
 #include "oops/objArrayOop.inline.hpp"
 #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"
 #include "prims/methodHandles.hpp"
 #include "runtime/arguments.hpp"

@@ -286,10 +287,38 @@
     k = TypeArrayKlass::cast(k)->array_klass(fd.dimension(), CHECK_NULL);
   }
   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
 // super-interface callers:
 //    parse_interfaces - for defineClass & jvmtiRedefineClasses

@@ -641,15 +670,26 @@
     event.commit();
   }
 #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) {
   assert(name != NULL && !FieldType::is_array(name) &&
          !FieldType::is_obj(name)  && !FieldType::is_valuetype(name), "invalid class name");
< prev index next >