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.

Match only if another class is accessible on the classloader's classpath

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
raphwcommented, Nov 1, 2017

Yes, in order to resolve all methods, Byte Buddy has to get hold of Method objects 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.

0reactions
raphwcommented, Apr 3, 2018

Closing, please reopen if this is still relevant.

Read more comments on GitHub >

github_iconTop 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 >

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