/** * Throws an exception when an invalid state is hit in a tableswitch */ private static void stateNotFound(final CodeAttribute c, final TableSwitchBuilder builder) { c.branchEnd(builder.getDefaultBranchEnd().get()); c.newInstruction(RuntimeException.class); c.dup(); c.ldc("Invalid character"); c.invokespecial(RuntimeException.class.getName(), "<init>", "(Ljava/lang/String;)V"); c.athrow(); }
c.dup(); c.getfield(parseStateClass, "stringBuilder", DescriptorUtils.makeDescriptor(StringBuilder.class)); c.astore(STATE_STRING_BUILDER_VAR); c.dup(); c.getfield(parseStateClass, "parseState", "I"); c.dup(); c.istore(CURRENT_STATE_VAR); c.dup(); c.getfield(parseStateClass, "pos", "I"); c.istore(STATE_POS_VAR); c.dup(); c.getfield(parseStateClass, "current", HTTP_STRING_DESCRIPTOR); c.astore(STATE_CURRENT_VAR); final CodeLocation returnIncompleteCode = c.mark(); c.aload(PARSE_STATE_VAR); c.dup(); c.dup(); c.dup(); c.dup(); final CodeLocation returnCompleteCode = c.mark(); c.aload(PARSE_STATE_VAR); c.dup(); c.dup(); c.dup(); c.dup();
@Override public void handleOtherToken(final CodeAttribute c) { c.aload(PARSE_STATE_VAR); c.swap(); c.dup(); c.invokestatic(CONNECTORS_CLASS, "verifyToken", "(" + HTTP_STRING_DESCRIPTOR + ")V"); c.putfield(parseStateClass, "nextHeader", HTTP_STRING_DESCRIPTOR); }
@Override public void handleOtherToken(final CodeAttribute c) { c.aload(HTTP_RESULT); c.swap(); c.dup(); c.invokestatic(CONNECTORS_CLASS, "verifyToken", "(" + HTTP_STRING_DESCRIPTOR + ")V"); c.invokevirtual(resultClass, "setRequestMethod", "(" + HTTP_STRING_DESCRIPTOR + ")" + HTTP_EXCHANGE_DESCRIPTOR); c.pop(); }
ca.dup(); ca.iconst(j); if (!type.isPrimitive()) { init.anewarray(String.class.getName()); for (i = 0; i < len; i++) { init.dup(); init.iconst(i); init.ldc(CDRStream.abbrevFor(paramTypes[i])); for (i = 0; i < len; i++) { if (!RemoteException.class.isAssignableFrom(exceptions[i])) { init.dup(); init.iconst(j); init.ldc( for (i = 0; i < len; i++) { if (!RemoteException.class.isAssignableFrom(exceptions[i])) { init.dup(); init.iconst(j); init.ldc(exceptions[i].getName());
c.dup(); final BranchEnd end = c.ifne(); c.pop(); c.dup(); final Set<BranchEnd> tokenEnds = new LinkedHashSet<>(); final Set<BranchEnd> badTokenEnds = new LinkedHashSet<>(); c.iconst(state.value); ends.put(state, c.ifIcmpeq()); c.dup(); c.dup(); c.iconst('\r'); tokenEnds.add(c.ifIcmpeq()); c.dup(); c.iconst('\n'); tokenEnds.add(c.ifIcmpeq()); c.dup(); c.iconst(' '); tokenEnds.add(c.ifIcmpeq()); c.iconst('\r'); tokenEnds.add(c.ifIcmpeq()); c.dup(); c.iconst('\n'); tokenEnds.add(c.ifIcmpeq()); c.iconst(' ');
clinit.anewarray(String.class.getName()); for (int i = 0; i < ids.length; i++) { clinit.dup(); clinit.iconst(i); clinit.ldc(ids[i]);
@Override void doWork(CodeAttribute b, ClassMethod classMethod) { loadBeanInstance(classMethod.getClassFile(), methodInfo, b); //now we should have the target bean instance on top of the stack // we need to dup it so we still have it to compare to the return value b.dup(); //lets create the method invocation String methodDescriptor = methodInfo.getDescriptor(); b.loadMethodParameters(); if (method.getDeclaringClass().isInterface()) { b.invokeinterface(methodInfo.getDeclaringClass(), methodInfo.getName(), methodDescriptor); } else { b.invokevirtual(methodInfo.getDeclaringClass(), methodInfo.getName(), methodDescriptor); } }
@Override void doWork(CodeAttribute b, ClassMethod classMethod) { loadBeanInstance(classMethod.getClassFile(), methodInfo, b); //now we should have the target bean instance on top of the stack // we need to dup it so we still have it to compare to the return value b.dup(); //lets create the method invocation String methodDescriptor = methodInfo.getDescriptor(); b.loadMethodParameters(); if (method.getDeclaringClass().isInterface()) { b.invokeinterface(methodInfo.getDeclaringClass(), methodInfo.getName(), methodDescriptor); } else { b.invokevirtual(methodInfo.getDeclaringClass(), methodInfo.getName(), methodDescriptor); } }
/** * Ends interception context if it was previously stated. This is indicated by a local variable with index 0. */ void endIfStarted(CodeAttribute b, ClassMethod method) { b.aload(getLocalVariableIndex(0)); b.dup(); final BranchEnd ifnotnull = b.ifnull(); b.checkcast(Stack.class); b.invokevirtual(Stack.class.getName(), END_INTERCEPTOR_CONTEXT_METHOD_NAME, EMPTY_PARENTHESES + VOID_CLASS_DESCRIPTOR); BranchEnd ifnull = b.gotoInstruction(); b.branchEnd(ifnotnull); b.pop(); // remove null Stack b.branchEnd(ifnull); }
/** * Ends interception context if it was previously stated. This is indicated by a local variable with index 0. */ void endIfStarted(CodeAttribute b, ClassMethod method) { b.aload(getLocalVariableIndex(0)); b.dup(); final BranchEnd ifnotnull = b.ifnull(); b.checkcast(Stack.class); b.invokevirtual(Stack.class.getName(), END_INTERCEPTOR_CONTEXT_METHOD_NAME, EMPTY_PARENTHESES + VOID_CLASS_DESCRIPTOR); BranchEnd ifnull = b.gotoInstruction(); b.branchEnd(ifnotnull); b.pop(); // remove null Stack b.branchEnd(ifnull); }
/** * Ends interception context if it was previously stated. This is indicated by a local variable with index 0. */ void endIfStarted(CodeAttribute b, ClassMethod method) { b.aload(getLocalVariableIndex(0)); b.dup(); final BranchEnd ifnotnull = b.ifnull(); b.checkcast(Stack.class); b.invokevirtual(Stack.class.getName(), END_INTERCEPTOR_CONTEXT_METHOD_NAME, EMPTY_PARENTHESES + VOID_CLASS_DESCRIPTOR); BranchEnd ifnull = b.gotoInstruction(); b.branchEnd(ifnotnull); b.pop(); // remove null Stack b.branchEnd(ifnull); }
/** * Ends interception context if it was previously stated. This is indicated by a local variable with index 0. */ void endIfStarted(CodeAttribute b, ClassMethod method) { b.aload(getLocalVariableIndex(0)); b.dup(); final BranchEnd ifnotnull = b.ifnull(); b.checkcast(Stack.class); b.invokevirtual(Stack.class.getName(), END_INTERCEPTOR_CONTEXT_METHOD_NAME, EMPTY_PARENTHESES + VOID_CLASS_DESCRIPTOR); BranchEnd ifnull = b.gotoInstruction(); b.branchEnd(ifnotnull); b.pop(); // remove null Stack b.branchEnd(ifnull); }
/** * Ends interception context if it was previously stated. This is indicated by a local variable with index 0. */ void endIfStarted(CodeAttribute b, ClassMethod method) { b.aload(getLocalVariableIndex(0)); b.dup(); final BranchEnd ifnotnull = b.ifnull(); b.checkcast(Stack.class); b.invokevirtual(Stack.class.getName(), END_INTERCEPTOR_CONTEXT_METHOD_NAME, EMPTY_PARENTHESES + VOID_CLASS_DESCRIPTOR); BranchEnd ifnull = b.gotoInstruction(); b.branchEnd(ifnotnull); b.pop(); // remove null Stack b.branchEnd(ifnull); }
@Override protected void addSerializationSupport(ClassFile proxyClassType) { final Class<Exception>[] exceptions = new Class[]{ObjectStreamException.class}; final ClassMethod writeReplace = proxyClassType.addMethod(AccessFlag.PRIVATE, "writeReplace", LJAVA_LANG_OBJECT); writeReplace.addCheckedExceptions(exceptions); CodeAttribute b = writeReplace.getCodeAttribute(); b.newInstruction(SerializableClientProxy.class.getName()); b.dup(); b.aload(0); b.getfield(proxyClassType.getName(), BEAN_ID_FIELD, BeanIdentifier.class); b.aload(0); b.getfield(proxyClassType.getName(), CONTEXT_ID_FIELD, String.class); b.invokespecial(SerializableClientProxy.class.getName(), INIT_METHOD_NAME, "(" + LBEAN_IDENTIFIER + LJAVA_LANG_STRING + ")" + BytecodeUtils.VOID_CLASS_DESCRIPTOR); b.returnInstruction(); }
@Override protected void addSerializationSupport(ClassFile proxyClassType) { final Class<Exception>[] exceptions = new Class[]{ObjectStreamException.class}; final ClassMethod writeReplace = proxyClassType.addMethod(AccessFlag.PRIVATE, "writeReplace", LJAVA_LANG_OBJECT); writeReplace.addCheckedExceptions(exceptions); CodeAttribute b = writeReplace.getCodeAttribute(); b.newInstruction(SerializableClientProxy.class.getName()); b.dup(); b.aload(0); b.getfield(proxyClassType.getName(), BEAN_ID_FIELD, BeanIdentifier.class); b.aload(0); b.getfield(proxyClassType.getName(), CONTEXT_ID_FIELD, String.class); b.invokespecial(SerializableClientProxy.class.getName(), INIT_METHOD_NAME, "(" + LBEAN_IDENTIFIER + LJAVA_LANG_STRING + ")" + BytecodeUtils.VOID_CLASS_DESCRIPTOR); b.returnInstruction(); }
@Override protected void addSerializationSupport(ClassFile proxyClassType) { final Class<Exception>[] exceptions = new Class[]{ObjectStreamException.class}; final ClassMethod writeReplace = proxyClassType.addMethod(AccessFlag.PRIVATE, "writeReplace", LJAVA_LANG_OBJECT); writeReplace.addCheckedExceptions(exceptions); CodeAttribute b = writeReplace.getCodeAttribute(); b.newInstruction(SerializableClientProxy.class.getName()); b.dup(); b.aload(0); b.getfield(proxyClassType.getName(), BEAN_ID_FIELD, BeanIdentifier.class); b.aload(0); b.getfield(proxyClassType.getName(), CONTEXT_ID_FIELD, String.class); b.invokespecial(SerializableClientProxy.class.getName(), INIT_METHOD_NAME, "(" + LBEAN_IDENTIFIER + LJAVA_LANG_STRING + ")" + BytecodeUtils.VOID_CLASS_DESCRIPTOR); b.returnInstruction(); }
void startIfNotOnTop(CodeAttribute b, ClassMethod method) { b.aload(0); factory.getMethodHandlerField(method.getClassFile(), b); b.dup(); // if handler != null (may happen inside constructor calls) final BranchEnd handlerNull = b.ifnull(); b.invokestatic(INTERCEPTION_DECORATION_CONTEXT_CLASS_NAME, START_INTERCEPTOR_CONTEXT_IF_NOT_ON_TOP_METHOD_NAME, START_INTERCEPTOR_CONTEXT_IF_NOT_ON_TOP_METHOD_SIGNATURE); final BranchEnd endOfIfStatement = b.gotoInstruction(); b.branchEnd(handlerNull); // else started = false // keeping null handler on top of stack b.branchEnd(endOfIfStatement); storeToLocalVariable(0); }
void startIfNotOnTop(CodeAttribute b, ClassMethod method) { b.aload(0); factory.getMethodHandlerField(method.getClassFile(), b); b.dup(); // if handler != null (may happen inside constructor calls) final BranchEnd handlerNull = b.ifnull(); b.invokestatic(INTERCEPTION_DECORATION_CONTEXT_CLASS_NAME, START_INTERCEPTOR_CONTEXT_IF_NOT_ON_TOP_METHOD_NAME, START_INTERCEPTOR_CONTEXT_IF_NOT_ON_TOP_METHOD_SIGNATURE); final BranchEnd endOfIfStatement = b.gotoInstruction(); b.branchEnd(handlerNull); // else started = false // keeping null handler on top of stack b.branchEnd(endOfIfStatement); storeToLocalVariable(0); }