public MethodDescription withModifiers(int newModifiers) { return new MethodDescription(newModifiers, returnType, methodName, argumentTypes, genericSignature, checkedExceptionTypes); }
@Override public String getMethodIdentifier() { plasticClass.check(); if (methodIdentifier == null) { methodIdentifier = String.format("%s.%s", plasticClass.className, description.toShortString()); } return methodIdentifier; }
@Override public int compareTo(PlasticMethodImpl o) { plasticClass.check(); return description.compareTo(o.description); }
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); desc.toShortString(), symbol.toString()), new Runnable()
@Override public PlasticMethod introduceMethod(MethodDescription description) { check(); if (Modifier.isAbstract(description.modifiers)) { description = description.withModifiers(description.modifiers & ~ACC_ABSTRACT); } PlasticMethod result = description2method.get(description); if (result == null) { result = createNewMethod(description); description2method.put(description, result); } methodNames.add(description.methodName); // Note that is it not necessary to add the new MethodNode to // fieldTransformMethods (the default implementations provided by introduceMethod() do not // ever access instance fields) ... unless the caller invokes changeImplementation(). return result; }
@Override public MethodHandle getHandle() { plasticClass.check(); if (handle == null) { methodIndex = plasticClass.nextMethodIndex++; handle = new MethodHandleImpl(plasticClass.className, description.toString(), methodIndex); plasticClass.shimMethods.add(this); } return handle; }
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); }
@Override public PlasticMethod introduceMethod(MethodDescription description) { check(); if (Modifier.isAbstract(description.modifiers)) { description = description.withModifiers(description.modifiers & ~ACC_ABSTRACT); } PlasticMethod result = description2method.get(description); if (result == null) { result = createNewMethod(description); description2method.put(description, result); } methodNames.add(description.methodName); // Note that is it not necessary to add the new MethodNode to // fieldTransformMethods (the default implementations provided by introduceMethod() do not // ever access instance fields) ... unless the caller invokes changeImplementation(). return result; }
@Override public MethodHandle getHandle() { plasticClass.check(); if (handle == null) { methodIndex = plasticClass.nextMethodIndex++; handle = new MethodHandleImpl(plasticClass.className, description.toString(), methodIndex); plasticClass.shimMethods.add(this); } return handle; }
public MethodDescription withModifiers(int newModifiers) { return new MethodDescription(newModifiers, returnType, methodName, argumentTypes, genericSignature, checkedExceptionTypes); }
@Override public String getMethodIdentifier() { plasticClass.check(); if (methodIdentifier == null) { methodIdentifier = String.format("%s.%s", plasticClass.className, description.toShortString()); } return methodIdentifier; }
@Override public PlasticMethod changeImplementation(InstructionBuilderCallback callback) { plasticClass.check(); // If the method is currently abstract, clear that flag. if (Modifier.isAbstract(node.access)) { node.access = node.access & ~org.apache.tapestry5.internal.plastic.asm.Opcodes.ACC_ABSTRACT; description = description.withModifiers(node.access); } node.instructions.clear(); plasticClass.newBuilder(description, node).doCallback(callback); // With the implementation changed, it is necessary to intercept field reads/writes. // The node may not already have been in the fieldTransformMethods Set if it was // an introduced method. plasticClass.fieldTransformMethods.add(node); return this; }
@Override public int compareTo(PlasticMethodImpl o) { plasticClass.check(); return description.compareTo(o.description); }
private static MethodDescription renderPhaseDescription(String name) { return new MethodDescription(Modifier.PUBLIC, "void", name, RENDER_PHASE_METHOD_PARAMETERS, null, null); }
@Override public PlasticMethod changeImplementation(InstructionBuilderCallback callback) { plasticClass.check(); // If the method is currently abstract, clear that flag. if (Modifier.isAbstract(node.access)) { node.access = node.access & ~org.apache.tapestry5.internal.plastic.asm.Opcodes.ACC_ABSTRACT; description = description.withModifiers(node.access); } node.instructions.clear(); plasticClass.newBuilder(description, node).doCallback(callback); // With the implementation changed, it is necessary to intercept field reads/writes. // The node may not already have been in the fieldTransformMethods Set if it was // an introduced method. plasticClass.fieldTransformMethods.add(node); return this; }
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()])));