# HG changeset patch # User vromero # Date 1558531608 14400 # Node ID 3b4ecc4180e08b13931b688a0ca95257ea37ab67 # Parent 37d8790efed793a8834d9be1e903d58e382ddac8 8223914: specification of j.l.c.MethodTypeDesc::of should document better the exceptions thrown Reviewed-by: rriggs diff -r 37d8790efed7 -r 3b4ecc4180e0 src/java.base/share/classes/java/lang/constant/MethodTypeDesc.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); diff -r 37d8790efed7 -r 3b4ecc4180e0 test/jdk/java/lang/constant/MethodTypeDescTest.java --- 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 + } } }