diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-11-04 04:15:09 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-11-04 04:15:09 +0000 |
commit | 8f203a4e3a192f3010235382f9998bb92531bd3e (patch) | |
tree | bfb510195ffe6d2346162253badade76808f1b85 /libjava | |
parent | 35a3065a3eaa382dc4b1f9e0f8f4c41b81a2014d (diff) | |
download | ppe42-gcc-8f203a4e3a192f3010235382f9998bb92531bd3e.tar.gz ppe42-gcc-8f203a4e3a192f3010235382f9998bb92531bd3e.zip |
* java/util/ResourceBundle.java (getClassContext): Removed.
(Security): New class, extends SecurityManger.
(getBundle): Use Security.getCallingClassLoader instead of
getClassContext.
* java/util/natResourceBundle.cc: Removed.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46761 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 8 | ||||
-rw-r--r-- | libjava/Makefile.am | 1 | ||||
-rw-r--r-- | libjava/Makefile.in | 60 | ||||
-rw-r--r-- | libjava/java/util/ResourceBundle.java | 61 | ||||
-rw-r--r-- | libjava/java/util/natResourceBundle.cc | 31 |
5 files changed, 66 insertions, 95 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index c8e45d0f9c4..e5dbc1f4da9 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,11 @@ +2001-11-04 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * java/util/ResourceBundle.java (getClassContext): Removed. + (Security): New class, extends SecurityManger. + (getBundle): Use Security.getCallingClassLoader instead of + getClassContext. + * java/util/natResourceBundle.cc: Removed. + 2001-11-03 Tom Tromey <tromey@redhat.com> * defineclass.cc (handleClassBegin): Use Object::class$, not diff --git a/libjava/Makefile.am b/libjava/Makefile.am index 84ac600cbef..1abb65c9578 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -1651,7 +1651,6 @@ java/net/natInetAddress.cc \ java/net/natPlainDatagramSocketImpl.cc \ java/net/natPlainSocketImpl.cc \ java/text/natCollator.cc \ -java/util/natResourceBundle.cc \ java/util/zip/natDeflater.cc \ java/util/zip/natInflater.cc diff --git a/libjava/Makefile.in b/libjava/Makefile.in index 5519f6b257d..ec25e38715f 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -123,19 +123,13 @@ libgcj_basedir = @libgcj_basedir@ mkinstalldirs = @mkinstalldirs@ AUTOMAKE_OPTIONS = foreign -@TESTSUBDIR_TRUE@SUBDIRS = \ -@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include -@TESTSUBDIR_FALSE@SUBDIRS = \ -@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include -@USE_LIBDIR_TRUE@toolexeclibdir = \ -@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR) -@USE_LIBDIR_FALSE@toolexeclibdir = \ -@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR) -@USE_LIBDIR_FALSE@toolexecdir = \ -@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias) -@XLIB_AWT_TRUE@cond_x_ltlibrary = \ -@XLIB_AWT_TRUE@libgcjx.la -@XLIB_AWT_FALSE@cond_x_ltlibrary = \ +@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include +@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include +@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR) +@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR) +@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias) +@XLIB_AWT_TRUE@cond_x_ltlibrary = @XLIB_AWT_TRUE@libgcjx.la +@XLIB_AWT_FALSE@cond_x_ltlibrary = toolexeclib_LTLIBRARIES = libgcj.la $(cond_x_ltlibrary) toolexeclib_DATA = libgcj.spec @@ -143,20 +137,14 @@ data_DATA = libgcj.jar secdir = $(libdir)/security -@NATIVE_TRUE@bin_PROGRAMS = \ -@NATIVE_TRUE@jv-convert gij rmic rmiregistry +@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij rmic rmiregistry bin_SCRIPTS = addr2name.awk -@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = \ -@CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT) -@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = \ -@CANADIAN_TRUE@@NULL_TARGET_FALSE@jar -@CANADIAN_FALSE@ZIP = \ -@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT) -@CANADIAN_TRUE@GCJH = \ -@CANADIAN_TRUE@gcjh -@CANADIAN_FALSE@GCJH = \ -@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT) +@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT) +@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@jar +@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT) +@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh +@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT) GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8 @@ -176,10 +164,8 @@ AM_CXXFLAGS = -fno-rtti -fnon-call-exceptions \ @LIBGCJ_CXXFLAGS@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE \ -DPREFIX="\"$(prefix)\"" -@USING_GCC_TRUE@AM_CFLAGS = \ -@USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS) -@USING_GCC_FALSE@AM_CFLAGS = \ -@USING_GCC_FALSE@@LIBGCJ_CFLAGS@ +@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS) +@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@ JCFLAGS = -g JC1FLAGS = @LIBGCJ_JAVAFLAGS@ $(GCJFLAGS) @@ -248,8 +234,7 @@ extra_headers = java/lang/Object.h java/lang/Class.h NM = nm -@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \ -@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS +@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS CONVERT_DIR = gnu/gcj/convert @@ -1383,7 +1368,6 @@ java/net/natInetAddress.cc \ java/net/natPlainDatagramSocketImpl.cc \ java/net/natPlainSocketImpl.cc \ java/text/natCollator.cc \ -java/util/natResourceBundle.cc \ java/util/zip/natDeflater.cc \ java/util/zip/natInflater.cc @@ -1533,8 +1517,8 @@ java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \ java/lang/reflect/natConstructor.lo java/lang/reflect/natField.lo \ java/lang/reflect/natMethod.lo java/net/natInetAddress.lo \ java/net/natPlainDatagramSocketImpl.lo java/net/natPlainSocketImpl.lo \ -java/text/natCollator.lo java/util/natResourceBundle.lo \ -java/util/zip/natDeflater.lo java/util/zip/natInflater.lo +java/text/natCollator.lo java/util/zip/natDeflater.lo \ +java/util/zip/natInflater.lo libgcjx_la_OBJECTS = gnu/gcj/xlib/natClip.lo \ gnu/gcj/xlib/natColormap.lo gnu/gcj/xlib/natDisplay.lo \ gnu/gcj/xlib/natDrawable.lo gnu/gcj/xlib/natFont.lo \ @@ -1578,7 +1562,7 @@ libgcj-test.spec.in libgcj.spec.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best DIST_SUBDIRS = @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ @@ -2235,8 +2219,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/util/jar/JarException.P .deps/java/util/jar/JarFile.P \ .deps/java/util/jar/JarInputStream.P \ .deps/java/util/jar/JarOutputStream.P .deps/java/util/jar/Manifest.P \ -.deps/java/util/natResourceBundle.P .deps/java/util/zip/Adler32.P \ -.deps/java/util/zip/CRC32.P .deps/java/util/zip/CheckedInputStream.P \ +.deps/java/util/zip/Adler32.P .deps/java/util/zip/CRC32.P \ +.deps/java/util/zip/CheckedInputStream.P \ .deps/java/util/zip/CheckedOutputStream.P \ .deps/java/util/zip/Checksum.P \ .deps/java/util/zip/DataFormatException.P \ @@ -2726,7 +2710,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/libjava/java/util/ResourceBundle.java b/libjava/java/util/ResourceBundle.java index f2fa7763d7c..130fc9cfbd6 100644 --- a/libjava/java/util/ResourceBundle.java +++ b/libjava/java/util/ResourceBundle.java @@ -28,6 +28,8 @@ executable file might be covered by the GNU General Public License. */ package java.util; import java.lang.ref.Reference; import java.lang.ref.SoftReference; +import java.security.AccessController; +import java.security.PrivilegedAction; import gnu.classpath.Configuration; /** @@ -74,14 +76,6 @@ import gnu.classpath.Configuration; * @author Jochen Hoenicke */ public abstract class ResourceBundle { - static - { - if (Configuration.INIT_LOAD_LIBRARY) - { - System.loadLibrary ("javautil"); - } - } - /** * The parent bundle. This is consulted when you call getObject * and there is no such resource in the current bundle. This @@ -97,6 +91,36 @@ public abstract class ResourceBundle private Locale locale; /** + * We override SecurityManager in order to access getClassContext(). + */ + class Security extends SecurityManager + { + /** Return the ClassLoader of the class which called into this + ResourceBundle, or null if it cannot be determined. */ + ClassLoader getCallingClassLoader() + { + Class[] stack = super.getClassContext(); + for (int i = 0; i < stack.length; i++) + if (stack[i] != Security.class && stack[i] != ResourceBundle.class) + return stack[i].getClassLoader(); + return null; + } + } + + // This will always work since java.util classes have (all) system + // permissions. + static Security security = (Security) AccessController.doPrivileged + ( + new PrivilegedAction() + { + public Object run() + { + return new Security(); + } + } + ); + + /** * The constructor. It does nothing special. */ public ResourceBundle() @@ -157,32 +181,19 @@ public abstract class ResourceBundle } /** - * This method returns an array with the classes of the calling - * methods. The zeroth entry is the class that called this method - * (should always be ResourceBundle), the first contains the class - * that called the caller (i.e. the class that called getBundle). - * - * Implementation note: This depends on the fact, that getBundle - * doesn't get inlined, but since it calls a private method, it - * isn't inlineable. - * - * @return an array containing the classes for the callers. - */ - private static native Class[] getClassContext(); - - /** * Get the appropriate ResourceBundle for the default locale. * @param baseName the name of the ResourceBundle. This should be * a name of a Class or a properties-File. See the class * description for details. * @return the desired resource bundle * @exception MissingResourceException - * if the resource bundle couldn't be found. */ + * if the resource bundle couldn't be found. + */ public static final ResourceBundle getBundle(String baseName) throws MissingResourceException { return getBundle(baseName, Locale.getDefault(), - getClassContext()[1].getClassLoader()); + security.getCallingClassLoader()); } /** @@ -199,7 +210,7 @@ public abstract class ResourceBundle Locale locale) throws MissingResourceException { - return getBundle(baseName, locale, getClassContext()[1].getClassLoader()); + return getBundle(baseName, locale, security.getCallingClassLoader()); } /** diff --git a/libjava/java/util/natResourceBundle.cc b/libjava/java/util/natResourceBundle.cc deleted file mode 100644 index c9e27b048f0..00000000000 --- a/libjava/java/util/natResourceBundle.cc +++ /dev/null @@ -1,31 +0,0 @@ -// natResourceBundle.cc - Native code for ResourceBundle class. - -/* Copyright (C) 2001 Free Software Foundation - - This file is part of libgcj. - -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - -#include <config.h> - -#include <gcj/cni.h> -#include <jvm.h> -#include <java/util/ResourceBundle.h> -#include <java/lang/Class.h> -#include <java/lang/ClassLoader.h> - -JArray<jclass> * -java::util::ResourceBundle::getClassContext () -{ - // FIXME: we currently lack the capability to correctly implement - // this method. So we fake it by telling ResourceBundle that we - // only have the system class loader. - jobjectArray a = JvNewObjectArray (2, &java::lang::Class::class$, NULL); - jobject *elts = elements (a); - elts[0] = &class$; - elts[1] = elts[0]; - - return reinterpret_cast< JArray<jclass> *> (a); -} |