This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libgcj/5695: verify.cc test that target is an object before running down interfaces
- From: toddastock at yahoo dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: Thu, 14 Feb 2002 18:24:05 -0800
- Subject: libgcj/5695: verify.cc test that target is an object before running down interfaces
>Number: 5695
>Category: libgcj
>Synopsis: verify.cc test that target is an object before running down interfaces
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 14 18:26:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:
>Release: 3.1 20020214 (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:
verify.cc test that target is an object before running down interfaces. Based on the prior bug (5670)
>How-To-Repeat:
import java.io.*;
import java.util.*;
public class Test2
{
Vector v = new Vector( );
public void addBuildListener( TestListener l )
{
v.addElement( l );
}
}
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( );
try
{
t.doit( );
}
catch( Exception e )
{
}
}
private void doit( ) throws Exception
{
final Test2 t = new Test2();
addListener(t);
}
protected void addListener( Test2 t )
{
t.addBuildListener(doitSub());
}
private TestLogger testE () throws IOException
{
return new TestLoggerDefault();
}
private TestLogger doitSub ()
{
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;
}
}
public interface TestListener
{
}
public class TestLoggerDefault implements TestLogger
{
public void print ( int y )
{
}
}
public interface TestLogger extends TestListener
{
void print ( int y );
}
>Fix:
Reorder to check if target is an Object prior to running down the sources interface chain.
Index: verify.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/verify.cc,v
retrieving revision 1.37
diff -u -r1.37 verify.cc
--- verify.cc 14 Feb 2002 17:48:36 -0000 1.37
+++ verify.cc 15 Feb 2002 02:16:54 -0000
@@ -245,7 +245,13 @@
// interface even if it hasn't been prepared.
else if ((target->state > JV_STATE_LINKED || target->isInterface ())
&& source->state > JV_STATE_LINKED)
+ {
return _Jv_IsAssignableFrom (target, source);
+ }
+ else if (target == &java::lang::Object::class$)
+ {
+ return true;
+ }
else if (target->isInterface ())
{
for (int i = 0; i < source->interface_count; ++i)
@@ -272,10 +278,10 @@
if (target == NULL)
return false;
}
- else if (target == &java::lang::Object::class$)
- return true;
else if (source == &java::lang::Object::class$)
+ {
return false;
+ }
else
source = source->getSuperclass ();
}
>Release-Note:
>Audit-Trail:
>Unformatted: