Improper visibility restrictions when applying `MemberSubstitution`
See original GitHub issueIn 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 tosuper.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:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for the slow response, new baby makes me little productive these weeks. I’ll have a look soon.
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!