RFR: 8178480: Wrong exception being thrown on an invalid MethodType

Claes Redestad claes.redestad at oracle.com
Tue Apr 11 19:42:36 UTC 2017


Hi,

JDK-8178387 subtly and inadvertently changed what exception was being 
thrown by LambdaForm.compileToBytecode in
certain cases - this patch reverts this simplification and adds a 
comment to warn against future attempts to
simplify too much..

Bug: https://bugs.openjdk.java.net/browse/JDK-8178480

diff -r 9363dd4a4fb9 
src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
--- 
a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java 
Tue Apr 11 18:57:46 2017 +0200
+++ 
b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java 
Tue Apr 11 21:35:59 2017 +0200
@@ -673,9 +673,7 @@
      /**
       * Generate customized bytecode for a given LambdaForm.
       */
-    static MemberName generateCustomizedCode(LambdaForm form) {
-        final MethodType invokerType = form.methodType();
-
+    static MemberName generateCustomizedCode(LambdaForm form, 
MethodType invokerType) {
          MemberName pregenerated = lookupPregenerated(form, invokerType);
          if (pregenerated != null)  return pregenerated; // 
pre-generated bytecode

diff -r 9363dd4a4fb9 
src/java.base/share/classes/java/lang/invoke/LambdaForm.java
--- a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Tue 
Apr 11 18:57:46 2017 +0200
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Tue 
Apr 11 21:35:59 2017 +0200
@@ -847,9 +847,10 @@
          if (vmentry != null && isCompiled) {
              return;  // already compiled somehow
          }
-        assert(vmentry == null || 
vmentry.getMethodType().basicType().equals(methodType()));
+        MethodType invokerType = methodType(); // forces IAE to happen 
outside try-catch block
+        assert(vmentry == null || 
vmentry.getMethodType().basicType().equals(invokerType));
          try {
-            vmentry = 
InvokerBytecodeGenerator.generateCustomizedCode(this);
+            vmentry = 
InvokerBytecodeGenerator.generateCustomizedCode(this, invokerType);
              if (TRACE_INTERPRETER)
                  traceInterpreter("compileToBytecode", this);
              isCompiled = true;


Thanks!

/Claes


More information about the core-libs-dev mailing list