-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
muzzle field and method matching #422
Changes from 8 commits
d257fdb
a8027dd
57c1c0d
8497b81
711e8e3
30fda8a
c1ec598
0cbef2d
50ed54c
8421dfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import datadog.trace.bootstrap.DatadogClassLoader; | ||
import datadog.trace.bootstrap.DatadogClassLoader.BootstrapClassLoaderProxy; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.net.URL; | ||
|
||
|
@@ -74,6 +75,30 @@ public static String getClassName(final String resourceName) { | |
return resourceName.replaceAll("\\.class\\$", "").replace('/', '.'); | ||
} | ||
|
||
/** com.foo.Bar -> com/foo/Bar */ | ||
public static String getInternalName(final String resourceName) { | ||
return resourceName.replaceAll("\\.class\\$", "").replace('.', '/'); | ||
} | ||
|
||
public static boolean isClassLoaded(final String className, final ClassLoader classLoader) { | ||
Class<?> loadedClass = findLoadedClass(className, classLoader); | ||
return loadedClass != null && loadedClass.getClassLoader() == classLoader; | ||
} | ||
|
||
public static Class<?> findLoadedClass(final String className, ClassLoader classLoader) { | ||
if (classLoader == ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER) { | ||
classLoader = ClassLoader.getSystemClassLoader(); | ||
} | ||
try { | ||
findLoadedClassMethod.setAccessible(true); | ||
return (Class<?>) findLoadedClassMethod.invoke(classLoader, className); | ||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { | ||
throw new IllegalStateException(e); | ||
} finally { | ||
findLoadedClassMethod.setAccessible(false); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn 't the plan to remove these methods to avoid Java10 problems? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, I brought that back when I resolved a merge conflict. I forgot that we intentionally removed it. |
||
|
||
static boolean getConfigEnabled(final String name, final boolean fallback) { | ||
final String property = | ||
System.getProperty( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this
this
es would get wiped out by our current IDEA config - but I guess not by gradle formatterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing for consistency.