harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r651231 - in /harmony/enhanced/drlvm/trunk/vm: tests/kernel/java/lang/ClassTestGetDeclaredClasses.java vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
Date Thu, 24 Apr 2008 12:06:27 GMT
Author: varlax
Date: Thu Apr 24 05:06:24 2008
New Revision: 651231

URL: http://svn.apache.org/viewvc?rev=651231&view=rev
Log:
Fixed HARMONY-5746 [drlvm][kernel] getDeclaredClasses returns nulls (Apache Axis2)

Modified:
    harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ClassTestGetDeclaredClasses.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ClassTestGetDeclaredClasses.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ClassTestGetDeclaredClasses.java?rev=651231&r1=651230&r2=651231&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ClassTestGetDeclaredClasses.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ClassTestGetDeclaredClasses.java
Thu Apr 24 05:06:24 2008
@@ -81,6 +81,18 @@
         assertEquals("Array must be empty", 0, cs.length);
     }
 
+    /**
+     * Should not include non-member inner classes 
+     * (anonymous and local).
+     */
+    public void testAnonymousLocal() {
+        Class[] cs = this.getClass().getDeclaredClasses();
+        for (Class c: cs) {
+            assertFalse("anonymous " + c, c.isAnonymousClass());
+            assertFalse("local " + c.toString(), c.isLocalClass());
+        }
+    }
+
     public class Helper1 {
         class Inner1 {
         }
@@ -95,5 +107,13 @@
     }
 
     private class Helper4 {
+    }
+    
+    static Object o1 = new Object() {};
+    static void m1() {
+        class CC{}
+    }
+    Object m2() {
+        return new Object() {};
     }
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp?rev=651231&r1=651230&r2=651231&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
Thu Apr 24 05:06:24 2008
@@ -227,13 +227,14 @@
     return jni_class_from_handle(jenv, pCompClass);
 }
 
-// return true if iklass is not inner of klass
+// return true if iklass is a declared member of klass
 inline static bool
-class_is_inner_skip( Class_Handle klass, Class_Handle iklass )
+class_is_direct_member( Class_Handle klass, Class_Handle iklass )
 {
-    Class* outer = class_get_declaring_class(iklass);
-
-    if (outer != NULL && outer != klass) {
+    // A class must have an EnclosingMethod attribute 
+    // if and only if it is a local class or an anonymous class.
+    if (0 == iklass->get_enclosing_class_index() 
+        && klass == class_get_declaring_class(iklass)) {
         return true;
     }
 
@@ -261,7 +262,7 @@
         iclss = class_get_inner_class(clss, index);
         if (!iclss)
             return NULL;        
-        if( class_is_inner_skip( clss, iclss ) )
+        if( !class_is_direct_member( clss, iclss ) )
             num_res--;
     }
 
@@ -272,7 +273,7 @@
     // set array
     for( index = 0, num_res = 0; index < num_ic; index++) {
         iclss = class_get_inner_class(clss, index);
-        if( class_is_inner_skip( clss, iclss ) )
+        if( !class_is_direct_member( clss, iclss ) )
             continue;
         SetObjectArrayElement(jenv, res, num_res++, jni_class_from_handle(jenv, iclss));
     }



Mime
View raw message