@Override public void visit(Method obj) { methodIsStatic = obj.isStatic(); state = 0; sawGetClass = -100; }
@Override public boolean choose(JavaClassAndMethod javaClassAndMethod) { return javaClassAndMethod.getMethod().isStatic(); }
@Override public boolean choose(JavaClassAndMethod javaClassAndMethod) { return !javaClassAndMethod.getMethod().isStatic(); }
@Override public void initMethod(Method method) { isEqualsObject = "equals".equals(getMethodName()) && "(Ljava/lang/Object;)Z".equals(getMethodSig()) && !method.isStatic(); sawInstanceofCheck = false; reportedBadCastInEquals = false; }
public static boolean isMainMethod(Method method) { return method.isStatic() && "main".equals(method.getName()) && "([Ljava/lang/String;)V".equals(method.getSignature()); }
/** is there a JUnit3TestSuite */ private boolean hasSuite(Method[] methods) { for (Method m : methods) { if (m.getName().equals("suite") && m.isPublic() && m.isStatic() // && m.getReturnType().equals(junit.framework.Test.class) // && m.getArgumentTypes().length == 0 && m.getSignature().equals("()Ljunit/framework/Test;")) { return true; } } return false; }
@Override public void visit(Code obj) { Method m = getMethod(); if (m.isStatic() || alreadyReported) { return; } state = SEEN_NOTHING; super.visit(obj); }
@Override public void visit(Code obj) { if (getMethod().isStatic()) { return; } initializedFields = new HashSet<>(); nullCheckedFields = new HashSet<>(); super.visit(obj); accumulator.reportAccumulatedBugs(); }
/** * Build map of value numbers to param indices. The first parameter has * index 0, the second has index 1, etc. * * @param method * the method analyzed by the ValueNumberAnalysis * @return the value number to parameter index map */ public Map<ValueNumber, Integer> getValueNumberToParamMap(Method method) { return getValueNumberToParamMap(method.getSignature(), method.isStatic()); }
public static Method findImplementation(JavaClass clazz, String name, String signature) { Method[] m = clazz.getMethods(); for (Method aM : m) { if (aM.getName().equals(name) && aM.getSignature().equals(signature) && !aM.isPrivate() && !aM.isStatic()) { return aM; } } return null; } }
private Set<ValueNumber> getParameterValueNumbers(ClassContext classContext, Method method, CFG cfg) throws DataflowAnalysisException, CFGBuilderException { ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); ValueNumberFrame vnaFrameAtEntry = vnaDataflow.getStartFact(cfg.getEntry()); Set<ValueNumber> paramValueNumberSet = new HashSet<>(); int firstParam = method.isStatic() ? 0 : 1; for (int i = firstParam; i < vnaFrameAtEntry.getNumLocals(); ++i) { paramValueNumberSet.add(vnaFrameAtEntry.getValue(i)); } return paramValueNumberSet; }
/** * @param obj * the method to parse * @return a descriptor for the method */ protected MethodDescriptor parseMethod(Method obj) { return new MethodDescriptor(slashedClassName, obj.getName(), obj.getSignature(), obj.isStatic()); }
@Override public void visit(Method obj) { if (getMethodName().equals("suite") && !obj.isStatic()) { bugReporter.reportBug(new BugInstance(this, "IJU_SUITE_NOT_STATIC", NORMAL_PRIORITY).addClassAndMethod(this)); } if (getMethodName().equals("suite") && obj.getSignature().startsWith("()") && obj.isStatic()) { if ((!obj.getSignature().equals("()Ljunit/framework/Test;") && !obj.getSignature().equals( "()Ljunit/framework/TestSuite;")) || !obj.isPublic()) { bugReporter.reportBug(new BugInstance(this, "IJU_BAD_SUITE_METHOD", NORMAL_PRIORITY).addClassAndMethod(this)); } } }
public static @CheckForNull XMethod definedIn(JavaClass clazz, XMethod m) { for (Method m2 : clazz.getMethods()) { if (m.getName().equals(m2.getName()) && m.getSignature().equals(m2.getSignature()) && m.isStatic() == m2.isStatic()) { return XFactory.createXMethod(clazz, m2); } } return null; }
private boolean classDefinesMethod(JavaClass c, XMethod m) { for (Method definedMethod : c.getMethods()) { if (definedMethod.getName().equals(m.getName()) && definedMethod.getSignature().equals(m.getSignature()) && definedMethod.isStatic() == m.isStatic()) { return true; } } return false; }
/** * Construct a MethodDescriptor from JavaClass and method. * * @param jclass * a JavaClass * @param method * a Method belonging to the JavaClass * @return a MethodDescriptor identifying the method */ public static MethodDescriptor getMethodDescriptor(JavaClass jclass, Method method) { return DescriptorFactory.instance().getMethodDescriptor(jclass.getClassName().replace('.', '/'), method.getName(), method.getSignature(), method.isStatic()); }
@Override public void visit(Code code) { boolean interesting = !getMethod().isStatic() && !getThisClass().isFinal(); if (interesting) { // initialize any variables we want to initialize for the method pendingBug = null; super.visit(code); // make callbacks to sawOpcode for all opcodes assert (pendingBug == null); } }
/** * Get the MethodDescriptor that (hopefully) uniqely names this method. * * @return the MethodDescriptor uniquely naming this method */ public MethodDescriptor toMethodDescriptor() { return DescriptorFactory.instance().getMethodDescriptor(getSlashedClassName(), method.getName(), method.getSignature(), method.isStatic()); }
public MethodDescriptor getMethodDescriptor(JavaClass jClass, Method method) { return getMethodDescriptor(ClassName.toSlashedClassName(jClass.getClassName()), method.getName(), method.getSignature(), method.isStatic()); }