natRuntime stack trace bug fix

Andrew Haley aph@redhat.com
Fri Jan 10 18:20:00 GMT 2003


2003-01-10    Andrew Haley <aph@.redhat.com>

        * java/lang/natRuntime.cc (_load): StackTrace access needs to be
        in a try block.

Index: natRuntime.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natRuntime.cc,v
retrieving revision 1.29
diff -c -2 -p -r1.29 natRuntime.cc
*** natRuntime.cc       10 Dec 2002 01:39:32 -0000      1.29
--- natRuntime.cc       10 Jan 2003 18:14:48 -0000
*************** java::lang::Runtime::_load (jstring path
*** 181,198 ****
        ClassLoader *sys = ClassLoader::getSystemClassLoader();
        ClassLoader *look = NULL;
!       gnu::gcj::runtime::StackTrace *t = new gnu::gcj::runtime::StackTrace(10);
!       for (int i = 0; i < 10; ++i)
        {
!         jclass klass = t->classAt(i);
!         if (klass != NULL)
            {
!             ClassLoader *loader = klass->getClassLoaderInternal();
!             if (loader != NULL && loader != sys)
                {
!                 look = loader;
!                 break;
                }
            }
        }
        if (look != NULL)
        {
--- 181,205 ----
        ClassLoader *sys = ClassLoader::getSystemClassLoader();
        ClassLoader *look = NULL;
!       gnu::gcj::runtime::StackTrace *t = new gnu::gcj::runtime::StackTrace(4);
!       try
        {
!         for (int i = 1; !klass; i++)
            {
!             jclass klass = t->classAt(i);
!             if (klass != NULL)
                {
!                 ClassLoader *loader = klass->getClassLoaderInternal();
!                 if (loader != NULL && loader != sys)
!                   {
!                     look = loader;
!                     break;
!                   }
                }
            }
        }
+       catch (::java::lang::ArrayIndexOutOfBoundsException *e)
+       {
+       }
+
        if (look != NULL)
        {



More information about the Java-patches mailing list