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

StackOverflowError when placing a "static" keyword #1099

Closed
mauromol opened this issue Apr 24, 2020 · 4 comments
Closed

StackOverflowError when placing a "static" keyword #1099

mauromol opened this issue Apr 24, 2020 · 4 comments
Assignees
Labels
Milestone

Comments

@mauromol
Copy link

Consider this class:

package test64

import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic

@CompileStatic
class Test64 {

	@CompileDynamic
	static enum ShippingAddressSynchType {
		ACCOUNTING {
			@Override
			void synch(Test64 customer) {
				truncate('foo', 2)
			}
		};

		void synch(Test64 customer) { }

		private String truncate(String input, int maxLength) {
			if(!input)
				return input
			if(input.length() > maxLength)
				input = input[0..maxLength - 1]
			return input
		}
	}
}

Now change the truncate(...) declaration by adding the static keyword and hit Ctrl+S:

private static String truncate(String input, int maxLength) {

BOOM!
You have to close the IDE, possibly kill it.

@mauromol
Copy link
Author

See also what happens with Groovy without the static keyword:
https://issues.apache.org/jira/browse/GROOVY-9523
https://issues.apache.org/jira/browse/GROOVY-9524

Adding static seems to work fine with Groovy itself, but because of this Greclipse issue it crashes my IDE.

@eric-milles eric-milles self-assigned this Apr 24, 2020
@eric-milles eric-milles added this to the v3.8.0 milestone Apr 24, 2020
@eric-milles
Copy link
Member

Quick observation, you can write truncate like this. Not important, just a suggestion.

private static String truncate(String input, int maxLength) {
  if (input && input.length() > maxLength)
    input = input[0..<maxLength]
  return input
}

@eric-milles
Copy link
Member

ready to test

@mauromol
Copy link
Author

Works with 3.8.0.v202004242058-e1912, thank you!

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

No branches or pull requests

2 participants