Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
I have the following ill-typed program
class A { A(int x) {} A(int y) {} }
Actual behavior
The program compiles but I get the following runtime exception
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
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)
Attachments
Issue Links
- links to