src/share/classes/java/lang/invoke/MethodHandleProxies.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Cdiff src/share/classes/java/lang/invoke/MethodHandleProxies.java

src/share/classes/java/lang/invoke/MethodHandleProxies.java

Print this page
rev 10274 : 8050052: Small cleanups in java.lang.invoke code
Reviewed-by: ?

*** 31,40 **** --- 31,41 ---- import sun.invoke.WrapperInstance; import java.util.ArrayList; import sun.reflect.CallerSensitive; import sun.reflect.Reflection; import sun.reflect.misc.ReflectUtil; + import static java.lang.invoke.MethodHandleStatics.*; /** * This class consists exclusively of static methods that help adapt * method handles to other JVM types, such as interfaces. */
*** 146,156 **** // @CallerSensitive public static <T> T asInterfaceInstance(final Class<T> intfc, final MethodHandle target) { if (!intfc.isInterface() || !Modifier.isPublic(intfc.getModifiers())) ! throw new IllegalArgumentException("not a public interface: "+intfc.getName()); final MethodHandle mh; if (System.getSecurityManager() != null) { final Class<?> caller = Reflection.getCallerClass(); final ClassLoader ccl = caller != null ? caller.getClassLoader() : null; ReflectUtil.checkProxyPackageAccess(ccl, intfc); --- 147,157 ---- // @CallerSensitive public static <T> T asInterfaceInstance(final Class<T> intfc, final MethodHandle target) { if (!intfc.isInterface() || !Modifier.isPublic(intfc.getModifiers())) ! throw newIllegalArgumentException("not a public interface", intfc.getName()); final MethodHandle mh; if (System.getSecurityManager() != null) { final Class<?> caller = Reflection.getCallerClass(); final ClassLoader ccl = caller != null ? caller.getClassLoader() : null; ReflectUtil.checkProxyPackageAccess(ccl, intfc);
*** 163,173 **** ClassLoader cl = Thread.currentThread().getContextClassLoader(); // avoid use of BCP proxyLoader = cl != null ? cl : ClassLoader.getSystemClassLoader(); } final Method[] methods = getSingleNameMethods(intfc); if (methods == null) ! throw new IllegalArgumentException("not a single-method interface: "+intfc.getName()); final MethodHandle[] vaTargets = new MethodHandle[methods.length]; for (int i = 0; i < methods.length; i++) { Method sm = methods[i]; MethodType smMT = MethodType.methodType(sm.getReturnType(), sm.getParameterTypes()); MethodHandle checkTarget = mh.asType(smMT); // make throw WMT --- 164,174 ---- ClassLoader cl = Thread.currentThread().getContextClassLoader(); // avoid use of BCP proxyLoader = cl != null ? cl : ClassLoader.getSystemClassLoader(); } final Method[] methods = getSingleNameMethods(intfc); if (methods == null) ! throw newIllegalArgumentException("not a single-method interface", intfc.getName()); final MethodHandle[] vaTargets = new MethodHandle[methods.length]; for (int i = 0; i < methods.length; i++) { Method sm = methods[i]; MethodType smMT = MethodType.methodType(sm.getReturnType(), sm.getParameterTypes()); MethodHandle checkTarget = mh.asType(smMT); // make throw WMT
*** 187,197 **** } if (method.getDeclaringClass() == WrapperInstance.class) return getArg(method.getName()); if (isObjectMethod(method)) return callObjectMethod(proxy, method, args); ! throw new InternalError("bad proxy method: "+method); } }; final Object proxy; if (System.getSecurityManager() != null) { --- 188,198 ---- } if (method.getDeclaringClass() == WrapperInstance.class) return getArg(method.getName()); if (isObjectMethod(method)) return callObjectMethod(proxy, method, args); ! throw newInternalError("bad proxy method: "+method); } }; final Object proxy; if (System.getSecurityManager() != null) {
*** 238,248 **** try { if (x != null) return (WrapperInstance) x; } catch (ClassCastException ex) { } ! throw new IllegalArgumentException("not a wrapper instance"); } /** * Produces or recovers a target method handle which is behaviorally * equivalent to the unique method of this wrapper instance. --- 239,249 ---- try { if (x != null) return (WrapperInstance) x; } catch (ClassCastException ex) { } ! throw newIllegalArgumentException("not a wrapper instance"); } /** * Produces or recovers a target method handle which is behaviorally * equivalent to the unique method of this wrapper instance.
src/share/classes/java/lang/invoke/MethodHandleProxies.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File