/** * The detector is only meaningful for Java5 class libraries. * * @param classContext * the context object that holds the JavaClass parsed */ @Override public void visitClassContext(ClassContext classContext) { int majorVersion = classContext.getJavaClass().getMajor(); if (majorVersion >= Const.MAJOR_1_5 && hasInterestingMethod(classContext.getJavaClass().getConstantPool(), methods)) { super.visitClassContext(classContext); } }
@Override public void visit(JavaClass obj) { isTigerOrHigher = obj.getMajor() >= Const.MAJOR_1_5; try { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); ClassDescriptor me = getClassDescriptor(); if (subtypes2.isSubtype(me, MAP_ENTRY) && subtypes2.isSubtype(me, ITERATOR)) { bugReporter.reportBug(new BugInstance(this, "PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS", NORMAL_PRIORITY) .addClass(this).addString("shouldn't reuse Iterator as a Map.Entry")); } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } }
&& (getThisClass().getMajor() >= Const.MAJOR_1_7 || getThisClass().getMajor() >= Const.MAJOR_1_4 && (primitiveType.equals("D") || primitiveType.equals("F")))) { MethodDescriptor shouldCall = new MethodDescriptor(called.getClassDescriptor().getClassName(), "compare", int majorVersion = getThisClass().getMajor(); if (majorVersion >= Const.MAJOR_1_4) { accumulator.accumulateBug(new BugInstance(this, "DM_BOOLEAN_CTOR", NORMAL_PRIORITY).addClassAndMethod(this),
/** * returns whether the class in question was compiled with a jdk less than 1.4 * * @param cls * the class to check * @return whether the class is compiled with a jdk less than 1.4 */ private static boolean isPre14Class(JavaClass cls) { return (cls != null) && (cls.getMajor() < Constants.MAJOR_1_4); }
/** * returns whether the class in question was compiled with a jdk less than 1.4 * * @param cls * the class to check * @return whether the class is compiled with a jdk less than 1.4 */ private static boolean isPre14Class(JavaClass cls) { return (cls != null) && (cls.getMajor() < Const.MAJOR_1_4); }
JavaClass c = Repository.lookupClass("com.x.MyClass") c.getMinor(); c.getMajor();
/** * overrides the visitor to make sure this is a 'modern' class better than 1.4 * * @param classContext * the currently parsed class */ @Override public void visitClassContext(ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); clsVersion = cls.getMajor(); super.visitClassContext(classContext); }
/** * overrides the visitor to make sure this is a 'modern' class better than 1.4 * * @param classContext * the currently parsed class */ @Override public void visitClassContext(ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); clsVersion = cls.getMajor(); super.visitClassContext(classContext); }
/** * implements the visitor to make sure the class is at least java 1.4 and to reset the opcode stack */ @Override public void visitClassContext(ClassContext classContext) { try { JavaClass cls = classContext.getJavaClass(); if (cls.getMajor() >= MAJOR_1_4) { stack = new OpcodeStack(); regValueType = new HashMap<>(); super.visitClassContext(classContext); } } finally { stack = null; regValueType = null; } }
/** * implements the visitor to create and tear down the opcode stack * * @param clsContext the context object of the currently parsed class */ @Override public void visitClassContext(ClassContext clsContext) { try { stack = new OpcodeStack(); clsVersion = clsContext.getJavaClass().getMajor(); unendedZLIBs = new HashMap<>(); super.visitClassContext(clsContext); } finally { unendedZLIBs = null; stack = null; } }
@Override public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); clsVersion = classContext.getJavaClass().getMajor(); super.visitClassContext(classContext); } finally { stack = null; } }
/** * implements the visitor to create and clear the stack and suspectLocals * * @param classContext * the context object of the currently parsed class */ @Override public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); suspectLocals = new HashMap<>(); classVersion = classContext.getJavaClass().getMajor(); super.visitClassContext(classContext); } finally { stack = null; suspectLocals = null; } }
@Override public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); clsVersion = classContext.getJavaClass().getMajor(); super.visitClassContext(classContext); } finally { stack = null; } }
/** * implements the visitor to create and tear down the opcode stack * * @param clsContext * the context object of the currently parsed class */ @Override public void visitClassContext(ClassContext clsContext) { try { stack = new OpcodeStack(); clsVersion = clsContext.getJavaClass().getMajor(); super.visitClassContext(clsContext); } finally { stack = null; } }
@Override public void visitClassContext(ClassContext classContext) { if (classContext.getJavaClass().getMajor() <= Const.MAJOR_1_5) { dumbMethods.put(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, SignatureBuilder.SIG_VOID_TO_VOID), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY)); dumbMethods.put(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, byteArrayToVoid), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY)); dumbMethods.put(new FQMethod("java/security/SecureRandom", "getSeed", intToByteArray), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY)); } else { dumbMethods.remove(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, SignatureBuilder.SIG_VOID_TO_VOID)); dumbMethods.remove(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, byteArrayToVoid)); dumbMethods.remove(new FQMethod("java/security/SecureRandom", "getSeed", intToByteArray)); } super.visitClassContext(classContext); }
@Override public void visitClassContext(ClassContext classContext) { if (classContext.getJavaClass().getMajor() <= MAJOR_1_5) { dumbMethods.put(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, SignatureBuilder.SIG_VOID_TO_VOID), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY)); dumbMethods.put(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, byteArrayToVoid), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY)); dumbMethods.put(new FQMethod("java/security/SecureRandom", "getSeed", intToByteArray), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY)); } else { dumbMethods.remove(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, SignatureBuilder.SIG_VOID_TO_VOID)); dumbMethods.remove(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, byteArrayToVoid)); dumbMethods.remove(new FQMethod("java/security/SecureRandom", "getSeed", intToByteArray)); } super.visitClassContext(classContext); }
/** * The detector is only meaningful for Java5 class libraries. * * @param classContext * the context object that holds the JavaClass parsed */ @Override public void visitClassContext(ClassContext classContext) { int majorVersion = classContext.getJavaClass().getMajor(); if (majorVersion >= MAJOR_1_5 && hasInterestingMethod(classContext.getJavaClass().getConstantPool(), methods)) { super.visitClassContext(classContext); } }
@Override public void visit(JavaClass obj) { isTigerOrHigher = obj.getMajor() >= MAJOR_1_5; try { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); ClassDescriptor me = getClassDescriptor(); if (subtypes2.isSubtype(me, MAP_ENTRY) && subtypes2.isSubtype(me, ITERATOR)) { bugReporter.reportBug(new BugInstance(this, "PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS", NORMAL_PRIORITY) .addClass(this).addString("shouldn't reuse Iterator as a Map.Entry")); } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } }