read J2SE jars from bootclasspath if wala.properties cannot be loaded
This commit is contained in:
parent
e82556450b
commit
7ca109967d
|
@ -17,6 +17,7 @@ import java.net.URL;
|
|||
import java.util.Collection;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.ibm.wala.util.PlatformUtil;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.io.FileProvider;
|
||||
|
@ -38,15 +39,17 @@ public final class WalaProperties {
|
|||
|
||||
/**
|
||||
* Determine the classpath noted in wala.properties for J2SE standard libraries
|
||||
* @throws IllegalStateException if there's a problem loading the wala properties
|
||||
*
|
||||
* If wala.properties cannot be loaded, returns jar files in boot classpath.
|
||||
* @throws IllegalStateException if jar files cannot be discovered
|
||||
* @see PlatformUtil#getBootClassPathJars()
|
||||
*/
|
||||
public static String[] getJ2SEJarFiles() {
|
||||
Properties p = null;
|
||||
try {
|
||||
p = WalaProperties.loadProperties();
|
||||
} catch (WalaException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException("problem loading wala.properties");
|
||||
return PlatformUtil.getBootClassPathJars();
|
||||
}
|
||||
|
||||
String dir = p.getProperty(WalaProperties.J2SE_DIR);
|
||||
|
@ -99,7 +102,7 @@ public final class WalaProperties {
|
|||
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
throw new WalaException("Unable to set up wala properties ", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Platform-specific utility functions.
|
||||
*/
|
||||
|
@ -47,4 +50,24 @@ public class PlatformUtil {
|
|||
return "IKVM.NET".equals(System.getProperty("java.runtime.name"));
|
||||
}
|
||||
|
||||
/**
|
||||
* get the jars in the boot classpath.
|
||||
* TODO test on more JVMs
|
||||
*
|
||||
* @throws IllegalStateException if boot classpath cannot be found
|
||||
*/
|
||||
public static String[] getBootClassPathJars() {
|
||||
String classpath = System.getProperty("sun.boot.class.path");
|
||||
if (classpath == null) {
|
||||
throw new IllegalStateException("could not find boot classpath");
|
||||
}
|
||||
String[] jars = classpath.split(File.pathSeparator);
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
for (String jar : jars) {
|
||||
if (jar.endsWith(".jar") && (new File(jar)).exists()) {
|
||||
result.add(jar);
|
||||
}
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue