private void processLoadConstant() { Constant c = getConstantRefOperand(); if (c instanceof ConstantClass) { String refClsName = normalizeArrayClass(getDottedClassConstantOperand()); if (!refClsName.equals(className)) { Set<String> dependencies = getDependenciesForClass(className); dependencies.add(refClsName); } } }
private void processInvoke() { String refClsName = normalizeArrayClass(getDottedClassConstantOperand()); if (refClsName == null) { return; } if (refClsName.startsWith(Values.JAVA)) { return; } if (className.equals(refClsName)) { return; } if (isEnclosingClassName(className, refClsName) || isEnclosingClassName(refClsName, className)) { return; } if (isStaticChild(className, refClsName) || isStaticChild(refClsName, className)) { return; } Set<String> dependencies = getDependenciesForClass(className); dependencies.add(refClsName); }
@Override public void sawOpcode(int seen) { if ((seen == Const.INVOKESPECIAL) || (seen == Const.INVOKESTATIC) || (seen == Const.INVOKEVIRTUAL)) { processInvoke(); } else if (seen == Const.LDC) { processLoadConstant(); } }
@Override public void report() { removeDependencyLeaves(); LoopFinder lf = new LoopFinder(); while (!dependencyGraph.isEmpty()) { String clsName = dependencyGraph.keySet().iterator().next(); Set<String> loop = lf.findLoop(dependencyGraph, clsName); boolean pruneLeaves; if (loop != null) { BugInstance bug = new BugInstance(this, BugType.FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY.name(), NORMAL_PRIORITY); for (String loopCls : loop) { bug.addClass(loopCls); } bugReporter.reportBug(bug); pruneLeaves = removeLoopLinks(loop); } else { dependencyGraph.remove(clsName); pruneLeaves = true; } if (pruneLeaves) { removeDependencyLeaves(); } } dependencyGraph.clear(); }
@Override public void visitAnnotation(@DottedClassName String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) { if (!runtimeVisible) { return; } for (ElementValue v : map.values()) { if (v.getElementValueType() == ElementValue.CLASS) { String annotationClsAttr = SignatureUtils.stripSignature(v.stringifyValue()); Set<String> dependencies = getDependenciesForClass(className); dependencies.add(annotationClsAttr); } } }
@Override public void report() { removeDependencyLeaves(); LoopFinder lf = new LoopFinder(); while (!dependencyGraph.isEmpty()) { String clsName = dependencyGraph.keySet().iterator().next(); Set<String> loop = lf.findLoop(dependencyGraph, clsName); boolean pruneLeaves; if (loop != null) { BugInstance bug = new BugInstance(this, BugType.FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY.name(), NORMAL_PRIORITY); for (String loopCls : loop) { bug.addClass(loopCls); } bugReporter.reportBug(bug); pruneLeaves = removeLoopLinks(loop); } else { dependencyGraph.remove(clsName); pruneLeaves = true; } if (pruneLeaves) { removeDependencyLeaves(); } } dependencyGraph.clear(); }
@Override public void visitAnnotation(@DottedClassName String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) { if (!runtimeVisible) { return; } for (ElementValue v : map.values()) { if (v.getElementValueType() == ElementValue.CLASS) { String annotationClsAttr = SignatureUtils.stripSignature(v.stringifyValue()); Set<String> dependencies = getDependenciesForClass(className); dependencies.add(annotationClsAttr); } } }
private void processInvoke() { String refClsName = normalizeArrayClass(getDottedClassConstantOperand()); if (refClsName == null) { return; } if (refClsName.startsWith(Values.JAVA)) { return; } if (className.equals(refClsName)) { return; } if (isEnclosingClassName(className, refClsName) || isEnclosingClassName(refClsName, className)) { return; } if (isStaticChild(className, refClsName) || isStaticChild(refClsName, className)) { return; } Set<String> dependencies = getDependenciesForClass(className); dependencies.add(refClsName); }
private void processLoadConstant() { Constant c = getConstantRefOperand(); if (c instanceof ConstantClass) { String refClsName = normalizeArrayClass(getDottedClassConstantOperand()); if (!refClsName.equals(className)) { Set<String> dependencies = getDependenciesForClass(className); dependencies.add(refClsName); } } }
@Override public void sawOpcode(int seen) { if ((seen == INVOKESPECIAL) || (seen == INVOKESTATIC) || (seen == INVOKEVIRTUAL)) { processInvoke(); } else if (seen == LDC) { processLoadConstant(); } }