This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: resolve.cc exception improvement


I'm checking this in on the trunk.  It is from Gary Benson.

This puts information about the inaccessible field or method into the
IllegalAccessError that is thrown during resolution.  This makes it
easier to figure out what is going wrong without resorting to gdb.

Tom

Index: ChangeLog
from  Gary Benson  <gbenson@redhat.com>

	* resolve.cc (_Jv_ResolvePoolEntry): Put field name in exception.
	(_Jv_SearchMethodInClass): Likewise.

Index: resolve.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/resolve.cc,v
retrieving revision 1.43
diff -u -r1.43 resolve.cc
--- resolve.cc 24 Oct 2003 09:29:41 -0000 1.43
+++ resolve.cc 1 Apr 2004 17:01:27 -0000
@@ -1,6 +1,6 @@
 // resolve.cc - Code for linking and resolving classes and pool entries.
 
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
 
    This file is part of libgcj.
 
@@ -185,7 +185,14 @@
 		}
 	      else
 		{
-		  throw new java::lang::IllegalAccessError;
+		  java::lang::StringBuffer *sb
+		    = new java::lang::StringBuffer ();
+		  sb->append(klass->getName());
+		  sb->append(JvNewStringLatin1(": "));
+		  sb->append(cls->getName());
+		  sb->append(JvNewStringLatin1("."));
+		  sb->append(_Jv_NewStringUtf8Const (field_name));
+		  throw new java::lang::IllegalAccessError(sb->toString());
 		}
 	    }
 	}
@@ -343,7 +350,16 @@
       if (_Jv_CheckAccess (klass, cls, method->accflags))
 	return method;
       else
-	throw new java::lang::IllegalAccessError;
+	{
+	  java::lang::StringBuffer *sb = new java::lang::StringBuffer();
+	  sb->append(klass->getName());
+	  sb->append(JvNewStringLatin1(": "));
+	  sb->append(cls->getName());
+	  sb->append(JvNewStringLatin1("."));
+	  sb->append(_Jv_NewStringUTF(method_name->data));
+	  sb->append(_Jv_NewStringUTF(method_signature->data));
+	  throw new java::lang::IllegalAccessError (sb->toString());
+	}
     }
   return 0;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]