hotspot/src/share/vm/classfile/classFileParser.cpp
changeset 46327 91576389a517
parent 43977 bf59cd83ea95
parent 46301 57f01b1bd33c
child 46329 53ccc37bda19
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Mon Mar 13 19:59:41 2017 +0000
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Tue Mar 14 14:07:24 2017 -0400
@@ -834,7 +834,7 @@
         const Klass* const k =
           SystemDictionary::resolve_super_or_fail(_class_name,
                                                   unresolved_klass,
-                                                  _loader_data->class_loader(),
+                                                  Handle(THREAD, _loader_data->class_loader()),
                                                   _protection_domain,
                                                   false,
                                                   CHECK);
@@ -863,11 +863,12 @@
                                                                  HASH_ROW_SIZE);
     initialize_hashtable(interface_names);
     bool dup = false;
+    const Symbol* name = NULL;
     {
       debug_only(NoSafepointVerifier nsv;)
       for (index = 0; index < itfs_len; index++) {
         const Klass* const k = _local_interfaces->at(index);
-        const Symbol* const name = InstanceKlass::cast(k)->name();
+        name = InstanceKlass::cast(k)->name();
         // If no duplicates, add (name, NULL) in hashtable interface_names.
         if (!put_after_lookup(name, NULL, interface_names)) {
           dup = true;
@@ -876,7 +877,8 @@
       }
     }
     if (dup) {
-      classfile_parse_error("Duplicate interface name in class file %s", CHECK);
+      classfile_parse_error("Duplicate interface name \"%s\" in class file %s",
+                             name->as_C_string(), CHECK);
     }
   }
 }
@@ -1628,11 +1630,13 @@
       THREAD, NameSigHash*, HASH_ROW_SIZE);
     initialize_hashtable(names_and_sigs);
     bool dup = false;
+    const Symbol* name = NULL;
+    const Symbol* sig = NULL;
     {
       debug_only(NoSafepointVerifier nsv;)
       for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
-        const Symbol* const name = fs.name();
-        const Symbol* const sig = fs.signature();
+        name = fs.name();
+        sig = fs.signature();
         // If no duplicates, add name/signature in hashtable names_and_sigs.
         if (!put_after_lookup(name, sig, names_and_sigs)) {
           dup = true;
@@ -1641,8 +1645,8 @@
       }
     }
     if (dup) {
-      classfile_parse_error("Duplicate field name&signature in class file %s",
-                            CHECK);
+      classfile_parse_error("Duplicate field name \"%s\" with signature \"%s\" in class file %s",
+                             name->as_C_string(), sig->as_klass_external_name(), CHECK);
     }
   }
 }
@@ -2858,7 +2862,6 @@
                                                    NULL,
                                                    CHECK);
 
-    HandleMark hm(THREAD);
     for (int index = 0; index < length; index++) {
       Method* method = parse_method(cfs,
                                     is_interface,
@@ -2885,20 +2888,24 @@
         THREAD, NameSigHash*, HASH_ROW_SIZE);
       initialize_hashtable(names_and_sigs);
       bool dup = false;
+      const Symbol* name = NULL;
+      const Symbol* sig = NULL;
       {
         debug_only(NoSafepointVerifier nsv;)
         for (int i = 0; i < length; i++) {
           const Method* const m = _methods->at(i);
+          name = m->name();
+          sig = m->signature();
           // If no duplicates, add name/signature in hashtable names_and_sigs.
-          if (!put_after_lookup(m->name(), m->signature(), names_and_sigs)) {
+          if (!put_after_lookup(name, sig, names_and_sigs)) {
             dup = true;
             break;
           }
         }
       }
       if (dup) {
-        classfile_parse_error("Duplicate method name&signature in class file %s",
-                              CHECK);
+        classfile_parse_error("Duplicate method name \"%s\" with signature \"%s\" in class file %s",
+                               name->as_C_string(), sig->as_klass_external_name(), CHECK);
       }
     }
   }
@@ -4388,10 +4395,12 @@
     }
 
     Reflection::VerifyClassAccessResults vca_result =
-      Reflection::verify_class_access(this_klass, super, false);
+      Reflection::verify_class_access(this_klass, InstanceKlass::cast(super), false);
     if (vca_result != Reflection::ACCESS_OK) {
       ResourceMark rm(THREAD);
-      char* msg =  Reflection::verify_class_access_msg(this_klass, super, vca_result);
+      char* msg = Reflection::verify_class_access_msg(this_klass,
+                                                      InstanceKlass::cast(super),
+                                                      vca_result);
       if (msg == NULL) {
         Exceptions::fthrow(
           THREAD_AND_LOCATION,
@@ -4420,10 +4429,12 @@
     Klass* const k = local_interfaces->at(i);
     assert (k != NULL && k->is_interface(), "invalid interface");
     Reflection::VerifyClassAccessResults vca_result =
-      Reflection::verify_class_access(this_klass, k, false);
+      Reflection::verify_class_access(this_klass, InstanceKlass::cast(k), false);
     if (vca_result != Reflection::ACCESS_OK) {
       ResourceMark rm(THREAD);
-      char* msg =  Reflection::verify_class_access_msg(this_klass, k, vca_result);
+      char* msg = Reflection::verify_class_access_msg(this_klass,
+                                                      InstanceKlass::cast(k),
+                                                      vca_result);
       if (msg == NULL) {
         Exceptions::fthrow(
           THREAD_AND_LOCATION,
@@ -5377,7 +5388,7 @@
   // Allocate mirror and initialize static fields
   // The create_mirror() call will also call compute_modifiers()
   java_lang_Class::create_mirror(ik,
-                                 _loader_data->class_loader(),
+                                 Handle(THREAD, _loader_data->class_loader()),
                                  module_handle,
                                  _protection_domain,
                                  CHECK);
@@ -5942,10 +5953,11 @@
         "Interfaces must have java.lang.Object as superclass in class file %s",
         CHECK);
     }
+    Handle loader(THREAD, _loader_data->class_loader());
     _super_klass = (const InstanceKlass*)
                        SystemDictionary::resolve_super_or_fail(_class_name,
                                                                super_class_name,
-                                                               _loader_data->class_loader(),
+                                                               loader,
                                                                _protection_domain,
                                                                true,
                                                                CHECK);
@@ -5987,6 +5999,7 @@
 
   _all_mirandas = new GrowableArray<Method*>(20);
 
+  Handle loader(THREAD, _loader_data->class_loader());
   klassVtable::compute_vtable_size_and_num_mirandas(&_vtable_size,
                                                     &_num_miranda_methods,
                                                     _all_mirandas,
@@ -5994,7 +6007,7 @@
                                                     _methods,
                                                     _access_flags,
                                                     _major_version,
-                                                    _loader_data->class_loader(),
+                                                    loader,
                                                     _class_name,
                                                     _local_interfaces,
                                                     CHECK);