/** * Returns a FastClass proxy for invoking the given member or {@code null} if access rules * disallow it. * * @see #newFastClassForMember(Class, Member) for a full description */ public static net.sf.cglib.reflect.FastClass newFastClassForMember(Member member) { return newFastClassForMember(member.getDeclaringClass(), member); }
final net.sf.cglib.reflect.FastClass fastClass = BytecodeGen.newFastClassForMember(method); if (fastClass != null) { final int index = fastClass.getMethod(method).getIndex();
@SuppressWarnings("unchecked") // the constructor promises to construct 'T's ProxyConstructor( Enhancer enhancer, InjectionPoint injectionPoint, Callback[] callbacks, ImmutableMap<Method, List<MethodInterceptor>> methodInterceptors) { this.enhanced = enhancer.createClass(); // this returns a cached class if possible this.injectionPoint = injectionPoint; this.constructor = (Constructor<T>) injectionPoint.getMember(); this.callbacks = callbacks; this.methodInterceptors = methodInterceptors; this.fastClass = newFastClassForMember(enhanced, constructor); this.constructorIndex = fastClass.getIndex(constructor.getParameterTypes()); }
net.sf.cglib.reflect.FastClass fc = BytecodeGen.newFastClassForMember(method); if (fc != null) { return new FastClassProviderMethod<T>(
@Override public ConstructionProxy<T> create() { @SuppressWarnings("unchecked") // the injection point is for a constructor of T final Constructor<T> constructor = (Constructor<T>) injectionPoint.getMember(); /*if[AOP]*/ try { net.sf.cglib.reflect.FastClass fc = BytecodeGen.newFastClassForMember(constructor); if (fc != null) { int index = fc.getIndex(constructor.getParameterTypes()); // We could just fall back to reflection in this case but I believe this should actually // be impossible. Preconditions.checkArgument( index >= 0, "Could not find constructor %s in fast class", constructor); return new FastClassProxy<T>(injectionPoint, constructor, fc, index); } } catch (net.sf.cglib.core.CodeGenerationException e) { /* fall-through */ } /*end[AOP]*/ return new ReflectiveProxy<T>(injectionPoint, constructor); }
/** * Returns a FastClass proxy for invoking the given member or {@code null} if access rules * disallow it. * * @see #newFastClassForMember(Class, Member) for a full description */ public static net.sf.cglib.reflect.FastClass newFastClassForMember(Member member) { return newFastClassForMember(member.getDeclaringClass(), member); }
/** * Returns a FastClass proxy for invoking the given member or {@code null} if access rules * disallow it. * * @see #newFastClassForMember(Class, Member) for a full description */ public static net.sf.cglib.reflect.FastClass newFastClassForMember(Member member) { return newFastClassForMember(member.getDeclaringClass(), member); }
@Override public MethodInvoker load(final Method method) throws Exception { int modifiers = method.getModifiers(); if (!Modifier.isPrivate(modifiers) && !Modifier.isProtected(modifiers)) { try { final $FastMethod fastMethod = BytecodeGen.newFastClassForMember(method.getDeclaringClass(), method).getMethod(method); return new MethodInvoker(method) { @Override public Object invoke(Object target, Object... parameters) { try { return fastMethod.invoke(target, parameters); } catch (InvocationTargetException e) { throw MycilaGuiceException.toRuntime(e); } } }; } catch ($CodeGenerationException e) {/* fall-through */} } if (!Modifier.isPublic(modifiers) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) { method.setAccessible(true); } return new MethodInvoker(method); } });
@Override public MethodInvoker load(final Method method) throws Exception { int modifiers = method.getModifiers(); if (!Modifier.isPrivate(modifiers) && !Modifier.isProtected(modifiers)) { try { final $FastMethod fastMethod = BytecodeGen.newFastClassForMember(method.getDeclaringClass(), method).getMethod(method); return new MethodInvoker(method) { @Override public Object invoke(Object target, Object... parameters) { try { return fastMethod.invoke(target, parameters); } catch (InvocationTargetException e) { throw MycilaGuiceException.toRuntime(e); } } }; } catch ($CodeGenerationException e) {/* fall-through */} } if (!Modifier.isPublic(modifiers) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) { method.setAccessible(true); } return new MethodInvoker(method); } });
@Override public MethodInvoker load(final Method method) throws Exception { int modifiers = method.getModifiers(); if (!Modifier.isPrivate(modifiers) && !Modifier.isProtected(modifiers)) { try { final $FastMethod fastMethod = BytecodeGen.newFastClassForMember(method.getDeclaringClass(), method).getMethod(method); return new MethodInvoker(method) { @Override public Object invoke(Object target, Object... parameters) { try { return fastMethod.invoke(target, parameters); } catch (InvocationTargetException e) { throw MycilaGuiceException.toRuntime(e); } } }; } catch ($CodeGenerationException e) {/* fall-through */} } if (!Modifier.isPublic(modifiers) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) { method.setAccessible(true); } return new MethodInvoker(method); } });
final net.sf.cglib.reflect.FastClass fastClass = BytecodeGen.newFastClassForMember(method); if (fastClass != null) { final int index = fastClass.getMethod(method).getIndex();
net.sf.cglib.reflect.FastClass fc = BytecodeGen.newFastClassForMember(method); if (fc != null) { return new FastClassProviderMethod<T>(
final net.sf.cglib.reflect.FastClass fastClass = BytecodeGen.newFastClassForMember(method); if (fastClass != null) { final int index = fastClass.getMethod(method).getIndex();
net.sf.cglib.reflect.FastClass fc = BytecodeGen.newFastClassForMember(method); if (fc != null) { return new FastClassProviderMethod<T>(
@SuppressWarnings("unchecked") // the constructor promises to construct 'T's ProxyConstructor( Enhancer enhancer, InjectionPoint injectionPoint, Callback[] callbacks, ImmutableMap<Method, List<MethodInterceptor>> methodInterceptors) { this.enhanced = enhancer.createClass(); // this returns a cached class if possible this.injectionPoint = injectionPoint; this.constructor = (Constructor<T>) injectionPoint.getMember(); this.callbacks = callbacks; this.methodInterceptors = methodInterceptors; this.fastClass = newFastClassForMember(enhanced, constructor); this.constructorIndex = fastClass.getIndex(constructor.getParameterTypes()); }
@SuppressWarnings("unchecked") // the constructor promises to construct 'T's ProxyConstructor( Enhancer enhancer, InjectionPoint injectionPoint, Callback[] callbacks, ImmutableMap<Method, List<MethodInterceptor>> methodInterceptors) { this.enhanced = enhancer.createClass(); // this returns a cached class if possible this.injectionPoint = injectionPoint; this.constructor = (Constructor<T>) injectionPoint.getMember(); this.callbacks = callbacks; this.methodInterceptors = methodInterceptors; this.fastClass = newFastClassForMember(enhanced, constructor); this.constructorIndex = fastClass.getIndex(constructor.getParameterTypes()); }
@Override public ConstructionProxy<T> create() { @SuppressWarnings("unchecked") // the injection point is for a constructor of T final Constructor<T> constructor = (Constructor<T>) injectionPoint.getMember(); /*if[AOP]*/ try { net.sf.cglib.reflect.FastClass fc = BytecodeGen.newFastClassForMember(constructor); if (fc != null) { int index = fc.getIndex(constructor.getParameterTypes()); // We could just fall back to reflection in this case but I believe this should actually // be impossible. Preconditions.checkArgument( index >= 0, "Could not find constructor %s in fast class", constructor); return new FastClassProxy<T>(injectionPoint, constructor, fc, index); } } catch (net.sf.cglib.core.CodeGenerationException e) { /* fall-through */ } /*end[AOP]*/ return new ReflectiveProxy<T>(injectionPoint, constructor); }
@Override public ConstructionProxy<T> create() { @SuppressWarnings("unchecked") // the injection point is for a constructor of T final Constructor<T> constructor = (Constructor<T>) injectionPoint.getMember(); /*if[AOP]*/ try { net.sf.cglib.reflect.FastClass fc = BytecodeGen.newFastClassForMember(constructor); if (fc != null) { int index = fc.getIndex(constructor.getParameterTypes()); // We could just fall back to reflection in this case but I believe this should actually // be impossible. Preconditions.checkArgument( index >= 0, "Could not find constructor %s in fast class", constructor); return new FastClassProxy<T>(injectionPoint, constructor, fc, index); } } catch (net.sf.cglib.core.CodeGenerationException e) { /* fall-through */ } /*end[AOP]*/ return new ReflectiveProxy<T>(injectionPoint, constructor); }