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 Eclipse throwing StackOverflowError: null at org.codehaus.groovy.control.GenericsVisitor.getPrintName #148

Closed
wodencafe opened this issue Nov 7, 2015 · 5 comments

Comments

@wodencafe
Copy link

Hi, I just installed the Groovy Eclipse plugin from this link http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/
onto Eclipse Mars SR1, and I get a StackOverFlowError: null as soon as I start Eclipse and it tries to build the workspace.

Here is the full error log:

STATUS

pluginId org.eclipse.core.jobs
pluginVersion 3.7.0.v20150330-2103
code 2
severity 4
message An internal error occurred during: "Building workspace".
fingerprint d38a9ecb

Exception:java.lang.StackOverflowError: null
at org.eclipse.jdt.internal.compiler.lookup.TypeSystem.getDerivedTypes(TypeSystem.java:422)
at org.eclipse.jdt.internal.compiler.lookup.AnnotatableTypeSystem.getRawType(AnnotatableTypeSystem.java:142)
at org.eclipse.jdt.internal.compiler.lookup.AnnotatableTypeSystem.getRawType(AnnotatableTypeSystem.java:167)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createRawType(LookupEnvironment.java:1018)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToRawType(LookupEnvironment.java:553)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.toRawType(JDTClassNodeBuilder.java:133)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureParameterizedType(JDTClassNodeBuilder.java:344)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureType(JDTClassNodeBuilder.java:68)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureTypeVariableReference(JDTClassNodeBuilder.java:243)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureTypeVariableDefinition(JDTClassNodeBuilder.java:254)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureTypeVariables(JDTClassNodeBuilder.java:95)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.setupGenerics(JDTClassNode.java:179)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.ensureGenericsInitialized(JDTClassNode.java:434)
at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.getGenericsTypes(JDTClassNode.java:422)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:135)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:140)
at org.codehaus.groovy.control.GenericsVisitor.getPrintName(GenericsVisitor.java:123)

...

REPORT

anonymousId 7b821dca-121f-4f1d-a72d-06ac70fbcfa7
name
email
comment
eclipseBuildId 4.5.1.M20150904-0015
eclipseProduct org.eclipse.epp.package.jee.product
javaRuntimeVersion 1.8.0_45-internal-b14
osgiWs gtk
osgiOs Linux
osgiOsVersion 3.19.0
osgiArch x86_64
logMessage false
ignoreSimilar false


BUNDLES

name org.codehaus.groovy
version 2.3.10.xx-201508121448-e45

name org.eclipse.jdt
version 3.11.1.v20150904-0015

@will-lauer
Copy link

I'm hitting this also. From the debugger, it appears this is an issue handling generics when a type references a generic that references itself, i.e Foo<Q extends Foo<? super Q>>.

@will-lauer
Copy link

Looks like the problem is specific to the handling of super in generic declarations. The standard groovy (and java) compiler looks like it translates Foo<Q extends Foo<? super Q>> into Foo<Q extends Foo<? extends Object>> while Groovy-Eclipse's compiler is changing it to Foo<Q extends Foo<? extends Foo<Q>>. Flipping the super for extends causes it to infinite loop while trying to calculate the type name.

@will-lauer
Copy link

A simple example to reproduce this is

// A.java
public interface A<Q extends A<? super Q>> {
}

// B.groovy
class B {
    public void test(A<?> a) {
    }
}

@wodencafe
Copy link
Author

Hi @will-lauer , do you think this is an issue with Groovy itself then, rather than the Groovy-Eclipse plug in?

@will-lauer
Copy link

It doesn't look like it. It looks like the lazy creation of the AST and associated objects that the groovy-eclipse plugin does to allow for recoverable parsing can create an object structure with a cycle in it when building the type information for the interface listed above. Then, when trying to traverse that graph when validating generics, it goes off into an infinite loop.

I don't really understand the code well enough to identify the real fix, but I have a simple workaround that I'm testing, and once its ready I'll post it as a pull request. Basically, when trying to print the error message about an invalid use of generics, the error would print the type names directly rather than the fully qualified name will exploded generic information. That prevents it from traversing the object structure with a cycle in it.

My fix also has a braindead fix for an additional bug that this uncovered. In the example above, an error will be generated basically saying that <?> doesn't match . This is happening because ? is being translated to Object prior to doing the validation, which is obviously wrong. My fix just skips the validation in the case of a wildcard that should match anything.

will-lauer added a commit to will-lauer/groovy-eclipse that referenced this issue Mar 2, 2016
Possible fix for groovy#148.
- Ensure wildcards don't cause generic resolution to fail
- don't get caught in an infinite loop while printing generic type names
will-lauer added a commit to will-lauer/groovy-eclipse that referenced this issue Jun 30, 2016
Possible fix for groovy#148.
- Ensure wildcards don't cause generic resolution to fail
- don't get caught in an infinite loop while printing generic type names
will-lauer added a commit to will-lauer/groovy-eclipse that referenced this issue Nov 7, 2016
Possible fix for groovy#148.
- Ensure wildcards don't cause generic resolution to fail
- don't get caught in an infinite loop while printing generic type names
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

3 participants