Home > Archive > Java Help > March 2004 > Re: Different complining result between SUN JDK 1.4 and IBM JDK 1.3.1
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Different complining result between SUN JDK 1.4 and IBM JDK 1.3.1
|
|
| Neal Gafter 2004-03-27, 12:30 am |
| I have to say: both compilers are in a sense correct. The Java Language
Specification says this (11.2):
"A compiler for the Java programming language checks, at compile time, that a
program contains handlers for checked exceptions, by analyzing which checked
exceptions can result from execution of a method or constructor. For each
checked exception which is a possible result, the throws clause for the method
(§8.4.4) or constructor (§8.8.4) must mention the class of that exception or one
of the superclasses of the class of that exception."
Now, computing which exceptions "can result from execution of a method or
constructor" is provably equivalent to the halting problem! In other words, the
Java Language Specification is severely underspecified in this area.
However, I prefer the behavior I implemented in javac in 1.4 to the previous
behavior.
-Neal
| |
| Dario 2004-03-27, 12:30 am |
| John C. Bollinger wrote:
> Dario wrote:
>
>
> Don't be sorry, you were right and Yates is mistaken. Following the
> decision tree set forth in JLS (2nd Ed.) 14.19.2, and assuming that an
> SQLException is thrown at every possible opportunity:
>
> () Exection of the try block completes abrupty for reason (throw of
> SQLException), therefore the catch block for SQLException is executed,
> with the caught exception passed in
>
> () The catch block completes abruptly for reason of (throw of
> [different] SQLException) and the finally block is executed
>
> () The finally block completes abruptly for reason (return of
> java.lang.Object), therefore the whole try statement completes abruptly
> for that reason and the second SQLException is discarded.
>
> The code can never throw an SQLException from the method, and the
> finally block can never complete normally. The Sun compiler is right on
> all counts. The IBM compiler is mistaken about the method throwing an
> exception, and does not diagnose the situation with the finally block
> (though it is in no way required to make such a diagnosis).
Many many thanks!
==> I forgot that a "return" statement always completes abruptly ! <==
And *this* is reason why my preferred Java compiler (i.e. jikes)
does not report any error.
Thanks.
- Dario
|
|
|
|
|