@@ -0,0 +1,2742 @@
+package net.bytebuddy.test.c;%0A%0Aimport net.bytebuddy.agent.ByteBuddyAgent;%0Aimport org.objectweb.asm.*;%0A%0Aimport java.lang.instrument.ClassFileTransformer;%0Aimport java.lang.instrument.Instrumentation;%0Aimport java.security.ProtectionDomain;%0A%0Apublic class Sample %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        ClassReader reader = new ClassReader(%22net.bytebuddy.test.c.NativeSample%22);%0A        ClassWriter writer = new ClassWriter(0);%0A        reader.accept(new ClassVisitor(Opcodes.ASM8, writer) %7B%0A%0A            @Override%0A            public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String%5B%5D exceptions) %7B%0A                if (name.equals(%22foo%22)) %7B%0A                    super.visitMethod(Opcodes.ACC_PRIVATE %7C Opcodes.ACC_NATIVE, %22$$renamed$$foo%22, descriptor, signature, exceptions).visitEnd();%0A                    MethodVisitor visitor = super.visitMethod(Opcodes.ACC_PUBLIC, name, descriptor, signature, exceptions);%0A                    visitor.visitCode();%0A                    visitor.visitVarInsn(Opcodes.ALOAD, 0);%0A                    visitor.visitVarInsn(Opcodes.ILOAD, 1);%0A                    visitor.visitInsn(Opcodes.ICONST_2);%0A                    visitor.visitMethodInsn(Opcodes.INVOKESPECIAL, %22net/bytebuddy/test/c/NativeSample%22, %22$$renamed$$foo%22, descriptor, false);%0A                    visitor.visitInsn(Opcodes.IRETURN);%0A                    visitor.visitMaxs(3, 3);%0A                    visitor.visitEnd();%0A                    return null;%0A                %7D else %7B%0A                    return super.visitMethod(access, name, descriptor, signature, exceptions);%0A                %7D%0A            %7D%0A        %7D, 0);%0A%0A%0A        ClassFileTransformer transformer = new ClassFileTransformer() %7B%0A            @Override%0A            public byte%5B%5D transform(ClassLoader loader,%0A                                    String className,%0A                                    Class%3C?%3E classBeingRedefined,%0A                                    ProtectionDomain protectionDomain,%0A                                    byte%5B%5D classfileBuffer) %7B%0A                if (%22net/bytebuddy/test/c/NativeSample%22.equals(className)) %7B%0A                    return writer.toByteArray();%0A                %7D else %7B%0A                    return null;%0A                %7D%0A            %7D%0A        %7D;%0A%0A        Class.forName(%22net.bytebuddy.test.c.NativeSample%22);%0A%0A        Instrumentation instrumentation = ByteBuddyAgent.install();%0A        instrumentation.addTransformer(transformer, true);%0A        instrumentation.setNativeMethodPrefix(transformer, %22$$renamed$$%22);%0A%0A        instrumentation.retransformClasses(NativeSample.class);%0A%0A        int result = new NativeSample().foo(42, 1);%0A        System.out.println(result);%0A    %7D%0A%0A%7D%0A

Add sample for same issue.