8178480: Wrong exception being thrown on an invalid MethodType
Reviewed-by: psandoz
--- 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;