This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: merge File.toURI() from Classpath


Bryce McKinlay wrote:
> Ranjit Mathew wrote:
> 
> 
>>Mohan Embar wrote:
>> 
>>
>>
>>>Just out of curiosity, why is the result of new InternalError()
>>>being explicitly cast to an InternalError?
>>>   
>>>
>>
>>Look closely - it's the return value (a Throwable) from
>>initCause() that is being cast into an InternalError:
>>
>>+        // Can't happen.
>>+        throw (InternalError) new InternalError("Unconvertible file: "
>>+						+ this).initCause(use);
>> 
>>
> 
> 
> I wonder if we should standardize on using RuntimeException in these 
> cases. A quick grep through the source code shows that we use both 
> InternalError and RuntimeException for these "shouldn't/can't happen" 
> catch blocks in various cases. I think RuntimeException would be a 
> better choice, since it has a proper "cause" constructor for re-throwing 
> exceptions.
> 

I don't like this idea.

RuntimeException is meant to be the base class for Exceptions that can
reasonable be expected to be thrown from error free library code when
called by buggy application code.

InternalError as its name suggests is meant to be thrown in situations
that could only be caused by a bug internal to the runtime.

If don't like the idiom new InternalError().initCause(), then add a
constructor to InternalError (and perhaps Error also) so that you can
pass the cause as a constructor parameter.

Just my $0.02

David Daney


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]