Match only if another class is accessible on the classloader's classpath
See original GitHub issueI would like to write instrumentation that is only applied if certain classes are available on the classpath.
Basically, want to I write an Advice that has a provided/compileOnly dependency on a class and I only want that instrumentation to be applied if that class is accessible on the classpath.
Any suggestions on how to do this? Would this be too expensive?
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
URLClassLoader and accessibility of package-private methods
So, if you use different classloaders for the two classes, it will not match. EDIT: The full call chain (on request) is: Method.invoke()...
Read more >Implementing Java Class Isolation Loading - Alibaba Cloud
Classes loaded by different class loaders are considered as two different classes in the JVM because the unique identifier of a class in...
Read more >Setting the class path
The class path is the path that the Java runtime environment searches for classes and other resource files. The class search path (more...
Read more >How ClassLoader Works in Java? Example - Javarevisited
Java class loaders are used to load classes at runtime. ClassLoader in Java works on three principles: delegation, visibility, and uniqueness.
Read more >Chapter 3. Class Loading and Modules Red Hat JBoss ...
Developers have fine-grained control of the classes available to their ... each other unless dependencies are explicitly declared as Class-Path entries in ...
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

Yes, in order to resolve all methods, Byte Buddy has to get hold of
Methodobjects when operating on a loaded type what is rather expensive as it involves security checks and other overhead. Also, the algorithm to resolve methods down a hierarchy (including several type of bridges and visibilities) is quite expensive in itself. If you can avoid it, it is a win.Closing, please reopen if this is still relevant.