changeset 4239:071ffa642203

80006267: InterfaceMethod_ref should allow invokestatic and invokespecial Contributed-by: Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
author mduigou
date Fri, 08 Mar 2013 14:35:22 -0800
parents b2c8e33dcd1c
children 273d4c638258
files src/share/vm/classfile/classFileParser.cpp src/share/vm/classfile/genericSignatures.cpp src/share/vm/interpreter/linkResolver.cpp src/share/vm/prims/methodHandles.cpp
diffstat 4 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/classFileParser.cpp	Wed Feb 20 13:10:16 2013 -0800
+++ b/src/share/vm/classfile/classFileParser.cpp	Fri Mar 08 14:35:22 2013 -0800
@@ -466,14 +466,19 @@
               ref_index, CHECK_(nullHandle));
             break;
           case JVM_REF_invokeVirtual:
-          case JVM_REF_invokeStatic:
-          case JVM_REF_invokeSpecial:
           case JVM_REF_newInvokeSpecial:
             check_property(
               tag.is_method(),
               "Invalid constant pool index %u in class file %s (not a method)",
               ref_index, CHECK_(nullHandle));
             break;
+          case JVM_REF_invokeStatic:
+          case JVM_REF_invokeSpecial:
+            check_property(
+              tag.is_method() || tag.is_interface_method(),
+              "Invalid constant pool index %u in class file %s (not a method)",
+              ref_index, CHECK_(nullHandle));
+            break;
           case JVM_REF_invokeInterface:
             check_property(
               tag.is_interface_method(),
@@ -3354,7 +3359,7 @@
     }
 
     if (TraceClassLoadingPreorder) {
-      tty->print("[Loading %s", name->as_klass_external_name());
+      tty->print("[Loading %s", (name != NULL) ? name->as_klass_external_name() : "NoName");
       if (cfs->source() != NULL) tty->print(" from %s", cfs->source());
       tty->print_cr("]");
     }
--- a/src/share/vm/classfile/genericSignatures.cpp	Wed Feb 20 13:10:16 2013 -0800
+++ b/src/share/vm/classfile/genericSignatures.cpp	Fri Mar 08 14:35:22 2013 -0800
@@ -268,8 +268,15 @@
     Klass* outer = SystemDictionary::find(
         outer_name, class_loader, protection_domain, CHECK_NULL);
     if (outer == NULL && !THREAD->is_Compiler_thread()) {
-      outer = SystemDictionary::resolve_super_or_fail(original_name,
-          outer_name, class_loader, protection_domain, false, CHECK_NULL);
+      if (outer_name == ik->super()->name()) {
+        outer = SystemDictionary::resolve_super_or_fail(original_name, outer_name,
+                                                        class_loader, protection_domain,
+                                                        false, CHECK_NULL);
+      }
+      else {
+        outer = SystemDictionary::resolve_or_fail(outer_name, class_loader,
+                                                  protection_domain, false, CHECK_NULL);
+      }
     }
 
     InstanceKlass* outer_ik;
--- a/src/share/vm/interpreter/linkResolver.cpp	Wed Feb 20 13:10:16 2013 -0800
+++ b/src/share/vm/interpreter/linkResolver.cpp	Fri Mar 08 14:35:22 2013 -0800
@@ -1007,11 +1007,13 @@
   }
   // check if public
   if (!sel_method->is_public()) {
-    ResourceMark rm(THREAD);
-    THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
-              Method::name_and_sig_as_C_string(recv_klass(),
-                                                      sel_method->name(),
-                                                      sel_method->signature()));
+    if (!(sel_method->is_private() && sel_method->is_synthetic())) {
+      ResourceMark rm(THREAD);
+      THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
+                Method::name_and_sig_as_C_string(recv_klass(),
+                                                 sel_method->name(),
+                                                 sel_method->signature()));
+    }
   }
   // check if abstract
   if (check_null_and_abstract && sel_method->is_abstract()) {
--- a/src/share/vm/prims/methodHandles.cpp	Wed Feb 20 13:10:16 2013 -0800
+++ b/src/share/vm/prims/methodHandles.cpp	Fri Mar 08 14:35:22 2013 -0800
@@ -186,6 +186,11 @@
     flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT);
   } else if (mods.is_static()) {
     flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT);
+    // Check if this method is a lambda method that is genrated as
+    // private static method.
+    if (m->is_private() && m->is_synthetic() && m->method_holder()->is_interface()) {
+      vmindex = klassItable::compute_itable_index(m);
+    }
   } else if (receiver_limit != mklass &&
              !receiver_limit->is_subtype_of(mklass)) {
     return NULL;  // bad receiver limit