try {
ConstructorInfo c1 = (ConstructorInfo) o1;
ConstructorInfo c2 = (ConstructorInfo) o2;
return c1.getSignature().compareTo(c2.getSignature());
} catch (Exception e) {
throw new WrappedRuntimeException(e);
}
}
}
);
for (int i = 0; i < constructors.length; i++) {
ConstructorInfo constructor = constructors[i];
int mods = constructor.getModifiers();
if ((mods & Constants.ACC_PRIVATE) == 0) {
out.writeUTF(INIT_METHOD_NAME);
out.writeInt(mods);
out.writeUTF(constructor.getSignature().replace('/', '.'));
}
}
// handle regular methods.
Arrays.sort(
methods, new Comparator() {
public int compare(Object o1, Object o2) {
try {
MethodInfo m1 = (MethodInfo) o1;
MethodInfo m2 = (MethodInfo) o2;
int value = m1.getName().compareTo(m2.getName());
if (value == 0) {
value = m1.getSignature().compareTo(m2.getSignature());
}
return value;
} catch (Exception e) {
throw new WrappedRuntimeException(e);
}
}
}
);
for (int i = 0; i < methods.length; i++) {
MethodInfo method = methods[i];
int mods = method.getModifiers();
if ((mods & Constants.ACC_PRIVATE) == 0) {
out.writeUTF(method.getName());
out.writeInt(mods & filterSynthetic());
out.writeUTF(method.getSignature().replace('/', '.'));
}
}
// calculate hash.
out.flush();
MessageDigest digest = MessageDigest.getInstance("SHA");
byte[] digested = digest.digest(bout.toByteArray());
long hash = 0;
for (int i = Math.min(digested.length, 8) - 1; i >= 0; i--) {
hash = (hash << 8) | (digested[i] & 0xFF);
}
return hash;
} catch (Exception e) {
e.printStackTrace();
throw new WrappedRuntimeException(e);
}
}