rogerkeays / unchecked Goto Github PK
View Code? Open in Web Editor NEWSay goodbye to checked exceptions forever.
Home Page: https://patreon.com/Jamaica440
License: MIT License
Say goodbye to checked exceptions forever.
Home Page: https://patreon.com/Jamaica440
License: MIT License
Test code
try {
assert new String(STARS, "UTF-8").equals("***");
} catch (UnsupportedEncodingException e) {} // okay, never thrown
compiler output
Test.java:18: warning: unreachable catch clause
} catch (UnsupportedEncodingException e) {} // okay, never thrown
^
thrown types have already been caught
other tests show that catch blocks are executed correctly:
for (int i = 0; i < 1; i++) {
try { throw new Exception(); } catch (Exception e) { if (1 == 1) break; }
assert false;
}
seen in the tomcat and hibernate build
Note: {0} uses or overrides a deprecated API
$ jshell -class-path unchecked.jar -C-Xplugin:unchecked -J--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED
| Welcome to JShell -- Version 17.0.2
| For an introduction type: /help intro
jshell> int i = 0;
Exception in thread "main" java.lang.IllegalStateException
at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.add(MultiTaskListener.java:90)
at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.addTaskListener(BasicJavacTask.java:124)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:187)
at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:205)
at jdk.jshell/jdk.jshell.TaskFactory.parse(TaskFactory.java:139)
at jdk.jshell/jdk.jshell.TaskFactory.parse(TaskFactory.java:239)
at jdk.jshell/jdk.jshell.CompletenessAnalyzer.lambda$scan$1(CompletenessAnalyzer.java:96)
at jdk.jshell/jdk.jshell.CompletenessAnalyzer$Parser.disambiguateDeclarationVsExpression(CompletenessAnalyzer.java:758)
at jdk.jshell/jdk.jshell.CompletenessAnalyzer$Parser.parseUnit(CompletenessAnalyzer.java:658)
at jdk.jshell/jdk.jshell.CompletenessAnalyzer.scan(CompletenessAnalyzer.java:97)
at jdk.jshell/jdk.jshell.SourceCodeAnalysisImpl.analyzeCompletion(SourceCodeAnalysisImpl.java:181)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.isComplete(JShellTool.java:1316)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.getInput(JShellTool.java:1260)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1209)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:995)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:261)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
Great work IMHO, but using an IDE seems to make it less usable. Therefore I requested support for this from JetBrains:
This is just to link the ticket with this code. If you are okay, just leave it open until IntelliJ supports or rejects the proposal, feel free to comment it or add improvements.
seeing as we override the logger, we might be able to intercept exceptions here and convert them into warnings
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.