diff --git a/src/staticAnalyzer/Analysis.java b/src/staticAnalyzer/Analysis.java index a0306fa..875584d 100644 --- a/src/staticAnalyzer/Analysis.java +++ b/src/staticAnalyzer/Analysis.java @@ -649,11 +649,21 @@ protected State analyzeInstructions( Method m, InstructionList il s.stackPush(v); } else if ( i instanceof CPInstruction ) { if ( i instanceof INSTANCEOF || i instanceof CHECKCAST ) { - s.stackPop(); //@TODO atm ignoring types - s.stackPush(new Variable("V" + s.stackPop(); + ConstantPoolGen gen = new ConstantPoolGen(m.getConstantPool()); + if ( i instanceof CHECKCAST ) { + CHECKCAST c = (CHECKCAST)i; + Type t = c.getType(gen); + s.stackPush(new Variable(t.getSignature() ,Variable.Kind.LOCAL ,Variable.DomainValue.TOP ,Integer.MAX_VALUE,pci)); + } else if ( i instanceof INSTANCEOF ) { + s.stackPush(new Variable("I" + ,Variable.Kind.LOCAL + ,Variable.DomainValue.GEQ0 + ,Integer.MAX_VALUE,pci)); + } } else if ( i instanceof InvokeInstruction ) { InvokeInstruction ii = (InvokeInstruction)i; ConstantPoolGen gen = new ConstantPoolGen( diff --git a/src/test/test24.java b/src/test/test24.java new file mode 100644 index 0000000..327e5f2 --- /dev/null +++ b/src/test/test24.java @@ -0,0 +1,16 @@ +package test; + +class test24 { + public void test(Object o) { + if (o instanceof String) { + String s = (String) o; + } + } + + public int test2(Object o) { + if (o instanceof int[]) { + return ((int[])o).length; + } + return 0; + } +}