src/share/classes/java/lang/invoke/CallSite.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
jdk Cdiff src/share/classes/java/lang/invoke/CallSite.java
src/share/classes/java/lang/invoke/CallSite.java
Print this page
rev 10274 : 8050052: Small cleanups in java.lang.invoke code
Reviewed-by: ?
rev 10275 : imported patch invokers
*** 100,110 ****
* via a call to {@link CallSite#setTarget(MethodHandle) setTarget}.
* @throws NullPointerException if the proposed type is null
*/
/*package-private*/
CallSite(MethodType type) {
! target = type.invokers().uninitializedCallSite();
}
/**
* Make a call site object equipped with an initial target method handle.
* @param target the method handle which will be the initial target of the call site
--- 100,110 ----
* via a call to {@link CallSite#setTarget(MethodHandle) setTarget}.
* @throws NullPointerException if the proposed type is null
*/
/*package-private*/
CallSite(MethodType type) {
! target = makeUninitializedCallSite(type);
}
/**
* Make a call site object equipped with an initial target method handle.
* @param target the method handle which will be the initial target of the call site
*** 215,239 ****
MethodHandle invoker = MethodHandles.exactInvoker(this.type());
return MethodHandles.foldArguments(invoker, getTarget);
}
private static final MethodHandle GET_TARGET;
static {
try {
GET_TARGET = IMPL_LOOKUP.
findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class));
} catch (ReflectiveOperationException e) {
throw newInternalError(e);
}
}
/** This guy is rolled into the default target if a MethodType is supplied to the constructor. */
! /*package-private*/
! static Empty uninitializedCallSite() {
throw new IllegalStateException("uninitialized call site");
}
// unsafe stuff:
private static final long TARGET_OFFSET;
static {
try {
TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target"));
--- 215,252 ----
MethodHandle invoker = MethodHandles.exactInvoker(this.type());
return MethodHandles.foldArguments(invoker, getTarget);
}
private static final MethodHandle GET_TARGET;
+ private static final MethodHandle THROW_UCS;
static {
try {
GET_TARGET = IMPL_LOOKUP.
findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class));
+ THROW_UCS = IMPL_LOOKUP.
+ findStatic(CallSite.class, "uninitializedCallSite", MethodType.methodType(Object.class, Object[].class));
} catch (ReflectiveOperationException e) {
throw newInternalError(e);
}
}
/** This guy is rolled into the default target if a MethodType is supplied to the constructor. */
! private static Object uninitializedCallSite(Object... ignore) {
throw new IllegalStateException("uninitialized call site");
}
+ private MethodHandle makeUninitializedCallSite(MethodType targetType) {
+ MethodType basicType = targetType.basicType();
+ MethodHandle invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_UNINIT_CS);
+ if (invoker == null) {
+ invoker = THROW_UCS.asType(basicType);
+ invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_UNINIT_CS, invoker);
+ }
+ // unchecked view is OK since no values will be received or returned
+ return invoker.viewAsType(targetType);
+ }
+
// unsafe stuff:
private static final long TARGET_OFFSET;
static {
try {
TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target"));
src/share/classes/java/lang/invoke/CallSite.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File