opalj / opal

https://www.opal-project.de
Other
51 stars 27 forks source link

Fix Class.forName Handling in AI #87

Closed TorunR closed 1 year ago

TorunR commented 2 years ago

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 2 years ago

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.

TorunR commented 2 years ago

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

errt commented 1 year ago

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

johannesduesing commented 1 year ago

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

johannesduesing commented 1 year ago

Closed by #152 and #153