final CodeAttribute codeAttribute = method.getCodeAttribute(); codeAttribute.aload(1); codeAttribute.invokevirtual("java/io/ObjectInputStream", "readObject", "()Ljava/lang/Object;"); codeAttribute.returnInstruction(); ctor.getCodeAttribute().aload(0); ctor.getCodeAttribute().invokespecial(SerializationHackProxy.class.getName(), "<init>", "()V"); ctor.getCodeAttribute().returnInstruction();
final CodeAttribute ca = asm.addMethod(m).getCodeAttribute(); ca.aload(0); ca.ldc(idlName); ca.getstatic(asm.getName(), strategyField, StubStrategy.class); if (!type.isPrimitive()) { ca.aload(index); } else if (type.equals(double.class)) { ca.dload(index); ca.checkcast(returnType); ca.returnInstruction(); final CodeAttribute init = asm.addMethod(Modifier.PRIVATE + Modifier.STATIC,initMethod, "V").getCodeAttribute(); int i; int len; init.putstatic(asm.getName(), strategyField, StubStrategy.class); init.returnInstruction();
c.aload(PARSE_STATE_VAR); c.getfield(parseStateClass, "leftOver", "B"); c.dup(); c.aload(BYTE_BUFFER_VAR); c.invokevirtual(ByteBuffer.class.getName(), "get", "()B"); BranchEnd cont = c.gotoInstruction(); c.branchEnd(end); c.aload(PARSE_STATE_VAR); c.iconst(0); c.putfield(parseStateClass, "leftOver", "B"); handleReturnIfNoMoreBytes(c, returnIncompleteCode); c.aload(BYTE_BUFFER_VAR); c.invokevirtual(ByteBuffer.class.getName(), "get", "()B"); c.aload(STATE_STRING_BUILDER_VAR); c.ldc(currentState.soFar); c.invokevirtual(StringBuilder.class.getName(), "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;"); c.branchEnd(parseDone); c.aload(PARSE_STATE_VAR); c.invokevirtual(parseStateClass, "parseComplete", "()V"); c.iconst(0); c.returnInstruction();
sc.ldc("ISO-8859-1"); sc.invokevirtual(String.class.getName(), "getBytes", "(Ljava/lang/String;)[B"); sc.putstatic(file.getName(), state.fieldName, "[B"); sc.aload(CONSTRUCTOR_HTTP_STRING_MAP_VAR); if (state.terminalState != null) { sc.ldc(state.terminalState); BranchEnd end = sc.ifnull(); sc.checkcast(HTTP_STRING_CLASS); sc.putstatic(file.getName(), state.httpStringFieldName, HTTP_STRING_DESCRIPTOR); BranchEnd done = sc.gotoInstruction(); sc.branchEnd(end); sc.putstatic(file.getName(), state.httpStringFieldName, HTTP_STRING_DESCRIPTOR); sc.branchEnd(done);
c.aload(BYTE_BUFFER_VAR); c.invokevirtual(ByteBuffer.class.getName(), "hasRemaining", "()Z"); final BranchEnd nonZero = c.ifne(); c.aload(PARSE_STATE_VAR); c.dup(); c.getfield(parseStateClass, "stringBuilder", DescriptorUtils.makeDescriptor(StringBuilder.class)); c.aload(PARSE_STATE_VAR); c.dup(); c.dup(); c.aload(STATE_CURRENT_VAR); c.putfield(parseStateClass, "current", HTTP_STRING_DESCRIPTOR); c.aload(STATE_CURRENT_BYTES_VAR); c.putfield(parseStateClass, "currentBytes", "[B"); c.iload(CURRENT_STATE_VAR); c.putfield(parseStateClass, "parseState", "I"); c.returnInstruction(); setupLocalVariables(c); final CodeLocation returnCompleteCode = c.mark(); c.aload(PARSE_STATE_VAR); c.dup(); c.dup(); c.aconstNull(); c.putfield(parseStateClass, "currentBytes", "[B"); c.aload(STATE_STRING_BUILDER_VAR); c.iconst(0);
/** * Client proxies are equal to other client proxies for the same bean. * <p/> * The corresponding java code: <code> * return other instanceof MyProxyClassType.class * </code> */ @Override protected void generateEqualsMethod(ClassFile proxyClassType) { ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, "equals", BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT); CodeAttribute b = method.getCodeAttribute(); b.aload(1); b.instanceofInstruction(proxyClassType.getName()); b.returnInstruction(); }
public byte[] createTokenizer(final String[] httpVerbs, String[] httpVersions, String[] standardHeaders) { final String className = existingClassName + CLASS_NAME_SUFFIX; final ClassFile file = new ClassFile(className, existingClassName); final ClassMethod ctor = file.addMethod(AccessFlag.PUBLIC, "<init>", "V", DescriptorUtils.parameterDescriptors(constructorDescriptor)); ctor.getCodeAttribute().aload(0); ctor.getCodeAttribute().loadMethodParameters(); ctor.getCodeAttribute().invokespecial(existingClassName, "<init>", constructorDescriptor); ctor.getCodeAttribute().returnInstruction(); final ClassMethod sctor = file.addMethod(AccessFlag.PUBLIC | AccessFlag.STATIC, "<clinit>", "V"); final AtomicInteger fieldCounter = new AtomicInteger(1); sctor.getCodeAttribute().invokestatic(existingClassName, "httpStrings", "()" + DescriptorUtils.makeDescriptor(Map.class)); sctor.getCodeAttribute().astore(CONSTRUCTOR_HTTP_STRING_MAP_VAR); createStateMachines(httpVerbs, httpVersions, standardHeaders, className, file, sctor, fieldCounter); sctor.getCodeAttribute().returnInstruction(); return file.toBytecode(); }
@Override void doReturn(CodeAttribute b, ClassMethod classMethod) { // assumes doWork() result is on top of the stack // if this method returns a primitive we just return if (method.getReturnType().isPrimitive()) { b.returnInstruction(); } else { // otherwise we have to check that the proxy is not returning 'this; // now we need to check if the proxy has return 'this' and if so return // an // instance of the proxy. // currently we have result, beanInstance on the stack. b.dupX1(); // now we have result, beanInstance, result // we need to compare result and beanInstance // first we need to build up the inner conditional that just returns // the // result final BranchEnd returnInstruction = b.ifAcmpeq(); b.returnInstruction(); b.branchEnd(returnInstruction); // now add the case where the proxy returns 'this'; b.aload(0); b.checkcast(methodInfo.getMethod().getReturnType().getName()); b.returnInstruction(); } } }.runStartIfNotEmpty();
/** * Client proxies are equal to other client proxies for the same bean. * <p/> * The corresponding java code: <code> * return other instanceof MyProxyClassType.class * </code> */ @Override protected void generateEqualsMethod(ClassFile proxyClassType) { ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, "equals", BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT); CodeAttribute b = method.getCodeAttribute(); b.aload(1); b.instanceofInstruction(proxyClassType.getName()); b.returnInstruction(); }
ctor.getCodeAttribute().aload(0); ctor.getCodeAttribute().invokespecial(superclass.getName(), "<init>", "()V"); ctor.getCodeAttribute().returnInstruction(); final CodeAttribute idMethod = asm.addMethod(Modifier.PUBLIC + Modifier.FINAL, "_ids", "[Ljava/lang/String;").getCodeAttribute(); idMethod.getstatic(stubClassName, ID_FIELD_NAME, "[Ljava/lang/String;"); idMethod.returnInstruction(); clinit.invokestatic(stubClassName, init(methodIndex), "()V"); clinit.returnInstruction();
/** * Client proxies are equal to other client proxies for the same bean. * <p/> * The corresponding java code: <code> * return other instanceof MyProxyClassType.class * </code> */ @Override protected void generateEqualsMethod(ClassFile proxyClassType) { ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, "equals", BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT); CodeAttribute b = method.getCodeAttribute(); b.aload(1); b.instanceofInstruction(proxyClassType.getName()); b.returnInstruction(); }
private static void generateGetTargetInstanceBody(ClassMethod method) { final CodeAttribute b = method.getCodeAttribute(); b.aload(0); b.returnInstruction(); }
/** * Client proxies are equal to other client proxies for the same bean. * <p/> * The corresponding java code: <code> * return other instanceof MyProxyClassType.class * </code> */ @Override protected void generateEqualsMethod(ClassFile proxyClassType) { ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, "equals", BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT); CodeAttribute b = method.getCodeAttribute(); b.aload(1); b.instanceofInstruction(proxyClassType.getName()); b.returnInstruction(); }
private static void generateGetTargetInstanceBody(ClassMethod method) { final CodeAttribute b = method.getCodeAttribute(); b.aload(0); b.returnInstruction(); }
/** * Client proxies are equal to other client proxies for the same bean. * <p/> * The corresponding java code: <code> * return other instanceof MyProxyClassType.class * </code> */ @Override protected void generateEqualsMethod(ClassFile proxyClassType) { ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, "equals", BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT); CodeAttribute b = method.getCodeAttribute(); b.aload(1); b.instanceofInstruction(proxyClassType.getName()); b.returnInstruction(); }
private static void generateGetTargetInstanceBody(ClassMethod method) { final CodeAttribute b = method.getCodeAttribute(); b.aload(0); b.returnInstruction(); }