Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Commit

Permalink
Make classloader handling more compatible with JDK 9
Browse files Browse the repository at this point in the history
From
http://www.oracle.com/technetwork/java/javase/9-relnote-issues-3704069.html:

The application class loader is no longer an instance of
java.net.URLClassLoader (an implementation detail that was never
specified in previous releases). Code that assumes that
ClassLoader::getSytemClassLoader returns a URLClassLoader object will
need to be updated. Note that Java SE and the JDK do not provide an API
for applications or libraries to dynamically augment the class path at
run-time.
  • Loading branch information
cushon committed Jan 26, 2018
1 parent 85556d0 commit 7d3e0ce
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.base.Splitter;
import com.google.common.base.StandardSystemProperty;
import com.google.common.base.Strings;
import com.google.common.base.Utf8;
import com.google.common.collect.ForwardingMap;
Expand Down Expand Up @@ -3198,6 +3200,10 @@ public String toString() {
* @return A list of absolute paths to the resources the class loader uses.
*/
protected static List<String> detectClassPathResourcesToStage(ClassLoader classLoader) {
if (classLoader == ClassLoader.getSystemClassLoader()) {
return Splitter.on(File.pathSeparatorChar)
.splitToList(StandardSystemProperty.JAVA_CLASS_PATH.value());
}
if (!(classLoader instanceof URLClassLoader)) {
String message = String.format("Unable to use ClassLoader to detect classpath elements. "
+ "Current ClassLoader is %s, only URLClassLoaders are supported.", classLoader);
Expand Down

0 comments on commit 7d3e0ce

Please sign in to comment.