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]

PR libgcj/34444: Class.getEnclosingClass() returns null on enclosed class


Another case where Sun's javadoc was rather vague.

Andrew.


2008-01-04  Andrew Haley  <aph@redhat.com>

	PR libgcj/34444
	* java/lang/natClass.cc (Class::getEnclosingClass): Call
	getDeclaringClass().

Index: natClass.cc
===================================================================
--- natClass.cc	(revision 131034)
+++ natClass.cc	(working copy)
@@ -1043,7 +1043,8 @@
   _Jv_word indexes;
   indexes.i = getEnclosingMethodData();
   if (indexes.i == 0)
-    return NULL;
+    // No enclosing method, but perhaps a member or anonymous class
+    return getDeclaringClass();
   _Jv_ushort class_index, method_index;
   _Jv_loadIndexes (&indexes, class_index, method_index);
   return _Jv_Linker::resolve_pool_entry (this, class_index).clazz;

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903


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