Commit 9f17a7af by Tom Tromey Committed by Tom Tromey

re PR libgcj/7416 (java.security startup refs "GNU libgcj.security")

	Fix for PR libgcj/7416:
	* javax/naming/InitialContext.java (init): 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.

From-SVN: r60722
parent 3d1252a9
2002-12-31 Tom Tromey <tromey@redhat.com> 2002-12-31 Tom Tromey <tromey@redhat.com>
Fix for PR libgcj/7416:
* javax/naming/InitialContext.java (init): 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-31 Tom Tromey <tromey@redhat.com>
Ranjit Mathew <rmathew@hotmail.com> Ranjit Mathew <rmathew@hotmail.com>
Fix for PR libgcj/8997: Fix for PR libgcj/8997:
......
...@@ -73,15 +73,32 @@ public final class System ...@@ -73,15 +73,32 @@ public final class System
loadLibrary("javalang"); loadLibrary("javalang");
Properties defaultProperties = Runtime.defaultProperties; Properties defaultProperties = Runtime.defaultProperties;
defaultProperties.put("gnu.cpu.endian",
isWordsBigEndian() ? "big" : "little");
// Set base URL if not already set.
if (defaultProperties.get("gnu.classpath.home.url") == null)
defaultProperties.put("gnu.classpath.home.url",
"file://"
+ defaultProperties.get("gnu.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",
isWordsBigEndian() ? "big" : "little");
// XXX FIXME - Temp hack for old systems that set the wrong property // XXX FIXME - Temp hack for old systems that set the wrong property
if (defaultProperties.get("java.io.tmpdir") == null) if (defaultProperties.get("java.io.tmpdir") == null)
defaultProperties.put("java.io.tmpdir", defaultProperties.put("java.io.tmpdir",
defaultProperties.get("java.tmpdir")); defaultProperties.get("java.tmpdir"));
} }
/** /**
* Stores the current system properties. This can be modified by * Stores the current system properties. This can be modified by
* {@link #setProperties(Properties)}, but will never be null, because * {@link #setProperties(Properties)}, but will never be null, because
...@@ -101,7 +118,7 @@ public final class System ...@@ -101,7 +118,7 @@ public final class System
* however. * however.
*/ */
public static final InputStream in public static final InputStream in
= new BufferedInputStream (new FileInputStream(FileDescriptor.in)); = new BufferedInputStream(new FileInputStream(FileDescriptor.in));
/** /**
* The standard output PrintStream. This is assigned at startup and * The standard output PrintStream. This is assigned at startup and
* starts its life perfectly valid. Although it is marked final, you can * starts its life perfectly valid. Although it is marked final, you can
...@@ -113,7 +130,7 @@ public final class System ...@@ -113,7 +130,7 @@ public final class System
* you, however. * you, however.
*/ */
public static final PrintStream out public static final PrintStream out
= new PrintStream(new BufferedOutputStream (new FileOutputStream(FileDescriptor.out)), true); = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)), true);
/** /**
* The standard output PrintStream. This is assigned at startup and * The standard output PrintStream. This is assigned at startup and
* starts its life perfectly valid. Although it is marked final, you can * starts its life perfectly valid. Although it is marked final, you can
...@@ -125,7 +142,7 @@ public final class System ...@@ -125,7 +142,7 @@ public final class System
* you, however. * you, however.
*/ */
public static final PrintStream err public static final PrintStream err
= new PrintStream(new BufferedOutputStream (new FileOutputStream(FileDescriptor.err)), true); = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err)), true);
/** /**
* This class is uninstantiable. * This class is uninstantiable.
...@@ -312,6 +329,10 @@ public final class System ...@@ -312,6 +329,10 @@ public final class System
* In addition, gnu defines several other properties, where ? stands for * In addition, gnu defines several other properties, where ? stands for
* each character in '0' through '9': * each character in '0' through '9':
* <dl> * <dl>
* <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.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_?
* <dt> gnu.java.io.encoding_scheme_alias.iso-8859-? <dd>8859_? * <dt> gnu.java.io.encoding_scheme_alias.iso-8859-? <dd>8859_?
......
...@@ -37,9 +37,10 @@ exception statement from your version. */ ...@@ -37,9 +37,10 @@ exception statement from your version. */
package java.security; package java.security;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.net.URL;
import java.security.Provider; import java.security.Provider;
import java.util.Vector; import java.util.Vector;
import java.util.Enumeration; import java.util.Enumeration;
...@@ -59,9 +60,9 @@ public final class Security extends Object ...@@ -59,9 +60,9 @@ public final class Security extends Object
static static
{ {
loadProviders(System.getProperty("java.home"), String base = System.getProperty("gnu.classpath.home.url");
System.getProperty("java.vm.name")); loadProviders(base, System.getProperty("gnu.classpath.vm.shortname"));
loadProviders(System.getProperty("gnu.classpath.home"), "classpath"); loadProviders(base, "classpath");
} }
// This class can't be instantiated. // This class can't be instantiated.
...@@ -69,20 +70,16 @@ public final class Security extends Object ...@@ -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; return;
String separator = System.getProperty("file.separator"); String secfilestr = baseUrl + "/security/" + vendor + ".security";
String secfilestr = (dir +
separator + "lib" +
separator + "security" +
separator + vendor + ".security");
try try
{ {
FileInputStream fin = new FileInputStream(secfilestr); InputStream fin = new URL(secfilestr).openStream();
secprops = new Properties(); secprops = new Properties();
secprops.load(fin); secprops.load(fin);
......
/* InitialContext.java -- /* InitialContext.java --
Copyright (C) 2000 Free Software Foundation, Inc. Copyright (C) 2000, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -126,18 +126,22 @@ public class InitialContext implements Context ...@@ -126,18 +126,22 @@ public class InitialContext implements Context
} }
catch (IOException e) {} catch (IOException e) {}
String home = System.getProperty("java.home"); String home = System.getProperty("gnu.classpath.home.url");
if (home != null) if (home != null)
{ {
String fileName = home + File.separator String url = home + "/jndi.properties";
+ "lib" + File.separator + "jndi.properties";
Properties p = new Properties (); Properties p = new Properties ();
try { try
InputStream is = new FileInputStream (fileName); {
p.load (is); InputStream is = new URL(url).openStream();
is.close (); p.load (is);
} catch (IOException e) {} is.close ();
}
catch (IOException e)
{
// Ignore.
}
merge (myProps, p); merge (myProps, p);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment