diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2008-12-05 16:08:01 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2008-12-05 16:08:01 +0000 |
commit | 594329d26539dae967b962fb89baa8b374a6b06d (patch) | |
tree | 8ce5d6acf2e27c873913ab6d980e134b3bdb880b /src/main/javassist/SerialVersionUID.java | |
parent | 4e0f7ad05ae2b8cd8e728a52ebb9e84490fd5b64 (diff) | |
download | javassist-594329d26539dae967b962fb89baa8b374a6b06d.tar.gz javassist-594329d26539dae967b962fb89baa8b374a6b06d.zip |
for fixing JASSIST-69
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@462 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/SerialVersionUID.java')
-rw-r--r-- | src/main/javassist/SerialVersionUID.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/main/javassist/SerialVersionUID.java b/src/main/javassist/SerialVersionUID.java index 936e45c3..5e62310d 100644 --- a/src/main/javassist/SerialVersionUID.java +++ b/src/main/javassist/SerialVersionUID.java @@ -16,6 +16,8 @@ package javassist; import java.io.*; +import java.lang.reflect.Modifier; + import javassist.bytecode.*; import java.util.*; import java.security.*; @@ -79,11 +81,19 @@ public class SerialVersionUID { // class name. String javaName = javaName(clazz); out.writeUTF(javaName); - + + CtMethod[] methods = clazz.getDeclaredMethods(); + // class modifiers. - out.writeInt(clazz.getModifiers() & (Modifier.PUBLIC | - Modifier.FINAL | Modifier.INTERFACE | Modifier.ABSTRACT)); - + int classMods = clazz.getModifiers(); + if ((classMods & Modifier.INTERFACE) != 0) + if (methods.length > 0) + classMods = classMods | Modifier.ABSTRACT; + else + classMods = classMods & ~Modifier.ABSTRACT; + + out.writeInt(classMods); + // interfaces. String[] interfaces = classFile.getInterfaces(); for (int i = 0; i < interfaces.length; i++) @@ -144,7 +154,6 @@ public class SerialVersionUID { } // methods. - CtMethod[] methods = clazz.getDeclaredMethods(); Arrays.sort(methods, new Comparator() { public int compare(Object o1, Object o2) { CtMethod m1 = (CtMethod)o1; @@ -160,7 +169,11 @@ public class SerialVersionUID { for (int i = 0; i < methods.length; i++) { CtMethod method = methods[i]; - int mods = method.getModifiers(); + int mods = method.getModifiers() + & (Modifier.PUBLIC | Modifier.PRIVATE + | Modifier.PROTECTED | Modifier.STATIC + | Modifier.FINAL | Modifier.SYNCHRONIZED + | Modifier.NATIVE | Modifier.ABSTRACT | Modifier.STRICT); if ((mods & Modifier.PRIVATE) == 0) { out.writeUTF(method.getName()); out.writeInt(mods); |