diff options
| author | Olivier Jolly <olivier.jolly@pcedev.com> | 2006-04-19 15:47:42 +0000 |
|---|---|---|
| committer | Olivier Jolly <olivier.jolly@pcedev.com> | 2006-04-19 15:47:42 +0000 |
| commit | 76f52c446b3cf94eb8e8572f9fdf507e159b8d6e (patch) | |
| tree | c92bdaed571f7d9ebfc17e51d70a2439e679a6d2 /vm/reference/java/lang/VMClassLoader.java | |
| parent | 6022ac19d225fd5d7613db73d3336c925b0a81b8 (diff) | |
| download | classpath-76f52c446b3cf94eb8e8572f9fdf507e159b8d6e.tar.gz | |
2006-04-19 Olivier Jolly <olivier.jolly@pcedev.com>
* vm/reference/java/lang/VMClassLoader.java (getBootPackages): Loads
boot packages list from the META-INF/INDEX.LIST file if it exists.
Diffstat (limited to 'vm/reference/java/lang/VMClassLoader.java')
| -rw-r--r-- | vm/reference/java/lang/VMClassLoader.java | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/vm/reference/java/lang/VMClassLoader.java b/vm/reference/java/lang/VMClassLoader.java index 218d60971..83ce884a7 100644 --- a/vm/reference/java/lang/VMClassLoader.java +++ b/vm/reference/java/lang/VMClassLoader.java @@ -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,20 +39,23 @@ exception statement from your version. */ package java.lang; -import gnu.classpath.SystemProperties; import gnu.classpath.Configuration; - +import gnu.classpath.SystemProperties; import gnu.java.lang.InstrumentationImpl; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import java.lang.instrument.Instrumentation; 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; @@ -238,12 +241,46 @@ final class VMClassLoader /** * 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]; } |
