Fixed calculation of SerialVersionUID

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1254 379699f6-c40d-0410-875b-85095c16579e
master
hoenicke 25 years ago
parent 96ef935ccc
commit 34081d2e06
  1. 19
      jode/jode/bytecode/ClassInfo.java

@ -1332,10 +1332,10 @@ public final class ClassInfo extends BinaryInfo implements Comparable {
if (status < DECLARATIONS) if (status < DECLARATIONS)
throw new IllegalStateException("status is "+status); throw new IllegalStateException("status is "+status);
FieldInfo fi = findField("serialVersionUID", "J"); FieldInfo fi = findField("serialVersionUID", "J");
if (fi != null && fi.getConstant() != null) if (fi != null
/* We don't check for static final: if it has a constant it && ((fi.getModifiers() & (Modifier.STATIC | Modifier.FINAL))
* must be static final. == (Modifier.STATIC | Modifier.FINAL))
*/ && fi.getConstant() != null)
return ((Long) fi.getConstant()).longValue(); return ((Long) fi.getConstant()).longValue();
final MessageDigest md = MessageDigest.getInstance("SHA"); final MessageDigest md = MessageDigest.getInstance("SHA");
@ -1378,19 +1378,24 @@ public final class ClassInfo extends BinaryInfo implements Comparable {
out.writeUTF(fields[i].getType()); out.writeUTF(fields[i].getType());
} }
FieldInfo[] methods = (FieldInfo[]) this.methods.clone(); MethodInfo[] methods = (MethodInfo[]) this.methods.clone();
Arrays.sort(methods); Arrays.sort(methods);
for (int i=0; i < methods.length; i++) { for (int i=0; i < methods.length; i++) {
modifs = methods[i].getModifiers(); modifs = methods[i].getModifiers();
/* The modifiers of <clinit> should be just static,
* but jikes also marks it final.
*/
if (methods[i].getName().equals("<clinit>"))
modifs = Modifier.STATIC;
if ((modifs & Modifier.PRIVATE) != 0) if ((modifs & Modifier.PRIVATE) != 0)
continue; continue;
out.writeUTF(methods[i].getName()); out.writeUTF(methods[i].getName());
out.writeInt(modifs); out.writeInt(modifs);
// the replacement of '/' with '.' was needed to make computed // the replacement of '/' with '.' was needed to make
// SUID's agree with those computed by JDK. // computed SUID's agree with those computed by JDK.
out.writeUTF(methods[i].getType().replace('/', '.')); out.writeUTF(methods[i].getType().replace('/', '.'));
} }

Loading…
Cancel
Save