libgcj/5696: natClass.cc run through superclasses of target if they exist while comparing variable types.
toddastock@yahoo.com
toddastock@yahoo.com
Thu Feb 14 22:16:00 GMT 2002
>Number: 5696
>Category: libgcj
>Synopsis: natClass.cc run through superclasses of target if they exist while comparing variable types.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 14 20:16:02 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:
It's possible that you are comparing an Object (as source) against another builtin type like a Thread (as target). In that case the Thread would have a superclass of Object which you have to search it's superclasses to validate that the variables are equal.
Shouldn't Thread even if it's a builtin type register true to the function 'isInterface()'?? Is this a bug generated by the compiler instead?
>How-To-Repeat:
import java.io.*;
public class TestException extends RuntimeException
{
}
import java.io.*;
import java.util.*;
public class Test
{
Object dummy = null;
public static void main (String[] args)
{
Test t = new Test( );
try
{
t.doit( new String("") );
}
catch( TestException e )
{
}
}
protected TestException dummyE()
{
return new TestException();
}
public void doit (String x) throws TestException
{
if( dummy != null )
{
throw dummyE();
}
if( dummy != null )
{
FileInputStream in = null;
try
{
Properties props = new Properties();
in = new FileInputStream(x);
Enumeration enum = props.propertyNames();
Vector v = new Vector();
}
catch( Exception e )
{
throw new TestException( );
}
finally
{
if( in != null )
{
try
{
in.close();
}
catch( IOException ioex )
{
}
}
}
}
else
{
throw new TestException( );
}
}
}
>Fix:
Possibly a non-recursive solution would be better??
Index: java/lang/natClass.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/lang/natClass.cc,v
retrieving revision 1.50
diff -u -r1.50 natClass.cc
--- java/lang/natClass.cc 21 Dec 2001 19:47:50 -0000 1.50
+++ java/lang/natClass.cc 15 Feb 2002 03:50:28 -0000
@@ -962,11 +962,16 @@
}
return false;
}
// Primitive TYPE classes are only assignable to themselves.
if (__builtin_expect (target->isPrimitive(), false))
return false;
+ if( target->getSuperclass( ) )
+ {
+ return _Jv_IsAssignableFrom( source, target->getSuperclass() );
+ }
+
if (target == &ObjectClass)
{
if (source->isPrimitive())
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list