Details
-
Bug
-
Resolution: Fixed
-
P4
-
7
-
None
-
Verified
Description
JSR 202 gave the following rule:
instructionIsTypeSafe(invokespecial(CP), Environment, _Offset, StackFrame, NextStackFrame, ExceptionStackFrame) :-
...
thisClass(Environment, CurrentClass),
reverse([CurrentClass | OperandArgList], StackArgList),
...
currentClassLoader(Environment, L),
reverse([class(MethodClassName, L) | OperandArgList], StackArgList2),
...
isAssignable(class(CurrentClassName, L), class(MethodClassName, L)).
The last line is erroneous because CurrentClassName is undefined. We can't say class(CurrentClass, L) because CurrentClass is not a string but rather a class(...) term obtained from thisClass. But observe that currentClassLoader(Environment, L) is just a wrapper for thisClass, so we can just modify the call to thisClass and then simplify and correct the remainder:
instructionIsTypeSafe(invokespecial(CP), Environment, _Offset, StackFrame, NextStackFrame, ExceptionStackFrame) :-
...
thisClass(Environment, class(CurrentClassName, L)),
reverse([class(CurrentClassName, L) | OperandArgList], StackArgList),
...
// No more currentClassLoader call. L is in scope thanks to thisClass.
reverse([class(MethodClassName, L) | OperandArgList], StackArgList2),
...
isAssignable(class(CurrentClassName, L), class(MethodClassName, L)).
instructionIsTypeSafe(invokespecial(CP), Environment, _Offset, StackFrame, NextStackFrame, ExceptionStackFrame) :-
...
thisClass(Environment, CurrentClass),
reverse([CurrentClass | OperandArgList], StackArgList),
...
currentClassLoader(Environment, L),
reverse([class(MethodClassName, L) | OperandArgList], StackArgList2),
...
isAssignable(class(CurrentClassName, L), class(MethodClassName, L)).
The last line is erroneous because CurrentClassName is undefined. We can't say class(CurrentClass, L) because CurrentClass is not a string but rather a class(...) term obtained from thisClass. But observe that currentClassLoader(Environment, L) is just a wrapper for thisClass, so we can just modify the call to thisClass and then simplify and correct the remainder:
instructionIsTypeSafe(invokespecial(CP), Environment, _Offset, StackFrame, NextStackFrame, ExceptionStackFrame) :-
...
thisClass(Environment, class(CurrentClassName, L)),
reverse([class(CurrentClassName, L) | OperandArgList], StackArgList),
...
// No more currentClassLoader call. L is in scope thanks to thisClass.
reverse([class(MethodClassName, L) | OperandArgList], StackArgList2),
...
isAssignable(class(CurrentClassName, L), class(MethodClassName, L)).