[jira] [Commented] (GROOVY-8878) make @Named* annotations a language feature
[ https://issues.apache.org/jira/browse/GROOVY-8878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16689239#comment-16689239 ] Vladimír Oraný commented on GROOVY-8878: thank you. yes, this was the point I was missing! > make @Named* annotations a language feature > --- > > Key: GROOVY-8878 > URL: https://issues.apache.org/jira/browse/GROOVY-8878 > Project: Groovy > Issue Type: Improvement > Components: Static compilation >Affects Versions: 3.x >Reporter: Vladimír Oraný >Priority: Major > Attachments: namedParams.patch > > > As of Groovy 2.5 @Named* annotations are processed by AST transformation > which disallows to apply the annotations to Java classes. Would be nice if > this becomes a language feature similar to how @DelegatesTo and > @ClosureParams annotation works which can be used in Java code and Groovy > compiler still understands them. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Resolved] (GROOVY-8878) make @Named* annotations a language feature
[ https://issues.apache.org/jira/browse/GROOVY-8878?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimír Oraný resolved GROOVY-8878. Resolution: Implemented This was just a misunderstanding how the annotation works. Thank [~paulk] for a detailed explanation. > make @Named* annotations a language feature > --- > > Key: GROOVY-8878 > URL: https://issues.apache.org/jira/browse/GROOVY-8878 > Project: Groovy > Issue Type: Improvement > Components: Static compilation >Affects Versions: 3.x >Reporter: Vladimír Oraný >Priority: Major > Attachments: namedParams.patch > > > As of Groovy 2.5 @Named* annotations are processed by AST transformation > which disallows to apply the annotations to Java classes. Would be nice if > this becomes a language feature similar to how @DelegatesTo and > @ClosureParams annotation works which can be used in Java code and Groovy > compiler still understands them. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Closed] (GROOVY-8878) make @Named* annotations a language feature
[ https://issues.apache.org/jira/browse/GROOVY-8878?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimír Oraný closed GROOVY-8878. -- > make @Named* annotations a language feature > --- > > Key: GROOVY-8878 > URL: https://issues.apache.org/jira/browse/GROOVY-8878 > Project: Groovy > Issue Type: Improvement > Components: Static compilation >Affects Versions: 3.x >Reporter: Vladimír Oraný >Priority: Major > Attachments: namedParams.patch > > > As of Groovy 2.5 @Named* annotations are processed by AST transformation > which disallows to apply the annotations to Java classes. Would be nice if > this becomes a language feature similar to how @DelegatesTo and > @ClosureParams annotation works which can be used in Java code and Groovy > compiler still understands them. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Assigned] (GROOVY-8881) Inner class - qualified "this" reference cast exception inside 2 closures
[ https://issues.apache.org/jira/browse/GROOVY-8881?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King reassigned GROOVY-8881: - Assignee: Paul King > Inner class - qualified "this" reference cast exception inside 2 closures > - > > Key: GROOVY-8881 > URL: https://issues.apache.org/jira/browse/GROOVY-8881 > Project: Groovy > Issue Type: Bug > Components: Compiler, groovy-runtime >Reporter: Anton Pryamostanov >Assignee: Paul King >Priority: Major > > Let's consider the below example of qualified (Outer class) "this" reference > from within the Inner class, used inside a closure defined inside another > closure (2 layers of closures): > {code:java} > class OuterClass implements Runnable { > class InnerClass { > String bar() { > Closure closureOne = { > Closure closureTwo = { > OuterClass outerClassViaQualifiedThisReference = > OuterClass.this > return outerClassViaQualifiedThisReference > } > return closureTwo.call() > } > closureOne.call() > } > } > String toString() { > return "OuterClass" > } > void run() { > System.out.println(new InnerClass().bar()) > } > } > {code} > It produces the below runtime exception: > {code} > java.lang.ClassCastException: OuterClass$InnerClass cannot be cast to > OuterClass$InnerClass$_bar_closure1 > at > OuterClass$InnerClass$_bar_closure1$_closure2.doCall(ConsoleScript279:8) > at > OuterClass$InnerClass$_bar_closure1$_closure2.doCall(ConsoleScript279) > at OuterClass$InnerClass$_bar_closure1.doCall(ConsoleScript279:11) > at OuterClass$InnerClass$_bar_closure1.doCall(ConsoleScript279) > at OuterClass$InnerClass.bar(ConsoleScript279:13) > at OuterClass$InnerClass$bar.call(Unknown Source) > at OuterClass.run(ConsoleScript279:23) > {code} > However the below code runs fine (if only 1 closure is used): > {code:groovy} > class OuterClass implements Runnable { > class InnerClass { > String bar() { > Closure closureOne = { > //Closure closureTwo = { > OuterClass outerClassViaQualifiedThisReference = > OuterClass.this > return outerClassViaQualifiedThisReference > //} > //return closureTwo.call() > } > closureOne.call() > } > } > String toString() { > return "OuterClass" > } > void run() { > System.out.println(new InnerClass().bar()) > } > } > {code} > *Expected result*: > Code should run in both cases without runtime exceptions and should output > "OuterClass". -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8875) NullObject.metaClass
[ https://issues.apache.org/jira/browse/GROOVY-8875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King updated GROOVY-8875: -- Description: Hi, I execute this. The third shell.evaluate throws an exception: {code} final GroovyShell shell = new GroovyShell( binding, FormsGroovyConfiguration.CONFIG ); // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL // http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = \{return ''}"); {code} And got the next exception. This used to work in Java 10 and before, it crashes under Java 11. Could have something to do with java modules ? {noformat} Exception in thread "JavaFX Application Thread" BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy' null at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558) at groovy.lang.GroovyShell.parse(GroovyShell.java:570) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) {noformat} was: Hi, I execute this. The third shell.evaluate throws an exception: final GroovyShell shell = new GroovyShell( binding, FormsGroovyConfiguration.CONFIG ); // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL // http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = \{return ''}"); And got the next exception. This used to work in Java 10 and before, it crashes under Java 11. Could have something to do with java modules ? Exception in thread "JavaFX Application Thread" BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy' null at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558) at groovy.lang.GroovyShell.parse(GroovyShell.java:570) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) > NullObject.metaClass > > > Key: GROOVY-8875 > URL: https://issues.apache.org/jira/browse/GROOVY-8875 > Project: Groovy > Issue Type: Bug >Reporter: Pruteanu Dragos >Priority: Blocker > Fix For: 3.x > > > Hi, > I execute this. The third shell.evaluate throws an exception: > {code} > final GroovyShell shell = new GroovyShell( binding, > FormsGroovyConfiguration.CONFIG ); > // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL > // > http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy > shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = > \{return ''}"); > {code} > And got the next exception. This used to work in Java 10 and before, it > crashes under Java 11. Could have something to do with java modules ? > {noformat} > Exception in thread "JavaFX Application Thread" BUG! exception in phase > 'semantic analysis' in source unit 'Script1.groovy' null > at > org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970) > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582) > at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324) > at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294) > at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558) > at groovy.lang.GroovyShell.parse(GroovyShell.java:570) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8875) NullObject.metaClass
[ https://issues.apache.org/jira/browse/GROOVY-8875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King updated GROOVY-8875: -- Description: Hi, I execute this. The third shell.evaluate throws an exception: {code} final GroovyShell shell = new GroovyShell( binding, FormsGroovyConfiguration.CONFIG ); // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL // http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = { return '' }"); {code} And got the next exception. This used to work in Java 10 and before, it crashes under Java 11. Could have something to do with java modules ? {noformat} Exception in thread "JavaFX Application Thread" BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy' null at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558) at groovy.lang.GroovyShell.parse(GroovyShell.java:570) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) {noformat} was: Hi, I execute this. The third shell.evaluate throws an exception: {code} final GroovyShell shell = new GroovyShell( binding, FormsGroovyConfiguration.CONFIG ); // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL // http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = \{return ''}"); {code} And got the next exception. This used to work in Java 10 and before, it crashes under Java 11. Could have something to do with java modules ? {noformat} Exception in thread "JavaFX Application Thread" BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy' null at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558) at groovy.lang.GroovyShell.parse(GroovyShell.java:570) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) {noformat} > NullObject.metaClass > > > Key: GROOVY-8875 > URL: https://issues.apache.org/jira/browse/GROOVY-8875 > Project: Groovy > Issue Type: Bug >Reporter: Pruteanu Dragos >Priority: Blocker > Fix For: 3.x > > > Hi, > I execute this. The third shell.evaluate throws an exception: > {code} > final GroovyShell shell = new GroovyShell( binding, > FormsGroovyConfiguration.CONFIG ); > // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL > // > http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy > shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = { > return '' }"); > {code} > And got the next exception. This used to work in Java 10 and before, it > crashes under Java 11. Could have something to do with java modules ? > {noformat} > Exception in thread "JavaFX Application Thread" BUG! exception in phase > 'semantic analysis' in source unit 'Script1.groovy' null > at > org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970) > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582) > at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324) > at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294) > at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558) > at groovy.lang.GroovyShell.parse(GroovyShell.java:570) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8875) NullObject.metaClass
[ https://issues.apache.org/jira/browse/GROOVY-8875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King updated GROOVY-8875: -- Priority: Major (was: Blocker) > NullObject.metaClass > > > Key: GROOVY-8875 > URL: https://issues.apache.org/jira/browse/GROOVY-8875 > Project: Groovy > Issue Type: Bug >Reporter: Pruteanu Dragos >Priority: Major > Fix For: 3.x > > > Hi, > I execute this. The third shell.evaluate throws an exception: > {code} > final GroovyShell shell = new GroovyShell( binding, > FormsGroovyConfiguration.CONFIG ); > // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL > // > http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy > shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = { > return '' }"); > {code} > And got the next exception. This used to work in Java 10 and before, it > crashes under Java 11. Could have something to do with java modules ? > {noformat} > Exception in thread "JavaFX Application Thread" BUG! exception in phase > 'semantic analysis' in source unit 'Script1.groovy' null > at > org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970) > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582) > at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324) > at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294) > at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558) > at groovy.lang.GroovyShell.parse(GroovyShell.java:570) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8875) NullObject.metaClass
[ https://issues.apache.org/jira/browse/GROOVY-8875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16689267#comment-16689267 ] Paul King commented on GROOVY-8875: --- Do you have any more of the stack trace? > NullObject.metaClass > > > Key: GROOVY-8875 > URL: https://issues.apache.org/jira/browse/GROOVY-8875 > Project: Groovy > Issue Type: Bug >Reporter: Pruteanu Dragos >Priority: Blocker > Fix For: 3.x > > > Hi, > I execute this. The third shell.evaluate throws an exception: > {code} > final GroovyShell shell = new GroovyShell( binding, > FormsGroovyConfiguration.CONFIG ); > // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL > // > http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy > shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = { > return '' }"); > {code} > And got the next exception. This used to work in Java 10 and before, it > crashes under Java 11. Could have something to do with java modules ? > {noformat} > Exception in thread "JavaFX Application Thread" BUG! exception in phase > 'semantic analysis' in source unit 'Script1.groovy' null > at > org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970) > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582) > at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324) > at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294) > at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558) > at groovy.lang.GroovyShell.parse(GroovyShell.java:570) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493) > at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464) > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Resolved] (GROOVY-8881) Inner class - qualified "this" reference cast exception inside 2 closures
[ https://issues.apache.org/jira/browse/GROOVY-8881?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King resolved GROOVY-8881. --- Resolution: Fixed Fix Version/s: 2.5.5 3.0.0-alpha-4 Should be fixed. If you can try a snapshot version, that would be great. Thanks for reporting the issue. > Inner class - qualified "this" reference cast exception inside 2 closures > - > > Key: GROOVY-8881 > URL: https://issues.apache.org/jira/browse/GROOVY-8881 > Project: Groovy > Issue Type: Bug > Components: Compiler, groovy-runtime >Reporter: Anton Pryamostanov >Assignee: Paul King >Priority: Major > Fix For: 3.0.0-alpha-4, 2.5.5 > > > Let's consider the below example of qualified (Outer class) "this" reference > from within the Inner class, used inside a closure defined inside another > closure (2 layers of closures): > {code:java} > class OuterClass implements Runnable { > class InnerClass { > String bar() { > Closure closureOne = { > Closure closureTwo = { > OuterClass outerClassViaQualifiedThisReference = > OuterClass.this > return outerClassViaQualifiedThisReference > } > return closureTwo.call() > } > closureOne.call() > } > } > String toString() { > return "OuterClass" > } > void run() { > System.out.println(new InnerClass().bar()) > } > } > {code} > It produces the below runtime exception: > {code} > java.lang.ClassCastException: OuterClass$InnerClass cannot be cast to > OuterClass$InnerClass$_bar_closure1 > at > OuterClass$InnerClass$_bar_closure1$_closure2.doCall(ConsoleScript279:8) > at > OuterClass$InnerClass$_bar_closure1$_closure2.doCall(ConsoleScript279) > at OuterClass$InnerClass$_bar_closure1.doCall(ConsoleScript279:11) > at OuterClass$InnerClass$_bar_closure1.doCall(ConsoleScript279) > at OuterClass$InnerClass.bar(ConsoleScript279:13) > at OuterClass$InnerClass$bar.call(Unknown Source) > at OuterClass.run(ConsoleScript279:23) > {code} > However the below code runs fine (if only 1 closure is used): > {code:groovy} > class OuterClass implements Runnable { > class InnerClass { > String bar() { > Closure closureOne = { > //Closure closureTwo = { > OuterClass outerClassViaQualifiedThisReference = > OuterClass.this > return outerClassViaQualifiedThisReference > //} > //return closureTwo.call() > } > closureOne.call() > } > } > String toString() { > return "OuterClass" > } > void run() { > System.out.println(new InnerClass().bar()) > } > } > {code} > *Expected result*: > Code should run in both cases without runtime exceptions and should output > "OuterClass". -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8881) Inner class - qualified "this" reference cast exception inside 2 closures
[ https://issues.apache.org/jira/browse/GROOVY-8881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16689361#comment-16689361 ] Anton Pryamostanov commented on GROOVY-8881: Retested OK on 2.5.4.SNAPSHOT and 3.0.0.SNAPSHOT Many thanks for fixing the issue! > Inner class - qualified "this" reference cast exception inside 2 closures > - > > Key: GROOVY-8881 > URL: https://issues.apache.org/jira/browse/GROOVY-8881 > Project: Groovy > Issue Type: Bug > Components: Compiler, groovy-runtime >Reporter: Anton Pryamostanov >Assignee: Paul King >Priority: Major > Fix For: 3.0.0-alpha-4, 2.5.5 > > > Let's consider the below example of qualified (Outer class) "this" reference > from within the Inner class, used inside a closure defined inside another > closure (2 layers of closures): > {code:java} > class OuterClass implements Runnable { > class InnerClass { > String bar() { > Closure closureOne = { > Closure closureTwo = { > OuterClass outerClassViaQualifiedThisReference = > OuterClass.this > return outerClassViaQualifiedThisReference > } > return closureTwo.call() > } > closureOne.call() > } > } > String toString() { > return "OuterClass" > } > void run() { > System.out.println(new InnerClass().bar()) > } > } > {code} > It produces the below runtime exception: > {code} > java.lang.ClassCastException: OuterClass$InnerClass cannot be cast to > OuterClass$InnerClass$_bar_closure1 > at > OuterClass$InnerClass$_bar_closure1$_closure2.doCall(ConsoleScript279:8) > at > OuterClass$InnerClass$_bar_closure1$_closure2.doCall(ConsoleScript279) > at OuterClass$InnerClass$_bar_closure1.doCall(ConsoleScript279:11) > at OuterClass$InnerClass$_bar_closure1.doCall(ConsoleScript279) > at OuterClass$InnerClass.bar(ConsoleScript279:13) > at OuterClass$InnerClass$bar.call(Unknown Source) > at OuterClass.run(ConsoleScript279:23) > {code} > However the below code runs fine (if only 1 closure is used): > {code:groovy} > class OuterClass implements Runnable { > class InnerClass { > String bar() { > Closure closureOne = { > //Closure closureTwo = { > OuterClass outerClassViaQualifiedThisReference = > OuterClass.this > return outerClassViaQualifiedThisReference > //} > //return closureTwo.call() > } > closureOne.call() > } > } > String toString() { > return "OuterClass" > } > void run() { > System.out.println(new InnerClass().bar()) > } > } > {code} > *Expected result*: > Code should run in both cases without runtime exceptions and should output > "OuterClass". -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8880) Traits - static/instance init blocks
[ https://issues.apache.org/jira/browse/GROOVY-8880?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16689364#comment-16689364 ] Anton Pryamostanov commented on GROOVY-8880: Once above commit pushed to Master and branch, I will retest this Jira. Thank you. > Traits - static/instance init blocks > > > Key: GROOVY-8880 > URL: https://issues.apache.org/jira/browse/GROOVY-8880 > Project: Groovy > Issue Type: Improvement > Components: Compiler, groovy-runtime >Affects Versions: 2.5.2 >Reporter: Anton Pryamostanov >Priority: Major > > Let's consider the below examples of Traits with Init blocks: > *Instance init block:* > {code} > trait InstanceTrait { > { > System.out.println("Instance init") > } > } > class InstanceTraitClass implements InstanceTrait { > } > new InstanceTraitClass() > {code} > This gives the below compilation exception: > {code:java} > General error during class generation: NPE while processing > script1542098577743.groovy > groovy.lang.GroovyRuntimeException: NPE while processing > script1542098577743.groovy > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:2 > at > org.codehaus.groovy.control.CompilationUnit$17.call(CompilationUnit.java:8 > at > org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:10 > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:6 > at > org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:5 > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:5 > at org.codehaus.groovy.control.CompilationUnit$compile$1.call(Unknown Sour > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java: > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > groovy.inspect.swingui.AstNodeToScriptAdapter.compileToScript(AstNodeToScriptAdapter.groovy: > at > groovy.inspect.swingui.AstNodeToScriptAdapter$compileToScript.call(Unknown > Sour > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java: > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > groovy.inspect.swingui.AstBrowser$_decompile_closure6.doCall(AstBrowser.groovy:3 > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Meth > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: > at java.lang.reflect.Method.invoke(Method.java:4 > at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java: > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:3 > at > org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:2 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.Closure.call(Closure.java:4 > at groovy.lang.Closure.call(Closure.java:4 > at groovy.lang.Closure.run(Closure.java:4 > at java.lang.Thread.run(Thread.java:7 > Caused by: java.lang.NullPointerException > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareCallSite(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareSiteAndReceiver(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareSiteAndReceiver(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCachedCall(InvocationWriter.java:3 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:3 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:1 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java: > at > org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:4 > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:7 > at > org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java: > at > org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:6 > at > org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressio
[jira] [Updated] (GROOVY-8882) STC: Loop over elements of String has different element type
[ https://issues.apache.org/jira/browse/GROOVY-8882?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Eric Milles updated GROOVY-8882: Issue Type: Bug (was: Documentation) > STC: Loop over elements of String has different element type > > > Key: GROOVY-8882 > URL: https://issues.apache.org/jira/browse/GROOVY-8882 > Project: Groovy > Issue Type: Bug >Reporter: Eric Milles >Priority: Minor > > When the method below is executed as-is, the output is "java.lang.String" x3. > When {{@CompileStatic}} is uncommented, the output is "java.lang.Character" > x3. Is it possible to have dynamic groovy match the static compilation > result? > {code:groovy} > //@groovy.transform.CompileStatic > void meth() { > for (c in 'abc') > println c.class.name > } > {code} > Similarly, {{'abc'*.anything}} runs against Strings of length one instead of > Characters. Although, spread-dot is not supported against strings under > static compilation. Is it possible to add that support? -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8882) STC: Loop over elements of String has different element type
Eric Milles created GROOVY-8882: --- Summary: STC: Loop over elements of String has different element type Key: GROOVY-8882 URL: https://issues.apache.org/jira/browse/GROOVY-8882 Project: Groovy Issue Type: Documentation Reporter: Eric Milles When the method below is executed as-is, the output is "java.lang.String" x3. When {{@CompileStatic}} is uncommented, the output is "java.lang.Character" x3. Is it possible to have dynamic groovy match the static compilation result? {code:groovy} //@groovy.transform.CompileStatic void meth() { for (c in 'abc') println c.class.name } {code} Similarly, {{'abc'*.anything}} runs against Strings of length one instead of Characters. Although, spread-dot is not supported against strings under static compilation. Is it possible to add that support? -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8882) STC: Loop over elements of String has different element type
[ https://issues.apache.org/jira/browse/GROOVY-8882?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Eric Milles updated GROOVY-8882: Description: When the method below is executed as-is, the output is "java.lang.String" x3. When {{@CompileStatic}} is uncommented, the output is "java.lang.Character" x3. Is it possible to have dynamic groovy match the static compilation result? {code:groovy} //@groovy.transform.CompileStatic void meth() { for (c in 'abc') println c.class.name } {code} Similarly, {{'abc'*.anything}} applies to Strings of length one instead of Characters. Although, spread-dot is not supported against strings under static compilation. Is it possible to add that support? was: When the method below is executed as-is, the output is "java.lang.String" x3. When {{@CompileStatic}} is uncommented, the output is "java.lang.Character" x3. Is it possible to have dynamic groovy match the static compilation result? {code:groovy} //@groovy.transform.CompileStatic void meth() { for (c in 'abc') println c.class.name } {code} Similarly, {{'abc'*.anything}} runs against Strings of length one instead of Characters. Although, spread-dot is not supported against strings under static compilation. Is it possible to add that support? > STC: Loop over elements of String has different element type > > > Key: GROOVY-8882 > URL: https://issues.apache.org/jira/browse/GROOVY-8882 > Project: Groovy > Issue Type: Bug >Reporter: Eric Milles >Priority: Minor > > When the method below is executed as-is, the output is "java.lang.String" x3. > When {{@CompileStatic}} is uncommented, the output is "java.lang.Character" > x3. Is it possible to have dynamic groovy match the static compilation > result? > {code:groovy} > //@groovy.transform.CompileStatic > void meth() { > for (c in 'abc') > println c.class.name > } > {code} > Similarly, {{'abc'*.anything}} applies to Strings of length one instead of > Characters. Although, spread-dot is not supported against strings under > static compilation. Is it possible to add that support? -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8882) STC: Loop over elements of String has different element type
[ https://issues.apache.org/jira/browse/GROOVY-8882?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Eric Milles updated GROOVY-8882: Affects Version/s: 2.4.15 > STC: Loop over elements of String has different element type > > > Key: GROOVY-8882 > URL: https://issues.apache.org/jira/browse/GROOVY-8882 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.4.15 >Reporter: Eric Milles >Priority: Minor > > When the method below is executed as-is, the output is "java.lang.String" x3. > When {{@CompileStatic}} is uncommented, the output is "java.lang.Character" > x3. Is it possible to have dynamic groovy match the static compilation > result? > {code:groovy} > //@groovy.transform.CompileStatic > void meth() { > for (c in 'abc') > println c.class.name > } > {code} > Similarly, {{'abc'*.anything}} applies to Strings of length one instead of > Characters. Although, spread-dot is not supported against strings under > static compilation. Is it possible to add that support? -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8883) Bump xstream to 1.4.11.1
Daniel Sun created GROOVY-8883: -- Summary: Bump xstream to 1.4.11.1 Key: GROOVY-8883 URL: https://issues.apache.org/jira/browse/GROOVY-8883 Project: Groovy Issue Type: Dependency upgrade Reporter: Daniel Sun Assignee: Daniel Sun -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8884) Bump spotbugs-annotations to 3.1.8
Daniel Sun created GROOVY-8884: -- Summary: Bump spotbugs-annotations to 3.1.8 Key: GROOVY-8884 URL: https://issues.apache.org/jira/browse/GROOVY-8884 Project: Groovy Issue Type: Dependency upgrade Reporter: Daniel Sun Assignee: Daniel Sun -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8885) Bump spotbugs gradle plugin to 1.6.5
Daniel Sun created GROOVY-8885: -- Summary: Bump spotbugs gradle plugin to 1.6.5 Key: GROOVY-8885 URL: https://issues.apache.org/jira/browse/GROOVY-8885 Project: Groovy Issue Type: Dependency upgrade Reporter: Daniel Sun Assignee: Daniel Sun -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8886) Bump asciidoctor-gradle-plugin to 1.5.9.2
Daniel Sun created GROOVY-8886: -- Summary: Bump asciidoctor-gradle-plugin to 1.5.9.2 Key: GROOVY-8886 URL: https://issues.apache.org/jira/browse/GROOVY-8886 Project: Groovy Issue Type: Dependency upgrade Reporter: Daniel Sun Assignee: Daniel Sun -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Resolved] (GROOVY-8884) Bump spotbugs-annotations to 3.1.8
[ https://issues.apache.org/jira/browse/GROOVY-8884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Sun resolved GROOVY-8884. Resolution: Fixed Fix Version/s: 3.0.0-alpha-4 > Bump spotbugs-annotations to 3.1.8 > -- > > Key: GROOVY-8884 > URL: https://issues.apache.org/jira/browse/GROOVY-8884 > Project: Groovy > Issue Type: Dependency upgrade >Reporter: Daniel Sun >Assignee: Daniel Sun >Priority: Major > Fix For: 3.0.0-alpha-4 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Resolved] (GROOVY-8883) Bump xstream to 1.4.11.1
[ https://issues.apache.org/jira/browse/GROOVY-8883?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Sun resolved GROOVY-8883. Resolution: Fixed Fix Version/s: 3.0.0-alpha-4 > Bump xstream to 1.4.11.1 > > > Key: GROOVY-8883 > URL: https://issues.apache.org/jira/browse/GROOVY-8883 > Project: Groovy > Issue Type: Dependency upgrade >Reporter: Daniel Sun >Assignee: Daniel Sun >Priority: Major > Fix For: 3.0.0-alpha-4 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Resolved] (GROOVY-8885) Bump spotbugs gradle plugin to 1.6.5
[ https://issues.apache.org/jira/browse/GROOVY-8885?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Sun resolved GROOVY-8885. Resolution: Fixed Fix Version/s: 3.0.0-alpha-4 > Bump spotbugs gradle plugin to 1.6.5 > > > Key: GROOVY-8885 > URL: https://issues.apache.org/jira/browse/GROOVY-8885 > Project: Groovy > Issue Type: Dependency upgrade >Reporter: Daniel Sun >Assignee: Daniel Sun >Priority: Major > Fix For: 3.0.0-alpha-4 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Resolved] (GROOVY-8886) Bump asciidoctor-gradle-plugin to 1.5.9.2
[ https://issues.apache.org/jira/browse/GROOVY-8886?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Sun resolved GROOVY-8886. Resolution: Fixed Fix Version/s: 3.0.0-alpha-4 > Bump asciidoctor-gradle-plugin to 1.5.9.2 > - > > Key: GROOVY-8886 > URL: https://issues.apache.org/jira/browse/GROOVY-8886 > Project: Groovy > Issue Type: Dependency upgrade >Reporter: Daniel Sun >Assignee: Daniel Sun >Priority: Major > Fix For: 3.0.0-alpha-4 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] groovy pull request #823: GROOVY-8880: Traits - static/instance init blocks
Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/823 ---
[jira] [Commented] (GROOVY-8880) Traits - static/instance init blocks
[ https://issues.apache.org/jira/browse/GROOVY-8880?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16690035#comment-16690035 ] ASF GitHub Bot commented on GROOVY-8880: Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/823 > Traits - static/instance init blocks > > > Key: GROOVY-8880 > URL: https://issues.apache.org/jira/browse/GROOVY-8880 > Project: Groovy > Issue Type: Improvement > Components: Compiler, groovy-runtime >Affects Versions: 2.5.2 >Reporter: Anton Pryamostanov >Priority: Major > > Let's consider the below examples of Traits with Init blocks: > *Instance init block:* > {code} > trait InstanceTrait { > { > System.out.println("Instance init") > } > } > class InstanceTraitClass implements InstanceTrait { > } > new InstanceTraitClass() > {code} > This gives the below compilation exception: > {code:java} > General error during class generation: NPE while processing > script1542098577743.groovy > groovy.lang.GroovyRuntimeException: NPE while processing > script1542098577743.groovy > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:2 > at > org.codehaus.groovy.control.CompilationUnit$17.call(CompilationUnit.java:8 > at > org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:10 > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:6 > at > org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:5 > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:5 > at org.codehaus.groovy.control.CompilationUnit$compile$1.call(Unknown Sour > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java: > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > groovy.inspect.swingui.AstNodeToScriptAdapter.compileToScript(AstNodeToScriptAdapter.groovy: > at > groovy.inspect.swingui.AstNodeToScriptAdapter$compileToScript.call(Unknown > Sour > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java: > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > groovy.inspect.swingui.AstBrowser$_decompile_closure6.doCall(AstBrowser.groovy:3 > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Meth > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: > at java.lang.reflect.Method.invoke(Method.java:4 > at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java: > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:3 > at > org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:2 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.Closure.call(Closure.java:4 > at groovy.lang.Closure.call(Closure.java:4 > at groovy.lang.Closure.run(Closure.java:4 > at java.lang.Thread.run(Thread.java:7 > Caused by: java.lang.NullPointerException > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareCallSite(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareSiteAndReceiver(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareSiteAndReceiver(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCachedCall(InvocationWriter.java:3 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:3 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:1 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java: > at > org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:4 > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:7 > at > org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java: > at > org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:6 > at > org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpres
[jira] [Resolved] (GROOVY-8880) Traits - static/instance init blocks
[ https://issues.apache.org/jira/browse/GROOVY-8880?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King resolved GROOVY-8880. --- Resolution: Fixed Assignee: Paul King Fix Version/s: 2.5.5 3.0.0-alpha-4 Should be fixed. If you can test a snapshot version, that would be great. Thanks for reporting the issue. > Traits - static/instance init blocks > > > Key: GROOVY-8880 > URL: https://issues.apache.org/jira/browse/GROOVY-8880 > Project: Groovy > Issue Type: Improvement > Components: Compiler, groovy-runtime >Affects Versions: 2.5.2 >Reporter: Anton Pryamostanov >Assignee: Paul King >Priority: Major > Fix For: 3.0.0-alpha-4, 2.5.5 > > > Let's consider the below examples of Traits with Init blocks: > *Instance init block:* > {code} > trait InstanceTrait { > { > System.out.println("Instance init") > } > } > class InstanceTraitClass implements InstanceTrait { > } > new InstanceTraitClass() > {code} > This gives the below compilation exception: > {code:java} > General error during class generation: NPE while processing > script1542098577743.groovy > groovy.lang.GroovyRuntimeException: NPE while processing > script1542098577743.groovy > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:2 > at > org.codehaus.groovy.control.CompilationUnit$17.call(CompilationUnit.java:8 > at > org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:10 > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:6 > at > org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:5 > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:5 > at org.codehaus.groovy.control.CompilationUnit$compile$1.call(Unknown Sour > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java: > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > groovy.inspect.swingui.AstNodeToScriptAdapter.compileToScript(AstNodeToScriptAdapter.groovy: > at > groovy.inspect.swingui.AstNodeToScriptAdapter$compileToScript.call(Unknown > Sour > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java: > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:1 > at > groovy.inspect.swingui.AstBrowser$_decompile_closure6.doCall(AstBrowser.groovy:3 > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Meth > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: > at java.lang.reflect.Method.invoke(Method.java:4 > at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java: > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:3 > at > org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:2 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:10 > at groovy.lang.Closure.call(Closure.java:4 > at groovy.lang.Closure.call(Closure.java:4 > at groovy.lang.Closure.run(Closure.java:4 > at java.lang.Thread.run(Thread.java:7 > Caused by: java.lang.NullPointerException > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareCallSite(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareSiteAndReceiver(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.prepareSiteAndReceiver(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:2 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCachedCall(InvocationWriter.java:3 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:3 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:1 > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java: > at > org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:4 > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:7 > at > org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java: > at > org.codehaus.groovy.classgen.asm.Statemen
[jira] [Commented] (GROOVY-8879) @NamedVariant on extension method
[ https://issues.apache.org/jira/browse/GROOVY-8879?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16690042#comment-16690042 ] Paul King commented on GROOVY-8879: --- So, after clarification on the previous issue, to make sure this issue is clear, @NamedVariant creates a new version of a method or constructor with Map as the first argument. Extension methods rely on the first argument being the target "self" object. This issue would be to consider whether we can combine those two features. In an ugly first suggestion, perhaps something like @NamedVariant(preserveFirstArg=true). As an alternative workaround, it might be possible to combine @Category and @NamedVariant since @Category works in a later phase. > @NamedVariant on extension method > - > > Key: GROOVY-8879 > URL: https://issues.apache.org/jira/browse/GROOVY-8879 > Project: Groovy > Issue Type: Bug > Components: Static compilation >Affects Versions: 2.5.2 >Reporter: Vladimír Oraný >Priority: Major > > I have a method on Java interface > > {code:java} > RelationshipDefinition source(String cardinality, String title);{code} > > And I want to create an extension method (as using @NamedVariant in Java > sources is not supported) > > {code:java} > @NamedVariant > static RelationshipDefinition source(RelationshipDefinition definition > @NamedDelegate TitleAndCardinality tac) { > return definition.source(tac.cardinality, tac.title) > }{code} > > I got an error when I try to use the method such as follows: > > {code:java} > definition.source(cardinality: '1'){code} > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)