code.addInvokespecial(clazz, MethodInfo.nameInit, desc); code.addReturn(null); minfo.setCodeAttribute(code.toCodeAttribute()); cf.addMethod(minfo);
code.addReturn(Descriptor.toCtClass(fieldType, pool)); minfo.setCodeAttribute(code.toCodeAttribute()); cf.addMethod(minfo);
code.addInvokevirtual(clazz, name, desc); code.addReturn(Descriptor.getReturnType(desc, pool)); minfo.setCodeAttribute(code.toCodeAttribute()); cf.addMethod(minfo);
code.addReturn(null); code.setMaxLocals(reg); minfo.setCodeAttribute(code.toCodeAttribute());
code.addInvokespecial(clazz, MethodInfo.nameInit, desc); code.addReturn(null); minfo.setCodeAttribute(code.toCodeAttribute()); cf.addMethod(minfo);
code.addReturn(Descriptor.toCtClass(fieldType, pool)); minfo.setCodeAttribute(code.toCodeAttribute()); cf.addMethod(minfo);
code.addGetstatic(Bytecode.THIS, fieldName, fieldType); code.addReturn(field.getType());
code.addInvokevirtual(clazz, name, desc); code.addReturn(Descriptor.getReturnType(desc, pool)); minfo.setCodeAttribute(code.toCodeAttribute()); cf.addMethod(minfo);
code.addReturn(null); code.setMaxLocals(reg); minfo.setCodeAttribute(code.toCodeAttribute());
code.addReturn(null);
code.addGetstatic(Bytecode.THIS, fieldName, fieldType); code.addReturn(field.getType());
code.addReturn(delegate.getReturnType()); code.setMaxLocals(++s); code.setMaxStack(s < 2 ? 2 : s); // for a 2-word return value
code.addReturn(null);
code.addReturn(delegate.getReturnType()); code.setMaxLocals(++s); code.setMaxStack(s < 2 ? 2 : s); // for a 2-word return value
private CtMethod createGetterBridge(CtClass cc, Method getter, CtMethod attributeGetter) throws NotFoundException, CannotCompileException { ConstPool cp = cc.getClassFile2().getConstPool(); CtClass bridgeReturnType = pool.get(getter.getReturnType().getName()); String desc = "()" + Descriptor.of(bridgeReturnType); MethodInfo bridge = new MethodInfo(cp, getter.getName(), desc); bridge.setAccessFlags(AccessFlag.PUBLIC | AccessFlag.BRIDGE | AccessFlag.SYNTHETIC); Bytecode code = new Bytecode(cp, needsTwoStackSlots(bridgeReturnType) ? 2 : 1, 1); code.addAload(0); code.addInvokevirtual(cc, getter.getName(), attributeGetter.getReturnType(), null); code.addReturn(bridgeReturnType); bridge.setCodeAttribute(code.toCodeAttribute()); return CtMethod.make(bridge, cc); }
private CtMethod createSetterBridge(CtClass cc, Method setter, CtMethod attributeSetter) throws NotFoundException, CannotCompileException { ConstPool cp = cc.getClassFile2().getConstPool(); CtClass bridgeParameterType = pool.get(setter.getParameterTypes()[0].getName()); String desc = "(" + Descriptor.of(bridgeParameterType) + ")V"; MethodInfo bridge = new MethodInfo(cp, setter.getName(), desc); bridge.setAccessFlags(AccessFlag.PUBLIC | AccessFlag.BRIDGE | AccessFlag.SYNTHETIC); Bytecode code = new Bytecode(cp, needsTwoStackSlots(bridgeParameterType) ? 4 : 2, 2); code.addAload(0); code.addAload(1); code.addCheckcast(attributeSetter.getParameterTypes()[0]); code.addInvokevirtual(cc, setter.getName(), CtClass.voidType, attributeSetter.getParameterTypes()); code.addReturn(CtClass.voidType); bridge.setCodeAttribute(code.toCodeAttribute()); return CtMethod.make(bridge, cc); }
} else { try { code.addReturn(field.getType()); } catch (NotFoundException e) { throw new CannotCompileException(e);
code.addReturn(delegate.getReturnType()); code.setMaxLocals(++s); code.setMaxStack(s < 2 ? 2 : s); // for a 2-word return value
code.addReturn(delegate.getReturnType()); code.setMaxLocals(++s); code.setMaxStack(s < 2 ? 2 : s); // for a 2-word return value
code.addReturn(delegate.getReturnType()); code.setMaxLocals(++s); code.setMaxStack(s < 2 ? 2 : s); // for a 2-word return value