Merge
authorrehn
Thu, 02 Mar 2017 14:19:49 +0100
changeset 46303 9cb271e01558
parent 46302 89b28b206eb2 (current diff)
parent 46301 57f01b1bd33c (diff)
child 46304 8d4d88f90669
Merge
--- a/hotspot/src/share/vm/classfile/classFileError.cpp	Thu Mar 02 09:51:47 2017 +0100
+++ b/hotspot/src/share/vm/classfile/classFileError.cpp	Thu Mar 02 14:19:49 2017 +0100
@@ -68,6 +68,16 @@
                      msg, index, name, _class_name->as_C_string());
 }
 
+void ClassFileParser::classfile_parse_error(const char* msg,
+                                            const char* name,
+                                            const char* signature,
+                                            TRAPS) const {
+  assert(_class_name != NULL, "invariant");
+  ResourceMark rm(THREAD);
+  Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(),
+                     msg, name, signature, _class_name->as_C_string());
+}
+
 PRAGMA_DIAG_POP
 
 void StackMapStream::stackmap_format_error(const char* msg, TRAPS) {
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Thu Mar 02 09:51:47 2017 +0100
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Thu Mar 02 14:19:49 2017 +0100
@@ -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);
     }
   }
 }
@@ -2884,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);
       }
     }
   }
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp	Thu Mar 02 09:51:47 2017 +0100
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp	Thu Mar 02 14:19:49 2017 +0100
@@ -301,6 +301,10 @@
                              int index,
                              const char *name,
                              TRAPS) const;
+  void classfile_parse_error(const char* msg,
+                             const char* name,
+                             const char* signature,
+                             TRAPS) const;
 
   inline void guarantee_property(bool b, const char* msg, TRAPS) const {
     if (!b) { classfile_parse_error(msg, CHECK); }