### Question:
SerialVersionUIDAdder extends ClassVisitor { protected long computeSVUID() throws IOException { long svuid = 0; try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream)) { dataOutputStream.writeUTF(name.replace('/', '.')); int mods = access; if ((mods & Opcodes.ACC_INTERFACE) != 0) { mods = svuidMethods.isEmpty() ? (mods & ~Opcodes.ACC_ABSTRACT) : (mods | Opcodes.ACC_ABSTRACT); } dataOutputStream.writeInt( mods & (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT)); Arrays.sort(interfaces); for (String interfaceName : interfaces) { dataOutputStream.writeUTF(interfaceName.replace('/', '.')); } writeItems(svuidFields, dataOutputStream, false); if (hasStaticInitializer) { dataOutputStream.writeUTF(CLINIT); dataOutputStream.writeInt(Opcodes.ACC_STATIC); dataOutputStream.writeUTF("()V"); } writeItems(svuidConstructors, dataOutputStream, true); writeItems(svuidMethods, dataOutputStream, true); dataOutputStream.flush(); byte[] hashBytes = computeSHAdigest(byteArrayOutputStream.toByteArray()); for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) { svuid = (svuid << 8) | (hashBytes[i] & 0xFF); } } return svuid; } SerialVersionUIDAdder(final ClassVisitor classVisitor); protected  SerialVersionUIDAdder(final int api, final ClassVisitor classVisitor); @Override void visit(
      final int version,
      final int access,
      final String name,
      final String signature,
      final String superName,
      final String[] interfaces); @Override MethodVisitor visitMethod(
      final int access,
      final String name,
      final String descriptor,
      final String signature,
      final String[] exceptions); @Override FieldVisitor visitField(
      final int access,
      final String name,
      final String desc,
      final String signature,
      final Object value); @Override void visitInnerClass(
      final String innerClassName,
      final String outerName,
      final String innerName,
      final int innerClassAccess); @Override void visitEnd(); boolean hasSVUID();  }### Answer:
@Test public void testAllMethods_class() throws IOException { ClassReader classReader = new ClassReader("SerialVersionClass"); SerialVersionUIDAdder svuidAdder = new SerialVersionUIDAdder(null); classReader.accept(svuidAdder, 0); long svuid = svuidAdder.computeSVUID(); assertEquals(4654798559887898126L, svuid); }
@Test public void testAllMethods_anonymousInnerClass() throws IOException { ClassReader classReader = new ClassReader("SerialVersionAnonymousInnerClass$1"); SerialVersionUIDAdder svuidAdder = new SerialVersionUIDAdder(null); classReader.accept(svuidAdder, 0); long svuid = svuidAdder.computeSVUID(); assertEquals(2591057588230880800L, svuid); }
@Test public void testAllMethods_interface() throws IOException { ClassReader classReader = new ClassReader("SerialVersionInterface"); SerialVersionUIDAdder svuidAdder = new SerialVersionUIDAdder(null); classReader.accept(svuidAdder, 0); long svuid = svuidAdder.computeSVUID(); assertEquals(682190902657822970L, svuid); }
@Test public void testAllMethods_emptyInterface() throws IOException { ClassReader classReader = new ClassReader("SerialVersionEmptyInterface"); SerialVersionUIDAdder svuidAdder = new SerialVersionUIDAdder(null); classReader.accept(svuidAdder, 0); long svuid = svuidAdder.computeSVUID(); assertEquals(-2126445979242430981L, svuid); }