Skip to content
Permalink
Browse files

Merge pull request #347 from Dichotomia/fix_build

Fix build
  • Loading branch information...
mebigfatguy committed Jun 2, 2019
2 parents f002c0e + 1c9030d commit 3b87ff10e63482c08290296ff85bc4bdaee6e5f0
Showing with 8 additions and 24 deletions.
  1. +8 −24 src/main/java/com/mebigfatguy/fbcontrib/utils/SerialVersionCalc.java
@@ -29,15 +29,20 @@

import org.apache.bcel.Const;
import org.apache.bcel.classfile.Field;
import org.apache.bcel.classfile.FieldOrMethod;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;

public class SerialVersionCalc {
public final class SerialVersionCalc {

enum ModifierType {
CLASS, METHOD, FIELD
}

private SerialVersionCalc() {

}

public static long uuid(JavaClass cls) throws IOException {

if (cls.isEnum()) {
@@ -55,7 +60,7 @@ public static long uuid(JavaClass cls) throws IOException {
Arrays.stream(infs).forEach(inf -> utfUpdate(digest, inf));

Field[] fields = cls.getFields();
Arrays.sort(fields, new FieldSorter());
Arrays.sort(fields, Comparator.comparing(FieldOrMethod::getName));
Arrays.stream(fields).filter(field -> !field.isPrivate() || (!field.isStatic() && !field.isTransient()))
.forEach(field -> {
utfUpdate(digest, field.getName());
@@ -64,7 +69,7 @@ public static long uuid(JavaClass cls) throws IOException {
});

Method[] methods = cls.getMethods();
Arrays.sort(methods, new MethodSorter());
Arrays.sort(methods, Comparator.comparing(FieldOrMethod::getName).thenComparing(FieldOrMethod::getSignature));

Arrays.stream(methods).filter(method -> "<clinit>".equals(method.getName())).limit(1).forEach(sinit -> {
utfUpdate(digest, "<clinit>");
@@ -130,25 +135,4 @@ private static void utfUpdate(MessageDigest digest, String str) {
digest.update(toArray(data.length), 2, 2);
digest.update(data);
}

static class FieldSorter implements Comparator<Field> {

@Override
public int compare(Field f1, Field f2) {
return f1.getName().compareTo(f2.getName());
}
}

static class MethodSorter implements Comparator<Method> {

@Override
public int compare(Method m1, Method m2) {
int cmp = m1.getName().compareTo(m2.getName());
if (cmp != 0) {
return cmp;
}

return m1.getSignature().compareTo(m2.getSignature());
}
}
}

0 comments on commit 3b87ff1

Please sign in to comment.
You can’t perform that action at this time.