mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-16 16:39:48 +00:00
8157590: MethodHandles.arrayLength() lacks @since tag, implementation throws wrong exception
Reviewed-by: psandoz
This commit is contained in:
parent
a74cd0321d
commit
73dea49766
@ -118,7 +118,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
case SET: return "setElement";
|
||||
case LENGTH: return "length";
|
||||
}
|
||||
throw new AssertionError();
|
||||
throw unmatchedArrayAccess(a);
|
||||
}
|
||||
|
||||
static MethodHandle objectAccessor(ArrayAccess a) {
|
||||
@ -127,7 +127,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
case SET: return ArrayAccessor.OBJECT_ARRAY_SETTER;
|
||||
case LENGTH: return ArrayAccessor.OBJECT_ARRAY_LENGTH;
|
||||
}
|
||||
throw new AssertionError();
|
||||
throw unmatchedArrayAccess(a);
|
||||
}
|
||||
|
||||
static int cacheIndex(ArrayAccess a) {
|
||||
@ -136,7 +136,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
case SET: return ArrayAccessor.SETTER_INDEX;
|
||||
case LENGTH: return ArrayAccessor.LENGTH_INDEX;
|
||||
}
|
||||
throw new AssertionError();
|
||||
throw unmatchedArrayAccess(a);
|
||||
}
|
||||
|
||||
static Intrinsic intrinsic(ArrayAccess a) {
|
||||
@ -145,10 +145,14 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
case SET: return Intrinsic.ARRAY_STORE;
|
||||
case LENGTH: return Intrinsic.ARRAY_LENGTH;
|
||||
}
|
||||
throw new AssertionError();
|
||||
throw unmatchedArrayAccess(a);
|
||||
}
|
||||
}
|
||||
|
||||
static InternalError unmatchedArrayAccess(ArrayAccess a) {
|
||||
return newInternalError("should not reach here (unmatched ArrayAccess: " + a + ")");
|
||||
}
|
||||
|
||||
static final class ArrayAccessor {
|
||||
/// Support for array element and length access
|
||||
static final int GETTER_INDEX = 0, SETTER_INDEX = 1, LENGTH_INDEX = 2, INDEX_LIMIT = 3;
|
||||
@ -218,7 +222,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
case SET: return MethodType.methodType(void.class, arrayArgClass, int.class, elemClass);
|
||||
case LENGTH: return MethodType.methodType(int.class, arrayArgClass);
|
||||
}
|
||||
throw new IllegalStateException("should not reach here");
|
||||
throw unmatchedArrayAccess(access);
|
||||
}
|
||||
static MethodType correctType(Class<?> arrayClass, ArrayAccess access) {
|
||||
Class<?> elemClass = arrayClass.getComponentType();
|
||||
@ -227,7 +231,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
case SET: return MethodType.methodType(void.class, arrayClass, int.class, elemClass);
|
||||
case LENGTH: return MethodType.methodType(int.class, arrayClass);
|
||||
}
|
||||
throw new IllegalStateException("should not reach here");
|
||||
throw unmatchedArrayAccess(access);
|
||||
}
|
||||
static MethodHandle getAccessor(Class<?> arrayClass, ArrayAccess access) {
|
||||
String name = name(arrayClass, access);
|
||||
|
||||
@ -2252,6 +2252,7 @@ return mh1;
|
||||
* @return a method handle which can retrieve the length of an array of the given array type
|
||||
* @throws NullPointerException if the argument is {@code null}
|
||||
* @throws IllegalArgumentException if arrayClass is not an array type
|
||||
* @since 9
|
||||
*/
|
||||
public static
|
||||
MethodHandle arrayLength(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user