InstructionHandle ctor_ih_4 = ctor.append(fac.createLoad(Type.OBJECT, 0)); ctor.append(fac.createLoad(Type.OBJECT, 1)); ctor.append(fac.createFieldAccess(CLASS_NAME_SERIALIZABLE_IMPL_WITH_VALUE, "value", Type.OBJECT, Constants.PUTFIELD)); InstructionHandle ctor_ih_9 = ctor.append(fac.createReturn(Type.VOID));
@SuppressWarnings("unused") // Called using reflection private Instruction createInstructionGetstatic(Element inst) throws IllegalXMLVMException { String classType= inst.getAttributeValue("class-type"); String field= inst.getAttributeValue("field"); Type type= parseTypeString(inst.getAttributeValue("type")); return factory.createFieldAccess(classType, field, type, Constants.GETSTATIC); }
private void JVMTools_storeStaticField(Class fieldtype, String fieldname) { il.append(factory.createFieldAccess(classname, fieldname, getObjectType(fieldtype), Constants.PUTSTATIC)); }
private InstructionHandle JVMTools_getStaticField(String classname, String fieldname, Class fieldtype) { return il.append(factory.createFieldAccess(classname, fieldname, getObjectType(fieldtype), Constants.GETSTATIC)); }
private InstructionHandle JVMTools_getField(Class fieldtype, String fieldname) { InstructionHandle ih = il.append(InstructionConstants.ALOAD_0); il.append(factory.createFieldAccess(classname, fieldname, getObjectType(fieldtype), Constants.GETFIELD)); return ih; }
private void JVMTools_storeField(Class fieldtype, String fieldname) { il.append(InstructionConstants.ALOAD_0); JVMTools_SWAP(); il.append(factory.createFieldAccess(classname, fieldname, getObjectType(fieldtype), Constants.PUTFIELD)); }
/** * @param il the instruction list * @param msg the message */ protected void createTestMethod(InstructionList il, String msg) { il.append(factory.createFieldAccess("java.lang.System", "out", new ObjectType("java.io.PrintStream"), Constants.GETSTATIC)); il.append(new PUSH(constantsPool, msg)); il.append(factory.createInvoke("java.io.PrintStream", "println", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKEVIRTUAL)); }
InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 0)); il.append(new PUSH(_cp, "Some string")); il.append(_factory.createFieldAccess("ClassContainingStrings", "someString", Type.STRING, Constants.PUTFIELD)); InstructionHandle ih_10 = il.append(_factory.createReturn(Type.VOID)); method.setMaxStack(); MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "call", "ClassContainingStrings", il, _cp); InstructionHandle ih_0 = il.append(_factory.createFieldAccess("java.lang.System", "out", new ObjectType("java.io.PrintStream"), Constants.GETSTATIC)); il.append(new PUSH(_cp, "Printed string")); il.append(_factory.createInvoke("java.io.PrintStream", "println", Type.VOID, new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL)); InstructionHandle ih_8 = il.append(_factory.createFieldAccess("java.lang.System", "out", new ObjectType("java.io.PrintStream"), Constants.GETSTATIC)); il.append(_factory.createLoad(Type.OBJECT, 0)); il.append(_factory.createFieldAccess("ClassContainingStrings", "someString", Type.STRING, Constants.GETFIELD)); il.append(_factory.createInvoke("java.io.PrintStream", "println", Type.VOID, new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL)); InstructionHandle ih_18 = il.append(_factory.createReturn(Type.VOID));
private void createResetMethod(String method_name, String field_name) { InstructionList tmpIl = new InstructionList(); // no-arg method MethodGen method = new MethodGen(ACC_PUBLIC | ACC_FINAL, Type.VOID, buildArgs(new Class[] {}), new String[] {}, method_name, classname, tmpIl, cp); // implement: setXX(ZERO) tmpIl.append(InstructionConstants.ALOAD_0); tmpIl.append(factory.createFieldAccess(classname, "ZERO", getObjectType(Integer.class), Constants.GETSTATIC)); tmpIl.append(factory.createFieldAccess(classname, field_name, getObjectType(Object.class), Constants.PUTFIELD)); tmpIl.append(InstructionFactory.createReturn(Type.VOID)); method.setMaxStack(); method.setMaxLocals(); cg.addMethod(method.getMethod()); tmpIl.dispose(); }
InstructionHandle ih2_end = il.append(InstructionConstants.ALOAD_0); il.append(factory.createFieldAccess(classname, "exit_code", Type.INT, Constants.GETFIELD)); il.append(InstructionFactory.createReturn(Type.INT)); bh1.setTarget(ih_reb); il.append(InstructionConstants.POP); il.append(InstructionConstants.ALOAD_0); il.append(factory.createFieldAccess(classname, "exit_code", Type.INT, Constants.GETFIELD)); il.append(InstructionFactory.createReturn(Type.INT));
InstructionFactory.createLoad( Type.OBJECT, 0 ) ); m_instructionList.append( m_instructionFactory.createFieldAccess( m_wrapperClassName, WRAPPED_CLASS_FN,
private void createSetMethod(String method_name, String field_name, Class field_type) { InstructionList tmpIl = new InstructionList(); MethodGen method = new MethodGen(ACC_PUBLIC | ACC_FINAL, Type.VOID, buildArgs(new Class[] {field_type}), new String[] {"arg"}, method_name, classname, tmpIl, cp); tmpIl.append(InstructionConstants.ALOAD_0); tmpIl.append(InstructionConstants.ALOAD_1); tmpIl.append(factory.createFieldAccess(classname, field_name, getObjectType(Object.class), Constants.PUTFIELD)); tmpIl.append(InstructionFactory.createReturn(Type.VOID)); method.setMaxStack(); method.setMaxLocals(); cg.addMethod(method.getMethod()); tmpIl.dispose(); }
private void createMethod_getARGV() { InstructionList tmpIl = new InstructionList(); MethodGen method = new MethodGen(ACC_PUBLIC | ACC_FINAL, getObjectType(Object.class), new Type[] {}, new String[] {}, "getARGV", classname, tmpIl, cp); tmpIl.append(InstructionConstants.ALOAD_0); tmpIl.append(factory.createFieldAccess(classname, argv_field, getObjectType(Object.class), Constants.GETFIELD)); tmpIl.append(InstructionFactory.createReturn(getObjectType(Object.class))); method.setMaxStack(); method.setMaxLocals(); cg.addMethod(method.getMethod()); tmpIl.dispose(); }
private void createIncMethod(String method_name, String field_method, String field_name) { InstructionList tmpIl = new InstructionList(); // no-arg method MethodGen method = new MethodGen(ACC_PUBLIC | ACC_FINAL, Type.VOID, buildArgs(new Class[] {}), new String[] {}, method_name, classname, tmpIl, cp); // implement: setXX((int) toDouble(inc(getXX()))) tmpIl.append(InstructionConstants.ALOAD_0); tmpIl.append(InstructionConstants.ALOAD_0); // get field tmpIl.append(factory.createInvoke(classname, field_method, getObjectType(Object.class), buildArgs(new Class[] {}), INVOKEVIRTUAL)); // inc tmpIl.append(factory.createInvoke(JRT_Class.getName(), "inc", getObjectType(Object.class), buildArgs(new Class[] {Object.class}), INVOKESTATIC)); // toDouble tmpIl.append(factory.createInvoke(JRT_Class.getName(), "toDouble", getObjectType(Double.TYPE), buildArgs(new Class[] {Object.class}), INVOKESTATIC)); // (int) tmpIl.append(InstructionConstants.D2I); // { convert int to Integer } tmpIl.append(factory.createInvoke("java.lang.Integer", "valueOf", getObjectType(Integer.class), buildArgs(new Class[] {Integer.TYPE}), Constants.INVOKESTATIC)); // set field tmpIl.append(factory.createFieldAccess(classname, field_name, getObjectType(Object.class), Constants.PUTFIELD)); tmpIl.append(InstructionFactory.createReturn(Type.VOID)); method.setMaxStack(); method.setMaxLocals(); cg.addMethod(method.getMethod()); tmpIl.dispose(); }
il.append(factory.createFieldAccess(JRT_Class.getName(), "input_line", getObjectType(String.class), Constants.PUTFIELD));
private void generateEqualsMethod(String generatedClassName) { /* public boolean equals(Object o) { * return stubHelper.isEquals(this,o); * } */ InstructionList il = new InstructionList(); MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.BOOLEAN, new Type[]{Type.OBJECT}, new String[]{"arg0"}, "equals", generatedClassName, il, constantsPool); il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); il.append(factory.createFieldAccess(generatedClassName, "stubHelper", new ObjectType("org.codehaus.jremoting.client.StubHelper"), Constants.GETFIELD)); il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); il.append(InstructionFactory.createLoad(Type.OBJECT, 1)); il.append(factory.createInvoke("org.codehaus.jremoting.client.StubHelper", "isEquals", Type.BOOLEAN, new Type[]{Type.OBJECT, Type.OBJECT}, Constants.INVOKEINTERFACE)); il.append(InstructionFactory.createReturn(Type.INT)); method.setMaxStack(); method.setMaxLocals(); classGen.addMethod(method.getMethod()); il.dispose(); }
/** * Method createConstructor. * This method adds a constructor that takes in a StubHelper Instance * * @param generatedClassName the stub class name */ protected void createConstructor(String generatedClassName) { InstructionList il = new InstructionList(); MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[]{new ObjectType("org.codehaus.jremoting.client.StubHelper")}, new String[]{"arg0"}, "<init>", generatedClassName, il, constantsPool); il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); il.append(factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); il.append(InstructionFactory.createLoad(Type.OBJECT, 1)); il.append(factory.createFieldAccess(generatedClassName, "stubHelper", new ObjectType("org.codehaus.jremoting.client.StubHelper"), Constants.PUTFIELD)); il.append(InstructionFactory.createReturn(Type.VOID)); method.setMaxStack(); method.setMaxLocals(); classGen.addMethod(method.getMethod()); il.dispose(); }
/** * Add method * <pre> * public Long jRemotingGetReferenceID(Object factoryThatIsAsking) { * return stubHelper.getReference(factoryThatIsAsking); * } * </pre> * * @param generatedClassName the generated class name */ protected void createGetReferenceIDMethod(String generatedClassName) { InstructionList il = new InstructionList(); MethodGen method = new MethodGen(Constants.ACC_PUBLIC, new ObjectType("java.lang.Long"), new Type[]{Type.OBJECT}, new String[]{"arg0"}, "jRemotingGetReferenceID", generatedClassName, il, constantsPool); il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); il.append(factory.createFieldAccess(generatedClassName, "stubHelper", new ObjectType("org.codehaus.jremoting.client.StubHelper"), Constants.GETFIELD)); il.append(InstructionFactory.createLoad(Type.OBJECT, 1)); il.append(factory.createInvoke("org.codehaus.jremoting.client.StubHelper", "getReference", new ObjectType("java.lang.Long"), new Type[]{Type.OBJECT}, Constants.INVOKEINTERFACE)); il.append(InstructionFactory.createReturn(Type.OBJECT)); method.setMaxStack(); method.setMaxLocals(); classGen.addMethod(method.getMethod()); il.dispose(); }
private void createGetMethod(int method_access, String method_name, String field_name) { InstructionList tmpIl = new InstructionList(); MethodGen method = new MethodGen(method_access | ACC_FINAL, getObjectType(Object.class), new Type[] {}, new String[] {}, method_name, classname, tmpIl, cp); tmpIl.append(InstructionConstants.ALOAD_0); tmpIl.append(factory.createFieldAccess(classname, field_name, getObjectType(Object.class), Constants.GETFIELD)); tmpIl.append(InstructionConstants.DUP); BranchHandle bh = tmpIl.append(new IFNONNULL(null)); // NULL! tmpIl.append(InstructionConstants.POP); // pop the null tmpIl.append(new PUSH(cp, "")); InstructionHandle ih = tmpIl.append(InstructionFactory.createReturn(getObjectType(Object.class))); bh.setTarget(ih); method.setMaxStack(); method.setMaxLocals(); cg.addMethod(method.getMethod()); tmpIl.dispose(); }
tmpIl.append(factory.createFieldAccess(classname, "EXTENSION_DESCRIPTION", getObjectType(String.class), Constants.GETSTATIC));