Java Code Examples for org.apache.bcel.Const#LDC_W
The following examples show how to use
org.apache.bcel.Const#LDC_W .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FindRoughConstants.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void sawOpcode(int seen) { if (seen == Const.LDC || seen == Const.LDC_W || seen == Const.LDC2_W) { Constant c = getConstantRefOperand(); if (c instanceof ConstantFloat) { checkConst(((ConstantFloat) c).getBytes()); } else if (c instanceof ConstantDouble) { checkConst(((ConstantDouble) c).getBytes()); } return; } // Lower priority if the constant is put into array immediately or after the boxing: // this is likely to be just similar number in some predefined dataset (like lookup table) if (seen == Const.INVOKESTATIC && lastBug != null) { if (getNextOpcode() == Const.AASTORE && getNameConstantOperand().equals("valueOf") && (getClassConstantOperand().equals("java/lang/Double") || getClassConstantOperand().equals( "java/lang/Float"))) { lastBug = ((BugInstance) lastBug.clone()); lastBug.setPriority(lastPriority + 1); bugAccumulator.forgetLastBug(); bugAccumulator.accumulateBug(lastBug, this); } } lastBug = null; }
Example 2
Source File: DismantleBytecode.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
public void printOpCode(int seen) { System.out.print(" " + this.getClass().getSimpleName() + ": [" + formatter.format(getPC()) + "] " + Const.getOpcodeName(seen)); if ((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKESPECIAL) || (seen == Const.INVOKEINTERFACE) || (seen == Const.INVOKESTATIC)) { System.out.print(" " + getClassConstantOperand() + "." + getNameConstantOperand() + " " + getSigConstantOperand()); } else if (seen == Const.LDC || seen == Const.LDC_W || seen == Const.LDC2_W) { Constant c = getConstantRefOperand(); if (c instanceof ConstantString) { System.out.print(" \"" + getStringConstantOperand() + "\""); } else if (c instanceof ConstantClass) { System.out.print(" " + getClassConstantOperand()); } else { System.out.print(" " + c); } } else if ((seen == Const.ALOAD) || (seen == Const.ASTORE)) { System.out.print(" " + getRegisterOperand()); } else if ((seen == Const.GOTO) || (seen == Const.GOTO_W) || (seen == Const.IF_ACMPEQ) || (seen == Const.IF_ACMPNE) || (seen == Const.IF_ICMPEQ) || (seen == Const.IF_ICMPGE) || (seen == Const.IF_ICMPGT) || (seen == Const.IF_ICMPLE) || (seen == Const.IF_ICMPLT) || (seen == Const.IF_ICMPNE) || (seen == Const.IFEQ) || (seen == Const.IFGE) || (seen == Const.IFGT) || (seen == Const.IFLE) || (seen == Const.IFLT) || (seen == Const.IFNE) || (seen == Const.IFNONNULL) || (seen == Const.IFNULL)) { System.out.print(" " + getBranchTarget()); } else if ((seen == Const.NEW) || (seen == Const.INSTANCEOF)) { System.out.print(" " + getClassConstantOperand()); } else if ((seen == Const.TABLESWITCH) || (seen == Const.LOOKUPSWITCH)) { System.out.print(" ["); int switchPC = getPC(); int[] offsets = getSwitchOffsets(); for (int offset : offsets) { System.out.print((switchPC + offset) + ","); } System.out.print((switchPC + getDefaultSwitchOffset()) + "]"); } System.out.println(); }
Example 3
Source File: ReflectiveClasses.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void sawClass() { int opcode = getOpcode(); if ((opcode == Const.LDC) || (opcode == Const.LDC_W)) { process(getClassConstantOperand()); } }
Example 4
Source File: UnnecessaryMath.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void sawOpcode(int seen) { if (state == SEEN_NOTHING) { if ((seen == Const.DCONST_0) || (seen == Const.DCONST_1)) { constValue = seen - Const.DCONST_0; state = SEEN_DCONST; } else if ((seen == Const.LDC2_W) || (seen == Const.LDC_W)) { state = SEEN_DCONST; Constant c = this.getConstantRefOperand(); if (c instanceof ConstantDouble) { constValue = ((ConstantDouble) c).getBytes(); } else if (c instanceof ConstantFloat) { constValue = ((ConstantFloat) c).getBytes(); } else if (c instanceof ConstantLong) { constValue = ((ConstantLong) c).getBytes(); } else { state = SEEN_NOTHING; } } } else if (state == SEEN_DCONST) { if (seen == Const.INVOKESTATIC) { state = SEEN_NOTHING; if ("java.lang.Math".equals(getDottedClassConstantOperand())) { String methodName = getNameConstantOperand(); if (((constValue == 0.0) && zeroMethods.contains(methodName)) || ((constValue == 1.0) && oneMethods.contains(methodName)) || (anyMethods.contains(methodName))) { bugReporter.reportBug(new BugInstance(this, "UM_UNNECESSARY_MATH", LOW_PRIORITY).addClassAndMethod(this) .addSourceLine(this)); } } } state = SEEN_NOTHING; } }