Re: [Jastadd] [bug report] bug in TryStmt.reachedException()

From: Jesper qvist <jesper.oqvist_at_cs.lth.se>
Date: Fri, 04 May 2012 15:56:58 +0200

Confirmed and fixed in svn revision 9259 using your suggested fix.

Thank you!
/Jesper

On 04/30/2012 04:34 PM, Na, Hyunik wrote:
>
> Hello JastAddJ Developers,
>
> In ExceptionHandling.jrag in Java1.4Frontend,
> TryStmt.reachedException() is defined as follows:
>
> -=-=-=
>
> protected boolean TryStmt.reachedException(TypeDecl type) {
>
> boolean found = false;
>
> // found is true if the exception type is caught by a catch clause
>
> for(int i = 0; i < getNumCatchClause() && !found; i++)
>
> if(getCatchClause(i).handles(type))
>
> found = true;
>
> // if an exception is thrown in the block and the exception is not
> caught and
>
> // either there is no finally block or the finally block can
> complete normally
>
> if(!found && (!hasFinally() || getFinally().canCompleteNormally()) )
>
> if(getBlock().reachedException(type))
>
> return true;
>
> // even if the exception is caught by the catch clauses they may
>
> // throw new exceptions
>
> for(int i = 0; i < getNumCatchClause() && found; i++)
> // ***
>
> if(getCatchClause(i).reachedException(type))
>
> return true;
>
> return hasFinally() && getFinally().reachedException(type);
>
> }
>
> -=-=-=
>
> I think that the ?&& found? should be dropped from the line marked by ***
>
> because the body of the second for statement should be executed
> regardless of whether ?found? is true or not.
>
> Current JastAddJ (rev. 9238) rejects the following correct program.
>
> -=-=-= Test.java
>
> class ExceptionA extends Exception {}
>
> class ExceptionB extends Exception {}
>
> public class Test {
>
> void test() {
>
> try {
>
> try {
>
> throw new ExceptionA();
>
> } catch ( ExceptionA e ) {
>
> throw new ExceptionB ();
>
> }
>
> } catch ( ExceptionB e ) {
>
> ;
>
> }
>
> }
>
> }
>
> -=-=-=
>
> The error message is as follows:
>
> -=-=-=
>
> Errors:
>
> Test.java:15:
>
> Semantic Error: statement is unreachable
>
> -=-=-=
>
> JastAddJ wrongly judges that the catch clause of the outer try
> statement is unreachable
>
> because it judges that ExceptionB does not reach the inner try statement.
>
> This problem was observed while compiling
>
> . sun/rmi/transport/Transport.java
>
> . sun/rmi/registry/RegistryImpl.java
>
> . sun/rmi/server/ActivationGroupImpl.java
>
> from OpenJDK1.6
>
> Please check this.
>
> - Hyunik
>
>
> _______________________________________________
> JastAdd mailing list
> JastAdd_at_cs.lth.se
> https://mail1.cs.lth.se/cgi-bin/mailman/listinfo/jastadd
Received on Fri May 04 2012 - 15:56:18 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST