/** * Adds a synthetic method as part of the compilation process */ public MethodNode addSyntheticMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { MethodNode answer = addMethod(name, modifiers|ACC_SYNTHETIC, returnType, parameters, exceptions, code); answer.setSynthetic(true); return answer; }
private MethodNode getOrAddStaticConstructorNode() { MethodNode method = null; List declaredMethods = getDeclaredMethods("<clinit>"); if (declaredMethods.isEmpty()) { method = addMethod("<clinit>", ACC_STATIC, ClassHelper.VOID_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, new BlockStatement()); method.setSynthetic(true); } else { method = (MethodNode) declaredMethods.get(0); } return method; }
private void visitGetter(PropertyNode node, Statement getterBlock, int getterModifiers, String secondGetterName) { MethodNode secondGetter = new MethodNode(secondGetterName, getterModifiers, node.getType(), Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, getterBlock); secondGetter.setSynthetic(true); addPropertyMethod(secondGetter); visitMethod(secondGetter); }
ClassNode[] exceptions = makeClassNodes(compileUnit, m.getGenericExceptionTypes(), m.getExceptionTypes()); MethodNode mn = new MethodNode(m.getName(), m.getModifiers(), ret, params, exceptions, null); mn.setSynthetic(m.isSynthetic()); setMethodDefaultValue(mn, m); setAnnotationMetaData(m.getAnnotations(), mn);
/** * Creates a setter method with the given body. * * @param declaringClass the class to which we will add the setter * @param propertyNode the field to back the setter * @param setterName the name of the setter * @param setterBlock the statement representing the setter block */ protected void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) { MethodNode setter = new MethodNode( setterName, PropertyNodeUtils.adjustPropertyModifiersForMethod(propertyNode), ClassHelper.VOID_TYPE, params(param(propertyNode.getType(), "value")), ClassNode.EMPTY_ARRAY, setterBlock); setter.setSynthetic(true); // add it to the class declaringClass.addMethod(setter); }
/** * Creates a setter method with the given body. * <p> * This differs from normal setters in that we need to add a declared * exception java.beans.PropertyVetoException * * @param declaringClass the class to which we will add the setter * @param propertyNode the field to back the setter * @param setterName the name of the setter * @param setterBlock the statement representing the setter block */ protected void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) { ClassNode[] exceptions = {ClassHelper.make(PropertyVetoException.class)}; MethodNode setter = new MethodNode( setterName, PropertyNodeUtils.adjustPropertyModifiersForMethod(propertyNode), ClassHelper.VOID_TYPE, params(param(propertyNode.getType(), "value")), exceptions, setterBlock); setter.setSynthetic(true); // add it to the class declaringClass.addMethod(setter); }
private MethodNode copyMethod(MethodNode method, String newName) { // can't hurt to set return type to void MethodNode newMethod = new MethodNode(newName, method.getModifiers(), ClassHelper.VOID_TYPE, method.getParameters(), method.getExceptions(), method.getCode()); newMethod.addAnnotations(method.getAnnotations()); newMethod.setSynthetic(method.isSynthetic()); newMethod.setDeclaringClass(method.getDeclaringClass()); newMethod.setSourcePosition(method); newMethod.setVariableScope(method.getVariableScope()); newMethod.setGenericsTypes(method.getGenericsTypes()); newMethod.setAnnotationDefault(method.hasAnnotationDefault()); return newMethod; }
if (clinit == null) { clinit = annotatedClass.addMethod("<clinit>", ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, ClassHelper.VOID_TYPE, noparams, null, new BlockStatement()); clinit.setSynthetic(true);
MethodNode getter = new MethodNode(getterName, propNodeModifiers, node.getType(), Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, getterBlock); getter.setSynthetic(true); cNode.addMethod(getter); MethodNode secondGetter = new MethodNode(secondGetterName, propNodeModifiers, node.getType(), Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, getterBlock); secondGetter.setSynthetic(true); cNode.addMethod(secondGetter); MethodNode setter = new MethodNode(setterName, propNodeModifiers, ClassHelper.VOID_TYPE, setterParameterTypes, ClassNode.EMPTY_ARRAY, setterBlock); setter.setSynthetic(true); cNode.addMethod(setter);
MethodNode setter = new MethodNode(setterName, accessorModifiers, ClassHelper.VOID_TYPE, setterParameterTypes, ClassNode.EMPTY_ARRAY, setterBlock); setter.setSynthetic(true); addPropertyMethod(setter); visitMethod(setter);
Parameter[] parameter = new Parameter[]{new Parameter(ClassHelper.OBJECT_TYPE.makeArray(), "para")}; MethodNode initMethod = new MethodNode("$INIT", PUBLIC_FS | Opcodes.ACC_SYNTHETIC, enumRef, parameter, ClassNode.EMPTY_ARRAY, null); initMethod.setSynthetic(true); ConstructorCallExpression cce = new ConstructorCallExpression( ClassNode.THIS,
valuesMethod.setSynthetic(true); BlockStatement code = new BlockStatement(); MethodCallExpression cloneCall = new MethodCallExpression(new FieldExpression(values), "clone", MethodCallExpression.NO_ARGUMENTS); Token ge = Token.newSymbol(Types.COMPARE_GREATER_THAN_EQUAL, -1, -1); MethodNode nextMethod = new MethodNode("next", Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, enumRef, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, null); nextMethod.setSynthetic(true); BlockStatement code = new BlockStatement(); BlockStatement ifStatement = new BlockStatement(); Token lt = Token.newSymbol(Types.COMPARE_LESS_THAN, -1, -1); MethodNode nextMethod = new MethodNode("previous", Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, enumRef, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, null); nextMethod.setSynthetic(true); BlockStatement code = new BlockStatement(); BlockStatement ifStatement = new BlockStatement(); valueOfMethod.setSynthetic(true); enumClass.addMethod(valueOfMethod);
/** * Adds a synthetic method as part of the compilation process */ public MethodNode addSyntheticMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { MethodNode answer = addMethod(name, modifiers|ACC_SYNTHETIC, returnType, parameters, exceptions, code); answer.setSynthetic(true); return answer; }
/** * Adds a synthetic method as part of the compilation process */ public MethodNode addSyntheticMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { MethodNode answer = addMethod(name, modifiers|ACC_SYNTHETIC, returnType, parameters, exceptions, code); answer.setSynthetic(true); return answer; }
/** * Adds a synthetic method as part of the compilation process */ public MethodNode addSyntheticMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { MethodNode answer = addMethod(name, modifiers, returnType, parameters, exceptions, code); answer.setSynthetic(true); return answer; }
/** * Adds a synthetic method as part of the compilation process */ public MethodNode addSyntheticMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { MethodNode answer = addMethod(name, modifiers|ACC_SYNTHETIC, returnType, parameters, exceptions, code); answer.setSynthetic(true); return answer; }
private MethodNode getOrAddStaticConstructorNode() { MethodNode method = null; List declaredMethods = getDeclaredMethods("<clinit>"); if (declaredMethods.isEmpty()) { method = addMethod("<clinit>", ACC_STATIC, ClassHelper.VOID_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, new BlockStatement()); method.setSynthetic(true); } else { method = (MethodNode) declaredMethods.get(0); } return method; }
private MethodNode getOrAddStaticConstructorNode() { MethodNode method = null; List declaredMethods = getDeclaredMethods("<clinit>"); if (declaredMethods.isEmpty()) { method = addMethod("<clinit>", ACC_STATIC, ClassHelper.VOID_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, new BlockStatement()); method.setSynthetic(true); } else { method = (MethodNode) declaredMethods.get(0); } return method; } public void addStaticInitializerStatements(List staticStatements, boolean fieldInit) {
private static void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) { MethodNode setter = new MethodNode( setterName, propertyNode.getModifiers(), VOID_TYPE, params(param(propertyNode.getType(), VALUE)), NO_EXCEPTIONS, setterBlock); setter.setSynthetic(true); // add it to the class declaringClass.addMethod(setter); }
private static void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) { MethodNode setter = new MethodNode( setterName, propertyNode.getModifiers(), VOID_TYPE, params(param(propertyNode.getType(), VALUE)), new ClassNode[]{PROPERTY_VETO_EXCEPTION_CNODE}, setterBlock); setter.setSynthetic(true); // add it to the class declaringClass.addMethod(setter); }