mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8234335: Remove line break in class declaration in java.base
Remove line break in class declarations where applicable Reviewed-by: rriggs, lancea
This commit is contained in:
parent
e636c69e61
commit
a8a2246158
103 changed files with 416 additions and 460 deletions
|
@ -280,8 +280,7 @@ public class MethodHandles {
|
|||
* @throws ClassCastException if the member is not of the expected type
|
||||
* @since 1.8
|
||||
*/
|
||||
public static <T extends Member> T
|
||||
reflectAs(Class<T> expected, MethodHandle target) {
|
||||
public static <T extends Member> T reflectAs(Class<T> expected, MethodHandle target) {
|
||||
SecurityManager smgr = System.getSecurityManager();
|
||||
if (smgr != null) smgr.checkPermission(ACCESS_PERMISSION);
|
||||
Lookup lookup = Lookup.IMPL_LOOKUP; // use maximally privileged lookup
|
||||
|
@ -1764,8 +1763,7 @@ assertEquals("[x, y]", MH_asList.invoke("x", "y").toString());
|
|||
* <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
|
||||
* @throws NullPointerException if any argument is null
|
||||
*/
|
||||
public
|
||||
MethodHandle findStatic(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
|
||||
public MethodHandle findStatic(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
|
||||
MemberName method = resolveOrFail(REF_invokeStatic, refc, name, type);
|
||||
return getDirectMethod(REF_invokeStatic, refc, method, findBoundCallerClass(method));
|
||||
}
|
||||
|
@ -3177,7 +3175,8 @@ return mh1;
|
|||
/** Hook called from the JVM (via MethodHandleNatives) to link MH constants:
|
||||
*/
|
||||
/*non-public*/
|
||||
MethodHandle linkMethodHandleConstant(byte refKind, Class<?> defc, String name, Object type) throws ReflectiveOperationException {
|
||||
MethodHandle linkMethodHandleConstant(byte refKind, Class<?> defc, String name, Object type)
|
||||
throws ReflectiveOperationException {
|
||||
if (!(type instanceof Class || type instanceof MethodType))
|
||||
throw new InternalError("unresolved MemberName");
|
||||
MemberName member = new MemberName(refKind, defc, name, type);
|
||||
|
@ -3213,8 +3212,7 @@ return mh1;
|
|||
}
|
||||
return mh;
|
||||
}
|
||||
private
|
||||
boolean canBeCached(byte refKind, Class<?> defc, MemberName member) {
|
||||
private boolean canBeCached(byte refKind, Class<?> defc, MemberName member) {
|
||||
if (refKind == REF_invokeSpecial) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3248,8 +3246,7 @@ return mh1;
|
|||
}
|
||||
return true;
|
||||
}
|
||||
private
|
||||
MethodHandle getDirectMethodForConstant(byte refKind, Class<?> defc, MemberName member)
|
||||
private MethodHandle getDirectMethodForConstant(byte refKind, Class<?> defc, MemberName member)
|
||||
throws ReflectiveOperationException {
|
||||
if (MethodHandleNatives.refKindIsField(refKind)) {
|
||||
return getDirectFieldNoSecurityManager(refKind, defc, member);
|
||||
|
@ -3282,8 +3279,7 @@ return mh1;
|
|||
* @jvms 6.5 {@code anewarray} Instruction
|
||||
* @since 9
|
||||
*/
|
||||
public static
|
||||
MethodHandle arrayConstructor(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
public static MethodHandle arrayConstructor(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
if (!arrayClass.isArray()) {
|
||||
throw newIllegalArgumentException("not an array class: " + arrayClass.getName());
|
||||
}
|
||||
|
@ -3308,8 +3304,7 @@ return mh1;
|
|||
* @jvms 6.5 {@code arraylength} Instruction
|
||||
* @since 9
|
||||
*/
|
||||
public static
|
||||
MethodHandle arrayLength(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
public static MethodHandle arrayLength(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.LENGTH);
|
||||
}
|
||||
|
||||
|
@ -3333,8 +3328,7 @@ return mh1;
|
|||
* @throws IllegalArgumentException if arrayClass is not an array type
|
||||
* @jvms 6.5 {@code aaload} Instruction
|
||||
*/
|
||||
public static
|
||||
MethodHandle arrayElementGetter(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
public static MethodHandle arrayElementGetter(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.GET);
|
||||
}
|
||||
|
||||
|
@ -3358,8 +3352,7 @@ return mh1;
|
|||
* @throws IllegalArgumentException if arrayClass is not an array type
|
||||
* @jvms 6.5 {@code aastore} Instruction
|
||||
*/
|
||||
public static
|
||||
MethodHandle arrayElementSetter(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
public static MethodHandle arrayElementSetter(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.SET);
|
||||
}
|
||||
|
||||
|
@ -3423,8 +3416,7 @@ return mh1;
|
|||
* @throws IllegalArgumentException if arrayClass is not an array type
|
||||
* @since 9
|
||||
*/
|
||||
public static
|
||||
VarHandle arrayElementVarHandle(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
public static VarHandle arrayElementVarHandle(Class<?> arrayClass) throws IllegalArgumentException {
|
||||
return VarHandles.makeArrayElementHandle(arrayClass);
|
||||
}
|
||||
|
||||
|
@ -3504,8 +3496,7 @@ return mh1;
|
|||
* viewArrayClass is not supported as a variable type
|
||||
* @since 9
|
||||
*/
|
||||
public static
|
||||
VarHandle byteArrayViewVarHandle(Class<?> viewArrayClass,
|
||||
public static VarHandle byteArrayViewVarHandle(Class<?> viewArrayClass,
|
||||
ByteOrder byteOrder) throws IllegalArgumentException {
|
||||
Objects.requireNonNull(byteOrder);
|
||||
return VarHandles.byteArrayViewHandle(viewArrayClass,
|
||||
|
@ -3592,8 +3583,7 @@ return mh1;
|
|||
* viewArrayClass is not supported as a variable type
|
||||
* @since 9
|
||||
*/
|
||||
public static
|
||||
VarHandle byteBufferViewVarHandle(Class<?> viewArrayClass,
|
||||
public static VarHandle byteBufferViewVarHandle(Class<?> viewArrayClass,
|
||||
ByteOrder byteOrder) throws IllegalArgumentException {
|
||||
Objects.requireNonNull(byteOrder);
|
||||
return VarHandles.makeByteBufferViewHandle(viewArrayClass,
|
||||
|
@ -3649,8 +3639,7 @@ return invoker;
|
|||
* or if the resulting method handle's type would have
|
||||
* <a href="MethodHandle.html#maxarity">too many parameters</a>
|
||||
*/
|
||||
public static
|
||||
MethodHandle spreadInvoker(MethodType type, int leadingArgCount) {
|
||||
public static MethodHandle spreadInvoker(MethodType type, int leadingArgCount) {
|
||||
if (leadingArgCount < 0 || leadingArgCount > type.parameterCount())
|
||||
throw newIllegalArgumentException("bad argument count", leadingArgCount);
|
||||
type = type.asSpreaderType(Object[].class, leadingArgCount, type.parameterCount() - leadingArgCount);
|
||||
|
@ -3692,8 +3681,7 @@ return invoker;
|
|||
* @throws IllegalArgumentException if the resulting method handle's type would have
|
||||
* <a href="MethodHandle.html#maxarity">too many parameters</a>
|
||||
*/
|
||||
public static
|
||||
MethodHandle exactInvoker(MethodType type) {
|
||||
public static MethodHandle exactInvoker(MethodType type) {
|
||||
return type.invokers().exactInvoker();
|
||||
}
|
||||
|
||||
|
@ -3731,8 +3719,7 @@ return invoker;
|
|||
* @throws IllegalArgumentException if the resulting method handle's type would have
|
||||
* <a href="MethodHandle.html#maxarity">too many parameters</a>
|
||||
*/
|
||||
public static
|
||||
MethodHandle invoker(MethodType type) {
|
||||
public static MethodHandle invoker(MethodType type) {
|
||||
return type.invokers().genericInvoker();
|
||||
}
|
||||
|
||||
|
@ -3750,8 +3737,7 @@ return invoker;
|
|||
* any VarHandle whose access mode type is of the given type.
|
||||
* @since 9
|
||||
*/
|
||||
static public
|
||||
MethodHandle varHandleExactInvoker(VarHandle.AccessMode accessMode, MethodType type) {
|
||||
public static MethodHandle varHandleExactInvoker(VarHandle.AccessMode accessMode, MethodType type) {
|
||||
return type.invokers().varHandleMethodExactInvoker(accessMode);
|
||||
}
|
||||
|
||||
|
@ -3779,13 +3765,12 @@ return invoker;
|
|||
* type.
|
||||
* @since 9
|
||||
*/
|
||||
static public
|
||||
MethodHandle varHandleInvoker(VarHandle.AccessMode accessMode, MethodType type) {
|
||||
public static MethodHandle varHandleInvoker(VarHandle.AccessMode accessMode, MethodType type) {
|
||||
return type.invokers().varHandleMethodInvoker(accessMode);
|
||||
}
|
||||
|
||||
static /*non-public*/
|
||||
MethodHandle basicInvoker(MethodType type) {
|
||||
/*non-public*/
|
||||
static MethodHandle basicInvoker(MethodType type) {
|
||||
return type.invokers().basicInvoker();
|
||||
}
|
||||
|
||||
|
@ -3835,8 +3820,7 @@ return invoker;
|
|||
* @throws WrongMethodTypeException if the conversion cannot be made
|
||||
* @see MethodHandle#asType
|
||||
*/
|
||||
public static
|
||||
MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) {
|
||||
public static MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) {
|
||||
explicitCastArgumentsChecks(target, newType);
|
||||
// use the asTypeCache when possible:
|
||||
MethodType oldType = target.type();
|
||||
|
@ -3915,8 +3899,7 @@ assert((int)twice.invokeExact(21) == 42);
|
|||
* or if two corresponding parameter types in
|
||||
* {@code target.type()} and {@code newType} are not identical,
|
||||
*/
|
||||
public static
|
||||
MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) {
|
||||
public static MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) {
|
||||
reorder = reorder.clone(); // get a private copy
|
||||
MethodType oldType = target.type();
|
||||
permuteArgumentChecks(reorder, newType, oldType);
|
||||
|
@ -4075,8 +4058,7 @@ assert((int)twice.invokeExact(21) == 42);
|
|||
* @throws ClassCastException if the value cannot be converted to the required return type
|
||||
* @throws IllegalArgumentException if the given type is {@code void.class}
|
||||
*/
|
||||
public static
|
||||
MethodHandle constant(Class<?> type, Object value) {
|
||||
public static MethodHandle constant(Class<?> type, Object value) {
|
||||
if (type.isPrimitive()) {
|
||||
if (type == void.class)
|
||||
throw newIllegalArgumentException("void type");
|
||||
|
@ -4099,8 +4081,7 @@ assert((int)twice.invokeExact(21) == 42);
|
|||
* @throws NullPointerException if the argument is null
|
||||
* @throws IllegalArgumentException if the given type is {@code void.class}
|
||||
*/
|
||||
public static
|
||||
MethodHandle identity(Class<?> type) {
|
||||
public static MethodHandle identity(Class<?> type) {
|
||||
Wrapper btw = (type.isPrimitive() ? Wrapper.forPrimitiveType(type) : Wrapper.OBJECT);
|
||||
int pos = btw.ordinal();
|
||||
MethodHandle ident = IDENTITY_MHS[pos];
|
||||
|
@ -4230,8 +4211,7 @@ assert((int)twice.invokeExact(21) == 42);
|
|||
* type.
|
||||
* @see MethodHandle#bindTo
|
||||
*/
|
||||
public static
|
||||
MethodHandle insertArguments(MethodHandle target, int pos, Object... values) {
|
||||
public static MethodHandle insertArguments(MethodHandle target, int pos, Object... values) {
|
||||
int insCount = values.length;
|
||||
Class<?>[] ptypes = insertArgumentsChecks(target, insCount, pos);
|
||||
if (insCount == 0) return target;
|
||||
|
@ -4316,8 +4296,7 @@ assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
|
|||
* or if {@code pos} is negative or greater than the arity of the target,
|
||||
* or if the new method handle's type would have too many parameters
|
||||
*/
|
||||
public static
|
||||
MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
|
||||
public static MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
|
||||
return dropArguments0(target, pos, copyTypes(valueTypes.toArray()));
|
||||
}
|
||||
|
||||
|
@ -4325,8 +4304,7 @@ assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
|
|||
return Arrays.asList(Arrays.copyOf(array, array.length, Class[].class));
|
||||
}
|
||||
|
||||
private static
|
||||
MethodHandle dropArguments0(MethodHandle target, int pos, List<Class<?>> valueTypes) {
|
||||
private static MethodHandle dropArguments0(MethodHandle target, int pos, List<Class<?>> valueTypes) {
|
||||
MethodType oldType = target.type(); // get NPE
|
||||
int dropped = dropArgumentChecks(oldType, pos, valueTypes);
|
||||
MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
|
||||
|
@ -4399,8 +4377,7 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
|
|||
* or if the new method handle's type would have
|
||||
* <a href="MethodHandle.html#maxarity">too many parameters</a>
|
||||
*/
|
||||
public static
|
||||
MethodHandle dropArguments(MethodHandle target, int pos, Class<?>... valueTypes) {
|
||||
public static MethodHandle dropArguments(MethodHandle target, int pos, Class<?>... valueTypes) {
|
||||
return dropArguments0(target, pos, copyTypes(valueTypes));
|
||||
}
|
||||
|
||||
|
@ -4506,8 +4483,7 @@ assertEquals("xy", h3.invoke("x", "y", 1, "a", "b", "c"));
|
|||
* {@code pos}.
|
||||
* @since 9
|
||||
*/
|
||||
public static
|
||||
MethodHandle dropArgumentsToMatch(MethodHandle target, int skip, List<Class<?>> newTypes, int pos) {
|
||||
public static MethodHandle dropArgumentsToMatch(MethodHandle target, int skip, List<Class<?>> newTypes, int pos) {
|
||||
Objects.requireNonNull(target);
|
||||
Objects.requireNonNull(newTypes);
|
||||
return dropArgumentsToMatch(target, skip, newTypes, pos, false);
|
||||
|
@ -4590,8 +4566,7 @@ assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY
|
|||
* or if the resulting method handle's type would have
|
||||
* <a href="MethodHandle.html#maxarity">too many parameters</a>
|
||||
*/
|
||||
public static
|
||||
MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) {
|
||||
public static MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) {
|
||||
// In method types arguments start at index 0, while the LF
|
||||
// editor have the MH receiver at position 0 - adjust appropriately.
|
||||
final int MH_RECEIVER_OFFSET = 1;
|
||||
|
@ -4649,8 +4624,8 @@ assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY
|
|||
return result.copyWithExtendL(newType, lform, filter);
|
||||
}
|
||||
|
||||
/*non-public*/ static
|
||||
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
|
||||
/*non-public*/
|
||||
static MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
|
||||
filterArgumentChecks(target, pos, filter);
|
||||
MethodType targetType = target.type();
|
||||
MethodType filterType = filter.type();
|
||||
|
@ -4796,8 +4771,7 @@ assertEquals("[top, [[up, down, strange], charm], bottom]",
|
|||
* @see MethodHandles#filterArguments
|
||||
* @see MethodHandles#filterReturnValue
|
||||
*/
|
||||
public static
|
||||
MethodHandle collectArguments(MethodHandle target, int pos, MethodHandle filter) {
|
||||
public static MethodHandle collectArguments(MethodHandle target, int pos, MethodHandle filter) {
|
||||
MethodType newType = collectArgumentsChecks(target, pos, filter);
|
||||
MethodType collectorType = filter.type();
|
||||
BoundMethodHandle result = target.rebind();
|
||||
|
@ -4890,8 +4864,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
|
|||
* @throws IllegalArgumentException if the argument list of {@code filter}
|
||||
* does not match the return type of target as described above
|
||||
*/
|
||||
public static
|
||||
MethodHandle filterReturnValue(MethodHandle target, MethodHandle filter) {
|
||||
public static MethodHandle filterReturnValue(MethodHandle target, MethodHandle filter) {
|
||||
MethodType targetType = target.type();
|
||||
MethodType filterType = filter.type();
|
||||
filterReturnValueChecks(targetType, filterType);
|
||||
|
@ -4999,8 +4972,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
* (skipping one matching the {@code combiner}'s return type)
|
||||
* are not identical with the argument types of {@code combiner}
|
||||
*/
|
||||
public static
|
||||
MethodHandle foldArguments(MethodHandle target, MethodHandle combiner) {
|
||||
public static MethodHandle foldArguments(MethodHandle target, MethodHandle combiner) {
|
||||
return foldArguments(target, 0, combiner);
|
||||
}
|
||||
|
||||
|
@ -5127,7 +5099,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
* (2) the {@code N} argument types at positions {@code argPositions[1...N]} of the target signature are
|
||||
* not identical with the argument types of {@code combiner}.
|
||||
*/
|
||||
/*non-public*/ static MethodHandle filterArgumentsWithCombiner(MethodHandle target, int position, MethodHandle combiner, int ... argPositions) {
|
||||
/*non-public*/
|
||||
static MethodHandle filterArgumentsWithCombiner(MethodHandle target, int position, MethodHandle combiner, int ... argPositions) {
|
||||
return argumentsWithCombiner(true, target, position, combiner, argPositions);
|
||||
}
|
||||
|
||||
|
@ -5149,7 +5122,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
* (skipping {@code position} where the {@code combiner}'s return will be folded in) are not identical
|
||||
* with the argument types of {@code combiner}.
|
||||
*/
|
||||
/*non-public*/ static MethodHandle foldArgumentsWithCombiner(MethodHandle target, int position, MethodHandle combiner, int ... argPositions) {
|
||||
/*non-public*/
|
||||
static MethodHandle foldArgumentsWithCombiner(MethodHandle target, int position, MethodHandle combiner, int ... argPositions) {
|
||||
return argumentsWithCombiner(false, target, position, combiner, argPositions);
|
||||
}
|
||||
|
||||
|
@ -5236,8 +5210,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
* or if all three method types do not match (with the return
|
||||
* type of {@code test} changed to match that of the target).
|
||||
*/
|
||||
public static
|
||||
MethodHandle guardWithTest(MethodHandle test,
|
||||
public static MethodHandle guardWithTest(MethodHandle test,
|
||||
MethodHandle target,
|
||||
MethodHandle fallback) {
|
||||
MethodType gtype = test.type();
|
||||
|
@ -5309,8 +5282,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
* corresponding parameters
|
||||
* @see MethodHandles#tryFinally(MethodHandle, MethodHandle)
|
||||
*/
|
||||
public static
|
||||
MethodHandle catchException(MethodHandle target,
|
||||
public static MethodHandle catchException(MethodHandle target,
|
||||
Class<? extends Throwable> exType,
|
||||
MethodHandle handler) {
|
||||
MethodType ttype = target.type();
|
||||
|
@ -5341,8 +5313,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
* @return method handle which can throw the given exceptions
|
||||
* @throws NullPointerException if either argument is null
|
||||
*/
|
||||
public static
|
||||
MethodHandle throwException(Class<?> returnType, Class<? extends Throwable> exType) {
|
||||
public static MethodHandle throwException(Class<?> returnType, Class<? extends Throwable> exType) {
|
||||
if (!Throwable.class.isAssignableFrom(exType))
|
||||
throw new ClassCastException(exType.getName());
|
||||
return MethodHandleImpl.throwException(methodType(returnType, exType));
|
||||
|
@ -6650,7 +6621,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
return iterableType; // help the caller a bit
|
||||
}
|
||||
|
||||
/*non-public*/ static MethodHandle swapArguments(MethodHandle mh, int i, int j) {
|
||||
/*non-public*/
|
||||
static MethodHandle swapArguments(MethodHandle mh, int i, int j) {
|
||||
// there should be a better way to uncross my wires
|
||||
int arity = mh.type().parameterCount();
|
||||
int[] order = new int[arity];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue