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

[Patterns][records] ECJ fails to generate code to deconstruct record in pattern #1985

Closed
srikanth-sankaran opened this issue Feb 9, 2024 · 0 comments · Fixed by #2016
Closed
Assignees

Comments

@srikanth-sankaran
Copy link
Contributor

srikanth-sankaran commented Feb 9, 2024

The following program when compiled and run should trigger a MatchException caused by java.lang.ArithmeticException but fails to - because ECJ does not generate code to deconstruct the pattern:

public class X {

	record R(int x) {
		public int x() {
			return 100 / this.x;
		}
	}

	public static void main(String[] args) {
		try {
			boolean b = new R(0) instanceof R(int i);
		} catch (Throwable t) {
			System.out.println(t.getClass().getName());
		}
	}
}

javac handles it correctly.

But javac behavior on this is suspect:

public class X {

	boolean b = new R(0) instanceof R(int i);
	record R(int x) {
		public int x() {
			return 100 / this.x;
		}
	}

	public static void main(String[] args) {
            try {
        	new X();
            } catch (Throwable t) {
        	System.out.println(t.getClass().getName());
            }
	}
}



This with javac reports java.lang.ArithmeticException unwrapped by MatchException which I think is a bug in javac

@srikanth-sankaran srikanth-sankaran self-assigned this Feb 9, 2024
@srikanth-sankaran srikanth-sankaran linked a pull request Feb 14, 2024 that will close this issue
3 tasks
srikanth-sankaran added a commit to datho7561/eclipse.jdt.core that referenced this issue Feb 14, 2024
srikanth-sankaran added a commit to datho7561/eclipse.jdt.core that referenced this issue Feb 14, 2024
srikanth-sankaran added a commit that referenced this issue Feb 14, 2024
* Fix RecordPattern generation for standalone instanceof
* Fixes #1804
* Fixes #1985

Signed-off-by: David Thompson <[email protected]>
Co-authored-by: Srikanth Sankaran <[email protected]>
mickaelistria pushed a commit to mickaelistria/eclipse.jdt.core that referenced this issue Feb 16, 2024
)

* Fix RecordPattern generation for standalone instanceof
* Fixes eclipse-jdt#1804
* Fixes eclipse-jdt#1985

Signed-off-by: David Thompson <[email protected]>
Co-authored-by: Srikanth Sankaran <[email protected]>
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Jul 18, 2024
)

* Fix RecordPattern generation for standalone instanceof
* Fixes eclipse-jdt#1804
* Fixes eclipse-jdt#1985

Signed-off-by: David Thompson <[email protected]>
Co-authored-by: Srikanth Sankaran <[email protected]>
gayanper pushed a commit to gayanper/eclipse.jdt.core that referenced this issue Sep 7, 2024
)

* Fix RecordPattern generation for standalone instanceof
* Fixes eclipse-jdt#1804
* Fixes eclipse-jdt#1985

Signed-off-by: David Thompson <[email protected]>
Co-authored-by: Srikanth Sankaran <[email protected]>
snjeza pushed a commit to snjeza/eclipse.jdt.core that referenced this issue Oct 21, 2024
)

* Fix RecordPattern generation for standalone instanceof
* Fixes eclipse-jdt#1804
* Fixes eclipse-jdt#1985

Signed-off-by: David Thompson <[email protected]>
Co-authored-by: Srikanth Sankaran <[email protected]>
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

Successfully merging a pull request may close this issue.

1 participant