Details
Description
First reported in http://jira.codehaus.org/browse/GROOVY-3823, opening a new Jira, as advised.
With:
interface II { Integer i Integer 2i = i * 2 }
Currently (1.7b2), one gets:
groovy> interface II { groovy> Integer i groovy> Integer i2 = i * 2 groovy> } groovy> println II.i groovy> println II.i2
Exception thrown
java.lang.IncompatibleClassChangeError: Found interface II, but class was expected
at II.<clinit>(ConsoleScript0:3)
at ConsoleScript0.class$(ConsoleScript0)
at ConsoleScript0.$get$$class$II(ConsoleScript0)
at ConsoleScript0.run(ConsoleScript0:6)
Attachments
Issue Links
| This issue relates to: | ||||
| GROOVY-3823 | Interface containing field without initialization expression incorrectly compiles |
|
|
|
I think the IncompatibleClassChangeError is coming because in the interface II's <clinit>, there is an invokestatic call being made for method $getCallSiteArray()[0] (for the multiply operation in i * 2).
Since interface II itself cannot contain any static methods such as $getCallSiteArray() or $createCallSiteArray(), callsites for the interface should probably be pushed into its synthetic, inner class and referenced as II$1.$getCallSiteArray()?
Is there any other, simpler suggestion?