public MethodDescription withModifiers(int newModifiers) { return new MethodDescription(newModifiers, returnType, methodName, argumentTypes, genericSignature, checkedExceptionTypes); }
public MethodDescription withModifiers(int newModifiers) { return new MethodDescription(newModifiers, returnType, methodName, argumentTypes, genericSignature, checkedExceptionTypes); }
private static MethodDescription renderPhaseDescription(String name) { return new MethodDescription(Modifier.PUBLIC, "void", name, RENDER_PHASE_METHOD_PARAMETERS, null, null); }
private static MethodDescription getMethodDescription(Class containingClass, String name, Class... parameterTypes) { return new MethodDescription(getMethod(containingClass, name, parameterTypes)); }
/** * Uses {@link #getMethod(Class, String, Class...)} and wraps the result as a {@link MethodDescription}. * * @param declaringClass * containing class * @param name * name of method * @param parameterTypes * types of parameters * @return description for method * @throws RuntimeException * if any error (such as method not found) */ public static MethodDescription getMethodDescription(Class declaringClass, String name, Class... parameterTypes) { return new MethodDescription(getMethod(declaringClass, name, parameterTypes)); }
/** * Uses {@link #getMethod(Class, String, Class...)} and wraps the result as a {@link MethodDescription}. * * @param declaringClass * containing class * @param name * name of method * @param parameterTypes * types of parameters * @return description for method * @throws RuntimeException * if any error (such as method not found) */ public static MethodDescription getMethodDescription(Class declaringClass, String name, Class... parameterTypes) { return new MethodDescription(getMethod(declaringClass, name, parameterTypes)); }
final MethodDescription newMethodDescription = new MethodDescription(m); if (!map.containsKey(methodSignature)) checkedExceptionTypes.addAll(Arrays.asList(methodDescription.checkedExceptionTypes)); checkedExceptionTypes.addAll(Arrays.asList(newMethodDescription.checkedExceptionTypes)); map.put(methodSignature, new MethodDescription( methodDescription, checkedExceptionTypes.toArray(new String[checkedExceptionTypes.size()])));
private Map<MethodSignature, MethodDescription> createMethodSignatureMap(Class interfaceType) { // TAP-2582: preprocessing the method list so we don't add duplicated // methods, something that happens when an interface has superinterfaces // and they define the same method signature. // In addition, we collect all the thrown checked exceptions, just in case. Map<MethodSignature, MethodDescription> map = new HashMap<>(); for (Method m : interfaceType.getMethods()) { final MethodSignature methodSignature = new MethodSignature(m); final MethodDescription newMethodDescription = new MethodDescription(m); if (!map.containsKey(methodSignature)) { map.put(methodSignature, newMethodDescription); } else { if (newMethodDescription.checkedExceptionTypes != null && newMethodDescription.checkedExceptionTypes.length > 0) { final MethodDescription methodDescription = map.get(methodSignature); final Set<String> checkedExceptionTypes = new HashSet<>(); checkedExceptionTypes.addAll(Arrays.asList(methodDescription.checkedExceptionTypes)); checkedExceptionTypes.addAll(Arrays.asList(newMethodDescription.checkedExceptionTypes)); map.put(methodSignature, new MethodDescription( methodDescription, checkedExceptionTypes.toArray(new String[checkedExceptionTypes.size()]))); } } } return map; }
@Override public PlasticMethod introduceMethod(Method method) { check(); return introduceMethod(new MethodDescription(method)); }
@Override public PlasticMethod introduceMethod(Method method) { check(); return introduceMethod(new MethodDescription(method)); }
@SuppressWarnings("unchecked") public static MethodDescription toMethodDescription(MethodNode node) { String returnType = Type.getReturnType(node.desc).getClassName(); String[] arguments = toClassNames(Type.getArgumentTypes(node.desc)); List<String> exceptions = node.exceptions; String[] exceptionClassNames = new String[exceptions.size()]; for (int i = 0; i < exceptionClassNames.length; i++) { exceptionClassNames[i] = exceptions.get(i).replace('/', '.'); } return new MethodDescription(node.access, returnType, node.name, arguments, node.signature, exceptionClassNames); }
@SuppressWarnings("unchecked") public static MethodDescription toMethodDescription(MethodNode node) { String returnType = Type.getReturnType(node.desc).getClassName(); String[] arguments = toClassNames(Type.getArgumentTypes(node.desc)); List<String> exceptions = node.exceptions; String[] exceptionClassNames = new String[exceptions.size()]; for (int i = 0; i < exceptionClassNames.length; i++) { exceptionClassNames[i] = exceptions.get(i).replace('/', '.'); } return new MethodDescription(node.access, returnType, node.name, arguments, node.signature, exceptionClassNames); }
private void introduceAccessorMethod(String returnType, String name, String[] parameterTypes, String signature, InstructionBuilderCallback callback) { MethodDescription description = new MethodDescription(Opcodes.ACC_PUBLIC, returnType, name, parameterTypes, signature, null); String desc = plasticClass.nameCache.toDesc(description); if (plasticClass.inheritanceData.isImplemented(name, desc)) { throw new IllegalArgumentException(String.format( "Unable to create new accessor method %s on class %s as the method is already implemented.", description.toString(), plasticClass.className)); } plasticClass.introduceMethod(description, callback); }
private void introduceAccessorMethod(String returnType, String name, String[] parameterTypes, String signature, InstructionBuilderCallback callback) { MethodDescription description = new MethodDescription(Opcodes.ACC_PUBLIC, returnType, name, parameterTypes, signature, null); String desc = plasticClass.nameCache.toDesc(description); if (plasticClass.inheritanceData.isImplemented(name, desc)) { throw new IllegalArgumentException(String.format( "Unable to create new accessor method %s on class %s as the method is already implemented.", description.toString(), plasticClass.className)); } plasticClass.introduceMethod(description, callback); }
private void bridgeToClojure(final PlasticClass plasticClass, final Method method) final MethodDescription desc = new MethodDescription(method);
public AspectInterceptorBuilderImpl(AnnotationAccess annotationAccess, PlasticProxyFactory plasticProxyFactory, Class<T> serviceInterface, T delegate, String description) { super(annotationAccess); this.serviceInterface = serviceInterface; final Class<? extends Object> delegateType = delegate.getClass(); transformation = plasticProxyFactory.createProxyTransformation(serviceInterface, (Class<? extends T>) delegateType); plasticClass = transformation.getPlasticClass(); plasticClass.addToString(description); allMethods.addAll(Arrays.asList(serviceInterface.getMethods())); final PlasticField delegateField = plasticClass.introduceField(serviceInterface, "delegate").inject(delegate); for (Method method : allMethods) { plasticClass.introduceMethod(method).delegateTo(delegateField); } // TAP5-2235 final String delegateTypeName = delegateType.getName(); MethodDescription getDelegateMethodDescription = new MethodDescription(delegateTypeName, PlasticProxyFactoryImpl.INTERNAL_GET_DELEGATE); plasticClass.introduceMethod(getDelegateMethodDescription, new InstructionBuilderCallback() { @Override public void doBuild(InstructionBuilder builder) { builder.loadThis().getField(delegateField); builder.checkcast(delegateType).returnResult(); } }); }
public AspectInterceptorBuilderImpl(AnnotationAccess annotationAccess, PlasticProxyFactory plasticProxyFactory, Class<T> serviceInterface, T delegate, String description) { super(annotationAccess); this.serviceInterface = serviceInterface; final Class<? extends Object> delegateType = delegate.getClass(); transformation = plasticProxyFactory.createProxyTransformation(serviceInterface, (Class<? extends T>) delegateType); plasticClass = transformation.getPlasticClass(); plasticClass.addToString(description); allMethods.addAll(Arrays.asList(serviceInterface.getMethods())); final PlasticField delegateField = plasticClass.introduceField(serviceInterface, "delegate").inject(delegate); for (Method method : allMethods) { plasticClass.introduceMethod(method).delegateTo(delegateField); } // TAP5-2235 final String delegateTypeName = delegateType.getName(); MethodDescription getDelegateMethodDescription = new MethodDescription(delegateTypeName, PlasticProxyFactoryImpl.INTERNAL_GET_DELEGATE); plasticClass.introduceMethod(getDelegateMethodDescription, new InstructionBuilderCallback() { @Override public void doBuild(InstructionBuilder builder) { builder.loadThis().getField(delegateField); builder.checkcast(delegateType).returnResult(); } }); }
@Override public PlasticMethod introducePrivateMethod(String typeName, String suggestedName, String[] argumentTypes, String[] exceptionTypes) { check(); assert PlasticInternalUtils.isNonBlank(typeName); assert PlasticInternalUtils.isNonBlank(suggestedName); String name = makeUnique(methodNames, suggestedName); MethodDescription description = new MethodDescription(Modifier.PRIVATE, typeName, name, argumentTypes, null, exceptionTypes); return introduceMethod(description); }
@Override public PlasticMethod introducePrivateMethod(String typeName, String suggestedName, String[] argumentTypes, String[] exceptionTypes) { check(); assert PlasticInternalUtils.isNonBlank(typeName); assert PlasticInternalUtils.isNonBlank(suggestedName); String name = makeUnique(methodNames, suggestedName); MethodDescription description = new MethodDescription(Modifier.PRIVATE, typeName, name, argumentTypes, null, exceptionTypes); return introduceMethod(description); }
new MethodDescription(interfaceType.getName(), INTERNAL_GET_DELEGATE); plasticClass.introduceMethod(getDelegateMethodDescription, returnCreateObject);