opalj/opal

Fix Class.forName Handling in AI

TorunR opened this issue · 5 comments

Currently, Abstract Interpretation of the JDK fails in it:test.
This happens since there are new private versions of Class.forName since this commit.
The error occurs in org/opalj/ai/domain/l1/ClassValues.scala in

methodDescriptor match {
                        case `forName_String`                     => simpleClassForNameCall(pc, value)
                        case `forName_String_boolean_ClassLoader` => simpleClassForNameCall(pc, value)
                        case _ =>
                            throw new DomainException(
                                s"unsupported Class { ${methodDescriptor.toJava("forName")} }"
                            )
                    }

since we miss the branches for these new private Methods (and the public Method that uses a Module parameter).

errt commented

Actually this does not fail for the third public method becaue that does not have a String as its first parameter. It should still probably be supported. Note though that it behaves differently compared to the other two methods (e.g., it returns null instead of throwing ClassNotFoundException), so simply invoking simpleClassForNameCall won't suffice.

Okay so this could be 2 Issues I guess.
We should check whether Reflection.getCallerClass() is handled correctly as well.

errt commented

The exception is now fixed with #97. The issues of more Class.forName methods to be handled remains open.

As discussed in the last OPAL call, i'll have a look into the remainder of this issue.

Closed by #152 and #153