mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8000989: smaller code changes to make future JSR 292 backports easier
Reviewed-by: jrose
This commit is contained in:
parent
d9aab5025e
commit
01d0ba69ce
13 changed files with 52 additions and 39 deletions
|
@ -27,6 +27,7 @@ package java.lang.invoke;
|
|||
|
||||
import java.util.Arrays;
|
||||
import sun.invoke.empty.Empty;
|
||||
import static java.lang.invoke.MethodHandleStatics.*;
|
||||
import static java.lang.invoke.MethodHandleNatives.Constants.*;
|
||||
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
||||
import static java.lang.invoke.LambdaForm.*;
|
||||
|
@ -128,7 +129,6 @@ class Invokers {
|
|||
try {
|
||||
//Lookup.findVirtual(MethodHandle.class, name, type);
|
||||
return IMPL_LOOKUP.resolveOrFail(REF_invokeVirtual, MethodHandle.class, name, type);
|
||||
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw newInternalError("JVM cannot find invoker for "+type, ex);
|
||||
}
|
||||
|
|
|
@ -93,6 +93,12 @@ import sun.misc.Unsafe;
|
|||
}
|
||||
|
||||
// handy shared exception makers (they simplify the common case code)
|
||||
/*non-public*/ static InternalError newInternalError(String message, Throwable cause) {
|
||||
return new InternalError(message, cause);
|
||||
}
|
||||
/*non-public*/ static InternalError newInternalError(Throwable cause) {
|
||||
return new InternalError(cause);
|
||||
}
|
||||
/*non-public*/ static RuntimeException newIllegalStateException(String message) {
|
||||
return new IllegalStateException(message);
|
||||
}
|
||||
|
|
|
@ -527,7 +527,6 @@ public class ValueConversions {
|
|||
MethodHandle.class, int.class, MethodHandle.class);
|
||||
m.setAccessible(true);
|
||||
mh = IMPL_LOOKUP.unreflect(m);
|
||||
|
||||
} catch (ReflectiveOperationException | SecurityException ex) {
|
||||
throw newInternalError(ex);
|
||||
}
|
||||
|
@ -1209,4 +1208,12 @@ public class ValueConversions {
|
|||
private static MethodHandle buildVarargsList(int nargs) {
|
||||
return MethodHandles.filterReturnValue(varargsArray(nargs), LazyStatics.MAKE_LIST);
|
||||
}
|
||||
|
||||
// handy shared exception makers (they simplify the common case code)
|
||||
private static InternalError newInternalError(String message, Throwable cause) {
|
||||
return new InternalError(message, cause);
|
||||
}
|
||||
private static InternalError newInternalError(Throwable cause) {
|
||||
return new InternalError(cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class BigArityTest {
|
|||
MethodHandles.lookup().unreflect(
|
||||
BigArityTest.class.getDeclaredMethod("hashArguments", Object[].class));
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new InternalError(ex);
|
||||
throw new Error(ex);
|
||||
}
|
||||
}
|
||||
static MethodHandle MH_hashArguments(int arity) {
|
||||
|
|
|
@ -145,21 +145,21 @@ public class PrivateInvokeTest {
|
|||
MH_DEBUG_STRING = DIRECT_INVOKER_LOOKUP
|
||||
.findVirtual(MethodHandle.class, "debugString", methodType(String.class));
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new InternalError(ex);
|
||||
throw new Error(ex);
|
||||
}
|
||||
}
|
||||
private Object internalMemberName(MethodHandle mh) {
|
||||
try {
|
||||
return MH_INTERNAL_MEMBER_NAME.invokeExact(mh);
|
||||
} catch (Throwable ex) {
|
||||
throw new InternalError(ex);
|
||||
throw new Error(ex);
|
||||
}
|
||||
}
|
||||
private String debugString(MethodHandle mh) {
|
||||
try {
|
||||
return (String) MH_DEBUG_STRING.invokeExact(mh);
|
||||
} catch (Throwable ex) {
|
||||
throw new InternalError(ex);
|
||||
throw new Error(ex);
|
||||
}
|
||||
}
|
||||
private static MethodHandle directInvoker(int refKind, MethodType mtype) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue