src/share/classes/java/lang/invoke/CallSite.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/classes/java/lang/invoke/CallSite.java	Fri Jul 11 20:22:59 2014
--- new/src/share/classes/java/lang/invoke/CallSite.java	Fri Jul 11 20:22:59 2014

*** 100,110 **** --- 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(); ! 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 **** --- 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. */ /*package-private*/ static Empty uninitializedCallSite() { + 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