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

eclipse can't build when error in switch #2870

Closed
thomas2123 opened this issue Aug 29, 2024 · 8 comments · Fixed by #2887
Closed

eclipse can't build when error in switch #2870

thomas2123 opened this issue Aug 29, 2024 · 8 comments · Fixed by #2887
Assignees
Milestone

Comments

@thomas2123
Copy link

Hi,
As I am a junior developper, I sometime make silly mistakes, sorry for that ^^'.
As @stephan-herrmann suggested, I'll create a new issue for this one.
I got this error in building with 2024-06 :
image
I tried to revert to 2024-03, but I got this error :
362346452-baa85cb4-d79a-44bb-bfc5-7bf2201e024c
But when I reverted back to 2023-12, I did not have the error in building anymore. As I went through the error, I found that it was linked to this error :
image
It's a mistake I often make, to use an enum as a Constant in a switch.

When the enum is replaced by a Constant, the error goes away and the building works again.
I hope I made this clear, sorry if I didn't.
Good luck and thank you for the beautiful software you make.

@thomas2123
Copy link
Author

image
proof I used eclipse 2024-06

@srikanth-sankaran srikanth-sankaran self-assigned this Aug 29, 2024
@srikanth-sankaran
Copy link
Contributor

Are you able to provide a small and self contained example to reproduce the problem ?? Screen shots are not very useful.

Can you try and attach a fuller stack trace when the problem shows up ?? Thanks.

@stephan-herrmann
Copy link
Contributor

As I am a junior developper, I sometime make silly mistakes, sorry for that ^^'.

Every developer makes mistakes, and still the tool should not throw exceptions.

So, if you provide the code that triggered this as text, not picture, then your mistake will help us fix the tool for the benefit of others running into a similar mistake :)

@thomas2123
Copy link
Author

thomas2123 commented Aug 29, 2024

Thank you for your answers
So here is a project that will trigger the building error : https://github.com/thomas2123/buildErrorProject
And the stack trace ? :
Internal compiler error: java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.internal.compiler.lookup.TypeBinding.isRecord()" because "this.resolvedType" is null at org.eclipse.jdt.internal.compiler.ast.RecordPattern.resolveType(RecordPattern.java:119)

@srikanth-sankaran
Copy link
Contributor

Reproduced. Thanks @thomas2123 for the test case.

@srikanth-sankaran srikanth-sankaran added this to the 4.34 M1 milestone Sep 3, 2024
@srikanth-sankaran
Copy link
Contributor

Simplified test case:

public class X {
	
	enum EnumError {
		TEST(0);
		
		private int value;
		
		private EnumError(int value) {
			this.value = value;
		}
		
		public int getValue() {
			return this.value;
		}
	}

	public static void main(String[] args) {
		int bouh = 0;
		switch(bouh) {
		case EnumError.TEST.getValue() : 
			break;
		}
	}

}

JDK-22 reports:

X.java:20: error: cannot find symbol
		case EnumError.TEST.getValue() : 
		              ^
  symbol:   class TEST
  location: class EnumError
X.java:20: error: deconstruction patterns can only be applied to records, getValue is not a record
		case EnumError.TEST.getValue() : 
		     ^
2 errors

srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Sep 3, 2024
@thomas2123
Copy link
Author

thanks for the fix ^^

srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Sep 4, 2024
@srikanth-sankaran
Copy link
Contributor

The fix is not merged in - master is not open for development of 4.34 work. Reopening.

In any case, the ticket will be closed automatically when the fix is integrated.

srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Sep 5, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Sep 5, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Sep 5, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Sep 5, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Sep 5, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Sep 5, 2024
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.

3 participants