Huh? test/Stock.java

Glynn Clements glynn at sensei.co.uk
Sun Jul 6 08:08:46 PDT 1997


Mark Huizer wrote:

> Just a small question. Just for fun I tried some of the tests, giving
> errors quite some times, but some are strange.
> 
> Take e.g. test/compiler/Stock.java...
> 
>                 try {
>                         url = new URL( "http://localhost/" );
>                         System.out.println( "Hi\n" );
>                         System.out.println( url.getContent().toString() );
>                         System.out.println( "Bye\n" );
>                 }
>                 catch (java.io.IOException e) {
>                 }
>                 catch (java.net.MalformedURLException e) {
> 
> Here it generates an error that it never reaches the second cache
> statement (Stock.java:27: catch not reached.)
> 
> Isn't it supposed to be able to reach it? Or am I so wrong in my
> understanding that one has to check for all exceptions in one catch and
> try to find out what it is in other ways?

MalformedURLException is a subclass of IOException. If you want to
catch instances of MalformedURLException separately, you need to
reverse the order of the two catch statements.

-- 
Glynn Clements <glynn at sensei.co.uk>



More information about the kaffe mailing list