You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2024/01/24 14:36:00 UTC
[jira] [Updated] (GROOVY-11297) Fail to identify duplicate constructor declaration
[ https://issues.apache.org/jira/browse/GROOVY-11297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-11297:
---------------------------------
Component/s: (was: Static Type Checker)
Language: groovy
Duplicate constructor or method signature should be caught (by {{Verifier}}) even without Static Type Checking.
> Fail to identify duplicate constructor declaration
> --------------------------------------------------
>
> Key: GROOVY-11297
> URL: https://issues.apache.org/jira/browse/GROOVY-11297
> Project: Groovy
> Issue Type: Bug
> Reporter: Thodoris Sotiropoulos
> Priority: Minor
>
> I have the following ill-typed program
> {code}
> class A {
> A(int x) {}
> A(int y) {}
> }
> {code}
> h3. Actual behavior
> The program compiles but I get the following runtime exception
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> General error during instruction selection: java.lang.ClassFormatError: Duplicate method name "<init>" with signature "(I)V" in class file A
> java.lang.RuntimeException: java.lang.ClassFormatError: Duplicate method name "<init>" with signature "(I)V" in class file A
> at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:934)
> at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:654)
> at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:628)
> at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:368)
> at groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:311)
> at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
> at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
> at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:309)
> at groovy.lang.GroovyShell.parseClass(GroovyShell.java:543)
> at groovy.lang.GroovyShell.run(GroovyShell.java:364)
> at groovy.lang.GroovyShell.run(GroovyShell.java:354)
> at groovy.ui.GroovyMain.processOnce(GroovyMain.java:645)
> at groovy.ui.GroovyMain.run(GroovyMain.java:390)
> at groovy.ui.GroovyMain.access$1400(GroovyMain.java:68)
> at groovy.ui.GroovyMain$GroovyCommand.process(GroovyMain.java:314)
> at groovy.ui.GroovyMain.processArgs(GroovyMain.java:142)
> at groovy.ui.GroovyMain.main(GroovyMain.java:115)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:568)
> at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:112)
> at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
> Caused by: java.lang.ClassFormatError: Duplicate method name "<init>" with signature "(I)V" in class file A
> at java.base/java.lang.ClassLoader.defineClass1(Native Method)
> at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
> at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
> at groovy.lang.GroovyClassLoader.access$400(GroovyClassLoader.java:90)
> at groovy.lang.GroovyClassLoader$ClassCollector.createClass(GroovyClassLoader.java:675)
> at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(GroovyClassLoader.java:692)
> at groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClassLoader.java:697)
> at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:768)
> at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:900)
> ... 22 more
> 1 error
> {code}
> h3. Expected behavior
> Reject the program and report duplicate constructor declaration. This check is performed for methods, but not for constructors.
> Tested against master (commit: b39bef39b5a22bd53769298d43a8192cbedecb63)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)