@Test public void testAreOppositeBranches() { assertTrue(DismantleBytecode.areOppositeBranches(Const.IF_ACMPEQ, Const.IF_ACMPNE)); assertTrue(DismantleBytecode.areOppositeBranches(Const.IF_ICMPEQ, Const.IF_ICMPNE)); assertTrue(DismantleBytecode.areOppositeBranches(Const.IF_ICMPLT, Const.IF_ICMPGE)); assertTrue(DismantleBytecode.areOppositeBranches(Const.IFNE, Const.IFEQ)); assertTrue(DismantleBytecode.areOppositeBranches(Const.IFLT, Const.IFGE)); assertTrue(DismantleBytecode.areOppositeBranches(Const.IFNULL, Const.IFNONNULL)); }
public static boolean areOppositeBranches(int opcode1, int opcode2) { if (!isBranch(opcode1)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode1) + " isn't a branch"); } if (!isBranch(opcode2)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode2) + " isn't a branch"); } switch (opcode1) { case Const.IF_ACMPEQ: case Const.IF_ACMPNE: case Const.IF_ICMPEQ: case Const.IF_ICMPNE: case Const.IF_ICMPLT: case Const.IF_ICMPLE: case Const.IF_ICMPGT: case Const.IF_ICMPGE: case Const.IFNE: case Const.IFEQ: case Const.IFLT: case Const.IFLE: case Const.IFGT: case Const.IFGE: return ((opcode1 + 1) ^ 1) == opcode2 + 1; case Const.IFNONNULL: return opcode2 == Const.IFNULL; case Const.IFNULL: return opcode2 == Const.IFNONNULL; default: return false; } }
DismantleBytecode extends AnnotationVisitor { public static boolean areOppositeBranches(int opcode1, int opcode2) { if (!isBranch(opcode1)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode1) + " isn't a branch"); } if (!isBranch(opcode2)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode2) + " isn't a branch"); } switch (opcode1) { case Const.IF_ACMPEQ: case Const.IF_ACMPNE: case Const.IF_ICMPEQ: case Const.IF_ICMPNE: case Const.IF_ICMPLT: case Const.IF_ICMPLE: case Const.IF_ICMPGT: case Const.IF_ICMPGE: case Const.IFNE: case Const.IFEQ: case Const.IFLT: case Const.IFLE: case Const.IFGT: case Const.IFGE: return ((opcode1 + 1) ^ 1) == opcode2 + 1; case Const.IFNONNULL: return opcode2 == Const.IFNULL; case Const.IFNULL: return opcode2 == Const.IFNONNULL; default: return false; } } }
DismantleBytecode extends AnnotationVisitor { public static boolean areOppositeBranches(int opcode1, int opcode2) { if (!isBranch(opcode1)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode1) + " isn't a branch"); } if (!isBranch(opcode2)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode2) + " isn't a branch"); } switch (opcode1) { case Const.IF_ACMPEQ: case Const.IF_ACMPNE: case Const.IF_ICMPEQ: case Const.IF_ICMPNE: case Const.IF_ICMPLT: case Const.IF_ICMPLE: case Const.IF_ICMPGT: case Const.IF_ICMPGE: case Const.IFNE: case Const.IFEQ: case Const.IFLT: case Const.IFLE: case Const.IFGT: case Const.IFGE: return ((opcode1 + 1) ^ 1) == opcode2 + 1; case Const.IFNONNULL: return opcode2 == Const.IFNULL; case Const.IFNULL: return opcode2 == Const.IFNONNULL; default: return false; } }  }
DismantleBytecode extends AnnotationVisitor { public static boolean areOppositeBranches(int opcode1, int opcode2) { if (!isBranch(opcode1)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode1) + " isn't a branch"); } if (!isBranch(opcode2)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode2) + " isn't a branch"); } switch (opcode1) { case Const.IF_ACMPEQ: case Const.IF_ACMPNE: case Const.IF_ICMPEQ: case Const.IF_ICMPNE: case Const.IF_ICMPLT: case Const.IF_ICMPLE: case Const.IF_ICMPGT: case Const.IF_ICMPGE: case Const.IFNE: case Const.IFEQ: case Const.IFLT: case Const.IFLE: case Const.IFGT: case Const.IFGE: return ((opcode1 + 1) ^ 1) == opcode2 + 1; case Const.IFNONNULL: return opcode2 == Const.IFNULL; case Const.IFNULL: return opcode2 == Const.IFNONNULL; default: return false; } }  ClassDescriptor getClassDescriptorOperand(); @CheckForNull XClass getXClassOperand(); boolean isMethodCall(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") MethodDescriptor getMethodDescriptorOperand(); @CheckForNull @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") XMethod getXMethodOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") FieldDescriptor getFieldDescriptorOperand(); @CheckForNull XField getXFieldOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getDottedClassConstantOperand(); @Deprecated @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getRefConstantOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getNameConstantOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getSigConstantOperand(); @SlashedClassName @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getClassConstantOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getStringConstantOperand(); Constant getConstantRefOperand(); boolean isRegisterLoad(); boolean isRegisterStore(); int getRegisterOperand(); int getIntConstant(); long getLongConstant(); int getBranchOffset(); int getBranchTarget(); int getBranchFallThrough(); int getDefaultSwitchOffset(); boolean getRefFieldIsStatic(); int getPC(); int getPrevOpcode(int offset); boolean isWideOpcode(); static boolean isBranch(int opcode); static boolean isSwitch(int opcode); @SuppressFBWarnings("EI") int[] getSwitchOffsets(); @SuppressFBWarnings("EI") int[] getSwitchLabels(); int getMaxPC(); int getCodeByte(int offset); int getOpcode(); boolean atCatchBlock(); @Override void visit(Code obj); void sawDouble(double seen); void sawFloat(float seen); void sawRegister(int r); void sawInt(int seen); void sawLong(long seen); void sawBranchTo(int targetPC); boolean beforeOpcode(int seen); void afterOpcode(int seen); void sawOpcode(int seen); void sawString(String seen); void sawField(); void sawMethod(); void sawIMethod(); void sawClass(); void printOpCode(int seen); int getNextPC(); int getNextOpcode(); int getNextCodeByte(int offset); boolean isReturn(int opcode); boolean isShift(int opcode); static boolean areOppositeBranches(int opcode1, int opcode2); boolean isRegisterStore(int opcode); }
DismantleBytecode extends AnnotationVisitor { public static boolean areOppositeBranches(int opcode1, int opcode2) { if (!isBranch(opcode1)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode1) + " isn't a branch"); } if (!isBranch(opcode2)) { throw new IllegalArgumentException(Const.getOpcodeName(opcode2) + " isn't a branch"); } switch (opcode1) { case Const.IF_ACMPEQ: case Const.IF_ACMPNE: case Const.IF_ICMPEQ: case Const.IF_ICMPNE: case Const.IF_ICMPLT: case Const.IF_ICMPLE: case Const.IF_ICMPGT: case Const.IF_ICMPGE: case Const.IFNE: case Const.IFEQ: case Const.IFLT: case Const.IFLE: case Const.IFGT: case Const.IFGE: return ((opcode1 + 1) ^ 1) == opcode2 + 1; case Const.IFNONNULL: return opcode2 == Const.IFNULL; case Const.IFNULL: return opcode2 == Const.IFNONNULL; default: return false; } }  ClassDescriptor getClassDescriptorOperand(); @CheckForNull XClass getXClassOperand(); boolean isMethodCall(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") MethodDescriptor getMethodDescriptorOperand(); @CheckForNull @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") XMethod getXMethodOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") FieldDescriptor getFieldDescriptorOperand(); @CheckForNull XField getXFieldOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getDottedClassConstantOperand(); @Deprecated @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getRefConstantOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getNameConstantOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getSigConstantOperand(); @SlashedClassName @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getClassConstantOperand(); @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") String getStringConstantOperand(); Constant getConstantRefOperand(); boolean isRegisterLoad(); boolean isRegisterStore(); int getRegisterOperand(); int getIntConstant(); long getLongConstant(); int getBranchOffset(); int getBranchTarget(); int getBranchFallThrough(); int getDefaultSwitchOffset(); boolean getRefFieldIsStatic(); int getPC(); int getPrevOpcode(int offset); boolean isWideOpcode(); static boolean isBranch(int opcode); static boolean isSwitch(int opcode); @SuppressFBWarnings("EI") int[] getSwitchOffsets(); @SuppressFBWarnings("EI") int[] getSwitchLabels(); int getMaxPC(); int getCodeByte(int offset); int getOpcode(); boolean atCatchBlock(); @Override void visit(Code obj); void sawDouble(double seen); void sawFloat(float seen); void sawRegister(int r); void sawInt(int seen); void sawLong(long seen); void sawBranchTo(int targetPC); boolean beforeOpcode(int seen); void afterOpcode(int seen); void sawOpcode(int seen); void sawString(String seen); void sawField(); void sawMethod(); void sawIMethod(); void sawClass(); void printOpCode(int seen); int getNextPC(); int getNextOpcode(); int getNextCodeByte(int offset); boolean isReturn(int opcode); boolean isShift(int opcode); static boolean areOppositeBranches(int opcode1, int opcode2); boolean isRegisterStore(int opcode); static final byte M_INT; static final byte M_UINT; static final byte M_CP; static final byte M_R; static final byte M_BR; static final byte M_PAD; }