Hi,
in the VMClassLoader reference file, we have a method to define boot
packages and tell vm implementors that they may override it. I propose
this patch to use the META-INF/INDEX.LIST in the glibj.zip file (if this
entry exists) to predefine boot packages as all packages found in this
archive.
Thanks for the feedback.
Regards
+Olivier
2006-04-13 Olivier Jolly <[EMAIL PROTECTED]>
* vm/reference/java/lang/VMClassLoader.java (getBootPackages): Loads
boot packages list from the META-INF/INDEX.LIST file if it exists.
Index: VMClassLoader.java
===================================================================
RCS file: /sources/classpath/classpath/vm/reference/java/lang/VMClassLoader.java,v
retrieving revision 1.34
diff -u -r1.34 VMClassLoader.java
--- VMClassLoader.java 2 Mar 2006 00:36:44 -0000 1.34
+++ VMClassLoader.java 13 Apr 2006 19:32:24 -0000
@@ -1,6 +1,6 @@
/* VMClassLoader.java -- Reference implementation of native interface
required by ClassLoader
- Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation
+ Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -39,17 +39,21 @@
package java.lang;
-import gnu.classpath.SystemProperties;
import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.ProtectionDomain;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.zip.ZipFile;
@@ -235,12 +239,46 @@
/**
* Returns a String[] of native package names. The default
- * implementation returns an empty array, or you may decide
- * this needs native help.
+ * implementation tries to load a list of package from
+ * the META-INF/INDEX.LIST file in the boot jar file.
+ * If not found or if any exception is raised, it returns
+ * an empty array. You may decide this needs native help.
*/
private static String[] getBootPackages()
{
- return new String[0];
+ URL indexList = getResource("META-INF/INDEX.LIST");
+ if (indexList != null)
+ {
+ try
+ {
+ Set packageSet = new HashSet();
+ String line;
+ int lineToSkip = 3;
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(
+ indexList.openStream()));
+ while ((line = reader.readLine()) != null)
+ {
+ if (lineToSkip == 0)
+ {
+ if (line.length() == 0)
+ lineToSkip = 1;
+ else
+ packageSet.add(line.replace('/', '.'));
+ }
+ else
+ lineToSkip--;
+ }
+ reader.close();
+ return (String[]) packageSet.toArray(new String[packageSet.size()]);
+ }
+ catch (IOException e)
+ {
+ return new String[0];
+ }
+ }
+ else
+ return new String[0];
}