Method Parameter Reflection spec

Joseph Darcy joe.darcy at oracle.com
Tue Sep 10 17:04:03 PDT 2013


On 9/9/2013 1:15 PM, Alex Buckley wrote:
> On 9/9/2013 12:02 PM, Eric McCorkle wrote:
>> On 09/05/13 00:24, Joe Darcy wrote:
>>> I agree the sort of cases below due to corrupt / inconsistent class
>>> files are closer in flavor to error conditions than to exceptional 
>>> ones.
>>> An end user program "shouldn't" have to worry about recovering from
>>> corrupt class files.
>>
>> Then it sounds like there's an agreement that the exception(s) should be
>> thrown from Executable.getParameters()  Good.
>>
>> What remains at this point is to determine what exceptions should be
>> thrown for what cases.  I don't really have a strong opinion on the
>> matter; I'll happily leave that up to someone else.
>
> First, we should stop using ReflectiveOperationException for 
> reflection-time detection of malformed MethodParameters. While ROE 
> itself is new, it represents the legacy checked exceptions from 
> j.l.Class. For j.l.r.Parameter, it would be better to throw unchecked 
> exceptions, in line with j.l.r.Field/Executable.
>
> Second, we all agree that the unchecked exceptions should be runtime 
> exceptions rather than Errors. (When Joe said "closer in flavor to 
> error conditions than to exceptional ones", I don't believe he 
> intended "error conditions" to mean java.lang.Error. I think he meant 
> "closer in flavor to problematic conditions than to truly exceptional, 
> program-stopping ones.")
>
> I suggest MalformedParametersException, a subclass of 
> RuntimeException, for cases (ii)-(vi). (Inspired by 
> MalformedParameterizedTypeException.)
>
> Alex

Hello,

The conditions under discussion actually seem to me most like the 
conditions associated with true errors such as:

     java.lang.AnnotationFormatError
     java.lang.ClassFormatError (subclass of LinkageError)

Whatever Throwable subtype we use for corrupt parameters information, it 
should certainly not be a checked exception. I think using a error as 
opposed to a runtime exception would be more consistent, but I'm willing 
to be convinced otherwise.

-Joe


More information about the enhanced-metadata-spec-discuss mailing list