import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
+import java.util.Stack;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
+import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
TaintSource[] ts;
private TranslationCollector translationCollector;
+ Stack<QualifiedAllocationExpression> anonymousConstructorCall = new Stack<>();
+
public TranslationCollectingVisitor(CompilationUnitDeclaration unit,
TaintSource[] target, TranslationCollector c) {
this.unit = unit;
}
return super.visit(allocationExpression, scope);
}
+
+ @Override
+ public boolean visit(QualifiedAllocationExpression qualifiedAllocationExpression, BlockScope scope) {
+ anonymousConstructorCall.push(qualifiedAllocationExpression);
+ return super.visit(qualifiedAllocationExpression, scope);
+ }
+
+ @Override
+ public void endVisit(QualifiedAllocationExpression qualifiedAllocationExpression, BlockScope scope) {
+ if(anonymousConstructorCall.pop() != qualifiedAllocationExpression){
+ throw new Error("stack illegally manipulated");
+ }
+ }
+
@Override
public boolean visit(ExplicitConstructorCall explicitConstructor,
BlockScope scope) {
for (TaintSource t0 : ts) {
if (t0.equals(t)) {
Expression[] ags = explicitConstructor.arguments;
+ if (anonymousConstructorCall.size() > 0) {
+ ags = anonymousConstructorCall.peek().arguments;
+ }
if (ags == null) {
System.out.println(explicitConstructor);
return true;
+ (call == null ? "constructor" : call.sourceStart) + " => "
+ caller);
System.out.println(e.getClass());
- System.out.println("To ignore: " + b.toConfLine());
+ System.out.println(
+ "To ignore: " + (b == null ? "don't know" : b.toConfLine()));
}
private void testEnum(Expression e, MethodBinding binding) {
if (binding.parameters.length != 0) {