/** * Factory method for creating a source line annotation describing the * source line number for the instruction being visited by given visitor. * * @param visitor * a DismantleBytecode visitor which is visiting the method * @return the SourceLineAnnotation, or null if we do not have line number * information for the instruction */ public static SourceLineAnnotation fromVisitedInstruction(BytecodeScanningDetector visitor) { return fromVisitedInstruction(visitor.getClassContext(), visitor, visitor.getPC()); }
@Override public void visit(Code obj) { if (inConstructor) { super.visit(obj); } }
@Override public void visitAfter(JavaClass obj) { interfaceMethods = null; super.visitAfter(obj); }
public ProgramPoint(BytecodeScanningDetector v) { method = v.getXMethod(); pc = v.getPC(); }
@Override public void visitClassContext(ClassContext classContext) { if (!Analysis.FIND_EFFECTIVE_RELEVANT_QUALIFIERS) { return; } super.visitClassContext(classContext); }
@Override public void visitCode(Code obj) { state = SEEN_NOTHING; super.visitCode(obj); }
@Override public void visitMethod(Method obj) { currentVertex = findVertex(getXMethod()); super.visitMethod(obj); }
instanceOfTypes = new HashSet<>(); instanceOfTypes.add(bsd.getClassConstantOperand()); state = State.SEEN_INSTANCEOF; return IfStatement.Action.PROCESSED_ACTION; branchTarget = bsd.getBranchTarget(); state = State.SEEN_IFEQ; matchCount++; if (bsd.getPC() == branchTarget) { if (OpcodeUtils.isALoad(seen) && (reg == RegisterUtils.getALoadReg(bsd, seen))) { state = State.SEEN_ALOAD; String clsName = bsd.getClassName(); int priority = NORMAL_PRIORITY; for (String type : instanceOfTypes) {
/** * overrides the visitor to visit all of the collected listener methods * * @param obj * the context object of the currently parsed class */ @Override public void visitAfter(JavaClass obj) { isListenerMethod = true; for (Code l : listenerCode.keySet()) { try { super.visitCode(l); } catch (StopOpcodeParsingException e) { // method already reported } } super.visitAfter(obj); }
public SourceLineAnnotation getCurrentSwitchStatement(BytecodeScanningDetector detector) { if (switchOffsetStack.isEmpty()) { throw new IllegalStateException("No current switch statement"); } SwitchDetails details = switchOffsetStack.get(switchOffsetStack.size()-1); return SourceLineAnnotation.fromVisitedInstructionRange( detector.getClassContext(), detector, details.switchPC, details.switchPC + details.maxOffset-1); } public static class SwitchDetails {
public IfStatement(BytecodeScanningDetector bsd, int seen) { state = State.SEEN_ALOAD; reg = RegisterUtils.getALoadReg(bsd, seen); matchCount = 0; firstPC = bsd.getPC(); }
@Override public void doVisitMethod(Method obj) { super.doVisitMethod(obj); if (pendingBug != null) { if (potentialSuperCall == null) {
@Override public void visitClassContext(ClassContext classContext) { curClass = classContext.getJavaClass(); super.visitClassContext(classContext); }
@Override public void visitCode(Code obj) { state = SEEN_NOTHING; super.visitCode(obj); bug = null; }
@Override public void visitMethod(Method obj) { if (!obj.isPrivate() || obj.isSynthetic()) { return; } super.visitMethod(obj); String methodName = getMethodName(); if (!"writeReplace".equals(methodName) && !"readResolve".equals(methodName) && !"readObject".equals(methodName) && !"readObjectNoData".equals(methodName) && !"writeObject".equals(methodName) && methodName.indexOf("debug") == -1 && methodName.indexOf("Debug") == -1 && methodName.indexOf("trace") == -1 && methodName.indexOf("Trace") == -1 && !Const.CONSTRUCTOR_NAME.equals(methodName) && !Const.STATIC_INITIALIZER_NAME.equals(methodName)) { for(AnnotationEntry a : obj.getAnnotationEntries()) { String typeName = a.getAnnotationType(); if ("Ljavax/annotation/PostConstruct;".equals(typeName) || "Ljavax/annotation/PreDestroy;".equals(typeName)) { return; } } definedPrivateMethods.add(MethodAnnotation.fromVisitedMethod(this)); } }
instanceOfTypes = new HashSet<>(); instanceOfTypes.add(bsd.getClassConstantOperand()); state = State.SEEN_INSTANCEOF; return IfStatement.Action.PROCESSED_ACTION; branchTarget = bsd.getBranchTarget(); state = State.SEEN_IFEQ; matchCount++; if (bsd.getPC() == branchTarget) { if (OpcodeUtils.isALoad(seen) && (reg == RegisterUtils.getALoadReg(bsd, seen))) { state = State.SEEN_ALOAD; String clsName = bsd.getClassName(); int priority = NORMAL_PRIORITY; for (String type : instanceOfTypes) {
/** * overrides the visitor to visit all of the collected listener methods * * @param obj * the context object of the currently parsed class */ @Override public void visitAfter(JavaClass obj) { isListenerMethod = true; for (Code l : listenerCode.keySet()) { try { super.visitCode(l); } catch (StopOpcodeParsingException e) { // method already reported } } super.visitAfter(obj); }
public ProgramPoint(BytecodeScanningDetector v) { method = v.getXMethod(); pc = v.getPC(); }
/** * Factory method for creating a source line annotation describing the * source line number for the instruction being visited by given visitor. * * @param visitor * a BetterVisitor which is visiting the method * @param pc * the bytecode offset of the instruction in the method * @return the SourceLineAnnotation, or null if we do not have line number * information for the instruction */ public static SourceLineAnnotation fromVisitedInstruction(BytecodeScanningDetector visitor, int pc) { return fromVisitedInstructionRange(visitor.getClassContext(), visitor, pc, pc); }
public IfStatement(BytecodeScanningDetector bsd, int seen) { state = State.SEEN_ALOAD; reg = RegisterUtils.getALoadReg(bsd, seen); matchCount = 0; firstPC = bsd.getPC(); }