Java Code Examples for org.apache.bcel.Const#ICONST_0
The following examples show how to use
org.apache.bcel.Const#ICONST_0 .
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: QuestionableBooleanAssignment.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void sawOpcode(int seen) { if (seen == Const.GOTO && getBranchOffset() == 4) { state = SEEN_GOTO; } else { switch (state) { case SEEN_NOTHING: if ((seen == Const.ICONST_1) || (seen == Const.ICONST_0)) { state = SEEN_ICONST_0_OR_1; } break; case SEEN_ICONST_0_OR_1: if (seen == Const.DUP) { state = SEEN_DUP; } else { state = SEEN_NOTHING; } break; case SEEN_DUP: if (((seen >= Const.ISTORE_0) && (seen <= Const.ISTORE_3)) || (seen == Const.ISTORE)) { state = SEEN_ISTORE; } else { state = SEEN_NOTHING; } break; case SEEN_ISTORE: if (seen == Const.IFEQ || seen == Const.IFNE) { bug = new BugInstance(this, "QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT", HIGH_PRIORITY).addClassAndMethod(this) .addSourceLine(this); state = SEEN_IF; } else { state = SEEN_NOTHING; } break; case SEEN_IF: state = SEEN_NOTHING; if (seen == Const.NEW) { String cName = getClassConstantOperand(); if ("java/lang/AssertionError".equals(cName)) { break; } } bugReporter.reportBug(bug); break; case SEEN_GOTO: state = SEEN_NOTHING; break; default: break; } } }
Example 2
Source File: InefficientToArray.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void sawOpcode(int seen) { if (DEBUG) { System.out.println("State: " + state + " Opcode: " + Const.getOpcodeName(seen)); } switch (state) { case SEEN_NOTHING: if (seen == Const.ICONST_0) { state = SEEN_ICONST_0; } break; case SEEN_ICONST_0: if (seen == Const.ANEWARRAY) { state = SEEN_ANEWARRAY; } else { state = SEEN_NOTHING; } break; case SEEN_ANEWARRAY: if (((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE)) && ("toArray".equals(getNameConstantOperand())) && ("([Ljava/lang/Object;)[Ljava/lang/Object;".equals(getSigConstantOperand()))) { try { String clsName = getDottedClassConstantOperand(); JavaClass cls = Repository.lookupClass(clsName); if (cls.implementationOf(collectionClass)) { bugAccumulator.accumulateBug( new BugInstance(this, "ITA_INEFFICIENT_TO_ARRAY", LOW_PRIORITY).addClassAndMethod(this), this); } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } } state = SEEN_NOTHING; break; default: state = SEEN_NOTHING; break; } }
Example 3
Source File: VarArgsProblems.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void sawOpcode(int seen) { // System.out.println("State:" + state); if (seen == Const.GOTO && getBranchOffset() == 4) { state = SEEN_GOTO; } else { switch (state) { case SEEN_NOTHING: if ((seen == Const.ICONST_1)) { state = SEEN_ICONST_1; } break; case SEEN_ICONST_1: if (seen == Const.ANEWARRAY && primitiveArray.matcher(getClassConstantOperand()).matches()) { // System.out.println("Allocation of array of type " + // getClassConstantOperand()); primitiveArraySig = getClassConstantOperand(); state = SEEN_ANEWARRAY; } else { state = SEEN_NOTHING; } break; case SEEN_ANEWARRAY: if (seen == Const.DUP) { state = SEEN_DUP; } else { state = SEEN_NOTHING; } break; case SEEN_DUP: if (seen == Const.ICONST_0) { state = SEEN_ICONST_0; } else { state = SEEN_NOTHING; } break; case SEEN_ICONST_0: if (((seen >= Const.ALOAD_0) && (seen < Const.ALOAD_3)) || (seen == Const.ALOAD)) { state = SEEN_ALOAD; } else { state = SEEN_NOTHING; } break; case SEEN_ALOAD: if (seen == Const.AASTORE) { state = SEEN_AASTORE; } else { state = SEEN_NOTHING; } break; case SEEN_AASTORE: if (seen == Const.INVOKESTATIC || seen == Const.INVOKEINTERFACE || seen == Const.INVOKESPECIAL || seen == Const.INVOKEVIRTUAL) { // System.out.println(getClassConstantOperand()); // System.out.println(getNameConstantOperand()); // System.out.println(getSigConstantOperand()); if (getSigConstantOperand().indexOf("Ljava/lang/Object;)") == -1) { break; } int priority = NORMAL_PRIORITY; if ("asList".equals(getNameConstantOperand()) && "java/util/Arrays".equals(getClassConstantOperand())) { priority = HIGH_PRIORITY; } bugReporter.reportBug(new BugInstance(this, "VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG", priority) .addClassAndMethod(this).addType(primitiveArraySig).describe(TypeAnnotation.FOUND_ROLE) .addCalledMethod(this).addSourceLine(this)); } state = SEEN_NOTHING; break; case SEEN_GOTO: state = SEEN_NOTHING; break; default: throw new IllegalStateException("State " + state + " not expected"); } } }
Example 4
Source File: FindNonShortCircuit.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
private void scanForBooleanValue(int seen) { switch (seen) { case Const.IAND: case Const.IOR: switch (prevOpcode) { case Const.ILOAD: case Const.ILOAD_0: case Const.ILOAD_1: case Const.ILOAD_2: case Const.ILOAD_3: clearAll(); break; default: break; } break; case Const.ICONST_1: stage1 = 1; switch (prevOpcode) { case Const.IFNONNULL: case Const.IFNULL: sawNullTest = true; break; case Const.IF_ICMPGT: case Const.IF_ICMPGE: case Const.IF_ICMPLT: case Const.IF_ICMPLE: sawNumericTest = true; break; } break; case Const.GOTO: if (stage1 == 1) { stage1 = 2; } else { stage1 = 0; clearAll(); } break; case Const.ICONST_0: if (stage1 == 2) { sawBooleanValue(); } stage1 = 0; break; case Const.INVOKEINTERFACE: case Const.INVOKEVIRTUAL: case Const.INVOKESPECIAL: case Const.INVOKESTATIC: String sig = getSigConstantOperand(); if (sig.endsWith(")Z")) { sawBooleanValue(); } stage1 = 0; break; default: stage1 = 0; } }