classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] RFC : modifiers in java/lang/Class


From: Nicolas Geoffray
Subject: [cp-patches] RFC : modifiers in java/lang/Class
Date: Sat, 17 Dec 2005 00:04:35 +0100
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051019)

Hi,

The access flag of a class might have the synchronized bit set, even if it's not appropriate for a class. The java file attached prints "public synchronized" as
modifiers with jamvm, whereas it prints "public" with sun. This patch just
changes the return of Class.getModifiers to return only interesting bits.

OK to commit?

2005-12-17  Nicolas Geoffray <address@hidden>

        * java/lang/Class.java (getModifiers): Only returns
        interesting bits.

import java.io.ObjectStreamClass;
import java.lang.reflect.Modifier;
public class Serial implements java.io.Serializable{
  
  public static void main(String[]args) throws Exception{
    System.out.println(Modifier.toString(Serial.class.getModifiers()));
    System.out.println(Serial.class.getModifiers());
    
System.out.println(ObjectStreamClass.lookup(Serial.class).getSerialVersionUID());
  }
}

  
Index: java/lang/Class.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Class.java,v
retrieving revision 1.42
diff -u -r1.42 Class.java
--- java/lang/Class.java        16 Dec 2005 18:06:52 -0000      1.42
+++ java/lang/Class.java        16 Dec 2005 23:03:40 -0000
@@ -836,7 +836,10 @@
    */
   public int getModifiers()
   {
-    return VMClass.getModifiers (this, false);
+    int mod = VMClass.getModifiers (this, false);
+    return (mod & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
+          Modifier.FINAL | Modifier.STATIC | Modifier.ABSTRACT |
+          Modifier.INTERFACE));
   }
   
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]