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 issues with try with resources #3144

Closed
giraudsa opened this issue Jun 9, 2023 · 2 comments
Closed

Compiler issues with try with resources #3144

giraudsa opened this issue Jun 9, 2023 · 2 comments

Comments

@giraudsa
Copy link

giraudsa commented Jun 9, 2023

The Try With Resources result in throwing bad exception type.

Environment
  • Operating System: Mac OS 13.4
  • JDK version: Temurin 17.0.7 (but tested on several others)
  • Visual Studio Code version: 1.79.0
  • Java extension version: 1.19.0 (commercial version)
Steps To Reproduce
  1. [step 1]
    Create a Main.java file
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    public static void main(final String[] args) throws Exception {
        try(final InputStream in = Files.newInputStream(Path.of("Main.java"))) {
            System.out.println("Hello, World!");
            throw new Exception("test");
        }
    }
}
  1. [step 2]
    execute in vscode
Current Result
Hello, World!
Exception in thread "main" java.lang.IllegalArgumentException: Self-suppression not permitted
        at java.base/java.lang.Throwable.addSuppressed(Throwable.java:1072)
        at Main.main(Main.java:10)
Caused by: java.lang.Exception: test
        at Main.main(Main.java:9)
Expected Result
Hello, World!
Exception in thread "main" java.lang.Exception: test
	at Main.main(Main.java:9)

Additional Informations
@snjeza
Copy link
Contributor

snjeza commented Jun 9, 2023

A duplicate of #3138
@giraudsa Could you check the issue in VS Code Pre-Release ?

@giraudsa
Copy link
Author

giraudsa commented Jun 9, 2023

thanks, and sorry for the duplication.

@snjeza snjeza closed this as completed Jun 9, 2023
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