Saravanan Subiramaniam created GROOVY-11813:
-----------------------------------------------
Summary: groovy.lang.MissingMethodException: No signature of
method: minus for class: java.util.Date is applicable for argument types:
(groovy.time.DatumDependentDuration)
Key: GROOVY-11813
URL: https://issues.apache.org/jira/browse/GROOVY-11813
Project: Groovy
Issue Type: Question
Affects Versions: 5.0.2
Reporter: Saravanan Subiramaniam
Could you please help me with TimeCategory? The following script worked fine in
Groovy 4.0.x, but fails after we upgraded to 5.0.2.
{code}
use(groovy.time.TimeCategory) {
new Date() - 7.months
}
{code}
Please note that this script works when running using standalone Groovy (eg:
using groovy command), but fails in our application (Java based) with this
error. Both groovy-dateutil and groovy-datetime dependencies are in the
classpath. Our application uses Java 21.
{code}
Dynamic logic TESTUNIT_2:
1: *ERROR* --> use(groovy.time.TimeCategory) {
2: new Date() - 7.months
3: }
groovy.lang.MissingMethodException: No signature of method: minus for class:
java.util.Date is applicable for argument types:
(groovy.time.DatumDependentDuration) values: [7 months]
Possible solutions: minus(java.util.Date), minus(int), find(),
find(groovy.lang.Closure), is(java.lang.Object), plus(int)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:74)
at
org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:163)
at
org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:344)
at
custom.dynamiclogic.testunit_2.TESTUNIT_2$_run_closure1.doCall(custom.dynamiclogic.testunit_2.TESTUNIT_2.groovy:2)
at
custom.dynamiclogic.testunit_2.TESTUNIT_2$_run_closure1.doCall(custom.dynamiclogic.testunit_2.TESTUNIT_2.groovy)
at
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:338)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:274)
at
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:270)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1008)
at groovy.lang.Closure.call(Closure.java:471)
at groovy.lang.Closure.call(Closure.java:450)
at
org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:124)
at
org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:262)
at
org.codehaus.groovy.runtime.DefaultGroovyMethods.use(DefaultGroovyMethods.java:17206)
at org.codehaus.groovy.runtime.dgm$1263.doMethodInvoke(Unknown Source)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1235)
at
org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:344)
at
custom.dynamiclogic.testunit_2.TESTUNIT_2.run(custom.dynamiclogic.testunit_2.TESTUNIT_2.groovy:1)
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)