Program: 26311
Project: 26311
Buggy source:
private static ByteBufferReuse getReuse(){
  ClassWriter cw=new ClassWriter(0);
  MethodVisitor mv;
  final String reuseImplClassName="String_Node_Str";
  cw.visit(V1_6,ACC_PUBLIC + ACC_SUPER,reuseImplClassName,null,"String_Node_Str",new String[]{"String_Node_Str"});
{
    mv=cw.visitMethod(ACC_PUBLIC,"String_Node_Str","String_Node_Str",null,null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD,0);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitInsn(RETURN);
    mv.visitMaxs(1,1);
    mv.visitEnd();
  }
  String attachedBufferFieldName=getAttachedBufferFieldName();
{
    mv=cw.visitMethod(ACC_PUBLIC,"String_Node_Str","String_Node_Str",null,null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD,5);
    String directByteBuffer="String_Node_Str";
    mv.visitTypeInsn(INSTANCEOF,directByteBuffer);
    Label l0=new Label();
    mv.visitJumpInsn(IFEQ,l0);
    mv.visitVarInsn(ALOAD,5);
    mv.visitTypeInsn(CHECKCAST,directByteBuffer);
    mv.visitVarInsn(ASTORE,6);
    mv.visitVarInsn(ALOAD,6);
    mv.visitFieldInsn(GETFIELD,directByteBuffer,attachedBufferFieldName,"String_Node_Str");
    String settableAtt="String_Node_Str";
    mv.visitTypeInsn(INSTANCEOF,settableAtt);
    mv.visitJumpInsn(IFEQ,l0);
    mv.visitVarInsn(ALOAD,6);
    mv.visitVarInsn(LLOAD,1);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitInsn(ICONST_M1);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitInsn(ICONST_0);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitVarInsn(ILOAD,3);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitVarInsn(ILOAD,3);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitFieldInsn(GETFIELD,directByteBuffer,attachedBufferFieldName,"String_Node_Str");
    mv.visitTypeInsn(CHECKCAST,settableAtt);
    mv.visitVarInsn(ALOAD,4);
    mv.visitFieldInsn(PUTFIELD,settableAtt,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitInsn(ARETURN);
    mv.visitLabel(l0);
    mv.visitFrame(Opcodes.F_SAME,0,null,0,null);
    mv.visitTypeInsn(NEW,settableAtt);
    mv.visitInsn(DUP);
    mv.visitMethodInsn(INVOKESPECIAL,settableAtt,"String_Node_Str","String_Node_Str",false);
    mv.visitVarInsn(ASTORE,6);
    mv.visitVarInsn(ALOAD,6);
    mv.visitVarInsn(ALOAD,4);
    mv.visitFieldInsn(PUTFIELD,settableAtt,"String_Node_Str","String_Node_Str");
    mv.visitTypeInsn(NEW,directByteBuffer);
    mv.visitInsn(DUP);
    mv.visitVarInsn(LLOAD,1);
    mv.visitVarInsn(ILOAD,3);
    mv.visitVarInsn(ALOAD,6);
    mv.visitMethodInsn(INVOKESPECIAL,directByteBuffer,"String_Node_Str","String_Node_Str",false);
    mv.visitInsn(ARETURN);
    mv.visitMaxs(6,7);
    mv.visitEnd();
  }
  cw.visitEnd();
  final byte[] impl=cw.toByteArray();
  final Unsafe unsafe=NativeBytes.UNSAFE;
  Class<ByteBufferReuse> clazz=AccessController.doPrivileged(new PrivilegedAction<Class<ByteBufferReuse>>(){
    @Override public Class<ByteBufferReuse> run(){
      ClassLoader cl=MAGIC_CLASS_LOADER;
      return unsafe.defineClass(reuseImplClassName,impl,0,impl.length,cl,null);
    }
  }
);
  try {
    return clazz.newInstance();
  }
 catch (  InstantiationException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private static ByteBufferReuse getReuse(){
  ClassWriter cw=new ClassWriter(0);
  MethodVisitor mv;
  final String reuseImplClassName="String_Node_Str";
  cw.visit(V1_6,ACC_PUBLIC + ACC_SUPER,reuseImplClassName,null,"String_Node_Str",new String[]{"String_Node_Str"});
{
    mv=cw.visitMethod(ACC_PUBLIC,"String_Node_Str","String_Node_Str",null,null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD,0);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitInsn(RETURN);
    mv.visitMaxs(1,1);
    mv.visitEnd();
  }
  String attachedBufferFieldName=getAttachedBufferFieldName();
{
    mv=cw.visitMethod(ACC_PUBLIC,"String_Node_Str","String_Node_Str",null,null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD,5);
    String directByteBuffer="String_Node_Str";
    mv.visitTypeInsn(INSTANCEOF,directByteBuffer);
    Label l0=new Label();
    mv.visitJumpInsn(IFEQ,l0);
    mv.visitVarInsn(ALOAD,5);
    mv.visitTypeInsn(CHECKCAST,directByteBuffer);
    mv.visitVarInsn(ASTORE,6);
    mv.visitVarInsn(ALOAD,6);
    mv.visitFieldInsn(GETFIELD,directByteBuffer,attachedBufferFieldName,"String_Node_Str");
    String settableAtt="String_Node_Str";
    mv.visitTypeInsn(INSTANCEOF,settableAtt);
    mv.visitJumpInsn(IFEQ,l0);
    mv.visitVarInsn(ALOAD,6);
    mv.visitVarInsn(LLOAD,1);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitInsn(ICONST_M1);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitInsn(ICONST_0);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitVarInsn(ILOAD,3);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitVarInsn(ILOAD,3);
    mv.visitFieldInsn(PUTFIELD,directByteBuffer,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitFieldInsn(GETFIELD,directByteBuffer,attachedBufferFieldName,"String_Node_Str");
    mv.visitTypeInsn(CHECKCAST,settableAtt);
    mv.visitVarInsn(ALOAD,4);
    mv.visitFieldInsn(PUTFIELD,settableAtt,"String_Node_Str","String_Node_Str");
    mv.visitVarInsn(ALOAD,6);
    mv.visitInsn(ARETURN);
    mv.visitLabel(l0);
    mv.visitFrame(Opcodes.F_SAME,0,null,0,null);
    mv.visitTypeInsn(NEW,settableAtt);
    mv.visitInsn(DUP);
    mv.visitMethodInsn(INVOKESPECIAL,settableAtt,"String_Node_Str","String_Node_Str",false);
    mv.visitVarInsn(ASTORE,6);
    mv.visitVarInsn(ALOAD,6);
    mv.visitVarInsn(ALOAD,4);
    mv.visitFieldInsn(PUTFIELD,settableAtt,"String_Node_Str","String_Node_Str");
    mv.visitTypeInsn(NEW,directByteBuffer);
    mv.visitInsn(DUP);
    mv.visitVarInsn(LLOAD,1);
    mv.visitVarInsn(ILOAD,3);
    mv.visitVarInsn(ALOAD,6);
    mv.visitMethodInsn(INVOKESPECIAL,directByteBuffer,"String_Node_Str","String_Node_Str",false);
    mv.visitInsn(ARETURN);
    mv.visitMaxs(6,7);
    mv.visitEnd();
  }
  cw.visitEnd();
  final byte[] impl=cw.toByteArray();
  final Unsafe unsafe=NativeBytes.UNSAFE;
  Class<ByteBufferReuse> clazz=AccessController.doPrivileged(new PrivilegedAction<Class<ByteBufferReuse>>(){
    @Override public Class<ByteBufferReuse> run(){
      ClassLoader cl=MAGIC_CLASS_LOADER;
      return (Class<ByteBufferReuse>)unsafe.defineClass(reuseImplClassName,impl,0,impl.length,cl,null);
    }
  }
);
  try {
    return clazz.newInstance();
  }
 catch (  InstantiationException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}