diff options
author | Tom Tromey <tromey@redhat.com> | 2003-08-20 15:32:23 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-08-20 15:32:23 +0000 |
commit | 3f1923dcc183ad589948318c2099b6548fc82e93 (patch) | |
tree | 9dc3ee43232dc76c5cf29cca667d555d8d9c62e7 /libjava/gnu/gcj/runtime/VMClassLoader.java | |
parent | 9c6f74cd3f4fa7711ab1eb9e7a176450aa699e54 (diff) | |
download | gcc-3f1923dcc183ad589948318c2099b6548fc82e93.zip gcc-3f1923dcc183ad589948318c2099b6548fc82e93.tar.gz gcc-3f1923dcc183ad589948318c2099b6548fc82e93.tar.bz2 |
re PR libgcj/9125 (VMClassLoader should cache the result of Runtime.(internal)loadLibrary())
Fix for PR libgcj/9125:
* gnu/gcj/runtime/natVMClassLoader.cc (findClass): Find Runtime
object outside of loop. Respect lib_control setting.
* gnu/gcj/runtime/VMClassLoader.java (tried_libraries): New
field.
(lib_control): New field.
(LIB_FULL, LIB_CACHE, LIB_NEVER): New constants.
(VMClassLoader): Initialize new field.
From-SVN: r70600
Diffstat (limited to 'libjava/gnu/gcj/runtime/VMClassLoader.java')
-rw-r--r-- | libjava/gnu/gcj/runtime/VMClassLoader.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/libjava/gnu/gcj/runtime/VMClassLoader.java b/libjava/gnu/gcj/runtime/VMClassLoader.java index fd0c32c..ca0f663 100644 --- a/libjava/gnu/gcj/runtime/VMClassLoader.java +++ b/libjava/gnu/gcj/runtime/VMClassLoader.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2001, 2002 Free Software Foundation +/* Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation This file is part of libgcj. @@ -12,6 +12,7 @@ package gnu.gcj.runtime; import java.io.*; import java.util.StringTokenizer; +import java.util.HashSet; import java.net.URL; public final class VMClassLoader extends java.net.URLClassLoader @@ -19,6 +20,20 @@ public final class VMClassLoader extends java.net.URLClassLoader private VMClassLoader () { super (init()); + String p + = System.getProperty ("gnu.gcj.runtime.VMClassLoader.library_control", + ""); + if ("never".equals(p)) + lib_control = LIB_NEVER; + else if ("cache".equals(p)) + lib_control = LIB_CACHE; + else if ("full".equals(p)) + { + // In case we ever want to change the default. + lib_control = LIB_FULL; + } + else + lib_control = LIB_FULL; } private static URL[] init() @@ -67,6 +82,17 @@ public final class VMClassLoader extends java.net.URLClassLoader protected native Class findClass(String name) throws java.lang.ClassNotFoundException; + // This keeps track of shared libraries we've already tried to load. + private HashSet tried_libraries = new HashSet(); + + // Holds one of the LIB_* constants; used to determine how shared + // library loads are done. + private int lib_control; + // The only VMClassLoader that can exist. - public static VMClassLoader instance = new VMClassLoader (); + public static VMClassLoader instance = new VMClassLoader(); + + private static final int LIB_FULL = 0; + private static final int LIB_CACHE = 1; + private static final int LIB_NEVER = 2; } |