@@ -116,7 +116,7 @@ public AgentClassLoader(File javaagentFile, String internalJarFileName) {
116
116
117
117
private static ClassLoader getParentClassLoader () {
118
118
if (JAVA_VERSION > 8 ) {
119
- return new JdkHttpServerClassLoader ();
119
+ return new PlatformDelegatingClassLoader ();
120
120
}
121
121
return null ;
122
122
}
@@ -441,7 +441,10 @@ public long getContentLengthLong() {
441
441
}
442
442
}
443
443
444
- private static class JdkHttpServerClassLoader extends ClassLoader {
444
+ // We don't always delegate to platform loader because platform class loader also contains user
445
+ // classes when running a modular application. We don't want these classes interfering with the
446
+ // agent.
447
+ private static class PlatformDelegatingClassLoader extends ClassLoader {
445
448
446
449
static {
447
450
// this class loader doesn't load any classes, so this is technically unnecessary,
@@ -452,14 +455,16 @@ private static class JdkHttpServerClassLoader extends ClassLoader {
452
455
453
456
private final ClassLoader platformClassLoader = getPlatformLoader ();
454
457
455
- public JdkHttpServerClassLoader () {
458
+ public PlatformDelegatingClassLoader () {
456
459
super (null );
457
460
}
458
461
459
462
@ Override
460
463
protected Class <?> loadClass (String name , boolean resolve ) throws ClassNotFoundException {
461
464
// prometheus exporter uses jdk http server, load it from the platform class loader
462
- if (name != null && name .startsWith ("com.sun.net.httpserver." )) {
465
+ // some custom extensions use java.sql classes, make these available to agent and extensions
466
+ if (name != null
467
+ && (name .startsWith ("com.sun.net.httpserver." ) || name .startsWith ("java.sql." ))) {
463
468
return platformClassLoader .loadClass (name );
464
469
}
465
470
return Class .forName (name , false , null );
0 commit comments