Robert Kasanicky created GROOVY-8752:
----------------------------------------
Summary: "gradle run" throws groovy.lang.MissingMethodExcpeption
after 2.5.1->2.5.2 groovy upgrade
Key: GROOVY-8752
URL: https://issues.apache.org/jira/browse/GROOVY-8752
Project: Groovy
Issue Type: Bug
Affects Versions: 2.5.2
Environment: ubuntu 18.04, oracle java 1.8.0_181, groovy 2.5.2, gradle
4.9
Reporter: Robert Kasanicky
Attachments: 252bug.zip
Initializing a class field using a GDK method somehow became problematic in
combination with gradle's application plugin. There was no such problem until
the 2.5.2 groovy version (also switching gradle versions doesn't make a
difference).
{code:java}
/*
* This Groovy source file was generated by the Gradle 'init' task.
*/
class App {
def today = new Date().format('yyyy-MM-dd')
String getGreeting() {
return 'Hello world.'
}
static void main(String[] args) {
println new App().greeting
}
}
{code}
{code:java}
$ groovy src/main/groovy/App.groovy
Hello world.
$ ./gradlew run
Exception in thread "main" groovy.lang.MissingMethodException: No signature of
method: java.util.Date.format() is applicable for argument types: (String)
values: [yyyy-MM-dd] Possible solutions: from(java.time.Instant), toYear(),
getAt(java.lang.String), parse(java.lang.String), print(java.lang.Object),
print(java.io.PrintWriter) at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:72)
at
org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:48)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at App.<init>(App.groovy:6) at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at
org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at
org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:238)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:242)
at App.main(App.groovy:13)
{code}
Runnable project including the code listed above is attached.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)