diff options
author | Andy Clement <aclement@pivotal.io> | 2017-09-27 14:46:47 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2017-09-27 14:46:47 -0700 |
commit | 23ee46988073b56e041aaabc05ff9d436732d6fe (patch) | |
tree | e0f5b9545c94a53c0312a054166dc043bd269508 /weaver | |
parent | 40fa8c710f916d3b44a8d133fc15b70f3cad813c (diff) | |
download | aspectj-23ee46988073b56e041aaabc05ff9d436732d6fe.tar.gz aspectj-23ee46988073b56e041aaabc05ff9d436732d6fe.zip |
Smarter classpath detection on Java9
On Java9 cannot rely on URLClassLoader being found from which
to determine classpath so use the environment variable. This may
have issues if loaders are being constructed that specifically
deviate from the java.class.path.
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index d0e24f8b2..c372afc83 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -20,7 +20,17 @@ import java.io.PrintWriter; import java.net.URL; import java.net.URLClassLoader; import java.security.ProtectionDomain; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; @@ -134,11 +144,20 @@ public class WeavingAdaptor implements IMessageContext { warn("cannot determine classpath"); } } - list.addAll(0, makeClasspath(System.getProperty("sun.boot.class.path"))); - // On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem + // On Java9 it is possible to fail to find a URLClassLoader from which to derive a suitable classpath + // For now we can determine it from the java.class.path: if (LangUtil.is19VMOrGreater()) { - list.add(0, LangUtil.getJrtFsFilePath()); + list.add(0, LangUtil.getJrtFsFilePath()); + List<String> javaClassPathEntries = makeClasspath(System.getProperty("java.class.path")); + for (int i=javaClassPathEntries.size()-1;i>=0;i--) { + String javaClassPathEntry = javaClassPathEntries.get(i); + if (!list.contains(javaClassPathEntry)) { + list.add(0,javaClassPathEntry); + } + } } + // On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem + list.addAll(0, makeClasspath(System.getProperty("sun.boot.class.path"))); return list; } |