changeset 55530:6f03b6bd948e lworld

8224068: [lworld] JCK api/java_lang/invoke/MethodHandles/Lookup/ExceptionsTests crashes Summary: Throw exception in MethodHandle.FindConstructor() if return type is not void Reviewed-by: jrose
author hseigel
date Mon, 20 May 2019 10:01:28 -0400
parents 7c52ca2024fd
children 9458389d5187
files src/java.base/share/classes/java/lang/invoke/MethodHandles.java
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Mon May 20 15:14:54 2019 +0200
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Mon May 20 10:01:28 2019 -0400
@@ -1270,6 +1270,9 @@
             if (refc.isArray()) {
                 throw new NoSuchMethodException("no constructor for array class: " + refc.getName());
             }
+            if (type.returnType() != void.class) {
+                throw new NoSuchMethodException("Constructors must have void return type: " + refc.getName());
+            }
             String name = "<init>";
             MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type);
             return getDirectConstructor(refc, ctor);