Patch: FYI: new gcj-specific endorsed directory
Tom Tromey
tromey@redhat.com
Tue Mar 29 22:19:00 GMT 2005
I'm checking this in on the trunk.
This refactors the BootClassLoader and VMClassLoader classes a little
so that code can be shared, and adds a new
"gcj.gnu.runtime.endorsed.dirs" property, which is just like
java.endorsed.dirs, but is examined after it.
The reason I added this is so that system integrators have an easy way
to install libraries which (1) are in rt.jar in a proprietary JDK, (2)
should be loaded by the bootstrap loader, and (3) for whatever reason
do not yet appear in libgcj. In my case, the library in question is
CORBA, but YMMV.
The same effect can be achieved via java.endorsed.dirs, of course, but
that doesn't work so well if you have a package that wants to set this
property in its launcher script.
With this patch in place I am able to launch jonas with only one
change to the launcher script -- changing 'java' to 'gij'. (On a
fully set up system this is handled by java-gcj-compat.)
I chose the default setting for this property arbitrarily.
Someday, when the class library is complete, we can consider removing
this property again.
Tom
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
* gcj.texi (libgcj Runtime Properties): Document
gnu.gcj.runtime.endorsed.dirs.
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/lang/natRuntime.cc (insertSystemProperties): Set
gnu.gcj.runtime.endorsed.dirs.
* Makefile.in: Rebuilt.
* Makefile.am (ordinary_java_source_files): Added
HelperClassLoader.java.
(AM_CXXFLAGS): Define GCJ_ENDORSED_DIRS.
* gnu/gcj/runtime/VMClassLoader.java (VMClassLoader): Extends
HelperClassLoader.
(init): Use addDirectoriesFromProperty.
* gnu/gcj/runtime/BootClassLoader.java (BootClassLoader): Extends
HelperClassLoader. Use addDirectoriesFromProperty. Handle
gnu.gcj.runtime.endorsed.dirs.
* gnu/gcj/runtime/HelperClassLoader.java: New file.
Index: gcc/java/gcj.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gcj.texi,v
retrieving revision 1.76
diff -u -r1.76 gcj.texi
--- gcc/java/gcj.texi 25 Mar 2005 00:38:38 -0000 1.76
+++ gcc/java/gcj.texi 29 Mar 2005 21:36:52 -0000
@@ -2515,6 +2515,15 @@
tried again. If this property is set to @samp{never}, then lookups
are never done. For more information, @xref{Extensions}.
+@item gnu.gcj.runtime.endorsed.dirs
+This is like the standard @code{java.endorsed.dirs}, property, but
+specifies some extra directories which are searched after the standard
+endorsed directories. This is primarily useful for telling
+@code{libgcj} about additional libraries which are ordinarily
+incorporated into the JDK, and which should be loaded by the bootstrap
+class loader, but which are not yet part of @code{libgcj} itself for
+some reason.
+
@item gnu.gcj.jit.compiler
@c FIXME we should probably have a whole node on this...
This is the full path to @command{gcj} executable which should be
Index: libjava/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.468
diff -u -r1.468 Makefile.am
--- libjava/Makefile.am 27 Mar 2005 18:38:05 -0000 1.468
+++ libjava/Makefile.am 29 Mar 2005 21:36:59 -0000
@@ -186,6 +186,7 @@
-DLIBDIR="\"$(libdir)\"" \
-DBOOT_CLASS_PATH="\"$(jardir)/$(jar_DATA)\"" \
-DJAVA_EXT_DIRS="\"$(jardir)/ext\"" \
+ -DGCJ_ENDORSED_DIRS="\"$(jardir)/gcj-endorsed\"" \
-DLIBGCJ_DEFAULT_DATABASE="\"$(dbexecdir)/$(db_name)\"" \
-DLIBGCJ_DEFAULT_DATABASE_PATH_TAIL="\"$(db_pathtail)\"" \
-DTOOLEXECLIBDIR="\"$(toolexeclibdir)\""
@@ -2992,6 +2993,7 @@
gnu/gcj/runtime/BootClassLoader.java \
gnu/gcj/runtime/FileDeleter.java \
gnu/gcj/runtime/FinalizerThread.java \
+gnu/gcj/runtime/HelperClassLoader.java \
gnu/gcj/runtime/JNIWeakRef.java \
gnu/gcj/runtime/NameFinder.java \
gnu/gcj/runtime/PersistentByteMap.java \
Index: libjava/gnu/gcj/runtime/BootClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/runtime/BootClassLoader.java,v
retrieving revision 1.2
diff -u -r1.2 BootClassLoader.java
--- libjava/gnu/gcj/runtime/BootClassLoader.java 24 Mar 2005 19:42:40 -0000 1.2
+++ libjava/gnu/gcj/runtime/BootClassLoader.java 29 Mar 2005 21:37:05 -0000
@@ -8,14 +8,9 @@
package gnu.gcj.runtime;
-import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.StringTokenizer;
/**
* This is a helper for the bootstrap class loader. It is a
@@ -24,37 +19,18 @@
* However, it is never called the way that an ordinary ClassLoader is
* called. For instance, loadClass() is never used.
*/
-public final class BootClassLoader extends URLClassLoader
+public final class BootClassLoader extends HelperClassLoader
{
BootClassLoader(String libdir)
{
- super(new URL[0]);
+ addDirectoriesFromProperty("java.endorsed.dirs");
+ addDirectoriesFromProperty("gnu.gcj.runtime.endorsed.dirs");
- // Add the contents of the endorsed directories.
- StringTokenizer st
- = new StringTokenizer (System.getProperty ("java.endorsed.dirs", ""),
- File.pathSeparator);
try
{
- while (st.hasMoreElements ())
- {
- String dirname = st.nextToken ();
- File dir = new File (dirname);
- if (dir.exists ())
- {
- if (! dirname.endsWith (File.separator))
- dirname = dirname + File.separator;
- String files[] = dir.list (new FilenameFilter ()
- {
- public boolean accept (File dir, String name)
- {
- return name.endsWith (".jar") || name.endsWith (".zip");
- }
- });
- for (int i = files.length - 1; i >= 0; i--)
- addURL(new URL("file", "", -1, dirname + files[i]));
- }
- }
+ // Add core:/ to the end so any resources compiled into this
+ // executable may be found.
+ addURL(new URL("core", "", -1, "/"));
}
catch (java.net.MalformedURLException x)
{
Index: libjava/gnu/gcj/runtime/VMClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/runtime/VMClassLoader.java,v
retrieving revision 1.18
diff -u -r1.18 VMClassLoader.java
--- libjava/gnu/gcj/runtime/VMClassLoader.java 2 Feb 2005 20:59:40 -0000 1.18
+++ libjava/gnu/gcj/runtime/VMClassLoader.java 29 Mar 2005 21:37:05 -0000
@@ -10,20 +10,16 @@
package gnu.gcj.runtime;
-import java.io.*;
-import java.util.StringTokenizer;
-import java.util.HashSet;
import java.net.URL;
-import java.net.URLClassLoader;
+import java.util.HashSet;
// Despite its name, this class is really the extension loader for
// libgcj. Class loader bootstrap is a bit tricky, see prims.cc and
// SystemClassLoader for some details.
-public final class VMClassLoader extends URLClassLoader
+public final class VMClassLoader extends HelperClassLoader
{
private VMClassLoader ()
{
- super (new URL[0]);
String p
= System.getProperty ("gnu.gcj.runtime.VMClassLoader.library_control",
"");
@@ -39,44 +35,7 @@
private void init()
{
- // Add the contents of the extensions directories.
- StringTokenizer st
- = new StringTokenizer (System.getProperty ("java.ext.dirs"),
- File.pathSeparator);
-
- try
- {
- while (st.hasMoreElements ())
- {
- String dirname = st.nextToken ();
- File dir = new File (dirname);
- if (dir.exists ())
- {
- if (! dirname.endsWith (File.separator))
- dirname = dirname + File.separator;
- String files[]
- = dir.list (new FilenameFilter ()
- {
- public boolean accept (File dir, String name)
- {
- return (name.endsWith (".jar")
- || name.endsWith (".zip"));
- }
- });
- for (int i = files.length - 1; i >= 0; i--)
- addURL(new URL("file", "", -1, dirname + files[i]));
- }
- }
-
- // Add core:/ to the end so any resources compiled into this
- // executable may be found.
- addURL(new URL("core", "", -1, "/"));
- }
- catch (java.net.MalformedURLException x)
- {
- // This should never happen.
- throw new RuntimeException(x);
- }
+ addDirectoriesFromProperty("java.ext.dirs");
}
/** This is overridden to search the internal hash table, which
Index: libjava/java/lang/natRuntime.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natRuntime.cc,v
retrieving revision 1.51
diff -u -r1.51 natRuntime.cc
--- libjava/java/lang/natRuntime.cc 11 Mar 2005 17:35:37 -0000 1.51
+++ libjava/java/lang/natRuntime.cc 29 Mar 2005 21:37:05 -0000
@@ -528,6 +528,11 @@
// The java extensions directory.
SET ("java.ext.dirs", JAVA_EXT_DIRS);
+ // The endorsed directories that libgcj knows about by default.
+ // This is a way to get other jars into the boot class loader
+ // without overriding java.endorsed.dirs.
+ SET ("gnu.gcj.runtime.endorsed.dirs", GCJ_ENDORSED_DIRS);
+
// The path to libgcj's boot classes
SET ("sun.boot.class.path", BOOT_CLASS_PATH);
More information about the Java-patches
mailing list