This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
libgcj/5670: verify.cc not properly merging states
- From: toddastock at yahoo dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: Tue, 12 Feb 2002 10:10:36 -0800
- Subject: libgcj/5670: verify.cc not properly merging states
>Number: 5670
>Category: libgcj
>Synopsis: verify.cc not properly merging states
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Feb 12 10:16:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:
>Release: 3.1 20020211 (experimental)
>Organization:
>Environment:
System: Linux escher 2.4.9-21 #1 Thu Jan 17 14:16:30 EST 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure --enable-threads=posix --prefix=/home/tstock/local --disable-shared --enable-languages=c++,java
>Description:
A problem occurs in the merge state when your comparing two merged states and the source is an interface.
>How-To-Repeat:
This code produces an error during verification because logger initially is TestLogger and then is set to TestLoggerDefault (which inherits TestLogger). TestLoggerDefault will case into TestLogger, but only if you run down it's interface chain.
import java.io.*;
import java.util.*;
public class Test
{
Object x = null;
int y = 0;
public static void main (String[] args)
{
Test t = new Test( );
t.doit( );
}
private TestLogger testE () throws IOException
{
return new TestLoggerDefault();
}
private TestLogger doit ()
{
TestLogger logger = null;
if( x != null )
{
try
{
logger = testE();
}
catch( IOException e )
{
throw new RuntimeException( );
}
catch( Exception e )
{
throw new RuntimeException( );
}
}
else
{
logger = new TestLoggerDefault( );
}
logger.print(y);
return logger;
}
protected void addListener( Test2 t )
{
t.addTestListener( doit() );
}
}
public class Test2
{
public void addTestListener ( TestListener t )
{
}
}
public interface TestListener
{
}
public interface TestLogger extends TestListener
{
void print ( int y );
}
public class TestLoggerDefault implements TestLogger
{
public void print ( int y )
{
}
}
>Fix:
Index: libjava/verify.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/verify.cc,v
retrieving revision 1.35
diff -r1.35 verify.cc
261a262,274
> else if (source->isInterface ())
> {
> for (int i = 0; i < target->interface_count; ++i)
> {
> // We use a recursive call because we also need to
> // check superinterfaces.
> if (is_assignable_from_slow (target->interfaces[i], source))
> return true;
> }
> target = target->getSuperclass ();
> if (target == NULL)
> return false;
> }
>Release-Note:
>Audit-Trail:
>Unformatted: