Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23] ECJ accepts both boolean values and a default case in a switch #2916

Closed
jarthana opened this issue Sep 5, 2024 · 6 comments
Closed
Assignees
Milestone

Comments

@jarthana
Copy link
Member

jarthana commented Sep 5, 2024

Consider this code:

public class X {
	public void foo(Boolean b) {
		final boolean TRUE = true;
		final boolean FALSE = false;
		switch (b) {
			case TRUE -> { break;}
			case FALSE -> { break;}
			default -> { break;}
		}
	}
}

ECJ accepts this but Javac rejects this with error:
X.java:8: error: switch has both boolean values and a default label

I haven't checked with the spec on this, though.

@stephan-herrmann
Copy link
Contributor

Thanks, @jarthana this is a good one. Keep'em coming! :)

@stephan-herrmann stephan-herrmann self-assigned this Sep 5, 2024
@jarthana
Copy link
Member Author

jarthana commented Sep 5, 2024

FWIW, when I remove any of the three case statements, Javac crashes. I have a raised a defect with Oracle for this.

@stephan-herrmann
Copy link
Contributor

Fixed by #2919

@stephan-herrmann
Copy link
Contributor

FWIW, when I remove any of the three case statements, Javac crashes. I have a raised a defect with Oracle for this.

This one: https://bugs.openjdk.org/browse/JDK-8339602 ? Wow that was fast.

Turned out my tests tip-toed narrowly around that case, otherwise run.javac mode would bark.

Should I add that case to our suite anyway?

@jarthana
Copy link
Member Author

FWIW, when I remove any of the three case statements, Javac crashes. I have a raised a defect with Oracle for this.

This one: https://bugs.openjdk.org/browse/JDK-8339602 ? Wow that was fast.

The JDK issue has been closed as "not an issue". Don't know what to make of it :)

@srikanth-sankaran
Copy link
Contributor

FWIW, when I remove any of the three case statements, Javac crashes. I have a raised a defect with Oracle for this.

This one: https://bugs.openjdk.org/browse/JDK-8339602 ? Wow that was fast.

The JDK issue has been closed as "not an issue". Don't know what to make of it :)

Not an issue could mean - it got fixed otherwise somehow and is not reproducible on their tip. It would be good to check their recent build. I don't think they would close a compiler crash otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants