question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improper visibility restrictions when applying `MemberSubstitution`

See original GitHub issue

In your suggestion in #483:

You can then register a member substitution to replace the call to blaBla(thiz, object) in the advice class with a call to super.blaBla(arg).

This doesn’t seem to work if the super call isn’t accessible to the advice class. https://github.com/raphw/byte-buddy/blob/master/byte-buddy-dep/src/main/java/net/bytebuddy/asm/MemberSubstitution.java#L1121-L1123

For example, say I have some advice:

public class AbstractExecutorAdvice {
    @Advice.OnMethodEnter
    public static void execute(
        @Advice.This AbstractExecutorService executor,
        @Advice.Argument(value = 0, readOnly = false) Runnable task) {
      task = superNewTaskFor(executor, task, null);
    }

    private static <T> RunnableFuture<T> superNewTaskFor(
        AbstractExecutorService executor, Runnable runnable, T value) {
      return null;
    }
}

This results in the following exception with MemberSubstitution applied:

Caused by: java.lang.IllegalStateException: class AbstractExecutorAdvice cannot access protected java.util.concurrent.RunnableFuture java.util.concurrent.AbstractExecutorService.newTaskFor(java.lang.Runnable,java.lang.Object)
        at net.bytebuddy.asm.MemberSubstitution$Substitution$ForMethodInvocation.resolve(MemberSubstitution.java:1122)
        at net.bytebuddy.asm.MemberSubstitution$Replacement$Binding$Resolved.make(MemberSubstitution.java:1755)
        at net.bytebuddy.asm.MemberSubstitution$SubstitutingMethodVisitor.visitMethodInsn(MemberSubstitution.java:2371)
MemberSubstitution.strict()
  .method(named("superNewTaskFor"))
  .replaceWith(AbstractExecutorService.class.getDeclaredMethod("newTaskFor", Runnable.class, Object.class))
  .on(any())

It would also be nice if #484 could handle this case without the need for MemberSubstitution.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
raphwcommented, Dec 3, 2020

Sorry for the slow response, new baby makes me little productive these weeks. I’ll have a look soon.

0reactions
raphwcommented, Dec 14, 2020

Yes, it’s still on the agenda. I have looked into it briefly but I want to plug a member substitution eventually which did not fit together well yet. But I certainly want to add it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Operating in Restricted Visibility | BOATERexam.com®
What to do when operating in restricted visibility, including rules for ... WHEN VISIBILITY IS RESTRICTED BY FOG OR SMOKE, ADDITIONAL SOUND SIGNALS...
Read more >
AC 120-35D - Advisory Circular
This advisory circular (AC) presents guidelines for the design and implementation of Line-Operational Simulations (LOS), including Line-Oriented ...
Read more >
Cannot add MemberSubstitution using Bytebuddy
I'm trying to add a MemberSubstitution using ByteBuddy to intercept any access to a specific field, but when running the following code I ......
Read more >
OFFICIAL 2017 RACE BIBLE - Index of - Ragnar Relay
H) Visible Race Number . ... name is inappropriate you will receive an email from the Race Director asking ... Specific rules apply...
Read more >
Low Visibility Procedures (LVP) | SKYbrary Aviation Safety
Low visibility procedures (LVP) are applied at an aerodrome for the purpose ... is required and special procedures, including restrictions on normal access, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found