groovy

cannot create class WholeNumber

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-5
  • Fix Version/s: 1.0-JSR-6
  • Component/s: groovy-jdk
  • Labels:
    None
  • Environment:
    Mustang b82
  • Number of attachments :
    0

Description

class WholeNumber/* extends Number*/ {
WholeNumber() {
}
}

Caught: BUG! exception in phase 'conversion' in source unit 'src\WholeNumber.groovy' Error: duplicate class declaration for name: WholeNumber and class: org.codehaus.groovy.ast.ClassNode@9173ef[name: WholeNumber]

Activity

Hide
blackdrag blackdrag added a comment -

I am currently unable to reprodcue that problem. Could you try the cvs version and tell if it still happens there?

Show
blackdrag blackdrag added a comment - I am currently unable to reprodcue that problem. Could you try the cvs version and tell if it still happens there?
Hide
Alex Lam S.L. added a comment -

I couldn't find instructions to grab my CVS version - any pointers?

Show
Alex Lam S.L. added a comment - I couldn't find instructions to grab my CVS version - any pointers?
Hide
blackdrag blackdrag added a comment -

use :pserver:anonymous@cvs.groovy.codehaus.org:/cvs/groovy/

Show
blackdrag blackdrag added a comment - use :pserver:anonymous@cvs.groovy.codehaus.org:/cvs/groovy/
Hide
Alex Lam S.L. added a comment -

It says user not authenicated...

Show
Alex Lam S.L. added a comment - It says user not authenicated...
Hide
Alex Lam S.L. added a comment -

Oh :-/

:pserver:anonymous@cvs.groovy.codehaus.org:/cvs/groovy

The extra slash at the end is causing trouble, somehow...

Show
Alex Lam S.L. added a comment - Oh :-/ :pserver:anonymous@cvs.groovy.codehaus.org:/cvs/groovy The extra slash at the end is causing trouble, somehow...
Hide
Alex Lam S.L. added a comment -

Argh....

Which JDK / Maven1 are you using to build the source?

I have groovy-core opened in NetBeans as a Maven1 project. But with {JDK5u6, Mustang b83} & {Maven1.0.2, Maven1.1-beta2} I get nothing but NPE upon building:

javax.xml.parsers.FactoryConfigurationError: Provider
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl could not
be instantiated: java.lang.NullPointerException
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:134)
at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:202)
at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:180)
at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:146)
at org.apache.maven.plugin.PluginManager.loadScript(PluginManager.java:1109)
at org.apache.maven.plugin.PluginManager.runScript(PluginManager.java:1135)
at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:647)
at org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
at org.apache.maven.cli.App.doMain(App.java:488)

at org.apache.maven.cli.App.main(App.java:1239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

In short, Maven won't start doing anything productive.

I have searched on Google and the bug that I've found against Maven is closed as incomplete, and the one against JDK has not been evaluated yet.

So if you can point me to your building environment (or better yet, if you can build a CVS snapshot for me) I'd be grateful.

Show
Alex Lam S.L. added a comment - Argh.... Which JDK / Maven1 are you using to build the source? I have groovy-core opened in NetBeans as a Maven1 project. But with {JDK5u6, Mustang b83} & {Maven1.0.2, Maven1.1-beta2} I get nothing but NPE upon building: javax.xml.parsers.FactoryConfigurationError: Provider com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl could not be instantiated: java.lang.NullPointerException at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:134) at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:202) at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:180) at org.apache.maven.jelly.JellyUtils.compileScript(JellyUtils.java:146) at org.apache.maven.plugin.PluginManager.loadScript(PluginManager.java:1109) at org.apache.maven.plugin.PluginManager.runScript(PluginManager.java:1135) at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:647) at org.apache.maven.MavenSession.attainGoals(MavenSession.java:263) at org.apache.maven.cli.App.doMain(App.java:488) at org.apache.maven.cli.App.main(App.java:1239) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) In short, Maven won't start doing anything productive. I have searched on Google and the bug that I've found against Maven is closed as incomplete, and the one against JDK has not been evaluated yet. So if you can point me to your building environment (or better yet, if you can build a CVS snapshot for me) I'd be grateful.
Hide
blackdrag blackdrag added a comment -

so, it took me some minutes... use http://dist.codehaus.org/groovy/distributions/groovy-1.0-RC-01-SNAPSHOT-20060601.jar, that is no official version. You can sue the scripts from the jsr-05 distribution, they haven't changed

Show
blackdrag blackdrag added a comment - so, it took me some minutes... use http://dist.codehaus.org/groovy/distributions/groovy-1.0-RC-01-SNAPSHOT-20060601.jar, that is no official version. You can sue the scripts from the jsr-05 distribution, they haven't changed
Hide
Alex Lam S.L. added a comment -

Thanks very much for taking the trouble!

Reproduced on 1.0 RC1 snapshot.
"groovyc.bat WholeNumber.groovy" in command prompt gives:

>>> a serious error occurred: BUG! exception in phase 'conversion' in source uni
t 'WholeNumber.groovy' Error: duplicate class declaration for name: WholeNumber
and class: org.codehaus.groovy.ast.ClassNode@7f4ec[name: WholeNumber]
>>> stacktrace:
BUG! exception in phase 'conversion' in source unit 'WholeNumber.groovy' Error:
duplicate class declaration for name: WholeNumber and class: org.codehaus.groovy
.ast.ClassNode@7f4ec[name: WholeNumber]
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(Compil
ationUnit.java:865)
at org.codehaus.groovy.control.CompilationUnit.convert(CompilationUnit.j
ava:587)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.j
ava:447)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.j
ava:421)
at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompil
er.java:72)
at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.
java:220)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java
:131)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:160)
Caused by: java.lang.RuntimeException: Error: duplicate class declaration for na
me: WholeNumber and class: org.codehaus.groovy.ast.ClassNode@7f4ec[name: WholeNu
mber]
at org.codehaus.groovy.ast.CompileUnit.addClass(CompileUnit.java:140)
at org.codehaus.groovy.ast.CompileUnit.addClasses(CompileUnit.java:128)
at org.codehaus.groovy.ast.CompileUnit.addModule(CompileUnit.java:84)
at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.ja
va:599)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(Compil
ationUnit.java:861)
... 11 more

Test Case that will fail:

class WholeNumber {
WholeNumber() {
}
}

def a = new WholeNumber()

Test Case that will pass (note the small letter w):

class wholeNumber {
wholeNumber() {
}
}

def a = new wholeNumber()

Show
Alex Lam S.L. added a comment - Thanks very much for taking the trouble! Reproduced on 1.0 RC1 snapshot. "groovyc.bat WholeNumber.groovy" in command prompt gives: >>> a serious error occurred: BUG! exception in phase 'conversion' in source uni t 'WholeNumber.groovy' Error: duplicate class declaration for name: WholeNumber and class: org.codehaus.groovy.ast.ClassNode@7f4ec[name: WholeNumber] >>> stacktrace: BUG! exception in phase 'conversion' in source unit 'WholeNumber.groovy' Error: duplicate class declaration for name: WholeNumber and class: org.codehaus.groovy .ast.ClassNode@7f4ec[name: WholeNumber] at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(Compil ationUnit.java:865) at org.codehaus.groovy.control.CompilationUnit.convert(CompilationUnit.j ava:587) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.j ava:447) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.j ava:421) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompil er.java:72) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler. java:220) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java :131) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:160) Caused by: java.lang.RuntimeException: Error: duplicate class declaration for na me: WholeNumber and class: org.codehaus.groovy.ast.ClassNode@7f4ec[name: WholeNu mber] at org.codehaus.groovy.ast.CompileUnit.addClass(CompileUnit.java:140) at org.codehaus.groovy.ast.CompileUnit.addClasses(CompileUnit.java:128) at org.codehaus.groovy.ast.CompileUnit.addModule(CompileUnit.java:84) at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.ja va:599) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(Compil ationUnit.java:861) ... 11 more Test Case that will fail: class WholeNumber { WholeNumber() { } } def a = new WholeNumber() Test Case that will pass (note the small letter w): class wholeNumber { wholeNumber() { } } def a = new wholeNumber()
Hide
Alex Lam S.L. added a comment -

Basically, try any alternative class name other than "WholeNumber" and it will pass.

Show
Alex Lam S.L. added a comment - Basically, try any alternative class name other than "WholeNumber" and it will pass.
Hide
blackdrag blackdrag added a comment -

you know this feeling when you see the trees, but not the forest? Ok, sorry.. this error is known. it shouldn't result in a bug error message, but currently it is correct that you can't ahve a script part and a class part in the same file if the class part has the same name as the script part. The reasons is that both parts are compiled into classes and they would have the same name then. I'm very sorry that I have totally overlooked the "duplicate class declaration" part in the message... This is on my todo list and will be fixed before 1.0

Show
blackdrag blackdrag added a comment - you know this feeling when you see the trees, but not the forest? Ok, sorry.. this error is known. it shouldn't result in a bug error message, but currently it is correct that you can't ahve a script part and a class part in the same file if the class part has the same name as the script part. The reasons is that both parts are compiled into classes and they would have the same name then. I'm very sorry that I have totally overlooked the "duplicate class declaration" part in the message... This is on my todo list and will be fixed before 1.0
Hide
Alex Lam S.L. added a comment -

Ah. True.

The source files starts off containing the class definition only, and mid-way through dev I've renamed my class but not the file name.

Then I've decided to be lazy and just type out some quick test codes at the bottom of the page, which also works.

But of course when I finally try to "complete the circle" by renaming the file to match the class I hit straight onto this bug....

Thanks again~

Show
Alex Lam S.L. added a comment - Ah. True. The source files starts off containing the class definition only, and mid-way through dev I've renamed my class but not the file name. Then I've decided to be lazy and just type out some quick test codes at the bottom of the page, which also works. But of course when I finally try to "complete the circle" by renaming the file to match the class I hit straight onto this bug.... Thanks again~
Hide
blackdrag blackdrag added a comment -

The message is now no longer a "BUG!" message and it contains valuable information that should help to solve this problem.

Show
blackdrag blackdrag added a comment - The message is now no longer a "BUG!" message and it contains valuable information that should help to solve this problem.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: