8223914: specification of j.l.c.MethodTypeDesc::of should document better the exceptions thrown
authorvromero
Wed, 22 May 2019 09:26:48 -0400
changeset 54986 3b4ecc4180e0
parent 54985 37d8790efed7
child 54987 2ffbc00d87ae
8223914: specification of j.l.c.MethodTypeDesc::of should document better the exceptions thrown Reviewed-by: rriggs
src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java
test/jdk/java/lang/constant/MethodTypeDescTest.java
--- a/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java	Wed May 22 09:10:07 2019 -0400
+++ b/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java	Wed May 22 09:26:48 2019 -0400
@@ -65,7 +65,9 @@
      * @param returnDesc a {@linkplain ClassDesc} describing the return type
      * @param paramDescs {@linkplain ClassDesc}s describing the argument types
      * @return a {@linkplain MethodTypeDesc} describing the desired method type
-     * @throws NullPointerException if any argument is {@code null}
+     * @throws NullPointerException if any argument or its contents are {@code null}
+     * @throws IllegalArgumentException if any element of {@code paramDescs} is a
+     * {@link ClassDesc} for {@code void}
      */
     static MethodTypeDesc of(ClassDesc returnDesc, ClassDesc... paramDescs) {
         return new MethodTypeDescImpl(returnDesc, paramDescs);
--- a/test/jdk/java/lang/constant/MethodTypeDescTest.java	Wed May 22 09:10:07 2019 -0400
+++ b/test/jdk/java/lang/constant/MethodTypeDescTest.java	Wed May 22 09:26:48 2019 -0400
@@ -286,5 +286,23 @@
         catch (IllegalArgumentException e) {
             // good
         }
+
+        try {
+            MethodTypeDesc r = MethodTypeDesc.of(CD_int, null);
+            fail("ClassDesc array should not be null");
+        }
+        catch (NullPointerException e) {
+            // good
+        }
+
+        try {
+            ClassDesc[] paramDescs = new ClassDesc[1];
+            paramDescs[0] = null;
+            MethodTypeDesc r = MethodTypeDesc.of(CD_int, paramDescs);
+            fail("ClassDesc should not be null");
+        }
+        catch (NullPointerException e) {
+            // good
+        }
     }
 }