8206181: ExceptionInInitializerError: improve handling of exceptions in user-provided taglets #44
Conversation
public class ExceptionInInitializerErrorTaglet implements Taglet { | ||
|
||
static { | ||
if (true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the if (true)
have any significance?
javac will optimize it, per JLS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ jshell
| Welcome to JShell -- Version 17
| For an introduction type: /help intro
jshell> public class Whatever {
...>
...> static {
...> throw new RuntimeException();
...> }
...> }
...>
| Error:
| initializer must be able to complete normally
| static {
| ^-------...
LGTM, within the spirit of the existing code.
Please file a followup bug for a more comprehensive cleanup to protect against errors in user code, like (untrusted) user-provided tablets and doclets. While this could be loosely modeled on javac
ClientCodeWrapper
and ClientCodeException
, this time round it might be reasonable to use a Proxy
-based wrapper, to catch exceptions in user-code and then throw them in a wrapped exception for better handling at a higher level. That suggests that going forward, failure to init a taglet should be a fatal error. Note: one potential complication for javadoc
not found in javac
is the hard tool-to-doclet abstraction barrier.
|
@pavelrappo This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been no new commits pushed to the
|
@pavelrappo The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
|
/integrate |
Going to push as commit 5aecb37.
Your commit was automatically rebased without conflicts. |
@pavelrappo Pushed as commit 5aecb37. |
Using a custom taglet may result in exceptions, not all of which are javadoc bugs. Some of these exceptions are taglet bugs.
It was noticed that an exception in a static initializer of a custom taglet looks like a javadoc bug, which it is not. The fix was to trivially catch java.lang.ExceptionInInitializerError and translate it into an error like it is already done for some other exceptions.
While working on this fix, I noticed that there were no tests that cover various exceptions that could arise while registering a taglet:
I added a test to cover all of those as well as ExceptionInInitializerError and ClassCastException, which I proactively handled similarly to ExceptionInInitializerError.
I note that a typical taglet-registration error message is quite poor and should be improved in the future. For example, it is unclear that the method that javadoc cannot find is the nullary (i.e. parameterless or no-arg) MyTaglet constructor:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk18 pull/44/head:pull/44
$ git checkout pull/44
Update a local copy of the PR:
$ git checkout pull/44
$ git pull https://git.openjdk.java.net/jdk18 pull/44/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 44
View PR using the GUI difftool:
$ git pr show -t 44
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk18/pull/44.diff