aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/gcj
diff options
context:
space:
mode:
authorBryce McKinlay <mckinlay@redhat.com>2006-04-11 16:23:00 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2006-04-11 17:23:00 +0100
commit20cbfac4e95d090a361db413209a1545ca058342 (patch)
tree03872f08048832a2727cb841b18b42692486f3e1 /libjava/gnu/gcj
parentb4426e0a707e05a8844fa53d429863b9bd9d9cfa (diff)
downloadgcc-20cbfac4e95d090a361db413209a1545ca058342.zip
gcc-20cbfac4e95d090a361db413209a1545ca058342.tar.gz
gcc-20cbfac4e95d090a361db413209a1545ca058342.tar.bz2
SystemClassLoader.java (addClass): Get the value of package-private field "loadedClasses" using reflection.
* gnu/gcj/runtime/SystemClassLoader.java (addClass): Get the value of package-private field "loadedClasses" using reflection. * java/lang/VMCompiler.java (compileClass): Remove unreachable catch block. From-SVN: r112858
Diffstat (limited to 'libjava/gnu/gcj')
-rw-r--r--libjava/gnu/gcj/runtime/SystemClassLoader.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/libjava/gnu/gcj/runtime/SystemClassLoader.java b/libjava/gnu/gcj/runtime/SystemClassLoader.java
index efd3323..d012211 100644
--- a/libjava/gnu/gcj/runtime/SystemClassLoader.java
+++ b/libjava/gnu/gcj/runtime/SystemClassLoader.java
@@ -9,8 +9,9 @@ details. */
package gnu.gcj.runtime;
import java.io.*;
+import java.lang.reflect.Field;
import java.util.StringTokenizer;
-import java.util.HashSet;
+import java.util.HashMap;
import java.net.URL;
import java.net.URLClassLoader;
@@ -21,6 +22,8 @@ public final class SystemClassLoader extends URLClassLoader
super(new URL[0], parent);
}
+ private HashMap loadedClasses;
+
// This is called to register a native class which was linked into
// the application but which is registered with the system class
// loader after the VM is initialized.
@@ -37,7 +40,23 @@ public final class SystemClassLoader extends URLClassLoader
// precompiled manifest.
definePackage(packageName, null, null, null, null, null, null, null);
}
- loadedClasses.put(className, klass);
+
+ // Use reflection to access the package-private "loadedClasses" field.
+ if (this.loadedClasses == null)
+ {
+ try
+ {
+ Class cl = java.lang.ClassLoader.class;
+ Field lcField = cl.getDeclaredField("loadedClasses");
+ lcField.setAccessible(true);
+ this.loadedClasses = (HashMap) lcField.get(this);
+ }
+ catch (Exception x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
+ this.loadedClasses.put(className, klass);
}
// We add the URLs to the system class loader late. The reason for