.getName(), handlerField.getType()));
static void emitOneArgConstructor(ClassGen stubClass, FieldGen handlerField) { String stubClassName = stubClass.getClassName(); ConstantPoolGen cp = stubClass.getConstantPool(); InstructionList il = new InstructionList(); Type[] args = new Type[] { handlerField.getType() }; MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, args, null, "<init>", stubClassName, il, cp); InstructionFactory fac = new InstructionFactory(stubClass, cp); // call super-constructor il.append(InstructionFactory.createThis()); il.append(fac.createInvoke(stubClass.getSuperclassName(), "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); // push this again... il.append(InstructionFactory.createThis()); // push the handler il.append(InstructionFactory.createLoad(handlerField.getType(), 1)); // put handlerField il.append(new PUTFIELD(cp.addFieldref(stubClassName, handlerField .getName(), handlerField.getSignature()))); // return il.append(InstructionConstants.RETURN); // compute stack and locals... mg.setMaxStack(); mg.setMaxLocals(); stubClass.addMethod(mg.getMethod()); }
static void emitInitializerConstructor(ClassGen stubClass, FieldGen handlerField, FieldGen initializerField) { String stubClassName = stubClass.getClassName(); ConstantPoolGen cp = stubClass.getConstantPool(); InstructionList il = new InstructionList(); MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, null, "<init>", stubClassName, il, cp); InstructionFactory fac = new InstructionFactory(stubClass, cp); // call super-constructor il.append(InstructionFactory.createThis()); il.append(fac.createInvoke(stubClass.getSuperclassName(), "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); // push "this" il.append(InstructionFactory.createThis()); // get static initializer il.append(fac.createGetStatic(stubClassName, initializerField.getName(), initializerField.getType())); emitInvoke(il, fac, getStubHandlerRef); // checkCast il.append(fac.createCast(Type.OBJECT, handlerField.getType())); // put handlerField il.append(new PUTFIELD(cp.addFieldref(stubClassName, handlerField .getName(), handlerField.getSignature()))); // return il.append(InstructionConstants.RETURN); // compute stack and locals... mg.setMaxStack(); mg.setMaxLocals(); stubClass.addMethod(mg.getMethod()); }