Skip to content

[Enhanced Switch] Bogus duplicate case error from ECJ #3334

@srikanth-sankaran

Description

@srikanth-sankaran

Found by code inspection & white box testing:

The program below when compiled with javac and run produces the output:

E1.ONE
E1.TWO
E2.ONE
E2.TWO
E1.TWO
E2.ONE
E2.TWO
E2.ONE
E2.TWO
E2.TWO

but is rejected by ECJ with three errors of: Duplicate case

public sealed interface X {
	public static void main(String[] args) {
        bar(E1.ONE);
        bar(E1.TWO);
        bar(E2.ONE);
        bar(E2.TWO);
	}
	public static void bar(X x) {
		switch (x) {
		case E1.ONE: 
			System.out.println("E1.ONE");
		case E1.TWO: 
			System.out.println("E1.TWO");
		case E2.ONE:
			System.out.println("E2.ONE");
		case E2.TWO:
			System.out.println("E2.TWO");
		}
	}
}
enum E1 implements X { ONE, TWO}
enum E2 implements X { ONE, TWO}

Metadata

Metadata

Labels

bugSomething isn't workingcompilerEclipse Java Compiler (ecj) related issuesregressionSomething was broken by a previous change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions