提交 9580c55f 编写于 作者: J jrose

7117167: Misc warnings in java.lang.invoke and sun.invoke.*

Reviewed-by: smarks
上级 81a31a38
...@@ -378,6 +378,7 @@ class AdapterMethodHandle extends BoundMethodHandle { ...@@ -378,6 +378,7 @@ class AdapterMethodHandle extends BoundMethodHandle {
} }
/** Construct an adapter conversion descriptor for a single-argument conversion. */ /** Construct an adapter conversion descriptor for a single-argument conversion. */
@SuppressWarnings("cast") // some (int) casts below provide clarity but trigger warnings
private static long makeConv(int convOp, int argnum, int src, int dest) { private static long makeConv(int convOp, int argnum, int src, int dest) {
assert(src == (src & CONV_TYPE_MASK)); assert(src == (src & CONV_TYPE_MASK));
assert(dest == (dest & CONV_TYPE_MASK)); assert(dest == (dest & CONV_TYPE_MASK));
...@@ -390,6 +391,7 @@ class AdapterMethodHandle extends BoundMethodHandle { ...@@ -390,6 +391,7 @@ class AdapterMethodHandle extends BoundMethodHandle {
insertStackMove(stackMove) insertStackMove(stackMove)
); );
} }
@SuppressWarnings("cast") // some (int) casts below provide clarity but trigger warnings
private static long makeDupConv(int convOp, int argnum, int stackMove) { private static long makeDupConv(int convOp, int argnum, int stackMove) {
// simple argument motion, requiring one slot to specify // simple argument motion, requiring one slot to specify
assert(convOp == OP_DUP_ARGS || convOp == OP_DROP_ARGS); assert(convOp == OP_DUP_ARGS || convOp == OP_DROP_ARGS);
...@@ -401,6 +403,7 @@ class AdapterMethodHandle extends BoundMethodHandle { ...@@ -401,6 +403,7 @@ class AdapterMethodHandle extends BoundMethodHandle {
insertStackMove(stackMove) insertStackMove(stackMove)
); );
} }
@SuppressWarnings("cast") // some (int) casts below provide clarity but trigger warnings
private static long makeSwapConv(int convOp, int srcArg, byte srcType, int destSlot, byte destType) { private static long makeSwapConv(int convOp, int srcArg, byte srcType, int destSlot, byte destType) {
// more complex argument motion, requiring two slots to specify // more complex argument motion, requiring two slots to specify
assert(convOp == OP_SWAP_ARGS || convOp == OP_ROT_ARGS); assert(convOp == OP_SWAP_ARGS || convOp == OP_ROT_ARGS);
...@@ -411,6 +414,7 @@ class AdapterMethodHandle extends BoundMethodHandle { ...@@ -411,6 +414,7 @@ class AdapterMethodHandle extends BoundMethodHandle {
(int) destSlot << CONV_VMINFO_SHIFT (int) destSlot << CONV_VMINFO_SHIFT
); );
} }
@SuppressWarnings("cast") // some (int) casts below provide clarity but trigger warnings
private static long makeSpreadConv(int convOp, int argnum, int src, int dest, int stackMove) { private static long makeSpreadConv(int convOp, int argnum, int src, int dest, int stackMove) {
// spreading or collecting, at a particular slot location // spreading or collecting, at a particular slot location
assert(convOp == OP_SPREAD_ARGS || convOp == OP_COLLECT_ARGS || convOp == OP_FOLD_ARGS); assert(convOp == OP_SPREAD_ARGS || convOp == OP_COLLECT_ARGS || convOp == OP_FOLD_ARGS);
......
...@@ -353,7 +353,7 @@ import static java.lang.invoke.MethodHandleStatics.*; ...@@ -353,7 +353,7 @@ import static java.lang.invoke.MethodHandleStatics.*;
assert(isResolved()); assert(isResolved());
} }
/** Create a name for the given reflected constructor. The resulting name will be in a resolved state. */ /** Create a name for the given reflected constructor. The resulting name will be in a resolved state. */
public MemberName(Constructor ctor) { public MemberName(Constructor<?> ctor) {
Object[] typeInfo = { void.class, ctor.getParameterTypes() }; Object[] typeInfo = { void.class, ctor.getParameterTypes() };
init(ctor.getDeclaringClass(), CONSTRUCTOR_NAME, typeInfo, flagsMods(IS_CONSTRUCTOR, ctor.getModifiers())); init(ctor.getDeclaringClass(), CONSTRUCTOR_NAME, typeInfo, flagsMods(IS_CONSTRUCTOR, ctor.getModifiers()));
// fill in vmtarget, vmindex while we have ctor in hand: // fill in vmtarget, vmindex while we have ctor in hand:
......
...@@ -112,7 +112,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; ...@@ -112,7 +112,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
assert(cookedConstructor.type().equals(ctype)); assert(cookedConstructor.type().equals(ctype));
ctype = ctype.dropParameterTypes(0, 1); ctype = ctype.dropParameterTypes(0, 1);
cookedConstructor = AdapterMethodHandle.makeCollectArguments(cookedConstructor, returner, 0, true); cookedConstructor = AdapterMethodHandle.makeCollectArguments(cookedConstructor, returner, 0, true);
MethodHandle allocator = new AllocateObject(allocateClass); AllocateObject allocator = new AllocateObject(allocateClass);
// allocate() => new C(void) // allocate() => new C(void)
assert(allocator.type().equals(MethodType.methodType(allocateClass))); assert(allocator.type().equals(MethodType.methodType(allocateClass)));
ctype = ctype.dropParameterTypes(0, 1); ctype = ctype.dropParameterTypes(0, 1);
...@@ -120,19 +120,19 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; ...@@ -120,19 +120,19 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
return fold; return fold;
} }
static final class AllocateObject<C> extends BoundMethodHandle { static final class AllocateObject /*<C>*/ extends BoundMethodHandle {
private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final Unsafe unsafe = Unsafe.getUnsafe();
private final Class<C> allocateClass; private final Class<?> /*<C>*/ allocateClass;
// for allocation only: // for allocation only:
private AllocateObject(Class<C> allocateClass) { private AllocateObject(Class<?> /*<C>*/ allocateClass) {
super(ALLOCATE.asType(MethodType.methodType(allocateClass, AllocateObject.class))); super(ALLOCATE.asType(MethodType.methodType(allocateClass, AllocateObject.class)));
this.allocateClass = allocateClass; this.allocateClass = allocateClass;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private C allocate() throws InstantiationException { private Object /*C*/ allocate() throws InstantiationException {
return (C) unsafe.allocateInstance(allocateClass); return unsafe.allocateInstance(allocateClass);
} }
static final MethodHandle ALLOCATE; static final MethodHandle ALLOCATE;
static { static {
...@@ -148,8 +148,8 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; ...@@ -148,8 +148,8 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
MethodHandle accessField(MemberName member, boolean isSetter, MethodHandle accessField(MemberName member, boolean isSetter,
Class<?> lookupClass) { Class<?> lookupClass) {
// Use sun. misc.Unsafe to dig up the dirt on the field. // Use sun. misc.Unsafe to dig up the dirt on the field.
MethodHandle mh = new FieldAccessor(member, isSetter); FieldAccessor accessor = new FieldAccessor(member, isSetter);
return mh; return accessor;
} }
static static
...@@ -175,7 +175,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; ...@@ -175,7 +175,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
return mhs[isSetter ? 1 : 0]; return mhs[isSetter ? 1 : 0];
} }
static final class FieldAccessor<C,V> extends BoundMethodHandle { static final class FieldAccessor /*<C,V>*/ extends BoundMethodHandle {
private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final Unsafe unsafe = Unsafe.getUnsafe();
final Object base; // for static refs only final Object base; // for static refs only
final long offset; final long offset;
...@@ -190,26 +190,24 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; ...@@ -190,26 +190,24 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
@Override @Override
String debugString() { return addTypeString(name, this); } String debugString() { return addTypeString(name, this); }
int getFieldI(C obj) { return unsafe.getInt(obj, offset); } int getFieldI(Object /*C*/ obj) { return unsafe.getInt(obj, offset); }
void setFieldI(C obj, int x) { unsafe.putInt(obj, offset, x); } void setFieldI(Object /*C*/ obj, int x) { unsafe.putInt(obj, offset, x); }
long getFieldJ(C obj) { return unsafe.getLong(obj, offset); } long getFieldJ(Object /*C*/ obj) { return unsafe.getLong(obj, offset); }
void setFieldJ(C obj, long x) { unsafe.putLong(obj, offset, x); } void setFieldJ(Object /*C*/ obj, long x) { unsafe.putLong(obj, offset, x); }
float getFieldF(C obj) { return unsafe.getFloat(obj, offset); } float getFieldF(Object /*C*/ obj) { return unsafe.getFloat(obj, offset); }
void setFieldF(C obj, float x) { unsafe.putFloat(obj, offset, x); } void setFieldF(Object /*C*/ obj, float x) { unsafe.putFloat(obj, offset, x); }
double getFieldD(C obj) { return unsafe.getDouble(obj, offset); } double getFieldD(Object /*C*/ obj) { return unsafe.getDouble(obj, offset); }
void setFieldD(C obj, double x) { unsafe.putDouble(obj, offset, x); } void setFieldD(Object /*C*/ obj, double x) { unsafe.putDouble(obj, offset, x); }
boolean getFieldZ(C obj) { return unsafe.getBoolean(obj, offset); } boolean getFieldZ(Object /*C*/ obj) { return unsafe.getBoolean(obj, offset); }
void setFieldZ(C obj, boolean x) { unsafe.putBoolean(obj, offset, x); } void setFieldZ(Object /*C*/ obj, boolean x) { unsafe.putBoolean(obj, offset, x); }
byte getFieldB(C obj) { return unsafe.getByte(obj, offset); } byte getFieldB(Object /*C*/ obj) { return unsafe.getByte(obj, offset); }
void setFieldB(C obj, byte x) { unsafe.putByte(obj, offset, x); } void setFieldB(Object /*C*/ obj, byte x) { unsafe.putByte(obj, offset, x); }
short getFieldS(C obj) { return unsafe.getShort(obj, offset); } short getFieldS(Object /*C*/ obj) { return unsafe.getShort(obj, offset); }
void setFieldS(C obj, short x) { unsafe.putShort(obj, offset, x); } void setFieldS(Object /*C*/ obj, short x) { unsafe.putShort(obj, offset, x); }
char getFieldC(C obj) { return unsafe.getChar(obj, offset); } char getFieldC(Object /*C*/ obj) { return unsafe.getChar(obj, offset); }
void setFieldC(C obj, char x) { unsafe.putChar(obj, offset, x); } void setFieldC(Object /*C*/ obj, char x) { unsafe.putChar(obj, offset, x); }
@SuppressWarnings("unchecked") Object /*V*/ getFieldL(Object /*C*/ obj) { return unsafe.getObject(obj, offset); }
V getFieldL(C obj) { return (V) unsafe.getObject(obj, offset); } void setFieldL(Object /*C*/ obj, Object /*V*/ x) { unsafe.putObject(obj, offset, x); }
@SuppressWarnings("unchecked")
void setFieldL(C obj, V x) { unsafe.putObject(obj, offset, x); }
// cast (V) is OK here, since we wrap convertArguments around the MH. // cast (V) is OK here, since we wrap convertArguments around the MH.
static Object staticBase(final MemberName field) { static Object staticBase(final MemberName field) {
...@@ -244,8 +242,9 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; ...@@ -244,8 +242,9 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
void setStaticS(short x) { unsafe.putShort(base, offset, x); } void setStaticS(short x) { unsafe.putShort(base, offset, x); }
char getStaticC() { return unsafe.getChar(base, offset); } char getStaticC() { return unsafe.getChar(base, offset); }
void setStaticC(char x) { unsafe.putChar(base, offset, x); } void setStaticC(char x) { unsafe.putChar(base, offset, x); }
V getStaticL() { return (V) unsafe.getObject(base, offset); } @SuppressWarnings("unchecked") // (V) is for internal clarity but triggers warning
void setStaticL(V x) { unsafe.putObject(base, offset, x); } Object /*V*/ getStaticL() { return unsafe.getObject(base, offset); }
void setStaticL(Object /*V*/ x) { unsafe.putObject(base, offset, x); }
static String fname(Class<?> vclass, boolean isSetter, boolean isStatic) { static String fname(Class<?> vclass, boolean isSetter, boolean isStatic) {
String stem; String stem;
......
...@@ -150,7 +150,7 @@ public class MethodHandleProxies { ...@@ -150,7 +150,7 @@ public class MethodHandleProxies {
} }
return intfc.cast(Proxy.newProxyInstance( return intfc.cast(Proxy.newProxyInstance(
intfc.getClassLoader(), intfc.getClassLoader(),
new Class[]{ intfc, WrapperInstance.class }, new Class<?>[]{ intfc, WrapperInstance.class },
new InvocationHandler() { new InvocationHandler() {
private Object getArg(String name) { private Object getArg(String name) {
if ((Object)name == "getWrapperInstanceTarget") return target; if ((Object)name == "getWrapperInstanceTarget") return target;
......
...@@ -1006,6 +1006,7 @@ return mh1; ...@@ -1006,6 +1006,7 @@ return mh1;
* is set and {@code asVarargsCollector} fails * is set and {@code asVarargsCollector} fails
* @throws NullPointerException if the argument is null * @throws NullPointerException if the argument is null
*/ */
@SuppressWarnings("rawtypes") // Will be Constructor<?> after JSR 292 MR
public MethodHandle unreflectConstructor(Constructor c) throws IllegalAccessException { public MethodHandle unreflectConstructor(Constructor c) throws IllegalAccessException {
MemberName ctor = new MemberName(c); MemberName ctor = new MemberName(c);
assert(ctor.isConstructor()); assert(ctor.isConstructor());
......
...@@ -55,9 +55,9 @@ public class ValueConversions { ...@@ -55,9 +55,9 @@ public class ValueConversions {
private static final Lookup IMPL_LOOKUP = MethodHandles.lookup(); private static final Lookup IMPL_LOOKUP = MethodHandles.lookup();
private static EnumMap<Wrapper, MethodHandle>[] newWrapperCaches(int n) { private static EnumMap<Wrapper, MethodHandle>[] newWrapperCaches(int n) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") // generic array creation
EnumMap<Wrapper, MethodHandle>[] caches EnumMap<Wrapper, MethodHandle>[] caches
= (EnumMap<Wrapper, MethodHandle>[]) new EnumMap[n]; // unchecked warning expected here = (EnumMap<Wrapper, MethodHandle>[]) new EnumMap<?,?>[n];
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
caches[i] = new EnumMap<>(Wrapper.class); caches[i] = new EnumMap<>(Wrapper.class);
return caches; return caches;
...@@ -1097,7 +1097,7 @@ public class ValueConversions { ...@@ -1097,7 +1097,7 @@ public class ValueConversions {
} }
private static MethodHandle buildNewArray(int nargs) { private static MethodHandle buildNewArray(int nargs) {
return MethodHandles.insertArguments(NEW_ARRAY, 0, (int) nargs); return MethodHandles.insertArguments(NEW_ARRAY, 0, nargs);
} }
private static final MethodHandle[] FILLERS = new MethodHandle[MAX_ARITY+1]; private static final MethodHandle[] FILLERS = new MethodHandle[MAX_ARITY+1];
...@@ -1122,7 +1122,7 @@ public class ValueConversions { ...@@ -1122,7 +1122,7 @@ public class ValueConversions {
} }
MethodHandle leftFill = filler(leftLen); // recursive fill MethodHandle leftFill = filler(leftLen); // recursive fill
MethodHandle rightFill = FILL_ARRAYS[rightLen]; MethodHandle rightFill = FILL_ARRAYS[rightLen];
rightFill = MethodHandles.insertArguments(rightFill, 1, (int) leftLen); // [leftLen..nargs-1] rightFill = MethodHandles.insertArguments(rightFill, 1, leftLen); // [leftLen..nargs-1]
// Combine the two fills: right(left(newArray(nargs), x1..x20), x21..x23) // Combine the two fills: right(left(newArray(nargs), x1..x20), x21..x23)
MethodHandle mh = filler(0); // identity function produces result MethodHandle mh = filler(0); // identity function produces result
......
...@@ -31,7 +31,7 @@ public enum Wrapper { ...@@ -31,7 +31,7 @@ public enum Wrapper {
BYTE(Byte.class, byte.class, 'B', (Byte)(byte)0, new byte[0], Format.signed(8)), BYTE(Byte.class, byte.class, 'B', (Byte)(byte)0, new byte[0], Format.signed(8)),
SHORT(Short.class, short.class, 'S', (Short)(short)0, new short[0], Format.signed(16)), SHORT(Short.class, short.class, 'S', (Short)(short)0, new short[0], Format.signed(16)),
CHAR(Character.class, char.class, 'C', (Character)(char)0, new char[0], Format.unsigned(16)), CHAR(Character.class, char.class, 'C', (Character)(char)0, new char[0], Format.unsigned(16)),
INT(Integer.class, int.class, 'I', (Integer)(int)0, new int[0], Format.signed(32)), INT(Integer.class, int.class, 'I', (Integer)/*(int)*/0, new int[0], Format.signed(32)),
LONG(Long.class, long.class, 'J', (Long)(long)0, new long[0], Format.signed(64)), LONG(Long.class, long.class, 'J', (Long)(long)0, new long[0], Format.signed(64)),
FLOAT(Float.class, float.class, 'F', (Float)(float)0, new float[0], Format.floating(32)), FLOAT(Float.class, float.class, 'F', (Float)(float)0, new float[0], Format.floating(32)),
DOUBLE(Double.class, double.class, 'D', (Double)(double)0, new double[0], Format.floating(64)), DOUBLE(Double.class, double.class, 'D', (Double)(double)0, new double[0], Format.floating(64)),
...@@ -539,7 +539,7 @@ public enum Wrapper { ...@@ -539,7 +539,7 @@ public enum Wrapper {
switch (basicTypeChar) { switch (basicTypeChar) {
case 'L': throw newIllegalArgumentException("cannot wrap to object type"); case 'L': throw newIllegalArgumentException("cannot wrap to object type");
case 'V': return null; case 'V': return null;
case 'I': return Integer.valueOf((int)x); case 'I': return Integer.valueOf(x);
case 'J': return Long.valueOf(x); case 'J': return Long.valueOf(x);
case 'F': return Float.valueOf(x); case 'F': return Float.valueOf(x);
case 'D': return Double.valueOf(x); case 'D': return Double.valueOf(x);
......
...@@ -43,7 +43,7 @@ import static java.lang.invoke.MethodHandles.*; ...@@ -43,7 +43,7 @@ import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*; import static java.lang.invoke.MethodType.*;
public class CallSiteTest { public class CallSiteTest {
private final static Class CLASS = CallSiteTest.class; private final static Class<?> CLASS = CallSiteTest.class;
private static CallSite mcs; private static CallSite mcs;
private static CallSite vcs; private static CallSite vcs;
......
...@@ -38,10 +38,6 @@ ...@@ -38,10 +38,6 @@
package test.java.lang.invoke; package test.java.lang.invoke;
import java.util.*;
import java.lang.invoke.*;
import org.junit.*; import org.junit.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
......
...@@ -45,6 +45,7 @@ import static org.junit.Assume.*; ...@@ -45,6 +45,7 @@ import static org.junit.Assume.*;
* *
* @author jrose * @author jrose
*/ */
@SuppressWarnings("cast") // various casts help emphasize arguments to invokeExact
public class InvokeGenericTest { public class InvokeGenericTest {
// How much output? // How much output?
static int verbosity = 0; static int verbosity = 0;
...@@ -129,7 +130,7 @@ public class InvokeGenericTest { ...@@ -129,7 +130,7 @@ public class InvokeGenericTest {
} }
} }
static List<Object> calledLog = new ArrayList<Object>(); static List<Object> calledLog = new ArrayList<>();
static Object logEntry(String name, Object... args) { static Object logEntry(String name, Object... args) {
return Arrays.asList(name, Arrays.asList(args)); return Arrays.asList(name, Arrays.asList(args));
} }
...@@ -237,8 +238,7 @@ public class InvokeGenericTest { ...@@ -237,8 +238,7 @@ public class InvokeGenericTest {
else else
try { try {
return param.newInstance(); return param.newInstance();
} catch (InstantiationException ex) { } catch (InstantiationException | IllegalAccessException ex) {
} catch (IllegalAccessException ex) {
} }
return null; // random class not Object, String, Integer, etc. return null; // random class not Object, String, Integer, etc.
} }
...@@ -274,9 +274,11 @@ public class InvokeGenericTest { ...@@ -274,9 +274,11 @@ public class InvokeGenericTest {
return zeroArgs(params.toArray(new Class<?>[0])); return zeroArgs(params.toArray(new Class<?>[0]));
} }
@SafeVarargs @SuppressWarnings("varargs")
static <T, E extends T> T[] array(Class<T[]> atype, E... a) { static <T, E extends T> T[] array(Class<T[]> atype, E... a) {
return Arrays.copyOf(a, a.length, atype); return Arrays.copyOf(a, a.length, atype);
} }
@SafeVarargs @SuppressWarnings("varargs")
static <T> T[] cat(T[] a, T... b) { static <T> T[] cat(T[] a, T... b) {
int alen = a.length, blen = b.length; int alen = a.length, blen = b.length;
if (blen == 0) return a; if (blen == 0) return a;
...@@ -311,7 +313,7 @@ public class InvokeGenericTest { ...@@ -311,7 +313,7 @@ public class InvokeGenericTest {
int beg, int end, Class<?> argType) { int beg, int end, Class<?> argType) {
MethodType targetType = target.type(); MethodType targetType = target.type();
end = Math.min(end, targetType.parameterCount()); end = Math.min(end, targetType.parameterCount());
ArrayList<Class<?>> argTypes = new ArrayList<Class<?>>(targetType.parameterList()); ArrayList<Class<?>> argTypes = new ArrayList<>(targetType.parameterList());
Collections.fill(argTypes.subList(beg, end), argType); Collections.fill(argTypes.subList(beg, end), argType);
MethodType ttype2 = MethodType.methodType(targetType.returnType(), argTypes); MethodType ttype2 = MethodType.methodType(targetType.returnType(), argTypes);
return target.asType(ttype2); return target.asType(ttype2);
...@@ -320,7 +322,7 @@ public class InvokeGenericTest { ...@@ -320,7 +322,7 @@ public class InvokeGenericTest {
// This lookup is good for all members in and under InvokeGenericTest. // This lookup is good for all members in and under InvokeGenericTest.
static final Lookup LOOKUP = MethodHandles.lookup(); static final Lookup LOOKUP = MethodHandles.lookup();
Map<List<Class<?>>, MethodHandle> CALLABLES = new HashMap<List<Class<?>>, MethodHandle>(); Map<List<Class<?>>, MethodHandle> CALLABLES = new HashMap<>();
MethodHandle callable(List<Class<?>> params) { MethodHandle callable(List<Class<?>> params) {
MethodHandle mh = CALLABLES.get(params); MethodHandle mh = CALLABLES.get(params);
if (mh == null) { if (mh == null) {
...@@ -353,8 +355,8 @@ public class InvokeGenericTest { ...@@ -353,8 +355,8 @@ public class InvokeGenericTest {
countTest(); countTest();
String[] args = { "one", "two" }; String[] args = { "one", "two" };
MethodHandle mh = callable(Object.class, String.class); MethodHandle mh = callable(Object.class, String.class);
Object res; List resl; Object res; List<?> resl;
res = resl = (List) mh.invoke((String)args[0], (Object)args[1]); res = resl = (List<?>) mh.invoke((String)args[0], (Object)args[1]);
//System.out.println(res); //System.out.println(res);
assertEquals(Arrays.asList(args), res); assertEquals(Arrays.asList(args), res);
} }
...@@ -365,8 +367,8 @@ public class InvokeGenericTest { ...@@ -365,8 +367,8 @@ public class InvokeGenericTest {
countTest(); countTest();
int[] args = { 1, 2 }; int[] args = { 1, 2 };
MethodHandle mh = callable(Object.class, Object.class); MethodHandle mh = callable(Object.class, Object.class);
Object res; List resl; Object res; List<?> resl;
res = resl = (List) mh.invoke(args[0], args[1]); res = resl = (List<?>) mh.invoke(args[0], args[1]);
//System.out.println(res); //System.out.println(res);
assertEquals(Arrays.toString(args), res.toString()); assertEquals(Arrays.toString(args), res.toString());
} }
...@@ -377,8 +379,8 @@ public class InvokeGenericTest { ...@@ -377,8 +379,8 @@ public class InvokeGenericTest {
countTest(); countTest();
String[] args = { "one", "two" }; String[] args = { "one", "two" };
MethodHandle mh = callable(Object.class, String.class); MethodHandle mh = callable(Object.class, String.class);
Object res; List resl; Object res; List<?> resl;
res = resl = (List) mh.invoke((String)args[0], (Object)args[1]); res = resl = (List<?>) mh.invoke((String)args[0], (Object)args[1]);
//System.out.println(res); //System.out.println(res);
assertEquals(Arrays.asList(args), res); assertEquals(Arrays.asList(args), res);
} }
...@@ -440,9 +442,9 @@ public class InvokeGenericTest { ...@@ -440,9 +442,9 @@ public class InvokeGenericTest {
* A void return type is possible iff the first type is void.class. * A void return type is possible iff the first type is void.class.
*/ */
static List<MethodType> allMethodTypes(int minargc, int maxargc, Class<?>... types) { static List<MethodType> allMethodTypes(int minargc, int maxargc, Class<?>... types) {
ArrayList<MethodType> result = new ArrayList<MethodType>(); ArrayList<MethodType> result = new ArrayList<>();
if (types.length > 0) { if (types.length > 0) {
ArrayList<MethodType> argcTypes = new ArrayList<MethodType>(); ArrayList<MethodType> argcTypes = new ArrayList<>();
// build arity-zero types first // build arity-zero types first
for (Class<?> rtype : types) { for (Class<?> rtype : types) {
argcTypes.add(MethodType.methodType(rtype)); argcTypes.add(MethodType.methodType(rtype));
...@@ -456,7 +458,7 @@ public class InvokeGenericTest { ...@@ -456,7 +458,7 @@ public class InvokeGenericTest {
if (argc >= maxargc) if (argc >= maxargc)
break; break;
ArrayList<MethodType> prevTypes = argcTypes; ArrayList<MethodType> prevTypes = argcTypes;
argcTypes = new ArrayList<MethodType>(); argcTypes = new ArrayList<>();
for (MethodType prevType : prevTypes) { for (MethodType prevType : prevTypes) {
for (Class<?> ptype : types) { for (Class<?> ptype : types) {
argcTypes.add(prevType.insertParameterTypes(argc, ptype)); argcTypes.add(prevType.insertParameterTypes(argc, ptype));
...@@ -524,8 +526,8 @@ public class InvokeGenericTest { ...@@ -524,8 +526,8 @@ public class InvokeGenericTest {
countTest(); countTest();
Object[] args = { 1, 2 }; Object[] args = { 1, 2 };
MethodHandle mh = callable(Object.class, int.class); MethodHandle mh = callable(Object.class, int.class);
Object res; List resl; int resi; Object res; List<?> resl; int resi;
res = resl = (List) mh.invoke((int)args[0], (Object)args[1]); res = resl = (List<?>) mh.invoke((int)args[0], (Object)args[1]);
//System.out.println(res); //System.out.println(res);
assertEquals(Arrays.asList(args), res); assertEquals(Arrays.asList(args), res);
mh = MethodHandles.identity(int.class); mh = MethodHandles.identity(int.class);
......
...@@ -54,6 +54,7 @@ import static org.junit.Assert.*; ...@@ -54,6 +54,7 @@ import static org.junit.Assert.*;
/** /**
* @author jrose * @author jrose
*/ */
@SuppressWarnings("LocalVariableHidesMemberVariable")
public class JavaDocExamplesTest { public class JavaDocExamplesTest {
/** Wrapper for running the JUnit tests in this module. /** Wrapper for running the JUnit tests in this module.
* Put JUnit on the classpath! * Put JUnit on the classpath!
...@@ -336,6 +337,7 @@ assertEquals("[123]", (String) longsToString.invokeExact((long)123)); ...@@ -336,6 +337,7 @@ assertEquals("[123]", (String) longsToString.invokeExact((long)123));
}} }}
} }
@SuppressWarnings("rawtypes")
@Test public void testAsVarargsCollector() throws Throwable { @Test public void testAsVarargsCollector() throws Throwable {
{{ {{
{} /// JAVADOC {} /// JAVADOC
......
...@@ -176,7 +176,7 @@ public class MethodHandlesTest { ...@@ -176,7 +176,7 @@ public class MethodHandlesTest {
} }
} }
static List<Object> calledLog = new ArrayList<Object>(); static List<Object> calledLog = new ArrayList<>();
static Object logEntry(String name, Object... args) { static Object logEntry(String name, Object... args) {
return Arrays.asList(name, Arrays.asList(args)); return Arrays.asList(name, Arrays.asList(args));
} }
...@@ -211,6 +211,7 @@ public class MethodHandlesTest { ...@@ -211,6 +211,7 @@ public class MethodHandlesTest {
return dst.cast(value); return dst.cast(value);
} }
@SuppressWarnings("cast") // primitive cast to (long) is part of the pattern
static Object castToWrapperOrNull(long value, Class<?> dst) { static Object castToWrapperOrNull(long value, Class<?> dst) {
if (dst == int.class || dst == Integer.class) if (dst == int.class || dst == Integer.class)
return (int)(value); return (int)(value);
...@@ -284,8 +285,7 @@ public class MethodHandlesTest { ...@@ -284,8 +285,7 @@ public class MethodHandlesTest {
else else
try { try {
return param.newInstance(); return param.newInstance();
} catch (InstantiationException ex) { } catch (InstantiationException | IllegalAccessException ex) {
} catch (IllegalAccessException ex) {
} }
return null; // random class not Object, String, Integer, etc. return null; // random class not Object, String, Integer, etc.
} }
...@@ -302,9 +302,11 @@ public class MethodHandlesTest { ...@@ -302,9 +302,11 @@ public class MethodHandlesTest {
return args; return args;
} }
@SafeVarargs @SuppressWarnings("varargs")
static <T, E extends T> T[] array(Class<T[]> atype, E... a) { static <T, E extends T> T[] array(Class<T[]> atype, E... a) {
return Arrays.copyOf(a, a.length, atype); return Arrays.copyOf(a, a.length, atype);
} }
@SafeVarargs @SuppressWarnings("varargs")
static <T> T[] cat(T[] a, T... b) { static <T> T[] cat(T[] a, T... b) {
int alen = a.length, blen = b.length; int alen = a.length, blen = b.length;
if (blen == 0) return a; if (blen == 0) return a;
...@@ -354,14 +356,14 @@ public class MethodHandlesTest { ...@@ -354,14 +356,14 @@ public class MethodHandlesTest {
try { try {
LIST_TO_STRING = PRIVATE.findStatic(PRIVATE.lookupClass(), "listToString", LIST_TO_STRING = PRIVATE.findStatic(PRIVATE.lookupClass(), "listToString",
MethodType.methodType(String.class, List.class)); MethodType.methodType(String.class, List.class));
} catch (Exception ex) { throw new RuntimeException(ex); } } catch (NoSuchMethodException | IllegalAccessException ex) { throw new RuntimeException(ex); }
list = MethodHandles.filterReturnValue(list, LIST_TO_STRING); list = MethodHandles.filterReturnValue(list, LIST_TO_STRING);
} else if (rtype.isPrimitive()) { } else if (rtype.isPrimitive()) {
if (LIST_TO_INT == null) if (LIST_TO_INT == null)
try { try {
LIST_TO_INT = PRIVATE.findStatic(PRIVATE.lookupClass(), "listToInt", LIST_TO_INT = PRIVATE.findStatic(PRIVATE.lookupClass(), "listToInt",
MethodType.methodType(int.class, List.class)); MethodType.methodType(int.class, List.class));
} catch (Exception ex) { throw new RuntimeException(ex); } } catch (NoSuchMethodException | IllegalAccessException ex) { throw new RuntimeException(ex); }
list = MethodHandles.filterReturnValue(list, LIST_TO_INT); list = MethodHandles.filterReturnValue(list, LIST_TO_INT);
list = MethodHandles.explicitCastArguments(list, listType); list = MethodHandles.explicitCastArguments(list, listType);
} else { } else {
...@@ -370,8 +372,8 @@ public class MethodHandlesTest { ...@@ -370,8 +372,8 @@ public class MethodHandlesTest {
return list.asType(listType); return list.asType(listType);
} }
private static MethodHandle LIST_TO_STRING, LIST_TO_INT; private static MethodHandle LIST_TO_STRING, LIST_TO_INT;
private static String listToString(List x) { return x.toString(); } private static String listToString(List<?> x) { return x.toString(); }
private static int listToInt(List x) { return x.toString().hashCode(); } private static int listToInt(List<?> x) { return x.toString().hashCode(); }
static MethodHandle changeArgTypes(MethodHandle target, Class<?> argType) { static MethodHandle changeArgTypes(MethodHandle target, Class<?> argType) {
return changeArgTypes(target, 0, 999, argType); return changeArgTypes(target, 0, 999, argType);
...@@ -380,7 +382,7 @@ public class MethodHandlesTest { ...@@ -380,7 +382,7 @@ public class MethodHandlesTest {
int beg, int end, Class<?> argType) { int beg, int end, Class<?> argType) {
MethodType targetType = target.type(); MethodType targetType = target.type();
end = Math.min(end, targetType.parameterCount()); end = Math.min(end, targetType.parameterCount());
ArrayList<Class<?>> argTypes = new ArrayList<Class<?>>(targetType.parameterList()); ArrayList<Class<?>> argTypes = new ArrayList<>(targetType.parameterList());
Collections.fill(argTypes.subList(beg, end), argType); Collections.fill(argTypes.subList(beg, end), argType);
MethodType ttype2 = MethodType.methodType(targetType.returnType(), argTypes); MethodType ttype2 = MethodType.methodType(targetType.returnType(), argTypes);
return target.asType(ttype2); return target.asType(ttype2);
...@@ -405,6 +407,7 @@ public class MethodHandlesTest { ...@@ -405,6 +407,7 @@ public class MethodHandlesTest {
final String name; final String name;
public Example() { name = "Example#"+nextArg(); } public Example() { name = "Example#"+nextArg(); }
protected Example(String name) { this.name = name; } protected Example(String name) { this.name = name; }
@SuppressWarnings("LeakingThisInConstructor")
protected Example(int x) { this(); called("protected <init>", this, x); } protected Example(int x) { this(); called("protected <init>", this, x); }
@Override public String toString() { return name; } @Override public String toString() { return name; }
...@@ -441,6 +444,7 @@ public class MethodHandlesTest { ...@@ -441,6 +444,7 @@ public class MethodHandlesTest {
static class SubExample extends Example { static class SubExample extends Example {
@Override public void v0() { called("Sub/v0", this); } @Override public void v0() { called("Sub/v0", this); }
@Override void pkg_v0() { called("Sub/pkg_v0", this); } @Override void pkg_v0() { called("Sub/pkg_v0", this); }
@SuppressWarnings("LeakingThisInConstructor")
private SubExample(int x) { called("<init>", this, x); } private SubExample(int x) { called("<init>", this, x); }
public SubExample() { super("SubExample#"+nextArg()); } public SubExample() { super("SubExample#"+nextArg()); }
} }
...@@ -912,7 +916,7 @@ public class MethodHandlesTest { ...@@ -912,7 +916,7 @@ public class MethodHandlesTest {
static final Object[][] CASES; static final Object[][] CASES;
static { static {
ArrayList<Object[]> cases = new ArrayList<Object[]>(); ArrayList<Object[]> cases = new ArrayList<>();
Object types[][] = { Object types[][] = {
{'L',Object.class}, {'R',String.class}, {'L',Object.class}, {'R',String.class},
{'I',int.class}, {'J',long.class}, {'I',int.class}, {'J',long.class},
...@@ -931,12 +935,12 @@ public class MethodHandlesTest { ...@@ -931,12 +935,12 @@ public class MethodHandlesTest {
Field field; Field field;
try { try {
field = HasFields.class.getDeclaredField(name); field = HasFields.class.getDeclaredField(name);
} catch (Exception ex) { } catch (NoSuchFieldException | SecurityException ex) {
throw new InternalError("no field HasFields."+name); throw new InternalError("no field HasFields."+name);
} }
try { try {
value = field.get(fields); value = field.get(fields);
} catch (Exception ex) { } catch (IllegalArgumentException | IllegalAccessException ex) {
throw new InternalError("cannot fetch field HasFields."+name); throw new InternalError("cannot fetch field HasFields."+name);
} }
if (type == float.class) { if (type == float.class) {
...@@ -1257,7 +1261,7 @@ public class MethodHandlesTest { ...@@ -1257,7 +1261,7 @@ public class MethodHandlesTest {
List<Object> array2list(Object array) { List<Object> array2list(Object array) {
int length = Array.getLength(array); int length = Array.getLength(array);
ArrayList<Object> model = new ArrayList<Object>(length); ArrayList<Object> model = new ArrayList<>(length);
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
model.add(Array.get(array, i)); model.add(Array.get(array, i));
return model; return model;
...@@ -1288,7 +1292,7 @@ public class MethodHandlesTest { ...@@ -1288,7 +1292,7 @@ public class MethodHandlesTest {
String name = pfx+"id"; String name = pfx+"id";
try { try {
return PRIVATE.findStatic(Callee.class, name, type); return PRIVATE.findStatic(Callee.class, name, type);
} catch (Exception ex) { } catch (NoSuchMethodException | IllegalAccessException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
} }
...@@ -1365,7 +1369,7 @@ public class MethodHandlesTest { ...@@ -1365,7 +1369,7 @@ public class MethodHandlesTest {
MethodHandle vac = vac0.asVarargsCollector(Object[].class); MethodHandle vac = vac0.asVarargsCollector(Object[].class);
testConvert(true, vac.asType(MethodType.genericMethodType(0)), null, "vac"); testConvert(true, vac.asType(MethodType.genericMethodType(0)), null, "vac");
testConvert(true, vac.asType(MethodType.genericMethodType(0)), null, "vac"); testConvert(true, vac.asType(MethodType.genericMethodType(0)), null, "vac");
for (Class<?> at : new Class[] { Object.class, String.class, Integer.class }) { for (Class<?> at : new Class<?>[] { Object.class, String.class, Integer.class }) {
testConvert(true, vac.asType(MethodType.genericMethodType(1)), null, "vac", at); testConvert(true, vac.asType(MethodType.genericMethodType(1)), null, "vac", at);
testConvert(true, vac.asType(MethodType.genericMethodType(2)), null, "vac", at, at); testConvert(true, vac.asType(MethodType.genericMethodType(2)), null, "vac", at, at);
} }
...@@ -1514,7 +1518,7 @@ public class MethodHandlesTest { ...@@ -1514,7 +1518,7 @@ public class MethodHandlesTest {
public void testSpreadArguments() throws Throwable { public void testSpreadArguments() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("spreadArguments"); startTest("spreadArguments");
for (Class<?> argType : new Class[]{Object.class, Integer.class, int.class}) { for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) {
if (verbosity >= 3) if (verbosity >= 3)
System.out.println("spreadArguments "+argType); System.out.println("spreadArguments "+argType);
for (int nargs = 0; nargs < 50; nargs++) { for (int nargs = 0; nargs < 50; nargs++) {
...@@ -1538,7 +1542,7 @@ public class MethodHandlesTest { ...@@ -1538,7 +1542,7 @@ public class MethodHandlesTest {
Object[] args = randomArgs(target2.type().parameterArray()); Object[] args = randomArgs(target2.type().parameterArray());
// make sure the target does what we think it does: // make sure the target does what we think it does:
if (pos == 0 && nargs < 5 && !argType.isPrimitive()) { if (pos == 0 && nargs < 5 && !argType.isPrimitive()) {
Object[] check = (Object[]) (Object) target.invokeWithArguments(args); Object[] check = (Object[]) target.invokeWithArguments(args);
assertArrayEquals(args, check); assertArrayEquals(args, check);
switch (nargs) { switch (nargs) {
case 0: case 0:
...@@ -1555,7 +1559,7 @@ public class MethodHandlesTest { ...@@ -1555,7 +1559,7 @@ public class MethodHandlesTest {
break; break;
} }
} }
List<Class<?>> newParams = new ArrayList<Class<?>>(target2.type().parameterList()); List<Class<?>> newParams = new ArrayList<>(target2.type().parameterList());
{ // modify newParams in place { // modify newParams in place
List<Class<?>> spreadParams = newParams.subList(pos, nargs); List<Class<?>> spreadParams = newParams.subList(pos, nargs);
spreadParams.clear(); spreadParams.add(arrayType); spreadParams.clear(); spreadParams.add(arrayType);
...@@ -1608,7 +1612,7 @@ public class MethodHandlesTest { ...@@ -1608,7 +1612,7 @@ public class MethodHandlesTest {
public void testCollectArguments() throws Throwable { public void testCollectArguments() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("collectArguments"); startTest("collectArguments");
for (Class<?> argType : new Class[]{Object.class, Integer.class, int.class}) { for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) {
if (verbosity >= 3) if (verbosity >= 3)
System.out.println("collectArguments "+argType); System.out.println("collectArguments "+argType);
for (int nargs = 0; nargs < 50; nargs++) { for (int nargs = 0; nargs < 50; nargs++) {
...@@ -1670,12 +1674,13 @@ public class MethodHandlesTest { ...@@ -1670,12 +1674,13 @@ public class MethodHandlesTest {
MethodHandle target = varargsArray(nargs + ins); MethodHandle target = varargsArray(nargs + ins);
Object[] args = randomArgs(target.type().parameterArray()); Object[] args = randomArgs(target.type().parameterArray());
List<Object> resList = Arrays.asList(args); List<Object> resList = Arrays.asList(args);
List<Object> argsToPass = new ArrayList<Object>(resList); List<Object> argsToPass = new ArrayList<>(resList);
List<Object> argsToInsert = argsToPass.subList(pos, pos + ins); List<Object> argsToInsert = argsToPass.subList(pos, pos + ins);
if (verbosity >= 3) if (verbosity >= 3)
System.out.println("insert: "+argsToInsert+" into "+target); System.out.println("insert: "+argsToInsert+" into "+target);
@SuppressWarnings("cast") // cast to spread Object... is helpful
MethodHandle target2 = MethodHandles.insertArguments(target, pos, MethodHandle target2 = MethodHandles.insertArguments(target, pos,
(Object[]) argsToInsert.toArray()); (Object[]/*...*/) argsToInsert.toArray());
argsToInsert.clear(); // remove from argsToInsert argsToInsert.clear(); // remove from argsToInsert
Object res2 = target2.invokeWithArguments(argsToPass); Object res2 = target2.invokeWithArguments(argsToPass);
Object res2List = Arrays.asList((Object[])res2); Object res2List = Arrays.asList((Object[])res2);
...@@ -1693,7 +1698,7 @@ public class MethodHandlesTest { ...@@ -1693,7 +1698,7 @@ public class MethodHandlesTest {
Class<?> classOfVCList = varargsList(1).invokeWithArguments(0).getClass(); Class<?> classOfVCList = varargsList(1).invokeWithArguments(0).getClass();
assertTrue(List.class.isAssignableFrom(classOfVCList)); assertTrue(List.class.isAssignableFrom(classOfVCList));
for (int nargs = 0; nargs <= 3; nargs++) { for (int nargs = 0; nargs <= 3; nargs++) {
for (Class<?> rtype : new Class[] { Object.class, for (Class<?> rtype : new Class<?>[] { Object.class,
List.class, List.class,
int.class, int.class,
byte.class, byte.class,
...@@ -1790,7 +1795,7 @@ public class MethodHandlesTest { ...@@ -1790,7 +1795,7 @@ public class MethodHandlesTest {
System.out.println("fold "+target+" with "+combine); System.out.println("fold "+target+" with "+combine);
MethodHandle target2 = MethodHandles.foldArguments(target, combine); MethodHandle target2 = MethodHandles.foldArguments(target, combine);
// Simulate expected effect of combiner on arglist: // Simulate expected effect of combiner on arglist:
List<Object> expected = new ArrayList<Object>(argsToPass); List<Object> expected = new ArrayList<>(argsToPass);
List<Object> argsToFold = expected.subList(pos, pos + fold); List<Object> argsToFold = expected.subList(pos, pos + fold);
if (verbosity >= 3) if (verbosity >= 3)
System.out.println("fold: "+argsToFold+" into "+target2); System.out.println("fold: "+argsToFold+" into "+target2);
...@@ -1822,9 +1827,9 @@ public class MethodHandlesTest { ...@@ -1822,9 +1827,9 @@ public class MethodHandlesTest {
MethodHandle target = varargsArray(nargs); MethodHandle target = varargsArray(nargs);
Object[] args = randomArgs(target.type().parameterArray()); Object[] args = randomArgs(target.type().parameterArray());
MethodHandle target2 = MethodHandles.dropArguments(target, pos, MethodHandle target2 = MethodHandles.dropArguments(target, pos,
Collections.nCopies(drop, Object.class).toArray(new Class[0])); Collections.nCopies(drop, Object.class).toArray(new Class<?>[0]));
List<Object> resList = Arrays.asList(args); List<Object> resList = Arrays.asList(args);
List<Object> argsToDrop = new ArrayList<Object>(resList); List<Object> argsToDrop = new ArrayList<>(resList);
for (int i = drop; i > 0; i--) { for (int i = drop; i > 0; i--) {
argsToDrop.add(pos, "blort#"+i); argsToDrop.add(pos, "blort#"+i);
} }
...@@ -1840,11 +1845,11 @@ public class MethodHandlesTest { ...@@ -1840,11 +1845,11 @@ public class MethodHandlesTest {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("exactInvoker, genericInvoker, varargsInvoker, dynamicInvoker"); startTest("exactInvoker, genericInvoker, varargsInvoker, dynamicInvoker");
// exactInvoker, genericInvoker, varargsInvoker[0..N], dynamicInvoker // exactInvoker, genericInvoker, varargsInvoker[0..N], dynamicInvoker
Set<MethodType> done = new HashSet<MethodType>(); Set<MethodType> done = new HashSet<>();
for (int i = 0; i <= 6; i++) { for (int i = 0; i <= 6; i++) {
if (CAN_TEST_LIGHTLY && i > 3) break; if (CAN_TEST_LIGHTLY && i > 3) break;
MethodType gtype = MethodType.genericMethodType(i); MethodType gtype = MethodType.genericMethodType(i);
for (Class<?> argType : new Class[]{Object.class, Integer.class, int.class}) { for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) {
for (int j = -1; j < i; j++) { for (int j = -1; j < i; j++) {
MethodType type = gtype; MethodType type = gtype;
if (j < 0) if (j < 0)
...@@ -1873,7 +1878,7 @@ public class MethodHandlesTest { ...@@ -1873,7 +1878,7 @@ public class MethodHandlesTest {
assertTrue(target.isVarargsCollector()); assertTrue(target.isVarargsCollector());
target = target.asType(type); target = target.asType(type);
Object[] args = randomArgs(type.parameterArray()); Object[] args = randomArgs(type.parameterArray());
List<Object> targetPlusArgs = new ArrayList<Object>(Arrays.asList(args)); List<Object> targetPlusArgs = new ArrayList<>(Arrays.asList(args));
targetPlusArgs.add(0, target); targetPlusArgs.add(0, target);
int code = (Integer) invokee(args); int code = (Integer) invokee(args);
Object log = logEntry("invokee", args); Object log = logEntry("invokee", args);
...@@ -1960,7 +1965,7 @@ public class MethodHandlesTest { ...@@ -1960,7 +1965,7 @@ public class MethodHandlesTest {
.appendParameterTypes(Object[].class) .appendParameterTypes(Object[].class)
.insertParameterTypes(0, MethodHandle.class)); .insertParameterTypes(0, MethodHandle.class));
assertEquals(expType, inv.type()); assertEquals(expType, inv.type());
List<Object> targetPlusVarArgs = new ArrayList<Object>(targetPlusArgs); List<Object> targetPlusVarArgs = new ArrayList<>(targetPlusArgs);
List<Object> tailList = targetPlusVarArgs.subList(1+k, 1+nargs); List<Object> tailList = targetPlusVarArgs.subList(1+k, 1+nargs);
Object[] tail = tailList.toArray(); Object[] tail = tailList.toArray();
tailList.clear(); tailList.add(tail); tailList.clear(); tailList.add(tail);
...@@ -2191,7 +2196,7 @@ public class MethodHandlesTest { ...@@ -2191,7 +2196,7 @@ public class MethodHandlesTest {
if (throwMode == THROW_NOTHING) { if (throwMode == THROW_NOTHING) {
assertSame(arg0, returned); assertSame(arg0, returned);
} else if (throwMode == THROW_CAUGHT) { } else if (throwMode == THROW_CAUGHT) {
List<Object> catchArgs = new ArrayList<Object>(Arrays.asList(args)); List<Object> catchArgs = new ArrayList<>(Arrays.asList(args));
// catcher receives an initial subsequence of target arguments: // catcher receives an initial subsequence of target arguments:
catchArgs.subList(nargs - catchDrops, nargs).clear(); catchArgs.subList(nargs - catchDrops, nargs).clear();
// catcher also receives the exception, prepended: // catcher also receives the exception, prepended:
...@@ -2317,12 +2322,13 @@ public class MethodHandlesTest { ...@@ -2317,12 +2322,13 @@ public class MethodHandlesTest {
INT_IDENTITY = PRIVATE.findStatic( INT_IDENTITY = PRIVATE.findStatic(
Surprise.class, "intIdentity", Surprise.class, "intIdentity",
MethodType.methodType(int.class, int.class)); MethodType.methodType(int.class, int.class));
} catch (Exception ex) { } catch (NoSuchMethodException | IllegalAccessException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
} }
} }
@SuppressWarnings("ConvertToStringSwitch")
void testCastFailure(String mode, int okCount) throws Throwable { void testCastFailure(String mode, int okCount) throws Throwable {
countTest(false); countTest(false);
if (verbosity > 2) System.out.println("mode="+mode); if (verbosity > 2) System.out.println("mode="+mode);
...@@ -2419,12 +2425,13 @@ public class MethodHandlesTest { ...@@ -2419,12 +2425,13 @@ public class MethodHandlesTest {
public interface Fooable { public interface Fooable {
// overloads: // overloads:
Object foo(Object x, String y); Object foo(Object x, String y);
List foo(String x, int y); List<?> foo(String x, int y);
Object foo(String x); Object foo(String x);
} }
static Object fooForFooable(String x, Object... y) { static Object fooForFooable(String x, Object... y) {
return called("fooForFooable/"+x, y); return called("fooForFooable/"+x, y);
} }
@SuppressWarnings("serial") // not really a public API, just a test case
public static class MyCheckedException extends Exception { public static class MyCheckedException extends Exception {
} }
public interface WillThrow { public interface WillThrow {
...@@ -2453,7 +2460,7 @@ public class MethodHandlesTest { ...@@ -2453,7 +2460,7 @@ public class MethodHandlesTest {
{ {
countTest(); countTest();
if (verbosity >= 2) System.out.println("Appendable"); if (verbosity >= 2) System.out.println("Appendable");
ArrayList<List> appendResults = new ArrayList<List>(); ArrayList<List<?>> appendResults = new ArrayList<>();
MethodHandle append = lookup.bind(appendResults, "add", MethodType.methodType(boolean.class, Object.class)); MethodHandle append = lookup.bind(appendResults, "add", MethodType.methodType(boolean.class, Object.class));
append = append.asType(MethodType.methodType(void.class, List.class)); // specialize the type append = append.asType(MethodType.methodType(void.class, List.class)); // specialize the type
MethodHandle asList = lookup.findStatic(Arrays.class, "asList", MethodType.methodType(List.class, Object[].class)); MethodHandle asList = lookup.findStatic(Arrays.class, "asList", MethodType.methodType(List.class, Object[].class));
...@@ -2475,11 +2482,11 @@ public class MethodHandlesTest { ...@@ -2475,11 +2482,11 @@ public class MethodHandlesTest {
formatter.format(fmt, fmtArgs); formatter.format(fmt, fmtArgs);
String actual = ""; String actual = "";
if (verbosity >= 3) System.out.println("appendResults="+appendResults); if (verbosity >= 3) System.out.println("appendResults="+appendResults);
for (List l : appendResults) { for (List<?> l : appendResults) {
Object x = l.get(0); Object x = l.get(0);
switch (l.size()) { switch (l.size()) {
case 1: actual += x; continue; case 1: actual += x; continue;
case 3: actual += ((String)x).substring((int)l.get(1), (int)l.get(2)); continue; case 3: actual += ((String)x).substring((int)(Object)l.get(1), (int)(Object)l.get(2)); continue;
} }
actual += l; actual += l;
} }
...@@ -2551,7 +2558,7 @@ public class MethodHandlesTest { ...@@ -2551,7 +2558,7 @@ public class MethodHandlesTest {
} }
} }
// Test error checking on bad interfaces: // Test error checking on bad interfaces:
for (Class<?> nonSMI : new Class[] { Object.class, for (Class<?> nonSMI : new Class<?>[] { Object.class,
String.class, String.class,
CharSequence.class, CharSequence.class,
java.io.Serializable.class, java.io.Serializable.class,
...@@ -2579,7 +2586,7 @@ public class MethodHandlesTest { ...@@ -2579,7 +2586,7 @@ public class MethodHandlesTest {
} }
} }
// Test error checking on interfaces with the wrong method type: // Test error checking on interfaces with the wrong method type:
for (Class<?> intfc : new Class[] { Runnable.class /*arity 0*/, for (Class<?> intfc : new Class<?>[] { Runnable.class /*arity 0*/,
Fooable.class /*arity 1 & 2*/ }) { Fooable.class /*arity 1 & 2*/ }) {
int badArity = 1; // known to be incompatible int badArity = 1; // known to be incompatible
if (verbosity > 2) System.out.println(intfc.getName()); if (verbosity > 2) System.out.println(intfc.getName());
...@@ -2657,7 +2664,7 @@ class ValueConversions { ...@@ -2657,7 +2664,7 @@ class ValueConversions {
Object a8, Object a9) Object a8, Object a9)
{ return makeArray(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); } { return makeArray(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
static MethodHandle[] makeArrays() { static MethodHandle[] makeArrays() {
ArrayList<MethodHandle> arrays = new ArrayList<MethodHandle>(); ArrayList<MethodHandle> arrays = new ArrayList<>();
MethodHandles.Lookup lookup = IMPL_LOOKUP; MethodHandles.Lookup lookup = IMPL_LOOKUP;
for (;;) { for (;;) {
int nargs = arrays.size(); int nargs = arrays.size();
...@@ -2746,7 +2753,7 @@ class ValueConversions { ...@@ -2746,7 +2753,7 @@ class ValueConversions {
Object a8, Object a9) Object a8, Object a9)
{ return makeList(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); } { return makeList(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
static MethodHandle[] makeLists() { static MethodHandle[] makeLists() {
ArrayList<MethodHandle> lists = new ArrayList<MethodHandle>(); ArrayList<MethodHandle> lists = new ArrayList<>();
MethodHandles.Lookup lookup = IMPL_LOOKUP; MethodHandles.Lookup lookup = IMPL_LOOKUP;
for (;;) { for (;;) {
int nargs = lists.size(); int nargs = lists.size();
...@@ -2769,7 +2776,7 @@ class ValueConversions { ...@@ -2769,7 +2776,7 @@ class ValueConversions {
static { static {
try { try {
AS_LIST = IMPL_LOOKUP.findStatic(Arrays.class, "asList", MethodType.methodType(List.class, Object[].class)); AS_LIST = IMPL_LOOKUP.findStatic(Arrays.class, "asList", MethodType.methodType(List.class, Object[].class));
} catch (Exception ex) { throw new RuntimeException(ex); } } catch (NoSuchMethodException | IllegalAccessException ex) { throw new RuntimeException(ex); }
} }
/** Return a method handle that takes the indicated number of Object /** Return a method handle that takes the indicated number of Object
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
package test.java.lang.invoke; package test.java.lang.invoke;
import java.io.IOException;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -378,7 +379,7 @@ public class MethodTypeTest { ...@@ -378,7 +379,7 @@ public class MethodTypeTest {
public void testHashCode() { public void testHashCode() {
System.out.println("hashCode"); System.out.println("hashCode");
MethodType instance = mt_viS; MethodType instance = mt_viS;
ArrayList<Class<?>> types = new ArrayList<Class<?>>(); ArrayList<Class<?>> types = new ArrayList<>();
types.add(instance.returnType()); types.add(instance.returnType());
types.addAll(instance.parameterList()); types.addAll(instance.parameterList());
int expResult = types.hashCode(); int expResult = types.hashCode();
...@@ -556,7 +557,7 @@ public class MethodTypeTest { ...@@ -556,7 +557,7 @@ public class MethodTypeTest {
Object decode; Object decode;
try { try {
decode = readSerial(wire); decode = readSerial(wire);
} catch (Exception ex) { } catch (IOException | ClassNotFoundException ex) {
decode = ex; // oops! decode = ex; // oops!
} }
assertEquals(mt, decode); assertEquals(mt, decode);
......
...@@ -45,7 +45,7 @@ import static java.lang.invoke.MethodHandles.*; ...@@ -45,7 +45,7 @@ import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*; import static java.lang.invoke.MethodType.*;
public class PermuteArgsTest { public class PermuteArgsTest {
private static final Class CLASS = PermuteArgsTest.class; private static final Class<?> CLASS = PermuteArgsTest.class;
private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 8); private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 8);
private static final boolean DRY_RUN = Boolean.getBoolean(CLASS.getSimpleName()+".DRY_RUN"); private static final boolean DRY_RUN = Boolean.getBoolean(CLASS.getSimpleName()+".DRY_RUN");
private static final boolean VERBOSE = Boolean.getBoolean(CLASS.getSimpleName()+".VERBOSE") || DRY_RUN; private static final boolean VERBOSE = Boolean.getBoolean(CLASS.getSimpleName()+".VERBOSE") || DRY_RUN;
...@@ -99,12 +99,12 @@ public class PermuteArgsTest { ...@@ -99,12 +99,12 @@ public class PermuteArgsTest {
return Arrays.asList(w, x, y, z); return Arrays.asList(w, x, y, z);
} }
static Object listI_etc(int... va) { static Object listI_etc(int... va) {
ArrayList<Object> res = new ArrayList<Object>(); ArrayList<Object> res = new ArrayList<>();
for (int x : va) res.add(x); for (int x : va) res.add(x);
return res; return res;
} }
static Object listIJL_etc(int x, long y, Object z, Object... va) { static Object listIJL_etc(int x, long y, Object z, Object... va) {
ArrayList<Object> res = new ArrayList<Object>(); ArrayList<Object> res = new ArrayList<>();
res.addAll(Arrays.asList(x, y, z)); res.addAll(Arrays.asList(x, y, z));
res.addAll(Arrays.asList(va)); res.addAll(Arrays.asList(va));
return res; return res;
...@@ -168,7 +168,7 @@ public class PermuteArgsTest { ...@@ -168,7 +168,7 @@ public class PermuteArgsTest {
mh1 = adjustArity(mh, arity); mh1 = adjustArity(mh, arity);
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
System.out.println("*** mh = "+name+" : "+mh+"; arity = "+arity+" => "+ex); System.out.println("*** mh = "+name+" : "+mh+"; arity = "+arity+" => "+ex);
ex.printStackTrace(); ex.printStackTrace(System.out);
break; // cannot get this arity for this type break; // cannot get this arity for this type
} }
test("("+arity+")"+name, mh1); test("("+arity+")"+name, mh1);
...@@ -213,7 +213,7 @@ public class PermuteArgsTest { ...@@ -213,7 +213,7 @@ public class PermuteArgsTest {
} }
static void testPermutations(MethodHandle mh) throws Throwable { static void testPermutations(MethodHandle mh) throws Throwable {
HashSet<String> done = new HashSet<String>(); HashSet<String> done = new HashSet<>();
MethodType mt = mh.type(); MethodType mt = mh.type();
int[] perm = nullPerm(mt.parameterCount()); int[] perm = nullPerm(mt.parameterCount());
final int MARGIN = (perm.length <= 10 ? 2 : 0); final int MARGIN = (perm.length <= 10 ? 2 : 0);
...@@ -326,8 +326,8 @@ public class PermuteArgsTest { ...@@ -326,8 +326,8 @@ public class PermuteArgsTest {
Class<?> pt = ptypes[i]; Class<?> pt = ptypes[i];
Object arg; Object arg;
if (pt == Void.class) arg = null; if (pt == Void.class) arg = null;
else if (pt == int.class) arg = (int) i + 101; else if (pt == int.class) arg = i + 101;
else if (pt == long.class) arg = (long) i + 10_000_000_001L; else if (pt == long.class) arg = i + 10_000_000_001L;
else arg = "#" + (i + 1); else arg = "#" + (i + 1);
args[i] = arg; args[i] = arg;
} }
......
...@@ -40,7 +40,6 @@ import org.junit.*; ...@@ -40,7 +40,6 @@ import org.junit.*;
import static java.lang.invoke.MethodType.*; import static java.lang.invoke.MethodType.*;
import static java.lang.invoke.MethodHandles.*; import static java.lang.invoke.MethodHandles.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.junit.Assume.*;
/** /**
...@@ -48,7 +47,7 @@ import static org.junit.Assume.*; ...@@ -48,7 +47,7 @@ import static org.junit.Assume.*;
* @author jrose * @author jrose
*/ */
public class RicochetTest { public class RicochetTest {
private static final Class CLASS = RicochetTest.class; private static final Class<?> CLASS = RicochetTest.class;
private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 40); private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 40);
public static void main(String... av) throws Throwable { public static void main(String... av) throws Throwable {
...@@ -148,7 +147,7 @@ public class RicochetTest { ...@@ -148,7 +147,7 @@ public class RicochetTest {
for (int nargs = 0; nargs <= MAX; nargs++) { for (int nargs = 0; nargs <= MAX; nargs++) {
if (nargs > 30 && nargs < MAX-20) nargs += 10; if (nargs > 30 && nargs < MAX-20) nargs += 10;
int[] args = new int[nargs]; int[] args = new int[nargs];
for (int j = 0; j < args.length; j++) args[j] = (int)(j + 11); for (int j = 0; j < args.length; j++) args[j] = j + 11;
//System.out.println("testIntSpreads "+Arrays.toString(args)); //System.out.println("testIntSpreads "+Arrays.toString(args));
int[] args1 = (int[]) id.invokeExact(args); int[] args1 = (int[]) id.invokeExact(args);
assertArrayEquals(args, args1); assertArrayEquals(args, args1);
...@@ -388,6 +387,7 @@ public class RicochetTest { ...@@ -388,6 +387,7 @@ public class RicochetTest {
java.util.Random random; java.util.Random random;
final MethodHandle[] fns; final MethodHandle[] fns;
int depth; int depth;
@SuppressWarnings("LeakingThisInConstructor")
RFCB(int seed) throws Throwable { RFCB(int seed) throws Throwable {
this.random = new java.util.Random(seed); this.random = new java.util.Random(seed);
this.fns = new MethodHandle[Math.max(29, (1 << MAX_DEPTH-2)/3)]; this.fns = new MethodHandle[Math.max(29, (1 << MAX_DEPTH-2)/3)];
...@@ -408,7 +408,7 @@ public class RicochetTest { ...@@ -408,7 +408,7 @@ public class RicochetTest {
case 1: case 1:
Throwable ex = new RuntimeException(); Throwable ex = new RuntimeException();
ex.fillInStackTrace(); ex.fillInStackTrace();
if (VERBOSITY >= 2) ex.printStackTrace(); if (VERBOSITY >= 2) ex.printStackTrace(System.out);
x = "ST; " + x; x = "ST; " + x;
break; break;
case 2: case 2:
...@@ -467,7 +467,7 @@ public class RicochetTest { ...@@ -467,7 +467,7 @@ public class RicochetTest {
return mh.invokeWithArguments(args); return mh.invokeWithArguments(args);
} catch (Throwable ex) { } catch (Throwable ex) {
System.out.println("threw: "+mh+Arrays.asList(args)); System.out.println("threw: "+mh+Arrays.asList(args));
ex.printStackTrace(); ex.printStackTrace(System.out);
return ex; return ex;
} }
} }
...@@ -515,8 +515,8 @@ public class RicochetTest { ...@@ -515,8 +515,8 @@ public class RicochetTest {
private static long opJ(long x) { return (long) opI((int)x); } private static long opJ(long x) { return (long) opI((int)x); }
private static Object opL2(Object x, Object y) { return (Object) opI2((int)x, (int)y); } private static Object opL2(Object x, Object y) { return (Object) opI2((int)x, (int)y); }
private static Object opL(Object x) { return (Object) opI((int)x); } private static Object opL(Object x) { return (Object) opI((int)x); }
private static int opL2_I(Object x, Object y) { return (int) opI2((int)x, (int)y); } private static int opL2_I(Object x, Object y) { return opI2((int)x, (int)y); }
private static int opL_I(Object x) { return (int) opI((int)x); } private static int opL_I(Object x) { return opI((int)x); }
private static long opL_J(Object x) { return (long) opI((int)x); } private static long opL_J(Object x) { return (long) opI((int)x); }
private static final MethodHandle opI, opI2, opI3, opI4, opI_L, opJ, opJ2, opJ3, opL2, opL, opL2_I, opL_I, opL_J; private static final MethodHandle opI, opI2, opI3, opI4, opI_L, opJ, opJ2, opJ3, opL2, opL, opL2_I, opL_I, opL_J;
static { static {
...@@ -570,8 +570,8 @@ public class RicochetTest { ...@@ -570,8 +570,8 @@ public class RicochetTest {
INT_LISTERS[i] = lister; INT_LISTERS[i] = lister;
LONG_LISTERS[i] = llister; LONG_LISTERS[i] = llister;
if (i == 0) break; if (i == 0) break;
lister = insertArguments(lister, i-1, (int)0); lister = insertArguments(lister, i-1, 0);
llister = insertArguments(llister, i-1, (long)0); llister = insertArguments(llister, i-1, 0L);
} }
} }
......
...@@ -40,7 +40,7 @@ import static java.lang.invoke.MethodHandles.*; ...@@ -40,7 +40,7 @@ import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*; import static java.lang.invoke.MethodType.*;
public class ThrowExceptionsTest { public class ThrowExceptionsTest {
private static final Class CLASS = ThrowExceptionsTest.class; private static final Class<?> CLASS = ThrowExceptionsTest.class;
private static final Lookup LOOKUP = lookup(); private static final Lookup LOOKUP = lookup();
public static void main(String argv[]) throws Throwable { public static void main(String argv[]) throws Throwable {
...@@ -132,9 +132,9 @@ public class ThrowExceptionsTest { ...@@ -132,9 +132,9 @@ public class ThrowExceptionsTest {
int tc = testCases; int tc = testCases;
try { try {
m.invoke(this); m.invoke(this);
} catch (Throwable ex) { } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
System.out.println("*** "+ex); System.out.println("*** "+ex);
ex.printStackTrace(); ex.printStackTrace(System.out);
} }
if (testCases == tc) testCases++; if (testCases == tc) testCases++;
} }
......
...@@ -27,11 +27,9 @@ import sun.invoke.util.ValueConversions; ...@@ -27,11 +27,9 @@ import sun.invoke.util.ValueConversions;
import sun.invoke.util.Wrapper; import sun.invoke.util.Wrapper;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
...@@ -52,7 +50,7 @@ import static org.junit.Assert.*; ...@@ -52,7 +50,7 @@ import static org.junit.Assert.*;
* @author jrose * @author jrose
*/ */
public class ValueConversionsTest { public class ValueConversionsTest {
private static final Class CLASS = ValueConversionsTest.class; private static final Class<?> CLASS = ValueConversionsTest.class;
private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 40); private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 40);
private static final int START_ARITY = Integer.getInteger(CLASS.getSimpleName()+".START_ARITY", 0); private static final int START_ARITY = Integer.getInteger(CLASS.getSimpleName()+".START_ARITY", 0);
private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE"); private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE");
...@@ -165,7 +163,7 @@ public class ValueConversionsTest { ...@@ -165,7 +163,7 @@ public class ValueConversionsTest {
Object expResult = box; Object expResult = box;
Object result = null; Object result = null;
switch (w) { switch (w) {
case INT: result = boxer.invokeExact((int)n); break; case INT: result = boxer.invokeExact(/*int*/n); break;
case LONG: result = boxer.invokeExact((long)n); break; case LONG: result = boxer.invokeExact((long)n); break;
case FLOAT: result = boxer.invokeExact((float)n); break; case FLOAT: result = boxer.invokeExact((float)n); break;
case DOUBLE: result = boxer.invokeExact((double)n); break; case DOUBLE: result = boxer.invokeExact((double)n); break;
...@@ -361,6 +359,7 @@ public class ValueConversionsTest { ...@@ -361,6 +359,7 @@ public class ValueConversionsTest {
assert(stype == MethodType.methodType(arrayType, arrayType)); assert(stype == MethodType.methodType(arrayType, arrayType));
if (nargs <= 5) { if (nargs <= 5) {
// invoke target as a spreader also: // invoke target as a spreader also:
@SuppressWarnings("cast")
Object res2 = spreader.invokeWithArguments((Object)res); Object res2 = spreader.invokeWithArguments((Object)res);
String res2String = toArrayString(res2); String res2String = toArrayString(res2);
assertEquals(Arrays.toString(args), res2String); assertEquals(Arrays.toString(args), res2String);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册