Changing the visibility of a method
<p>Is it possible to (just) change the visibility of some methods with Byte Buddy ? I have a user class with private static methods, and I'd need to delegate some calls to those methods, but it currently fails because they are private. So, I wonder if I can redefine the user class, by tranforming the aforementioned methods by adding a public modifier. </p>

<p>For the record, calling <code>setAccessible(true)</code> method on the target Java method as not effect, as Byte Buddy still fails with the following exception:</p>

<pre><code>java.lang.IllegalStateException: class net.bytebuddy.renamed.java.lang.Object$ByteBuddy$VHdvjIkb cannot see private java.lang.String org.mockaccino.MockaccinoTest.lambda$3() throws java.lang.Exception
at net.bytebuddy.implementation.MethodCall$MethodInvoker$ForContextualInvocation.invoke(MethodCall.java:2387)
...
</code></pre>

<p>I've found some APIs that might do the trick, but I need to instrument the methods, which is not needed in my case.</p>

<p>Eg:</p>

<pre><code>byteBuddy.redefine(targetClass)
  .method(ElementMatchers.named(targetMethod.getName()))
  .intercept(???)
  .transform(Transformer.ForMethod.withModifiers(Visibility.PUBLIC))
  .make()
  .load(getClassLoader(), ClassReloadingStrategy.fromInstalledAgent());
</code></pre>

<p>My question is: is there an interceptor that is able of calling the body of source method that is being redefined ? </p>

<p>Or is there another way to make the target methods publicly visible ?</p>