mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-03 07:00:27 +08:00
ResourceBundle.java (getClassContext): Removed.
* java/util/ResourceBundle.java (getClassContext): Removed. (Security): New class, extends SecurityManger. (getBundle): Use Security.getCallingClassLoader instead of getClassContext. * java/util/natResourceBundle.cc: Removed. From-SVN: r46761
This commit is contained in:
parent
f5143c46a9
commit
cb3f834fb6
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
@ -96,6 +90,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.
|
||||
*/
|
||||
@ -156,20 +180,6 @@ public abstract class ResourceBundle
|
||||
("Key not found", getClass().getName(), key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -177,12 +187,13 @@ public abstract class ResourceBundle
|
||||
* 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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user