[
https://issues.apache.org/jira/browse/GROOVY-9822?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Christopher Smith updated GROOVY-9822:
--------------------------------------
Description:
This appears similar to GROOVY-9565, but it's happening in a context that is
generics-free as far as I can tell.
{code}
Caused by: java.lang.StackOverflowError
at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.isUsingGenerics
(DecompiledClassNode.java:86)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1880)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1870)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1827)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1816)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1882)
{code}
I managed attempted to trim down the example, but not without referring to the
TinkerPop classes (3.4.8). This code triggers the recursion:
{code:groovy}
import
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
import
org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy
import org.apache.tinkerpop.gremlin.structure.Graph
import groovy.transform.CompileStatic
@CompileStatic
class Groovy9822 {
static GraphTraversalSource readOnly(Graph graph) {
def i = ReadOnlyStrategy.instance()
graph.traversal().withStrategies(i)
}
}
{code}
Removing the second {{i}} so that the varargs is empty and the instance is not
passed to {{withStrategies}} prevents the error. In case it is relevant, the
{{withStrategies}} method takes a non-generic {{TraversalStrategy}}, but the
class declaration of {{ReadOnlyStrategy}} is as follows:
{code:java}
public final class ReadOnlyStrategy extends
AbstractTraversalStrategy<TraversalStrategy.VerificationStrategy> implements
TraversalStrategy.VerificationStrategy
{code}
was:
This appears similar to GROOVY-9565, but it's happening in a context that is
generics-free as far as I can tell. I have the following pair of files, where
the graph-related types are from TinkerPop:
{code:groovy}
@CompileStatic
interface GremlinAccess {
GraphTraversalSource readOnly()
GremlinSession session()
interface GremlinSession extends AutoCloseable {
GraphTraversalSource traversal()
}
}
{code}
{code:groovy}
@TupleConstructor(defaults = false)
@CompileStatic
class GraphObjectGremlinAccess implements GremlinAccess {
final Graph graph
@Override
GraphTraversalSource readOnly() {
graph.traversal().withStrategies(ReadOnlyStrategy.instance())
}
@Override
GremlinSession session() {
new PlaceboGremlinSession()
}
private class PlaceboGremlinSession implements GremlinSession {
@Override
void close() {}
@Override
GraphTraversalSource traversal() {
graph.traversal()
}
}
}
{code}
The first file compiles without problem. The second file triggers a stack
overflow, looping the four lines from 1870 to 1882:
{code}
Caused by: java.lang.StackOverflowError
at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.isUsingGenerics
(DecompiledClassNode.java:86)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1880)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1870)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1827)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1816)
at
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
(StaticTypeCheckingSupport.java:1882)
{code}
I have attempted to trim down the example, but have been unable to do so. This
example compiles without error. Is there a straightforward way for me to find
out what is being processed in the above stack trace? Does the presence of
{{DecompiledClassNode}} indicate that it's being triggered by something inside
a TinkerPop class?
{code:groovy}
@TupleConstructor(defaults = false)
@CompileStatic
class Groovy9822 implements Provider {
final IntSupplier supplier
@Override
Integer getDirectly() {
supplier.getAsInt()
}
@Override
Provided getIndirectly() {
new Impl()
}
private class Impl implements Provided {
@Override
void close() {}
@Override
Integer number() { supplier.getAsInt() }
}
}
@CompileStatic
interface Provider {
Integer getDirectly()
Provided getIndirectly()
interface Provided extends AutoCloseable {
Integer number()
}
}
{code}
> StackOverflowError in STC
> -------------------------
>
> Key: GROOVY-9822
> URL: https://issues.apache.org/jira/browse/GROOVY-9822
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 3.0.6
> Reporter: Christopher Smith
> Priority: Major
>
> This appears similar to GROOVY-9565, but it's happening in a context that is
> generics-free as far as I can tell.
> {code}
> Caused by: java.lang.StackOverflowError
> at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.isUsingGenerics
> (DecompiledClassNode.java:86)
> at
> org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
> (StaticTypeCheckingSupport.java:1880)
> at
> org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
> (StaticTypeCheckingSupport.java:1870)
> at
> org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
> (StaticTypeCheckingSupport.java:1827)
> at
> org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
> (StaticTypeCheckingSupport.java:1816)
> at
> org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext
> (StaticTypeCheckingSupport.java:1882)
> {code}
> I managed attempted to trim down the example, but not without referring to
> the TinkerPop classes (3.4.8). This code triggers the recursion:
> {code:groovy}
> import
> org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
> import
> org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy
> import org.apache.tinkerpop.gremlin.structure.Graph
> import groovy.transform.CompileStatic
> @CompileStatic
> class Groovy9822 {
> static GraphTraversalSource readOnly(Graph graph) {
> def i = ReadOnlyStrategy.instance()
> graph.traversal().withStrategies(i)
> }
> }
> {code}
> Removing the second {{i}} so that the varargs is empty and the instance is
> not passed to {{withStrategies}} prevents the error. In case it is relevant,
> the {{withStrategies}} method takes a non-generic {{TraversalStrategy}}, but
> the class declaration of {{ReadOnlyStrategy}} is as follows:
> {code:java}
> public final class ReadOnlyStrategy extends
> AbstractTraversalStrategy<TraversalStrategy.VerificationStrategy> implements
> TraversalStrategy.VerificationStrategy
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)