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"); c.getstatic(file.getName(), currentState.httpStringFieldName, HTTP_STRING_DESCRIPTOR); stateMachine.handleStateMachineMatchedToken(c); c.invokevirtual(parseStateClass, "parseComplete", "()V"); c.iconst(0); c.returnInstruction();
/** * Client proxies use the following hashCode: * <code>MyProxyName.class.hashCode()</code> */ @Override protected void generateHashCodeMethod(ClassFile proxyClassType) { final ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, HASH_CODE_METHOD, BytecodeUtils.INT_CLASS_DESCRIPTOR); final CodeAttribute b = method.getCodeAttribute(); // MyProxyName.class.hashCode() b.loadClass(proxyClassType.getName()); // now we have the class object on top of the stack b.invokevirtual("java.lang.Object", HASH_CODE_METHOD, EMPTY_PARENTHESES + BytecodeUtils.INT_CLASS_DESCRIPTOR); // now we have the hashCode b.returnInstruction(); }
/** * This method must be called by subclasses after they have finished generating the class. */ protected void finalizeStaticConstructor() { setupCachedProxyFields(); staticConstructor.getCodeAttribute().returnInstruction(); }
private void writeStateMachine(final String className, final ClassFile file, final CodeAttribute c, final State initial, final List<State> allStates, int noStates, final CustomStateMachine stateMachine, boolean expectNewline) { c.aload(BYTE_BUFFER_VAR); c.invokevirtual(ByteBuffer.class.getName(), "hasRemaining", "()Z"); final BranchEnd nonZero = c.ifne(); c.returnInstruction(); 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.iload(CURRENT_STATE_VAR); c.putfield(parseStateClass, "parseState", "I"); c.returnInstruction(); setupLocalVariables(c); final CodeLocation returnCompleteCode = c.mark(); c.iconst(0); c.putfield(parseStateClass, "parseState", "I"); c.returnInstruction(); c.putfield(parseStateClass, "parseState", "I"); c.iconst(0); c.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(); }
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(); }
/** * Client proxies use the following hashCode: * <code>MyProxyName.class.hashCode()</code> */ @Override protected void generateHashCodeMethod(ClassFile proxyClassType) { final ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, HASH_CODE_METHOD, BytecodeUtils.INT_CLASS_DESCRIPTOR); final CodeAttribute b = method.getCodeAttribute(); // MyProxyName.class.hashCode() b.loadClass(proxyClassType.getName()); // now we have the class object on top of the stack b.invokevirtual("java.lang.Object", HASH_CODE_METHOD, EMPTY_PARENTHESES + BytecodeUtils.INT_CLASS_DESCRIPTOR); // now we have the hashCode b.returnInstruction(); }
private static void generateGetTargetClassBody(ClassMethod method) { final CodeAttribute b = method.getCodeAttribute(); BytecodeUtils.pushClassType(b, method.getClassFile().getSuperclass()); 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(); }
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 use the following hashCode: * <code>MyProxyName.class.hashCode()</code> */ @Override protected void generateHashCodeMethod(ClassFile proxyClassType) { final ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, HASH_CODE_METHOD, BytecodeUtils.INT_CLASS_DESCRIPTOR); final CodeAttribute b = method.getCodeAttribute(); // MyProxyName.class.hashCode() b.loadClass(proxyClassType.getName()); // now we have the class object on top of the stack b.invokevirtual("java.lang.Object", HASH_CODE_METHOD, EMPTY_PARENTHESES + BytecodeUtils.INT_CLASS_DESCRIPTOR); // now we have the hashCode b.returnInstruction(); }
private static void generateGetTargetClassBody(ClassMethod method) { final CodeAttribute b = method.getCodeAttribute(); BytecodeUtils.pushClassType(b, method.getClassFile().getSuperclass()); 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 use the following hashCode: * <code>MyProxyName.class.hashCode()</code> */ @Override protected void generateHashCodeMethod(ClassFile proxyClassType) { final ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, HASH_CODE_METHOD, BytecodeUtils.INT_CLASS_DESCRIPTOR); final CodeAttribute b = method.getCodeAttribute(); // MyProxyName.class.hashCode() b.loadClass(proxyClassType.getName()); // now we have the class object on top of the stack b.invokevirtual("java.lang.Object", HASH_CODE_METHOD, EMPTY_PARENTHESES + BytecodeUtils.INT_CLASS_DESCRIPTOR); // now we have the hashCode b.returnInstruction(); }
private static void generateGetTargetClassBody(ClassMethod method) { final CodeAttribute b = method.getCodeAttribute(); BytecodeUtils.pushClassType(b, method.getClassFile().getSuperclass()); 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(); }