From 34081d2e064446147909c8673be17dcc3820791e Mon Sep 17 00:00:00 2001 From: hoenicke Date: Thu, 6 Jul 2000 16:46:40 +0000 Subject: [PATCH] Fixed calculation of SerialVersionUID git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1254 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/bytecode/ClassInfo.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/jode/jode/bytecode/ClassInfo.java b/jode/jode/bytecode/ClassInfo.java index ebeb7e5..b837af9 100644 --- a/jode/jode/bytecode/ClassInfo.java +++ b/jode/jode/bytecode/ClassInfo.java @@ -1332,10 +1332,10 @@ public final class ClassInfo extends BinaryInfo implements Comparable { if (status < DECLARATIONS) throw new IllegalStateException("status is "+status); FieldInfo fi = findField("serialVersionUID", "J"); - if (fi != null && fi.getConstant() != null) - /* We don't check for static final: if it has a constant it - * must be static final. - */ + if (fi != null + && ((fi.getModifiers() & (Modifier.STATIC | Modifier.FINAL)) + == (Modifier.STATIC | Modifier.FINAL)) + && fi.getConstant() != null) return ((Long) fi.getConstant()).longValue(); final MessageDigest md = MessageDigest.getInstance("SHA"); @@ -1378,19 +1378,24 @@ public final class ClassInfo extends BinaryInfo implements Comparable { out.writeUTF(fields[i].getType()); } - FieldInfo[] methods = (FieldInfo[]) this.methods.clone(); + MethodInfo[] methods = (MethodInfo[]) this.methods.clone(); Arrays.sort(methods); for (int i=0; i < methods.length; i++) { modifs = methods[i].getModifiers(); + /* The modifiers of should be just static, + * but jikes also marks it final. + */ + if (methods[i].getName().equals("")) + modifs = Modifier.STATIC; if ((modifs & Modifier.PRIVATE) != 0) continue; out.writeUTF(methods[i].getName()); out.writeInt(modifs); - // the replacement of '/' with '.' was needed to make computed - // SUID's agree with those computed by JDK. + // the replacement of '/' with '.' was needed to make + // computed SUID's agree with those computed by JDK. out.writeUTF(methods[i].getType().replace('/', '.')); }