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

compiler shows incorrect error for inner static on record #3443

Closed
robaho opened this issue Dec 22, 2023 · 6 comments
Closed

compiler shows incorrect error for inner static on record #3443

robaho opened this issue Dec 22, 2023 · 6 comments

Comments

@robaho
Copy link

robaho commented Dec 22, 2023

Code like:

public class X {
    public record SomeRecord() {
        public static final int SOMEVALUE = 1;
    }
}

is valid.

The compiler reports

Illegal modifier for parameter SOMEVALUE; only final is permitted Java(67109220)

The code compiles fine with javac.

@snjeza
Copy link
Contributor

snjeza commented Dec 22, 2023

@robaho I can't reproduce the issue. Could you try the latest VS Code Java 1.25.1 or Pre-Release?

@robaho
Copy link
Author

robaho commented Dec 22, 2023

I am running the pre-release v1.26.2023122208. The JDK is JavaSE-17.

I created the below file. It doesn't show an error. Select File->Save and the error appears:

import java.util.function.Predicate;

public class TestCompiler {
    public record MyRecord(int v) {
        public static final Predicate<Object> ALWAYS_TRUE_FILTER = w -> true;
    }
}

image

@robaho
Copy link
Author

robaho commented Dec 22, 2023

If I close the tab, then reopen, the error is gone. As soon as I use File->Save it will reappear.

@snjeza
Copy link
Contributor

snjeza commented Dec 22, 2023

I still can't reproduce the issue.
@robaho Could you create a simple project?

@robaho
Copy link
Author

robaho commented Dec 22, 2023

Btw, this is a gradle based project. I will try and create a simple project shortly.

@robaho
Copy link
Author

robaho commented Dec 28, 2023

I did some more investigation on this. I created a new project and saw the same error. After using 'clean workspace' the error went away and did not return.

I went back to my original project and did the same and the error disappeared and I could not make it happen again with the save.

So at this point I cannot reliably reproduce and there is a 'workaround/fix' to remove it, so you can close the issue. I am fairly certain there is a bug lurking though...

@snjeza snjeza closed this as completed Jan 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

No branches or pull requests

2 participants