Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unexpected type: class com.ibm.wala.analysis.typeInference.JavaPrimitiveType #42

Closed
vazexqi opened this issue Mar 29, 2013 · 4 comments
Closed
Labels

Comments

@vazexqi
Copy link
Owner

vazexqi commented Mar 29, 2013

Here's the stack trace

Caused by: com.ibm.wala.util.debug.UnimplementedError: Unexpected type: class com.ibm.wala.analysis.typeInference.JavaPrimitiveType
    at com.ibm.wala.util.debug.Assertions.UNREACHABLE(Assertions.java:55)
    at com.ibm.wala.analysis.typeInference.PointType.meet(PointType.java:69)
    at com.ibm.wala.analysis.typeInference.TypeInference$PrimitivePropagateOperator.evaluate(TypeInference.java:392)
    at com.ibm.wala.cast.java.analysis.typeInference.AstJavaTypeInference$PrimAndStringOp.evaluate(AstJavaTypeInference.java:142)
    at com.ibm.wala.analysis.typeInference.TypeInference$PrimitivePropagateOperator.evaluate(TypeInference.java:1)
    at com.ibm.wala.fixedpoint.impl.GeneralStatement.evaluate(GeneralStatement.java:36)
    at com.ibm.wala.fixedpoint.impl.AbstractFixedPointSolver.solve(AbstractFixedPointSolver.java:149)
    at com.ibm.wala.analysis.typeInference.TypeInference.solve(TypeInference.java:126)
    at com.ibm.wala.analysis.typeInference.TypeInference.solve(TypeInference.java:117)
    at com.ibm.wala.analysis.typeInference.TypeInference.<init>(TypeInference.java:113)
    at com.ibm.wala.cast.analysis.typeInference.AstTypeInference.<init>(AstTypeInference.java:70)
    at com.ibm.wala.cast.java.analysis.typeInference.AstJavaTypeInference.<init>(AstJavaTypeInference.java:98)
    at edu.illinois.jflow.jflow.wala.dataflowanalysis.ProgramDependenceGraph.<init>(ProgramDependenceGraph.java:80)
    at edu.illinois.jflow.jflow.wala.dataflowanalysis.ProgramDependenceGraph.makeWithSourceCode(ProgramDependenceGraph.java:65)
    at edu.illinois.jflow.core.transformations.code.ExtractClosureRefactoring.createPDGAnalyzer(ExtractClosureRefactoring.java:302)

Here's the offending code:

package extractclosure;

public class Project1 {
    public static void main(String[] args) {
        int a = producer(1);
        /*[*/
        int b = producer(a);
        int c = producer(b);
        System.out.println("a: " + a + ", c: " + c); // <--- This line here, if we remove it al is well.
        /*]*/
    }

    static int producer(int input) {
        return input + 2;
    }
}
@vazexqi
Copy link
Owner Author

vazexqi commented Mar 29, 2013

This is probably because the "a: " + a gets translated into a binaryop(add) and that confuses Wala since it is not expecting the + on a string and an integer.

@vazexqi
Copy link
Owner Author

vazexqi commented Mar 29, 2013

I confirm this by replacing the offending line with

        int b = producer(a);
        int c = producer(b);
        System.out.println(String.format("a: %s, b: %s", a, b)); // <-- this avoid the binaryop(add) that confuses Wala

@vazexqi vazexqi closed this as completed Mar 29, 2013
@vazexqi
Copy link
Owner Author

vazexqi commented Mar 29, 2013

After more investigation, the culprit for this is actually

  public AstJavaTypeInference(IR ir, IClassHierarchy cha, boolean doPrimitives) {
    super(ir, cha, JavaPrimitiveType.BOOLEAN, doPrimitives);
    this.stringClass = cha.lookupClass(TypeReference.JavaLangString);
  }

The field, stringClass, is not initialized in time. That is because the call to super actually calls the call to initialize() and solve, which will cause trouble when you try to compare the types.

@vazexqi vazexqi reopened this Mar 29, 2013
@vazexqi
Copy link
Owner Author

vazexqi commented Apr 3, 2013

Reported and fixed in the latest version of WALA
wala/WALA#12
wala/WALA#13

@vazexqi vazexqi closed this as completed Apr 3, 2013
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant