-
Notifications
You must be signed in to change notification settings - Fork 431
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 Bug with Record Pattern (java.lang.VerifyError: Stack map does not match the one at exception handler) #3479
Comments
This is an upstream jdt.core issue - eclipse-jdt/eclipse.jdt.core#1796 |
Thanks! Do you want this issue closed or should we wait until upstream has a fix? |
We will wait. eclipse-jdt/eclipse.jdt.core#1796 is not merged yet |
eclipse-jdt/eclipse.jdt.core#1796 has been merged. |
It's not fixed, the bug is still present in the extension. Both release and pre-release. |
I can't reproduce the issue.
Could you try to the following:
|
Interesting, I used the reproducer from the issue you linked. For me that one consistently fails with a |
@musiKk The issue is reproducible in v1.28.1. Could you, please, try |
I tested with edit: I noticed that I stated earlier that I already tried pre-release. I was so sure that I recompiled after switching versions but it seems I messed it up. Apologies for the noise! |
Sorry for issue hijacking, but i can still reproduce in my code: https://gist.github.com/Nightenom/b857fb93a41f7e8bcbb69b103476395c#file-crash Using v1.29.2024031308 (pre-release), did "force java compilation: full" and "clean java language server workspace" yet no success, gradle clean/cleanEclipse didn't help either |
@musiKk could you create a project example? |
I'm not the author of the comment. @Nightenom can you fulfill the request? |
I thought he meant me too
@snjeza not right now, tight schedule, but since i have a half-way workaround through jar debug it can wait |
Upgrading Eclipse works. For those that still want a minimal reproducible example: public class Hello {
public static void main(String[] args) {}
class Group {}
enum Tag {
A
};
sealed interface ContentSource {
public static record MultipartSource(
Object multipart
) implements ContentSource {}
public static record FileSource(
Object file
) implements ContentSource {}
}
public Object uploadFile(Group group, Tag tag, ContentSource file) {
return switch (file) {
case ContentSource.MultipartSource(Object x) -> {
yield x;
}
case ContentSource.FileSource(Object y) -> {
yield y;
}
};
}
} If the classes and naming looks off its because I extracted it from my work codebase and only added what was missing to make it works. Once Eclipse is upgraded, everything works fine! |
I randomly started encountering the following error in one of my projects and am unable to get rid of it
Even though the bug surfaces during running/debugging, I strongly believe that the error occurs during compilation. I know that reports of compiler bugs are often met with scepticism but I verified that it works with the OpenJDK compiler (Temurin) and reliably and repeatedly fails when compiling with VSCode.
Environment
Steps To Reproduce
java -cp target/classes com.github.musiKk.Runner
I tried the following workarounds, none of them worked:
I had a look at the language server log file but it only contained tons of occurrences of the following error which I'm not sure is related:
Current Result
The following error occurs:
It looks like the error is triggered in this method:
It looks like there may be a very special problem with matching the structure of the records (the first case). If I refactor the switch to
it still fails. If I refactor to
it succeeds.
That being said, I tried to isolate the issue with this test but here the error does not happen.
Expected Result
The code runs.
Additional Informations
It is important that the class was compiled by VSCode/the embedded Eclipse compiler! When compiling this on the command line with
mvn clean compile
which delegates to the installed JDK, the code works (ignore any exceptions that occur, the code is not correct but that is not the point). Then, it also does not matter which method from step 4 is used; it always succeeds. As soon as the file is touched from within VSCode and compilation is triggered, the VerifyError is back.The text was updated successfully, but these errors were encountered: