Using gcontracts with Groovy Eclipse plug-in

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Using gcontracts with Groovy Eclipse plug-in

Thomas Hofmann
Hi,

I am trying to use gcontracts with the Groovy Eclipse plugin and I get the following errors:

Marker Error in Groovy Editor:

Groovy: Only classes can be used for attribute 'value' in @org.gcontracts.annotations.Requires


And in the error log view:

eclipse.buildId=I20090611-1540
java.version=1.6.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_us_DE
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product


Error
Tue May 18 10:40:24 CEST 2010
Groovy bug when compiling.

BUG! exception in phase 'canonicalization' in source unit '/com.ibm.ecc.core/src/com/ibm/ecc/core/serveraccess/internal/ExtensionPointBasedServerAccessComponent.groovy' ClassNode#getTypeClass for org.gcontracts.annotations.Requires is called before the type class is set
        at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1337)
        at org.gcontracts.injection.BasicAssertionInjector$1.visitMethod(BasicAssertionInjector.java:96)
        at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1092)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:51)
        at org.gcontracts.injection.BasicAssertionInjector$1.visitClass(BasicAssertionInjector.java:86)
        at org.gcontracts.injection.BasicAssertionInjector.rewrite(BasicAssertionInjector.java:74)
        at org.gcontracts.ast.ContractValidationASTTransformation.visit(ContractValidationASTTransformation.java:62)
        at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:358)
        at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:948)
        at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:580)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:556)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:533)
        at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:161)
        at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:1287)
        at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:845)
        at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137)
        at java.lang.Thread.run(Unknown Source)



The code causig this looks like this:

@Requires({ identifier != null &&  configurationRepository != null})
public Configuration retrieveConfiguration(String identifier,
        ConfigurationRepository configurationRepository) {



I am using:

Groovy-Eclipse Feature  2.0.2.20100504-2000-e35


Thanks, Thomas

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Using gcontracts with Groovy Eclipse plug-in

Andy Clement
I'm afraid the stack trace shows that gcontracts is not compatible
with Groovy-Eclipse.

>        at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1337)
>        at org.gcontracts.injection.BasicAssertionInjector$1.visitMethod(BasicAssertionInjector.java:96)

we do not support the use of getTypeClass().  There is more discussion
about getTypeClass() in this groovy Jira where I proposed to remove
it:
http://jira.codehaus.org/browse/GROOVY-4156

However, it is possible we could put a dirty hack in that would let it
limp along for now until that issue is properly sorted out - if you
really want to go down that route, please raise a groovy-eclipse jira.

cheers,
Andy

On 18 May 2010 01:48, Thomas Hofmann <[hidden email]> wrote:

> Hi,
>
> I am trying to use gcontracts with the Groovy Eclipse plugin and I get the following errors:
>
> Marker Error in Groovy Editor:
>
> Groovy: Only classes can be used for attribute 'value' in @org.gcontracts.annotations.Requires
>
>
> And in the error log view:
>
> eclipse.buildId=I20090611-1540
> java.version=1.6.0_20
> java.vendor=Sun Microsystems Inc.
> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_us_DE
> Framework arguments:  -product org.eclipse.epp.package.jee.product
> Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product
>
>
> Error
> Tue May 18 10:40:24 CEST 2010
> Groovy bug when compiling.
>
> BUG! exception in phase 'canonicalization' in source unit '/com.ibm.ecc.core/src/com/ibm/ecc/core/serveraccess/internal/ExtensionPointBasedServerAccessComponent.groovy' ClassNode#getTypeClass for org.gcontracts.annotations.Requires is called before the type class is set
>        at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1337)
>        at org.gcontracts.injection.BasicAssertionInjector$1.visitMethod(BasicAssertionInjector.java:96)
>        at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1092)
>        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:51)
>        at org.gcontracts.injection.BasicAssertionInjector$1.visitClass(BasicAssertionInjector.java:86)
>        at org.gcontracts.injection.BasicAssertionInjector.rewrite(BasicAssertionInjector.java:74)
>        at org.gcontracts.ast.ContractValidationASTTransformation.visit(ContractValidationASTTransformation.java:62)
>        at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:358)
>        at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:948)
>        at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:580)
>        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:556)
>        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:533)
>        at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:161)
>        at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:1287)
>        at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:845)
>        at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137)
>        at java.lang.Thread.run(Unknown Source)
>
>
>
> The code causig this looks like this:
>
> @Requires({ identifier != null &&  configurationRepository != null})
> public Configuration retrieveConfiguration(String identifier,
>        ConfigurationRepository configurationRepository) {
>
>
>
> I am using:
>
> Groovy-Eclipse Feature  2.0.2.20100504-2000-e35
>
>
> Thanks, Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: Using gcontracts with Groovy Eclipse plug-in

Thomas Hofmann
So if I understand correctly this is an eclipse groovy/java joint compiler issue.

I don't have any real important requirement to use gcontracts but I was looking for something like that for quite some time. It saves you some lines of code that you probably would not write if you would need to do so "by hand".

Anyway my guess is that I am not the only one that will try to use gcontracts with eclipse groovy plug-in.

So I raised http://jira.codehaus.org/browse/GRECLIPSE-738

-----Original Message-----
From: Andy Clement [mailto:[hidden email]]
Sent: Dienstag, 18. Mai 2010 17:48
To: [hidden email]
Subject: Re: [groovy-eclipse-plugin-user] Using gcontracts with Groovy Eclipse plug-in

I'm afraid the stack trace shows that gcontracts is not compatible with Groovy-Eclipse.

>        at
> org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1337)
>        at
> org.gcontracts.injection.BasicAssertionInjector$1.visitMethod(BasicAss
> ertionInjector.java:96)

we do not support the use of getTypeClass().  There is more discussion about getTypeClass() in this groovy Jira where I proposed to remove
it:
http://jira.codehaus.org/browse/GROOVY-4156

However, it is possible we could put a dirty hack in that would let it limp along for now until that issue is properly sorted out - if you really want to go down that route, please raise a groovy-eclipse jira.

cheers,
Andy

On 18 May 2010 01:48, Thomas Hofmann <[hidden email]> wrote:

> Hi,
>
> I am trying to use gcontracts with the Groovy Eclipse plugin and I get the following errors:
>
> Marker Error in Groovy Editor:
>
> Groovy: Only classes can be used for attribute 'value' in
> @org.gcontracts.annotations.Requires
>
>
> And in the error log view:
>
> eclipse.buildId=I20090611-1540
> java.version=1.6.0_20
> java.vendor=Sun Microsystems Inc.
> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_us_DE
> Framework arguments:  -product org.eclipse.epp.package.jee.product
> Command-line arguments:  -os win32 -ws win32 -arch x86 -product
> org.eclipse.epp.package.jee.product
>
>
> Error
> Tue May 18 10:40:24 CEST 2010
> Groovy bug when compiling.
>
> BUG! exception in phase 'canonicalization' in source unit
> '/com.ibm.ecc.core/src/com/ibm/ecc/core/serveraccess/internal/Extensio
> nPointBasedServerAccessComponent.groovy' ClassNode#getTypeClass for
> org.gcontracts.annotations.Requires is called before the type class is
> set
>        at
> org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1337)
>        at
> org.gcontracts.injection.BasicAssertionInjector$1.visitMethod(BasicAss
> ertionInjector.java:96)
>        at
> org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1092)
>        at
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVi
> sitorSupport.java:51)
>        at
> org.gcontracts.injection.BasicAssertionInjector$1.visitClass(BasicAsse
> rtionInjector.java:86)
>        at
> org.gcontracts.injection.BasicAssertionInjector.rewrite(BasicAssertion
> Injector.java:74)
>        at
> org.gcontracts.ast.ContractValidationASTTransformation.visit(ContractV
> alidationASTTransformation.java:62)
>        at
> org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTrans
> formationVisitor.java:358)
>        at
> org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(Compila
> tionUnit.java:948)
>        at
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(Compilati
> onUnit.java:580)
>        at
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(Com
> pilationUnit.java:556)
>        at
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.ja
> va:533)
>        at
> org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDec
> laration.processToPhase(GroovyCompilationUnitDeclaration.java:161)
>        at
> org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDec
> laration.generateCode(GroovyCompilationUnitDeclaration.java:1287)
>        at
> org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:845)
>        at
> org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskMa
> nager.java:137)
>        at java.lang.Thread.run(Unknown Source)
>
>
>
> The code causig this looks like this:
>
> @Requires({ identifier != null &&  configurationRepository != null})
> public Configuration retrieveConfiguration(String identifier,
>        ConfigurationRepository configurationRepository) {
>
>
>
> I am using:
>
> Groovy-Eclipse Feature  2.0.2.20100504-2000-e35
>
>
> Thanks, Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: Using gcontracts with Groovy Eclipse plug-in

Peter Niederwieser
Administrator
(Reposting because my first post didn't seem to get through)

I think there are two independent problems here:

1. gcontracts call ClassNode.getTypeClass at the wrong time (though maybe it works with plain groovyc). As Andy mentioned, getTypeClass is problematic. Among other things, you can quickly run into class loader issues with it. One way out would be for gcontracts to use the ClassNode API instead of the java.lang.Class API, which should be possible with some work.

2. Annotation closures aren't yet supported by Groovy. gcontracts essentially turns an incorrect Groovy program into a correct one by replacing such closures with class literals. However, tools like IDEs that operate on source code keep seeing the incorrect code and thus fail. There isn't much gcontracts can do here other than to wait until annotation closures are supported by Groovy (very likely in 1.8) and tools catch up.

Cheers,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: Using gcontracts with Groovy Eclipse plug-in

Andre Steingress
In reply to this post by Thomas Hofmann
this issue is now fixed in gcontracts' master branch on github.

all calls to getTypeClass have been replaced with valid alternatives. the fix will be part of 1.0.3.
Reply | Threaded
Open this post in threaded view
|

Re: Using gcontracts with Groovy Eclipse plug-in

Thomas Hofmann
Hi Andre,

Sounds great. When will you be releasing 1.0.3?

Regards,

Thomas

-----Original Message-----
From: Andre Steingress [mailto:[hidden email]]
Sent: Montag, 7. Juni 2010 10:22
To: [hidden email]
Subject: [groovy-eclipse-plugin-user] Re: Using gcontracts with Groovy Eclipse plug-in


this issue is now fixed in
http://github.com/andresteingress/gcontracts/commit/0351e3be1bbe28c68b352f77886a31ce451470a6
gcontracts' master branch on github .

all calls to getTypeClass have been replaced with valid alternatives. the fix will be part of 1.0.3.
--
View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/Using-gcontracts-with-Groovy-Eclipse-plug-in-tp825739p875653.html
Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Using gcontracts with Groovy Eclipse plug-in

Andre Steingress
I hope it is working out by the end of this week :-)

regards, andre

Am 07.06.2010 um 22:15 schrieb Thomas Hofmann <[hidden email]>:

> Hi Andre,
>
> Sounds great. When will you be releasing 1.0.3?
>
> Regards,
>
> Thomas
>
> -----Original Message-----
> From: Andre Steingress [mailto:[hidden email]]
> Sent: Montag, 7. Juni 2010 10:22
> To: [hidden email]
> Subject: [groovy-eclipse-plugin-user] Re: Using gcontracts with  
> Groovy Eclipse plug-in
>
>
> this issue is now fixed in
> http://github.com/andresteingress/gcontracts/commit/0351e3be1bbe28c68b352f77886a31ce451470a6
> gcontracts' master branch on github .
>
> all calls to getTypeClass have been replaced with valid  
> alternatives. the fix will be part of 1.0.3.
> --
> View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/Using-gcontracts-with-Groovy-Eclipse-plug-in-tp825739p875653.html
> Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.com
> .
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email