Skip to content

Commit 92bd65c

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 87670e6 commit 92bd65c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/PipelineResources.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package org.apache.beam.runners.core.construction;
1919

20+
import com.google.common.base.Splitter;
21+
import com.google.common.base.StandardSystemProperty;
2022
import java.io.File;
2123
import java.net.URISyntaxException;
2224
import java.net.URL;
@@ -37,6 +39,11 @@ public class PipelineResources {
3739
* @return A list of absolute paths to the resources the class loader uses.
3840
*/
3941
public static List<String> detectClassPathResourcesToStage(ClassLoader classLoader) {
42+
if (classLoader == ClassLoader.getSystemClassLoader()) {
43+
return Splitter.on(File.pathSeparatorChar)
44+
.splitToList(StandardSystemProperty.JAVA_CLASS_PATH.value());
45+
}
46+
4047
if (!(classLoader instanceof URLClassLoader)) {
4148
String message = String.format("Unable to use ClassLoader to detect classpath elements. "
4249
+ "Current ClassLoader is %s, only URLClassLoaders are supported.", classLoader);

0 commit comments

Comments
 (0)