Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6-beta-1, 1.6-beta-2
-
None
Description
Some generated fields that should be marked as synthetic are not.
Given:
class MyService { def thing def something() { } def anotherSomething() { assert true } }
We see:
MyService.getDeclaredFields().grep { it.synthetic } ==> [public static final java.lang.Class MyService.$ownClass, private static java.lang.Class MyService.$class$java$lang$Class, private static java.lang.Class MyService.$class$groovy$lang$MetaClass, private static java.lang.Class MyService.$class$MyService, private static java.lang.ref.SoftReference MyService.$callSiteArray]
MyService.getDeclaredFields().grep { !it.synthetic } ==> [private java.lang.Object MyService.thing, private static org.codehaus.groovy.reflection.ClassInfo MyService.$staticClassInfo, private transient groovy.lang.MetaClass MyService.metaClass, public static java.lang.Long MyService.__timeStamp, public static java.lang.Long MyService.__timeStamp__239_neverHappen1227930452630]
The only non-synthetic field should be MyService.thing, the rest are synthetic.
on further investigation I found, that the property field needs to be synthetic or else the compiler won't be able to replace the filed in case the user gives an additional field. If the synthetic flag is not set the compiler is unable to see if the existing field is given by the user or not. As a result the test above will now return no fields that are not synthetic