8223914: specification of j.l.c.MethodTypeDesc::of should document better the exceptions thrown

Reviewed-by: rriggs
This commit is contained in:
Vicente Romero 2019-05-22 09:26:48 -04:00
parent 23b2871246
commit ff2fa1e422
2 changed files with 21 additions and 1 deletions

View File

@ -65,7 +65,9 @@ public interface MethodTypeDesc
* @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);

View File

@ -286,5 +286,23 @@ public class MethodTypeDescTest extends SymbolicDescTest {
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
}
}
}