Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The code below gets a ClassCastException:java.lang.Integer in the first line of goAhead() method. The reason is that the 'res' has already been reserved for static field of the class, and 1 is casted to this field instead of the variable 'res'.
class StaticTest {
private static final Date res = new Date()
def goAhead ()
{ def res = 1}public static void main (args)
{ new StaticTest().goAhead() }}
For goAhead the bytecode of following java code is created:
public Object goAhead() {
Date date = (Date)ScriptBytecodeAdapter.asType(new Integer(1), java.util.Date.class);
date;
res = (Date) date;
return res;
}
instead of:
public Object goAhead() {
Integer integer = new Integer(1);
return integer;
}