diff options
Diffstat (limited to 'src/main/javassist/SerialVersionUID.java')
-rw-r--r-- | src/main/javassist/SerialVersionUID.java | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/main/javassist/SerialVersionUID.java b/src/main/javassist/SerialVersionUID.java index c1a93bb6..ebb18bfa 100644 --- a/src/main/javassist/SerialVersionUID.java +++ b/src/main/javassist/SerialVersionUID.java @@ -16,12 +16,17 @@ package javassist; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; import java.lang.reflect.Modifier; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.Comparator; -import javassist.bytecode.*; -import java.util.*; -import java.security.*; +import javassist.bytecode.ClassFile; +import javassist.bytecode.Descriptor; /** * Utility for calculating serialVersionUIDs for Serializable classes. @@ -108,16 +113,15 @@ public class SerialVersionUID { // fields. CtField[] fields = clazz.getDeclaredFields(); - Arrays.sort(fields, new Comparator() { - public int compare(Object o1, Object o2) { - CtField field1 = (CtField)o1; - CtField field2 = (CtField)o2; + Arrays.sort(fields, new Comparator<CtField>() { + @Override + public int compare(CtField field1, CtField field2) { return field1.getName().compareTo(field2.getName()); } }); for (int i = 0; i < fields.length; i++) { - CtField field = (CtField) fields[i]; + CtField field = fields[i]; int mods = field.getModifiers(); if (((mods & Modifier.PRIVATE) == 0) || ((mods & (Modifier.STATIC | Modifier.TRANSIENT)) == 0)) { @@ -136,10 +140,9 @@ public class SerialVersionUID { // constructors. CtConstructor[] constructors = clazz.getDeclaredConstructors(); - Arrays.sort(constructors, new Comparator() { - public int compare(Object o1, Object o2) { - CtConstructor c1 = (CtConstructor)o1; - CtConstructor c2 = (CtConstructor)o2; + Arrays.sort(constructors, new Comparator<CtConstructor>() { + @Override + public int compare(CtConstructor c1, CtConstructor c2) { return c1.getMethodInfo2().getDescriptor().compareTo( c2.getMethodInfo2().getDescriptor()); } @@ -157,10 +160,9 @@ public class SerialVersionUID { } // methods. - Arrays.sort(methods, new Comparator() { - public int compare(Object o1, Object o2) { - CtMethod m1 = (CtMethod)o1; - CtMethod m2 = (CtMethod)o2; + Arrays.sort(methods, new Comparator<CtMethod>() { + @Override + public int compare(CtMethod m1, CtMethod m2) { int value = m1.getName().compareTo(m2.getName()); if (value == 0) value = m1.getMethodInfo2().getDescriptor() |