Handling for new warning?

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Sep 25 00:59:17 UTC 2019

On 9/24/19 5:46 PM, Mike Duigou wrote:
> On 2019-09-24 16:25, mark.reinhold at oracle.com wrote:
>> 2019/9/24 15:56:37 -0700, openjdk at duigou.org:
>>> The proposed change is to add a lint level warning, ie.
>>> -XLint:runtime-undeclared , suggestion to add the unrequired but 
>>> missing
>>> throws declarations for RuntimeException et al. The advantage to
>>> providing the complete throws including RuntimeExceptions is to make
>>> them more visible and encourage handling of them. We have one good
>>> example of a library which does declare the RuntimeException that are
>>> thrown, the JDK.
>> I’m confused.  I thought you said earlier that there are thousands of
>> missing cases in the JDK.
> JDK seems to be in pretty good shape though -Werror stops compilation 
> well before completion. The observed problems with large numbers of 
> missing declarations have been in javac where there are hundreds 
> (perhaps many more) missing throws declarations primarily, so far, for 
> IllegalArgumentException and CompletionFailure.

I don't think it would be acceptable to change javac so that 
CompletionFailure is specified all over the place.   Story: a long time 
ago, back when I joined the javac team, I tried doing something similar 
to what you're proposing now, except that I tried to do it by changing 
CompletionFailure to a checked exception. As you might guess, the size 
of the change became unreasonable and I abandoned the experiment.

I'd also be concerned about IllegalArgumentException and friends like 
NullPointerException becoming too pervasive across the codebase.

-- Jon

> There's no easy way to know the total number of potential throws 
> "fixes" needed because adding missing declarations has a tendency to 
> produce new warnings in the methods which call the fixed method. I 
> added a couple hundred across a dozen or so files but didn't feel I 
> was any near complete based on the number of files I hadn't yet 
> covered in the javac source.
>>> ...
>>> The check will apply to all instances of RuntimeException and all
>>> subclasses.
>> I agree with Jon: This proposal is likely to have broad impact and thus
>> needs wider discussion.  May I suggest the jdk-dev list?
> For JDK this would seem to be a separate problem--the missing "throws" 
> could in some cases mean that the method signature and javadoc are an 
> incomplete specification of the API and a potential/probable JCK issue.
> For the moment I am going to working on completing the minimal patch 
> which provides the new lint warning and allows compilation by 
> disabling the warning.
>> - Mark
> Cheers,
> Mike

More information about the compiler-dev mailing list