Make ExtendedGroovyClassLoader compatible with Java 9
Closes gh-10445
This commit is contained in:
parent
bec2e97b95
commit
ebf3b47305
|
|
@ -175,7 +175,8 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
|
|||
|
||||
DefaultScopeParentClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
this.groovyOnlyClassLoader = new URLClassLoader(getGroovyJars(parent), null);
|
||||
this.groovyOnlyClassLoader = new URLClassLoader(getGroovyJars(parent),
|
||||
parent.getParent());
|
||||
}
|
||||
|
||||
private URL[] getGroovyJars(final ClassLoader parent) {
|
||||
|
|
@ -232,7 +233,9 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
|
|||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve)
|
||||
throws ClassNotFoundException {
|
||||
this.groovyOnlyClassLoader.loadClass(name);
|
||||
if (!name.startsWith("java.")) {
|
||||
this.groovyOnlyClassLoader.loadClass(name);
|
||||
}
|
||||
return super.loadClass(name, resolve);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -64,4 +64,10 @@ public class ExtendedGroovyClassLoaderTests {
|
|||
this.defaultScopeGroovyClassLoader.loadClass("java.lang.Boolean");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadsSqlTypes() throws Exception {
|
||||
this.contextClassLoader.loadClass("java.sql.SQLException");
|
||||
this.defaultScopeGroovyClassLoader.loadClass("java.sql.SQLException");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue