diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | java/lang/System.java | 19 | ||||
-rw-r--r-- | java/security/Security.java | 21 | ||||
-rw-r--r-- | java/util/logging/LogManager.java | 30 | ||||
-rw-r--r-- | javax/naming/InitialContext.java | 22 |
5 files changed, 70 insertions, 35 deletions
@@ -1,3 +1,16 @@ +2002-12-31 Tom Tromey <tromey@redhat.com> + + * javax/naming/InitialContext.java (init): Use + gnu.classpath.home.url. + * java/util/logging/LogManager.java (readConfiguration): Use + gnu.classpath.home.url. + * java/security/Security.java: Use new properties. + (loadProviders): Accept base url; use it. + * java/lang/System.java: Document gnu.classpath.vm.shortname, and + gnu.classpath.home.url. + (gnu.classpath.home.url): Define. + (gnu.classpath.vm.shortname): Likewise. + 2002-12-28 Jeroen Frijters <jeroen@sumatra.nl> * gnu/java/net/protocol/file/Handler.java (parseURL): Make sure that diff --git a/java/lang/System.java b/java/lang/System.java index 7f6363550..1684a49a1 100644 --- a/java/lang/System.java +++ b/java/lang/System.java @@ -84,6 +84,21 @@ public final class System defaultProperties.put("gnu.classpath.version", Configuration.CLASSPATH_VERSION); + // Set base URL if not already set. + if (defaultProperties.get("gnu.classpath.home.url") == null) + defaultProperties.put("gnu.classpath.home.url", + "file://" + Configuration.CLASSPATH_HOME + "/lib"); + + // Set short name if not already set. + if (defaultProperties.get("gnu.classpath.vm.shortname") == null) + { + String value = defaultProperties.getProperty("java.vm.name"); + int index = value.lastIndexOf(' '); + if (index != -1) + value = value.substring(index + 1); + defaultProperties.put("gnu.classpath.vm.shortname", value); + } + defaultProperties.put("gnu.cpu.endian", VMSystem.isWordsBigEndian() ? "big" : "little"); @@ -435,6 +450,10 @@ public final class System * <dl> * <dl> gnu.classpath.home <dd> Path to the classpath libraries. * <dl> gnu.classpath.version <dd> Version of the classpath libraries. + * <dl> gnu.classpath.vm.shortname <dd> Succinct version of the VM name; + * used for finding property files in file system + * <dl> gnu.classpath.home.url <dd> Base URL; used for finding + * property files in file system * <dt> gnu.cpu.endian <dd>big or little * <dt> gnu.java.io.encoding_scheme_alias.ISO-8859-? <dd>8859_? * <dt> gnu.java.io.encoding_scheme_alias.iso-8859-? <dd>8859_? diff --git a/java/security/Security.java b/java/security/Security.java index bf7a993ad..39d75eef0 100644 --- a/java/security/Security.java +++ b/java/security/Security.java @@ -37,9 +37,10 @@ exception statement from your version. */ package java.security; import java.io.File; -import java.io.FileInputStream; +import java.io.InputStream; import java.io.IOException; import java.io.FileNotFoundException; +import java.net.URL; import java.security.Provider; import java.util.Vector; import java.util.Enumeration; @@ -59,9 +60,9 @@ public final class Security extends Object static { - loadProviders(System.getProperty("java.home"), - System.getProperty("java.vm.name")); - loadProviders(System.getProperty("gnu.classpath.home"), "classpath"); + String base = System.getProperty("gnu.classpath.home.url"); + loadProviders(base, System.getProperty("gnu.classpath.vm.shortname")); + loadProviders(base, "classpath"); } // This class can't be instantiated. @@ -69,20 +70,16 @@ public final class Security extends Object { } - private static void loadProviders(String dir, String vendor) + private static void loadProviders(String baseUrl, String vendor) { - if (dir == null || vendor == null) + if (baseUrl == null || vendor == null) return; - String separator = System.getProperty("file.separator"); - String secfilestr = (dir + - separator + "lib" + - separator + "security" + - separator + vendor + ".security"); + String secfilestr = baseUrl + "/security/" + vendor + ".security"; try { - FileInputStream fin = new FileInputStream(secfilestr); + InputStream fin = new URL(secfilestr).openStream(); secprops = new Properties(); secprops.load(fin); diff --git a/java/util/logging/LogManager.java b/java/util/logging/LogManager.java index 80df7a385..a137c8ef3 100644 --- a/java/util/logging/LogManager.java +++ b/java/util/logging/LogManager.java @@ -46,6 +46,7 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.util.Collections; import java.util.Properties; import java.util.Enumeration; @@ -91,11 +92,11 @@ import java.lang.ref.WeakReference; * property <code>java.util.logging.config.file</code>.</li> * * <li>If the system property <code>java.util.logging.config.file</code> - * is not set, however, the contents of the file - * "{java.home}/lib/logging.properties" are passed to + * is not set, however, the contents of the URL + * "{gnu.classpath.home.url}/lib/logging.properties" are passed to * {@link #readConfiguration(java.io.InputStream)}. - * Here, "{java.home}" stands for the value of - * the system property <code>java.home</code>.</li> + * Here, "{gnu.classpath.home.url}" stands for the value of + * the system property <code>gnu.classpath.home.url</code>.</li> * </ol> * * @author Sascha Brawer (brawer@acm.org) @@ -467,9 +468,10 @@ public class LogManager * Configures the logging framework by reading a configuration file. * The name and location of this file are specified by the system * property <code>java.util.logging.config.file</code>. If this - * property is not set, the file "{java.home}/lib/logging.properties" - * is taken, where "{java.home}" stands for the value of the system - * property <code>java.home</code>. + * property is not set, the URL + * "{gnu.classpath.home.url}/lib/logging.properties" is taken, where + * "{gnu.classpath.home.url}" stands for the value of the system + * property <code>gnu.classpath.home.url</code>. * * <p>The task of configuring the framework is then delegated to * {@link #readConfiguration(java.io.InputStream)}, which will @@ -488,19 +490,19 @@ public class LogManager throws IOException, SecurityException { String path; - String pathSep; InputStream inputStream; path = System.getProperty("java.util.logging.config.file"); if ((path == null) || (path.length() == 0)) { - pathSep = System.getProperty("file.separator"); - path = System.getProperty("java.home") - + pathSep + "lib" - + pathSep + "logging.properties"; + String url = (System.getProperty("gnu.classpath.home.url") + + "/lib/logging.properties"); + inputStream = new URL(url).openStream(); + } + else + { + inputStream = new java.io.FileInputStream(path); } - - inputStream = new java.io.FileInputStream(path); try { diff --git a/javax/naming/InitialContext.java b/javax/naming/InitialContext.java index 99ae426e9..19f241772 100644 --- a/javax/naming/InitialContext.java +++ b/javax/naming/InitialContext.java @@ -1,5 +1,5 @@ /* InitialContext.java -- - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -126,18 +126,22 @@ public class InitialContext implements Context } catch (IOException e) {} - String home = System.getProperty("java.home"); + String home = System.getProperty("gnu.classpath.home.url"); if (home != null) { - String fileName = home + File.separator - + "lib" + File.separator + "jndi.properties"; + String url = home + "/lib/jndi.properties"; Properties p = new Properties (); - try { - InputStream is = new FileInputStream (fileName); - p.load (is); - is.close (); - } catch (IOException e) {} + try + { + InputStream is = new URL(url).openStream(); + p.load (is); + is.close (); + } + catch (IOException e) + { + // Ignore. + } merge (myProps, p); } |