Public feed
#377860
public void addAccessor(ClassGen clazz,String accessorName, Field field) { Type type = field.getType(); ConstantPoolGen cpg = clazz.getConstantPool(); InstructionFactory factory = new InstructionFactory(clazz, cpg); InstructionList list = new InstructionList(); MethodGen methodGen = new MethodGen(Constants.ACC_PUBLIC, Type.STRING, Type.NO_ARGS, new String[]{}, accessorName, className, list, cpg); list.append(InstructionFactory.createLoad(type, 0)); list.append(factory.createFieldAccess(className, field.getName(), type, Constants.GETFIELD)); list.append(InstructionFactory.createReturn(Type.OBJECT)); methodGen.setMaxStack(); methodGen.setMaxLocals(); clazz.addMethod(methodGen.getMethod()); }