changeset 44592:6b028630b652

8178480: Wrong exception being thrown on an invalid MethodType Reviewed-by: psandoz
author redestad
date Tue, 11 Apr 2017 22:32:49 +0200
parents b9bf065070fe
children 273249225894
files jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Tue Apr 11 18:57:46 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Tue Apr 11 22:32:49 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
 
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Tue Apr 11 18:57:46 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Tue Apr 11 22:32:49 2017 +0200
@@ -847,9 +847,14 @@
         if (vmentry != null && isCompiled) {
             return;  // already compiled somehow
         }
-        assert(vmentry == null || vmentry.getMethodType().basicType().equals(methodType()));
+
+        // Obtain the invoker MethodType outside of the following try block.
+        // This ensures that an IllegalArgumentException is directly thrown if the
+        // type would have 256 or more parameters
+        MethodType invokerType = methodType();
+        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;