Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groovy JDK classes not supported by default #1046

Closed
JE-coding opened this issue Feb 28, 2020 · 4 comments
Closed

Groovy JDK classes not supported by default #1046

JE-coding opened this issue Feb 28, 2020 · 4 comments

Comments

@JE-coding
Copy link

JE-coding commented Feb 28, 2020

I use the configuration:

  • Windows 10
  • a fresh installed Eclipse Version: 2019-12 (4.14.0) running on Java 12 JDK
  • Groovy Development Tools 3.7.0.SNAPSHOT
  • Groovy Compiler Version 3.0.1

A simple Groovy script, created in a new Groovy Project:

def d = new Date();
println d + 1

results in:
caught: groovy.lang.MissingMethodException: No signature of method: java.util.Date.plus() is applicable for argument types: (Integer) values: [1] Possible solutions: parse(java.lang.String), is(java.lang.Object), split(groovy.lang.Closure), use([Ljava.lang.Object;), wait(), clone()

When I switch to Groovy Compiler Version 2.4.1.8, the Groovy script is running correctly and shows the expected result!

After the compiler switch, the Eclipse windows are destroyed (errors like "Failed to create the parts controls", "Invalid registry object", read crosses) but I can reopen them.

The same problem happens for Java8 or Eclipse 4.8.0 or Compiler Level 2.5.9.

I guess this as a bug. I would expect that the plugin supports the Groovy JDK classes by default.

Thank You!

@JE-coding JE-coding changed the title Groovy extended Java classes not supported Groovy JDK classes not supported by default Feb 28, 2020
@eric-milles
Copy link
Member

This is because Groovy 2.5 broke up the groovy-all jar into multiple jars. If you want to use the DGM "plus(Date, int)", you need to add groovy-dateutil library to your project or to your ~/.groovy/lib/ directory.

@eric-milles
Copy link
Member

The "Invalid Registry Object" is a known issue. I have a workaround: #981 (comment) and I have a fix that is yet to be merged: https://git.eclipse.org/r/#/c/155098/

@JE-coding
Copy link
Author

Thanks for the fast answer :-)
For me it was quite frustrating that I was not able to simply run such an easy Groovy snipplet. It would be nice if there would be the same default-support for the Groovy libraries as in the GroovyConsole application.

@eric-milles
Copy link
Member

I think the maintainers of Groovy are trying to push a switch to DateTime from Date. The extension methods for DateTime are present out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants