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

Commit 7d3e0ce

Browse files
committed
Make classloader handling more compatible with JDK 9
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.
1 parent 85556d0 commit 7d3e0ce

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sdk/src/main/java/com/google/cloud/dataflow/sdk/runners/DataflowPipelineRunner.java

+6
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@
136136
import com.google.common.base.Function;
137137
import com.google.common.base.Joiner;
138138
import com.google.common.base.Optional;
139+
import com.google.common.base.Splitter;
140+
import com.google.common.base.StandardSystemProperty;
139141
import com.google.common.base.Strings;
140142
import com.google.common.base.Utf8;
141143
import com.google.common.collect.ForwardingMap;
@@ -3198,6 +3200,10 @@ public String toString() {
31983200
* @return A list of absolute paths to the resources the class loader uses.
31993201
*/
32003202
protected static List<String> detectClassPathResourcesToStage(ClassLoader classLoader) {
3203+
if (classLoader == ClassLoader.getSystemClassLoader()) {
3204+
return Splitter.on(File.pathSeparatorChar)
3205+
.splitToList(StandardSystemProperty.JAVA_CLASS_PATH.value());
3206+
}
32013207
if (!(classLoader instanceof URLClassLoader)) {
32023208
String message = String.format("Unable to use ClassLoader to detect classpath elements. "
32033209
+ "Current ClassLoader is %s, only URLClassLoaders are supported.", classLoader);

0 commit comments

Comments
 (0)