8223803: j.l.c.MethodTypeDesc::insertParameterTypes doesn't control type of parameters
Reviewed-by: rriggs
This commit is contained in:
parent
092bb9e108
commit
917645194b
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -97,6 +97,11 @@ public interface ConstantDesc {
|
|||||||
* @throws ReflectiveOperationException if a class, method, or field
|
* @throws ReflectiveOperationException if a class, method, or field
|
||||||
* could not be reflectively resolved in the course of resolution
|
* could not be reflectively resolved in the course of resolution
|
||||||
* @throws LinkageError if a linkage error occurs
|
* @throws LinkageError if a linkage error occurs
|
||||||
|
*
|
||||||
|
* @apiNote {@linkplain MethodTypeDesc} can represent method type descriptors
|
||||||
|
* that are not representable by {@linkplain MethodType}, such as methods with
|
||||||
|
* more than 255 parameter slots, so attempts to resolve these may result in errors.
|
||||||
|
*
|
||||||
* @jvms 5.4.3 Resolution
|
* @jvms 5.4.3 Resolution
|
||||||
* @jvms 5.4.4 Access Control
|
* @jvms 5.4.4 Access Control
|
||||||
*/
|
*/
|
||||||
|
@ -154,9 +154,11 @@ public interface MethodTypeDesc
|
|||||||
* @param paramTypes {@link ClassDesc}s describing the new parameter types
|
* @param paramTypes {@link ClassDesc}s describing the new parameter types
|
||||||
* to insert
|
* to insert
|
||||||
* @return a {@linkplain MethodTypeDesc} describing the desired method type
|
* @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 IndexOutOfBoundsException if {@code pos} is outside the closed
|
* @throws IndexOutOfBoundsException if {@code pos} is outside the closed
|
||||||
* range {[0, parameterCount]}
|
* range {[0, parameterCount]}
|
||||||
|
* @throws IllegalArgumentException if any element of {@code paramTypes}
|
||||||
|
* is a {@link ClassDesc} for {@code void}
|
||||||
*/
|
*/
|
||||||
MethodTypeDesc insertParameterTypes(int pos, ClassDesc... paramTypes);
|
MethodTypeDesc insertParameterTypes(int pos, ClassDesc... paramTypes);
|
||||||
|
|
||||||
|
@ -171,6 +171,34 @@ public class MethodTypeDescTest extends SymbolicDescTest {
|
|||||||
} catch (IndexOutOfBoundsException ex) {
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
// good
|
// good
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ClassDesc[] newParamTypes = new ClassDesc[1];
|
||||||
|
newParamTypes[0] = CD_void;
|
||||||
|
MethodTypeDesc newDesc = MethodTypeDesc.of(returnType, CD_int);
|
||||||
|
newDesc = newDesc.insertParameterTypes(0, newParamTypes);
|
||||||
|
fail("shouldn't allow parameters with class descriptor CD_void");
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
// good
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
MethodTypeDesc newDesc = MethodTypeDesc.of(returnType, CD_int);
|
||||||
|
newDesc = newDesc.insertParameterTypes(0, null);
|
||||||
|
fail("should fail with NPE");
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
// good
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ClassDesc[] newParamTypes = new ClassDesc[1];
|
||||||
|
newParamTypes[0] = null;
|
||||||
|
MethodTypeDesc newDesc = MethodTypeDesc.of(returnType, CD_int);
|
||||||
|
newDesc = newDesc.insertParameterTypes(0, newParamTypes);
|
||||||
|
fail("should fail with NPE");
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
// good
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void badDropParametersTypes(ClassDesc returnType, String... paramDescTypes) {
|
private void badDropParametersTypes(ClassDesc returnType, String... paramDescTypes) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user