Updated to work with JDK 1.1.x properly: added try...catch and null checks

for various places system properties, etc. may be unavailable on 1.1.x systems;
Check for new JAXP related jars


git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@225992 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
curcuru 2002-08-06 21:37:15 +00:00
parent 7c30a0a75d
commit 44d3664db4
3 changed files with 49 additions and 3 deletions

View File

@ -177,7 +177,6 @@ public class Which
try
{
hash.put("java" + WhichConstant.TAG_VERSION, System.getProperty("java.version"));
hash.put("java.runtime.name", System.getProperty("java.runtime.name"));
hash.put("file.encoding", System.getProperty("file.encoding"));
hash.put("java.vendor", System.getProperty("java.vendor"));
hash.put("os.name", System.getProperty("os.name"));
@ -185,6 +184,15 @@ public class Which
catch (Exception e)
{
hash.put("Which" + WhichConstant.TAG_ERROR, "Accessing System.getProperty(...) threw: " + e.toString());
}
try
{
// Not available on JDK 1.1.x
hash.put("java.runtime.name", System.getProperty("java.runtime.name"));
}
catch (Exception e)
{
hash.put("Which" + WhichConstant.TAG_ERROR + "11x", "Accessing System.getProperty(java.runtime.name) threw: " + e.toString());
}
}
@ -230,11 +238,14 @@ public class Which
Hashtable subHash = new Hashtable();
WhichProject proj = WhichFactory.newWhichProject(projName,
options);
int tmpRetVal = proj.getInfo(subHash, options);
int subStatus = proj.getInfo(subHash, options);
subHash.put(projName + WhichConstant.TAG_STATUS,
WhichConstant.ITEM_DESC[subStatus]);
hash.put(projName + WhichConstant.TAG_HASHINFO, subHash);
retVal = Math.max(tmpRetVal, retVal);
retVal = Math.max(subStatus, retVal);
}
catch (Exception e)
{
@ -243,6 +254,7 @@ public class Which
hash.put(projName
+ WhichConstant.ITEM_DESC[WhichConstant.ITEM_ERROR],
"newWhichProject threw: " + e.toString());
e.printStackTrace();
retVal = Math.max(WhichConstant.ITEM_ERROR, retVal);
}

View File

@ -157,6 +157,20 @@ public abstract class WhichJar // prevent instantiation; provide static service
// Grab the actual path from the System
String path = System.getProperty(pathName);
if (null == path)
{
// Protect cases where the path isn't found
hash.put(
jarName
+ WhichConstant.ITEM_DESC[WhichConstant.ITEM_WARNING],
"searchPath [" + pathName
+ "] not found!");
return (WhichConstant.isStrict(options)
? WhichConstant.ITEM_WARNING
: WhichConstant.ITEM_NOTFOUND);
}
StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
int retVal = WhichConstant.ITEM_UNKNOWN;
boolean jarFound = false;
@ -238,6 +252,20 @@ public abstract class WhichJar // prevent instantiation; provide static service
// Grab the actual path(s) from the System
String path = System.getProperty(pathName);
if (null == path)
{
// Protect cases where the path isn't found
hash.put(
jarName
+ WhichConstant.ITEM_DESC[WhichConstant.ITEM_WARNING],
" searchDirs [" + pathName
+ "] not found!");
return (WhichConstant.isStrict(options)
? WhichConstant.ITEM_WARNING
: WhichConstant.ITEM_NOTFOUND);
}
StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
int retVal = WhichConstant.ITEM_UNKNOWN;

View File

@ -213,6 +213,12 @@ public class WhichXmlCommons implements WhichProject
// Try to find older jaxp.jar in the classpath, etc.
int ignored = WhichJar.searchClasspaths(hash, "jaxp.jar", options);
// Also try to find varous Sun shipped classes from JAXP packs, etc.
ignored = WhichJar.searchClasspaths(hash, "dom.jar", options);
ignored = WhichJar.searchClasspaths(hash, "sax.jar", options);
ignored = WhichJar.searchClasspaths(hash, "jaxp-api.jar", options);
return status;
}