changeset 50737:cd7f4c80a4db jep-334

checking for constructor with non void return type
author vromero
date Thu, 24 May 2018 10:15:08 -0700
parents ed6fdf96e5fa
children 3248898657dc 201b586b8f7a
files test/jdk/java/lang/invoke/constant/MethodHandleRefTest.java
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/java/lang/invoke/constant/MethodHandleRefTest.java	Thu May 24 09:56:02 2018 -0700
+++ b/test/jdk/java/lang/invoke/constant/MethodHandleRefTest.java	Thu May 24 10:15:08 2018 -0700
@@ -116,6 +116,13 @@
                             LOOKUP.findConstructor(ArrayList.class, MethodType.methodType(void.class)));
         testMethodHandleRef(MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList")),
                             LOOKUP.findConstructor(ArrayList.class, MethodType.methodType(void.class)));
+        // bad constructor non void return type
+        try {
+            MethodHandleDesc.of(MethodHandleDesc.Kind.CONSTRUCTOR, ClassDesc.of("java.util.ArrayList"), "<init>", CR_int);
+            fail("should have failed: non void return type for constructor");
+        } catch (IllegalArgumentException ex) {
+            // good
+        }
     }
 
     public void testAsType() throws Throwable {