This commit is contained in:
Mikael Gerdin 2013-04-29 09:31:59 +02:00
commit fa84ba4ba9
1232 changed files with 103638 additions and 24459 deletions

View File

@ -207,3 +207,5 @@ e41d716405b209d3eddef8bd4240cec2bd34dcca jdk8-b81
bcebd3fdefc91abb9d7fa0c5af6211b3f8720da6 jdk8-b83
d7ad0dfaa41151bd3a9ae46725b0aec3730a9cd0 jdk8-b84
1872c12529090e1c1dbf567f02ad7ae6231b8f0c jdk8-b85
da9a4c9312816451884aa6db6f18be51a07bff13 jdk8-b86
5ebf6c63714de2c9dcf831074086d31daec819df jdk8-b87

View File

@ -207,3 +207,5 @@ fd1a5574cf68af24bfd52decc37ac6361afb278a jdk8-b78
466685ba01bfb7bc1e1ac61490fd8c0f3cc18763 jdk8-b83
01f631f89fa392b4e484d0812c40ea8f9d2353aa jdk8-b84
7fc358f5943676b82f1dccd3152b1ac07d92e38b jdk8-b85
df9b5240f0a76c91cfe1a5b39da4d08df56e05be jdk8-b86
b9415faa7066a4d3b16d466556d5428446918d95 jdk8-b87

View File

@ -166,6 +166,7 @@ PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS
TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS
TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION
TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK
TOOLCHAIN_SETUP_COMPILER_FLAGS_MISC
# Setup debug symbols (need objcopy from the toolchain for that)
JDKOPT_SETUP_DEBUG_SYMBOLS

View File

@ -639,6 +639,8 @@ CXXFLAGS_DEBUG_SYMBOLS
CFLAGS_DEBUG_SYMBOLS
ZIP_DEBUGINFO_FILES
ENABLE_DEBUG_SYMBOLS
COMPILER_SUPPORTS_TARGET_BITS_FLAG
ZERO_ARCHFLAG
LDFLAGS_CXX_JDK
LDFLAGS_JDKEXE_SUFFIX
LDFLAGS_JDKLIB_SUFFIX
@ -679,6 +681,7 @@ LIBRARY_PREFIX
STATIC_LIBRARY
SHARED_LIBRARY
OBJ_SUFFIX
COMPILER_NAME
LIPO
ac_ct_OBJDUMP
OBJDUMP
@ -835,7 +838,6 @@ SYS_ROOT
PATH_SEP
SRC_ROOT
ZERO_ARCHDEF
ZERO_ARCHFLAG
DEFINE_CROSS_COMPILE_ARCH
LP64
OPENJDK_TARGET_OS_API_DIR
@ -3714,6 +3716,15 @@ fi
# TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
# [RUN-IF-FALSE])
# ------------------------------------------------------------
# Check that the c and c++ compilers support an argument
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@ -3764,7 +3775,7 @@ fi
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
DATE_WHEN_GENERATED=1365493306
DATE_WHEN_GENERATED=1367502949
###############################################################################
#
@ -7099,17 +7110,6 @@ $as_echo "$COMPILE_TYPE" >&6; }
fi
# Some Zero and Shark settings.
# ZERO_ARCHFLAG tells the compiler which mode to build for
case "${OPENJDK_TARGET_CPU}" in
s390)
ZERO_ARCHFLAG="-m31"
;;
*)
ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}"
esac
# ZERO_ARCHDEF is used to enable architecture-specific code
case "${OPENJDK_TARGET_CPU}" in
ppc*) ZERO_ARCHDEF=PPC ;;
@ -28344,6 +28344,7 @@ done
# (The JVM can use 32 or 64 bit Java pointers but that decision
# is made at runtime.)
#
if test "x$OPENJDK_TARGET_OS" = xsolaris; then
# Always specify -m flags on Solaris
@ -28805,6 +28806,7 @@ fi
# The (cross) compiler is now configured, we can now test capabilities
# of the target platform.
@ -29268,6 +29270,161 @@ esac
# Some Zero and Shark settings.
# ZERO_ARCHFLAG tells the compiler which mode to build for
case "${OPENJDK_TARGET_CPU}" in
s390)
ZERO_ARCHFLAG="-m31"
;;
*)
ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}"
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$ZERO_ARCHFLAG\"" >&5
$as_echo_n "checking if compiler supports \"$ZERO_ARCHFLAG\"... " >&6; }
supports=yes
saved_cflags="$CFLAGS"
CFLAGS="$CFLAGS $ZERO_ARCHFLAG"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int i;
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
supports=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CFLAGS="$saved_cflags"
saved_cxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAG $ZERO_ARCHFLAG"
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int i;
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
else
supports=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CXXFLAGS="$saved_cxxflags"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
$as_echo "$supports" >&6; }
if test "x$supports" = "xyes" ; then
:
else
ZERO_ARCHFLAG=""
fi
# Check that the compiler supports -mX flags
# Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"-m${OPENJDK_TARGET_CPU_BITS}\"" >&5
$as_echo_n "checking if compiler supports \"-m${OPENJDK_TARGET_CPU_BITS}\"... " >&6; }
supports=yes
saved_cflags="$CFLAGS"
CFLAGS="$CFLAGS -m${OPENJDK_TARGET_CPU_BITS}"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int i;
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
supports=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CFLAGS="$saved_cflags"
saved_cxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAG -m${OPENJDK_TARGET_CPU_BITS}"
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int i;
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
else
supports=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CXXFLAGS="$saved_cxxflags"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
$as_echo "$supports" >&6; }
if test "x$supports" = "xyes" ; then
COMPILER_SUPPORTS_TARGET_BITS_FLAG=true
else
COMPILER_SUPPORTS_TARGET_BITS_FLAG=false
fi
# Setup debug symbols (need objcopy from the toolchain for that)
#
@ -29446,7 +29603,6 @@ fi
###############################################################################
#
# Check for X Windows

View File

@ -333,17 +333,6 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
fi
AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
# Some Zero and Shark settings.
# ZERO_ARCHFLAG tells the compiler which mode to build for
case "${OPENJDK_TARGET_CPU}" in
s390)
ZERO_ARCHFLAG="-m31"
;;
*)
ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}"
esac
AC_SUBST(ZERO_ARCHFLAG)
# ZERO_ARCHDEF is used to enable architecture-specific code
case "${OPENJDK_TARGET_CPU}" in
ppc*) ZERO_ARCHDEF=PPC ;;
@ -444,6 +433,7 @@ AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
# (The JVM can use 32 or 64 bit Java pointers but that decision
# is made at runtime.)
#
if test "x$OPENJDK_TARGET_OS" = xsolaris; then
# Always specify -m flags on Solaris
PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS

View File

@ -300,6 +300,9 @@ MACOSX_VERSION_MIN=@MACOSX_VERSION_MIN@
# CC is gcc and others behaving reasonably similar.
# CL is cl.exe only.
COMPILER_TYPE:=@COMPILER_TYPE@
COMPILER_NAME:=@COMPILER_NAME@
COMPILER_SUPPORTS_TARGET_BITS_FLAG=@COMPILER_SUPPORTS_TARGET_BITS_FLAG@
CC_OUT_OPTION:=@CC_OUT_OPTION@
EXE_OUT_OPTION:=@EXE_OUT_OPTION@

View File

@ -573,6 +573,7 @@ else
fi
fi
AC_SUBST(COMPILER_NAME)
AC_SUBST(OBJ_SUFFIX)
AC_SUBST(SHARED_LIBRARY)
AC_SUBST(STATIC_LIBRARY)
@ -1030,3 +1031,61 @@ AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
AC_SUBST(LDFLAGS_CXX_JDK)
])
# TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
# [RUN-IF-FALSE])
# ------------------------------------------------------------
# Check that the c and c++ compilers support an argument
AC_DEFUN([TOOLCHAIN_COMPILER_CHECK_ARGUMENTS],
[
AC_MSG_CHECKING([if compiler supports "$1"])
supports=yes
saved_cflags="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_LANG_PUSH([C])
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[int i;]])
], [], [supports=no])
AC_LANG_POP([C])
CFLAGS="$saved_cflags"
saved_cxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAG $1"
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[int i;]])
], [], [supports=no])
AC_LANG_POP([C++])
CXXFLAGS="$saved_cxxflags"
AC_MSG_RESULT([$supports])
if test "x$supports" = "xyes" ; then
m4_ifval([$2], [$2], [:])
else
m4_ifval([$3], [$3], [:])
fi
])
AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_MISC],
[
# Some Zero and Shark settings.
# ZERO_ARCHFLAG tells the compiler which mode to build for
case "${OPENJDK_TARGET_CPU}" in
s390)
ZERO_ARCHFLAG="-m31"
;;
*)
ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}"
esac
TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
AC_SUBST(ZERO_ARCHFLAG)
# Check that the compiler supports -mX flags
# Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([-m${OPENJDK_TARGET_CPU_BITS}],
[COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
[COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
])

View File

@ -95,10 +95,28 @@ define add_native_source
$$($1_$2_OBJ) : $2
ifeq ($(COMPILER_TYPE),CC)
$$(call COMPILING_MSG,$2,$$($1_TARGET))
# The Sun studio compiler doesn't output the full path to the object file in the
# generated deps files. Fixing it with sed. If compiling assembly, don't try this.
ifeq ($(COMPILER_NAME)$$(filter %.s,$2),ossc)
$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2
$(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP)
else
$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2
endif
endif
# The Visual Studio compiler lacks a feature for generating make dependencies, but by
# setting -showIncludes, all included files are printed. These are filtered out and
# parsed into make dependences.
ifeq ($(COMPILER_TYPE),CL)
$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEBUG_OUT_FLAGS) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2
$$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 | $(TEE) $$($1_$2_DEP).raw | $(GREP) -v "^Note: including file:"
($(ECHO) $$@: \\ \
&& $(SED) -e '/^Note: including file:/!d' \
-e 's|Note: including file: *||' \
-e 's|\\|/|g' \
-e 's|^\([a-zA-Z]\):|/cygdrive/\1|g' \
-e '/$(subst /,\/,$(TOPDIR))/!d' \
-e 's|$$$$| \\|g' \
$$($1_$2_DEP).raw) > $$($1_$2_DEP)
endif
endif
endef

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.cnd.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>OpenJDK (Native)</name>
<c-extensions>c,m</c-extensions>
<cpp-extensions>cc,cpp</cpp-extensions>
<header-extensions>ad,h,hpp,in_out</header-extensions>
<sourceEncoding>UTF-8</sourceEncoding>
<make-dep-projects/>
<sourceRootList>
<sourceRootElem>../..</sourceRootElem>
</sourceRootList>
<confList>
<confElem>
<name>Mac_64</name>
<type>0</type>
</confElem>
<confElem>
<name>Linux_64</name>
<type>0</type>
</confElem>
<confElem>
<name>Solaris_64</name>
<type>0</type>
</confElem>
</confList>
</data>
</configuration>
</project>

View File

@ -207,3 +207,5 @@ e41fb1aa0329767b2737303c994e38bede1baa07 jdk8-b79
a45bb25a67c7517b45f00c9682e317f46fecbba9 jdk8-b83
928f8b888deb785cbd7bbd5f951cd6880f11f14e jdk8-b84
9583a6431596bac1959d2d8828f5ea217843dd12 jdk8-b85
44a8ce4a759f2668ff434661a93ff462ea472478 jdk8-b86
f1709874d55a06bc3d5dfa02dbcdfbc59f4cba34 jdk8-b87

View File

@ -334,4 +334,6 @@ a947f40fb536e5b9e0aa210cf26abb430f80887a hs25-b26
09b0d3e9ba6cdf7da07d4010d2d1df14596f6864 hs25-b27
6d88a566d369f6a1f86912cad7d0912686b2fda1 hs25-b28
86db4847f195c0ecceea646431f1ff22d56282e8 jdk8-b86
d4c2667846607042370760e23f64c3ab9350e60d jdk8-b87
01d5f04e64dc2d64625b2db2056f5ed4de918a45 hs25-b29
c4af77d2045476c56fbf3f914b336bb1b7cd18af hs25-b30

View File

@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013
HS_MAJOR_VER=25
HS_MINOR_VER=0
HS_BUILD_NUMBER=30
HS_BUILD_NUMBER=31
JDK_MAJOR_VER=1
JDK_MINOR_VER=8

View File

@ -2097,7 +2097,8 @@ void InterpreterMacroAssembler::get_method_counters(Register method,
call_VM(noreg, CAST_FROM_FN_PTR(address,
InterpreterRuntime::build_method_counters), method);
ld_ptr(method_counters, Rcounters);
br_null_short(Rcounters, Assembler::pn, skip); // No MethodCounters, OutOfMemory
br_null(Rcounters, false, Assembler::pn, skip); // No MethodCounters, OutOfMemory
delayed()->nop();
bind(has_counters);
}

View File

@ -360,7 +360,7 @@ void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile
const Address mdo_invocation_counter(rax, in_bytes(MethodData::invocation_counter_offset()) +
in_bytes(InvocationCounter::counter_offset()));
__ increment_mask_and_jump(mdo_invocation_counter, increment, mask, rcx, false, Assembler::zero, overflow);
__ jmpb(done);
__ jmp(done);
}
__ bind(no_mdo);
// Increment counter in MethodCounters

View File

@ -315,7 +315,7 @@ void InterpreterGenerator::generate_counter_incr(
const Address mdo_invocation_counter(rax, in_bytes(MethodData::invocation_counter_offset()) +
in_bytes(InvocationCounter::counter_offset()));
__ increment_mask_and_jump(mdo_invocation_counter, increment, mask, rcx, false, Assembler::zero, overflow);
__ jmpb(done);
__ jmp(done);
}
__ bind(no_mdo);
// Increment counter in MethodCounters

View File

@ -2222,12 +2222,6 @@ encode %{
$$$emit32$src$$constant;
%}
enc_class Con64(immL src)
%{
// Output immediate
emit_d64($src$$constant);
%}
enc_class Con32F_as_bits(immF src)
%{
// Output Float immediate bits
@ -7608,7 +7602,7 @@ instruct xaddI( memory mem, rRegI newval, rFlagsReg cr) %{
ins_pipe( pipe_cmpxchg );
%}
instruct xaddL_no_res( memory mem, Universe dummy, immL add, rFlagsReg cr) %{
instruct xaddL_no_res( memory mem, Universe dummy, immL32 add, rFlagsReg cr) %{
predicate(n->as_LoadStore()->result_not_used());
match(Set dummy (GetAndAddL mem add));
effect(KILL cr);

View File

@ -459,7 +459,7 @@ void RangeCheckEliminator::in_block_motion(BlockBegin *block, AccessIndexedList
// Iterate over all different indices
if (_optimistic) {
for (int i=0; i<indices.length(); i++) {
for (int i = 0; i < indices.length(); i++) {
Instruction *index_instruction = indices.at(i);
AccessIndexedInfo *info = _access_indexed_info[index_instruction->id()];
assert(info != NULL, "Info must not be null");
@ -531,9 +531,7 @@ void RangeCheckEliminator::in_block_motion(BlockBegin *block, AccessIndexedList
remove_range_check(ai);
}
}
_access_indexed_info[index_instruction->id()] = NULL;
}
indices.clear();
if (list_constant.length() > 1) {
AccessIndexed *first = list_constant.at(0);
@ -560,6 +558,13 @@ void RangeCheckEliminator::in_block_motion(BlockBegin *block, AccessIndexedList
}
}
}
// Clear data structures for next array
for (int i = 0; i < indices.length(); i++) {
Instruction *index_instruction = indices.at(i);
_access_indexed_info[index_instruction->id()] = NULL;
}
indices.clear();
}
}

View File

@ -436,14 +436,19 @@ constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) {
ref_index, CHECK_(nullHandle));
break;
case JVM_REF_invokeVirtual:
case JVM_REF_invokeStatic:
case JVM_REF_invokeSpecial:
case JVM_REF_newInvokeSpecial:
check_property(
tag.is_method(),
"Invalid constant pool index %u in class file %s (not a method)",
ref_index, CHECK_(nullHandle));
break;
case JVM_REF_invokeStatic:
case JVM_REF_invokeSpecial:
check_property(
tag.is_method() || tag.is_interface_method(),
"Invalid constant pool index %u in class file %s (not a method)",
ref_index, CHECK_(nullHandle));
break;
case JVM_REF_invokeInterface:
check_property(
tag.is_interface_method(),
@ -3837,7 +3842,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
}
if (TraceClassLoadingPreorder) {
tty->print("[Loading %s", name->as_klass_external_name());
tty->print("[Loading %s", (name != NULL) ? name->as_klass_external_name() : "NoName");
if (cfs->source() != NULL) tty->print(" from %s", cfs->source());
tty->print_cr("]");
}

View File

@ -268,8 +268,15 @@ ClassDescriptor* ClassDescriptor::parse_generic_signature(
Klass* outer = SystemDictionary::find(
outer_name, class_loader, protection_domain, CHECK_NULL);
if (outer == NULL && !THREAD->is_Compiler_thread()) {
outer = SystemDictionary::resolve_super_or_fail(original_name,
outer_name, class_loader, protection_domain, false, CHECK_NULL);
if (outer_name == ik->super()->name()) {
outer = SystemDictionary::resolve_super_or_fail(original_name, outer_name,
class_loader, protection_domain,
false, CHECK_NULL);
}
else {
outer = SystemDictionary::resolve_or_fail(outer_name, class_loader,
protection_domain, false, CHECK_NULL);
}
}
InstanceKlass* outer_ik;

View File

@ -2625,6 +2625,15 @@ Metadata* java_lang_invoke_MemberName::vmtarget(oop mname) {
return (Metadata*)mname->address_field(_vmtarget_offset);
}
#if INCLUDE_JVMTI
// Can be executed on VM thread only
void java_lang_invoke_MemberName::adjust_vmtarget(oop mname, Metadata* ref) {
assert((is_instance(mname) && (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0), "wrong type");
assert(Thread::current()->is_VM_thread(), "not VM thread");
mname->address_field_put(_vmtarget_offset, (address)ref);
}
#endif // INCLUDE_JVMTI
void java_lang_invoke_MemberName::set_vmtarget(oop mname, Metadata* ref) {
assert(is_instance(mname), "wrong type");
// check the type of the vmtarget

View File

@ -1036,6 +1036,9 @@ class java_lang_invoke_MemberName: AllStatic {
static Metadata* vmtarget(oop mname);
static void set_vmtarget(oop mname, Metadata* target);
#if INCLUDE_JVMTI
static void adjust_vmtarget(oop mname, Metadata* target);
#endif // INCLUDE_JVMTI
static intptr_t vmindex(oop mname);
static void set_vmindex(oop mname, intptr_t index);

View File

@ -1014,13 +1014,28 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHand
resolved_method->name(),
resolved_method->signature()));
}
// check if public
if (!sel_method->is_public()) {
ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
Method::name_and_sig_as_C_string(recv_klass(),
sel_method->name(),
sel_method->signature()));
// check access
if (sel_method->method_holder()->is_interface()) {
// Method holder is an interface. Throw Illegal Access Error if sel_method
// is neither public nor private.
if (!(sel_method->is_public() || sel_method->is_private())) {
ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
Method::name_and_sig_as_C_string(recv_klass(),
sel_method->name(),
sel_method->signature()));
}
}
else {
// Method holder is a class. Throw Illegal Access Error if sel_method
// is not public.
if (!sel_method->is_public()) {
ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
Method::name_and_sig_as_C_string(recv_klass(),
sel_method->name(),
sel_method->signature()));
}
}
// check if abstract
if (check_null_and_abstract && sel_method->is_abstract()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -2329,6 +2329,12 @@ void InstanceKlass::release_C_heap_structures() {
FreeHeap(jmeths);
}
MemberNameTable* mnt = member_names();
if (mnt != NULL) {
delete mnt;
set_member_names(NULL);
}
int* indices = methods_cached_itable_indices_acquire();
if (indices != (int*)NULL) {
release_set_methods_cached_itable_indices(NULL);
@ -2757,6 +2763,17 @@ nmethod* InstanceKlass::lookup_osr_nmethod(Method* const m, int bci, int comp_le
return NULL;
}
void InstanceKlass::add_member_name(Handle mem_name) {
jweak mem_name_wref = JNIHandles::make_weak_global(mem_name);
MutexLocker ml(MemberNameTable_lock);
DEBUG_ONLY(No_Safepoint_Verifier nsv);
if (_member_names == NULL) {
_member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable();
}
_member_names->add_member_name(mem_name_wref);
}
// -----------------------------------------------------------------------------------------------------
// Printing

View File

@ -90,6 +90,7 @@ class DepChange;
class nmethodBucket;
class PreviousVersionNode;
class JvmtiCachedClassFieldMap;
class MemberNameTable;
// This is used in iterators below.
class FieldClosure: public StackObj {
@ -246,6 +247,7 @@ class InstanceKlass: public Klass {
int _vtable_len; // length of Java vtable (in words)
int _itable_len; // length of Java itable (in words)
OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
MemberNameTable* _member_names; // Member names
JNIid* _jni_ids; // First JNI identifier for static fields in this class
jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
int* _methods_cached_itable_indices; // itable_index cache for JNI invoke corresponding to methods idnum, or NULL
@ -1028,6 +1030,11 @@ public:
// jvm support
jint compute_modifier_flags(TRAPS) const;
// JSR-292 support
MemberNameTable* member_names() { return _member_names; }
void set_member_names(MemberNameTable* member_names) { _member_names = member_names; }
void add_member_name(Handle member_name);
public:
// JVMTI support
jint jvmti_class_status() const;

View File

@ -3284,6 +3284,16 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass,
// that reference methods of the evolved class.
SystemDictionary::classes_do(adjust_cpool_cache_and_vtable, THREAD);
// JSR-292 support
MemberNameTable* mnt = the_class->member_names();
if (mnt != NULL) {
bool trace_name_printed = false;
mnt->adjust_method_entries(_matching_old_methods,
_matching_new_methods,
_matching_methods_length,
&trace_name_printed);
}
// Fix Resolution Error table also to remove old constant pools
SystemDictionary::delete_resolution_error(old_constants);

View File

@ -29,6 +29,7 @@
#include "interpreter/oopMapCache.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/oopFactory.hpp"
#include "prims/jvmtiRedefineClassesTrace.hpp"
#include "prims/methodHandles.hpp"
#include "runtime/compilationPolicy.hpp"
#include "runtime/javaCalls.hpp"
@ -124,7 +125,9 @@ Handle MethodHandles::new_MemberName(TRAPS) {
return Handle(THREAD, k->allocate_instance(THREAD));
}
oop MethodHandles::init_MemberName(oop mname_oop, oop target_oop) {
oop MethodHandles::init_MemberName(Handle mname, Handle target) {
Thread* thread = Thread::current();
oop target_oop = target();
Klass* target_klass = target_oop->klass();
if (target_klass == SystemDictionary::reflect_Field_klass()) {
oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder()
@ -132,24 +135,24 @@ oop MethodHandles::init_MemberName(oop mname_oop, oop target_oop) {
int mods = java_lang_reflect_Field::modifiers(target_oop);
oop type = java_lang_reflect_Field::type(target_oop);
oop name = java_lang_reflect_Field::name(target_oop);
Klass* k = java_lang_Class::as_Klass(clazz);
intptr_t offset = InstanceKlass::cast(k)->field_offset(slot);
return init_field_MemberName(mname_oop, k, accessFlags_from(mods), type, name, offset);
KlassHandle k(thread, java_lang_Class::as_Klass(clazz));
intptr_t offset = InstanceKlass::cast(k())->field_offset(slot);
return init_field_MemberName(mname, k, accessFlags_from(mods), type, name, offset);
} else if (target_klass == SystemDictionary::reflect_Method_klass()) {
oop clazz = java_lang_reflect_Method::clazz(target_oop);
int slot = java_lang_reflect_Method::slot(target_oop);
Klass* k = java_lang_Class::as_Klass(clazz);
if (k != NULL && k->oop_is_instance()) {
Method* m = InstanceKlass::cast(k)->method_with_idnum(slot);
return init_method_MemberName(mname_oop, m, true, k);
KlassHandle k(thread, java_lang_Class::as_Klass(clazz));
if (!k.is_null() && k->oop_is_instance()) {
Method* m = InstanceKlass::cast(k())->method_with_idnum(slot);
return init_method_MemberName(mname, m, true, k);
}
} else if (target_klass == SystemDictionary::reflect_Constructor_klass()) {
oop clazz = java_lang_reflect_Constructor::clazz(target_oop);
int slot = java_lang_reflect_Constructor::slot(target_oop);
Klass* k = java_lang_Class::as_Klass(clazz);
if (k != NULL && k->oop_is_instance()) {
Method* m = InstanceKlass::cast(k)->method_with_idnum(slot);
return init_method_MemberName(mname_oop, m, false, k);
KlassHandle k(thread, java_lang_Class::as_Klass(clazz));
if (!k.is_null() && k->oop_is_instance()) {
Method* m = InstanceKlass::cast(k())->method_with_idnum(slot);
return init_method_MemberName(mname, m, false, k);
}
} else if (target_klass == SystemDictionary::MemberName_klass()) {
// Note: This only works if the MemberName has already been resolved.
@ -157,17 +160,18 @@ oop MethodHandles::init_MemberName(oop mname_oop, oop target_oop) {
int flags = java_lang_invoke_MemberName::flags(target_oop);
Metadata* vmtarget=java_lang_invoke_MemberName::vmtarget(target_oop);
intptr_t vmindex = java_lang_invoke_MemberName::vmindex(target_oop);
Klass* k = java_lang_Class::as_Klass(clazz);
KlassHandle k(thread, java_lang_Class::as_Klass(clazz));
int ref_kind = (flags >> REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK;
if (vmtarget == NULL) return NULL; // not resolved
if ((flags & IS_FIELD) != 0) {
assert(vmtarget->is_klass(), "field vmtarget is Klass*");
int basic_mods = (ref_kind_is_static(ref_kind) ? JVM_ACC_STATIC : 0);
// FIXME: how does k (receiver_limit) contribute?
return init_field_MemberName(mname_oop, (Klass*)vmtarget, accessFlags_from(basic_mods), NULL, NULL, vmindex);
KlassHandle k_vmtarget(thread, (Klass*)vmtarget);
return init_field_MemberName(mname, k_vmtarget, accessFlags_from(basic_mods), NULL, NULL, vmindex);
} else if ((flags & (IS_METHOD | IS_CONSTRUCTOR)) != 0) {
assert(vmtarget->is_method(), "method or constructor vmtarget is Method*");
return init_method_MemberName(mname_oop, (Method*)vmtarget, ref_kind_does_dispatch(ref_kind), k);
return init_method_MemberName(mname, (Method*)vmtarget, ref_kind_does_dispatch(ref_kind), k);
} else {
return NULL;
}
@ -175,8 +179,9 @@ oop MethodHandles::init_MemberName(oop mname_oop, oop target_oop) {
return NULL;
}
oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_dispatch,
Klass* receiver_limit) {
oop MethodHandles::init_method_MemberName(Handle mname, Method* m, bool do_dispatch,
KlassHandle receiver_limit_h) {
Klass* receiver_limit = receiver_limit_h();
AccessFlags mods = m->access_flags();
int flags = (jushort)( mods.as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS );
int vmindex = Method::nonvirtual_vtable_index; // implies never any dispatch
@ -187,6 +192,10 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp
flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT);
} else if (mods.is_static()) {
flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT);
// Get vindex from itable if method holder is an interface.
if (m->method_holder()->is_interface()) {
vmindex = klassItable::compute_itable_index(m);
}
} else if (receiver_limit != mklass &&
!receiver_limit->is_subtype_of(mklass)) {
return NULL; // bad receiver limit
@ -213,6 +222,7 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp
flags |= CALLER_SENSITIVE;
}
oop mname_oop = mname();
java_lang_invoke_MemberName::set_flags( mname_oop, flags);
java_lang_invoke_MemberName::set_vmtarget(mname_oop, m);
java_lang_invoke_MemberName::set_vmindex( mname_oop, vmindex); // vtable/itable index
@ -225,10 +235,11 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp
// This is done eagerly, since it is readily available without
// constructing any new objects.
// TO DO: maybe intern mname_oop
return mname_oop;
m->method_holder()->add_member_name(mname);
return mname();
}
Handle MethodHandles::init_method_MemberName(oop mname_oop, CallInfo& info, TRAPS) {
Handle MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, TRAPS) {
Handle empty;
if (info.resolved_appendix().not_null()) {
// The resolved MemberName must not be accompanied by an appendix argument,
@ -248,19 +259,20 @@ Handle MethodHandles::init_method_MemberName(oop mname_oop, CallInfo& info, TRAP
} else {
vmindex = info.vtable_index();
}
oop res = init_method_MemberName(mname_oop, m(), (vmindex >= 0), defc());
oop res = init_method_MemberName(mname, m(), (vmindex >= 0), defc());
assert(res == NULL || (java_lang_invoke_MemberName::vmindex(res) == vmindex), "");
return Handle(THREAD, res);
}
oop MethodHandles::init_field_MemberName(oop mname_oop, Klass* field_holder,
oop MethodHandles::init_field_MemberName(Handle mname, KlassHandle field_holder,
AccessFlags mods, oop type, oop name,
intptr_t offset, bool is_setter) {
int flags = (jushort)( mods.as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS );
flags |= IS_FIELD | ((mods.is_static() ? JVM_REF_getStatic : JVM_REF_getField) << REFERENCE_KIND_SHIFT);
if (is_setter) flags += ((JVM_REF_putField - JVM_REF_getField) << REFERENCE_KIND_SHIFT);
Metadata* vmtarget = field_holder;
Metadata* vmtarget = field_holder();
int vmindex = offset; // determines the field uniquely when combined with static bit
oop mname_oop = mname();
java_lang_invoke_MemberName::set_flags(mname_oop, flags);
java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget);
java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex);
@ -277,10 +289,11 @@ oop MethodHandles::init_field_MemberName(oop mname_oop, Klass* field_holder,
// Although the fieldDescriptor::_index would also identify the field,
// we do not use it, because it is harder to decode.
// TO DO: maybe intern mname_oop
return mname_oop;
InstanceKlass::cast(field_holder())->add_member_name(mname);
return mname();
}
Handle MethodHandles::init_field_MemberName(oop mname_oop, FieldAccessInfo& info, TRAPS) {
Handle MethodHandles::init_field_MemberName(Handle mname, FieldAccessInfo& info, TRAPS) {
return Handle();
#if 0 // FIXME
KlassHandle field_holder = info.klass();
@ -679,7 +692,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
return empty;
}
}
return init_method_MemberName(mname(), result, THREAD);
return init_method_MemberName(mname, result, THREAD);
}
case IS_CONSTRUCTOR:
{
@ -697,7 +710,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
}
}
assert(result.is_statically_bound(), "");
return init_method_MemberName(mname(), result, THREAD);
return init_method_MemberName(mname, result, THREAD);
}
case IS_FIELD:
{
@ -710,7 +723,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
oop name = field_name_or_null(fd.name());
bool is_setter = (ref_kind_is_valid(ref_kind) && ref_kind_is_setter(ref_kind));
mname = Handle(THREAD,
init_field_MemberName(mname(), sel_klass(),
init_field_MemberName(mname, sel_klass,
fd.access_flags(), type, name, fd.offset(), is_setter));
return mname;
}
@ -802,16 +815,15 @@ void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) {
THROW_MSG(vmSymbols::java_lang_InternalError(), "unrecognized MemberName format");
}
int MethodHandles::find_MemberNames(Klass* k,
int MethodHandles::find_MemberNames(KlassHandle k,
Symbol* name, Symbol* sig,
int mflags, Klass* caller,
int skip, objArrayOop results) {
DEBUG_ONLY(No_Safepoint_Verifier nsv);
// this code contains no safepoints!
int mflags, KlassHandle caller,
int skip, objArrayHandle results) {
// %%% take caller into account!
if (k == NULL || !k->oop_is_instance()) return -1;
Thread* thread = Thread::current();
if (k.is_null() || !k->oop_is_instance()) return -1;
int rfill = 0, rlimit = results->length(), rskip = skip;
// overflow measurement:
@ -839,7 +851,7 @@ int MethodHandles::find_MemberNames(Klass* k,
}
if ((match_flags & IS_FIELD) != 0) {
for (FieldStream st(k, local_only, !search_intfc); !st.eos(); st.next()) {
for (FieldStream st(k(), local_only, !search_intfc); !st.eos(); st.next()) {
if (name != NULL && st.name() != name)
continue;
if (sig != NULL && st.signature() != sig)
@ -848,15 +860,15 @@ int MethodHandles::find_MemberNames(Klass* k,
if (rskip > 0) {
--rskip;
} else if (rfill < rlimit) {
oop result = results->obj_at(rfill++);
if (!java_lang_invoke_MemberName::is_instance(result))
Handle result(thread, results->obj_at(rfill++));
if (!java_lang_invoke_MemberName::is_instance(result()))
return -99; // caller bug!
oop type = field_signature_type_or_null(st.signature());
oop name = field_name_or_null(st.name());
oop saved = MethodHandles::init_field_MemberName(result, st.klass()(),
oop saved = MethodHandles::init_field_MemberName(result, st.klass(),
st.access_flags(), type, name,
st.offset());
if (saved != result)
if (saved != result())
results->obj_at_put(rfill-1, saved); // show saved instance to user
} else if (++overflow >= overflow_limit) {
match_flags = 0; break; // got tired of looking at overflow
@ -889,7 +901,7 @@ int MethodHandles::find_MemberNames(Klass* k,
} else {
// caller will accept either sort; no need to adjust name
}
for (MethodStream st(k, local_only, !search_intfc); !st.eos(); st.next()) {
for (MethodStream st(k(), local_only, !search_intfc); !st.eos(); st.next()) {
Method* m = st.method();
Symbol* m_name = m->name();
if (m_name == clinit_name)
@ -902,11 +914,11 @@ int MethodHandles::find_MemberNames(Klass* k,
if (rskip > 0) {
--rskip;
} else if (rfill < rlimit) {
oop result = results->obj_at(rfill++);
if (!java_lang_invoke_MemberName::is_instance(result))
Handle result(thread, results->obj_at(rfill++));
if (!java_lang_invoke_MemberName::is_instance(result()))
return -99; // caller bug!
oop saved = MethodHandles::init_method_MemberName(result, m, true, NULL);
if (saved != result)
if (saved != result())
results->obj_at_put(rfill-1, saved); // show saved instance to user
} else if (++overflow >= overflow_limit) {
match_flags = 0; break; // got tired of looking at overflow
@ -917,6 +929,99 @@ int MethodHandles::find_MemberNames(Klass* k,
// return number of elements we at leasted wanted to initialize
return rfill + overflow;
}
//------------------------------------------------------------------------------
// MemberNameTable
//
MemberNameTable::MemberNameTable() : GrowableArray<jweak>(10, true) {
assert_locked_or_safepoint(MemberNameTable_lock);
}
MemberNameTable::~MemberNameTable() {
assert_locked_or_safepoint(MemberNameTable_lock);
int len = this->length();
for (int idx = 0; idx < len; idx++) {
jweak ref = this->at(idx);
JNIHandles::destroy_weak_global(ref);
}
}
// Return entry index if found, return -1 otherwise.
int MemberNameTable::find_member_name(oop mem_name) {
assert_locked_or_safepoint(MemberNameTable_lock);
int len = this->length();
for (int idx = 0; idx < len; idx++) {
jweak ref = this->at(idx);
oop entry = JNIHandles::resolve(ref);
if (entry == mem_name) {
return idx;
}
}
return -1;
}
void MemberNameTable::add_member_name(jweak mem_name_wref) {
assert_locked_or_safepoint(MemberNameTable_lock);
oop mem_name = JNIHandles::resolve(mem_name_wref);
// Each member name may appear just once: add only if not found
if (find_member_name(mem_name) == -1) {
this->append(mem_name_wref);
}
}
#if INCLUDE_JVMTI
oop MemberNameTable::find_member_name_by_method(Method* old_method) {
assert_locked_or_safepoint(MemberNameTable_lock);
oop found = NULL;
int len = this->length();
for (int idx = 0; idx < len; idx++) {
oop mem_name = JNIHandles::resolve(this->at(idx));
if (mem_name == NULL) {
continue;
}
Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name);
if (method == old_method) {
found = mem_name;
break;
}
}
return found;
}
// It is called at safepoint only
void MemberNameTable::adjust_method_entries(Method** old_methods, Method** new_methods,
int methods_length, bool *trace_name_printed) {
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
// search the MemberNameTable for uses of either obsolete or EMCP methods
for (int j = 0; j < methods_length; j++) {
Method* old_method = old_methods[j];
Method* new_method = new_methods[j];
oop mem_name = find_member_name_by_method(old_method);
if (mem_name != NULL) {
java_lang_invoke_MemberName::adjust_vmtarget(mem_name, new_method);
if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
if (!(*trace_name_printed)) {
// RC_TRACE_MESG macro has an embedded ResourceMark
RC_TRACE_MESG(("adjust: name=%s",
old_method->method_holder()->external_name()));
*trace_name_printed = true;
}
// RC_TRACE macro has an embedded ResourceMark
RC_TRACE(0x00400000, ("MemberName method update: %s(%s)",
new_method->name()->as_C_string(),
new_method->signature()->as_C_string()));
}
}
}
}
#endif // INCLUDE_JVMTI
//
// Here are the native methods in java.lang.invoke.MethodHandleNatives
// They are the private interface between this JVM and the HotSpot-specific
@ -1010,8 +1115,8 @@ JVM_ENTRY(void, MHN_init_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jobje
if (mname_jh == NULL) { THROW_MSG(vmSymbols::java_lang_InternalError(), "mname is null"); }
if (target_jh == NULL) { THROW_MSG(vmSymbols::java_lang_InternalError(), "target is null"); }
Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh));
oop target_oop = JNIHandles::resolve_non_null(target_jh);
MethodHandles::init_MemberName(mname(), target_oop);
Handle target(THREAD, JNIHandles::resolve_non_null(target_jh));
MethodHandles::init_MemberName(mname, target);
}
JVM_END
@ -1118,7 +1223,7 @@ JVM_ENTRY(jobject, MHN_getMemberVMInfo(JNIEnv *env, jobject igcls, jobject mname
x = ((Klass*) vmtarget)->java_mirror();
} else if (vmtarget->is_method()) {
Handle mname2 = MethodHandles::new_MemberName(CHECK_NULL);
x = MethodHandles::init_method_MemberName(mname2(), (Method*)vmtarget, false, NULL);
x = MethodHandles::init_method_MemberName(mname2, (Method*)vmtarget, false, NULL);
}
result->obj_at_put(1, x);
return JNIHandles::make_local(env, result());
@ -1161,8 +1266,8 @@ JVM_ENTRY(jint, MHN_getMembers(JNIEnv *env, jobject igcls,
// %%% TO DO
}
int res = MethodHandles::find_MemberNames(k(), name, sig, mflags,
caller(), skip, results());
int res = MethodHandles::find_MemberNames(k, name, sig, mflags,
caller, skip, results);
// TO DO: expand at least some of the MemberNames, to avoid massive callbacks
return res;
}

View File

@ -54,23 +54,23 @@ class MethodHandles: AllStatic {
static Handle resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type
static void expand_MemberName(Handle mname, int suppress, TRAPS); // expand defc/name/type if missing
static Handle new_MemberName(TRAPS); // must be followed by init_MemberName
static oop init_MemberName(oop mname_oop, oop target_oop); // compute vmtarget/vmindex from target
static oop init_method_MemberName(oop mname_oop, Method* m, bool do_dispatch,
Klass* receiver_limit);
static oop init_field_MemberName(oop mname_oop, Klass* field_holder,
static oop init_MemberName(Handle mname_h, Handle target_h); // compute vmtarget/vmindex from target
static oop init_method_MemberName(Handle mname_h, Method* m, bool do_dispatch,
KlassHandle receiver_limit_h);
static oop init_field_MemberName(Handle mname_h, KlassHandle field_holder_h,
AccessFlags mods, oop type, oop name,
intptr_t offset, bool is_setter = false);
static Handle init_method_MemberName(oop mname_oop, CallInfo& info, TRAPS);
static Handle init_field_MemberName(oop mname_oop, FieldAccessInfo& info, TRAPS);
static Handle init_method_MemberName(Handle mname_h, CallInfo& info, TRAPS);
static Handle init_field_MemberName(Handle mname_h, FieldAccessInfo& info, TRAPS);
static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true);
static int find_MemberNames(Klass* k, Symbol* name, Symbol* sig,
int mflags, Klass* caller,
int skip, objArrayOop results);
static int find_MemberNames(KlassHandle k, Symbol* name, Symbol* sig,
int mflags, KlassHandle caller,
int skip, objArrayHandle results);
// bit values for suppress argument to expand_MemberName:
enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 };
// Generate MethodHandles adapters.
static void generate_adapters();
static void generate_adapters();
// Called from MethodHandlesAdapterGenerator.
static address generate_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid);
@ -230,4 +230,27 @@ public:
void generate();
};
//------------------------------------------------------------------------------
// MemberNameTable
//
class MemberNameTable : public GrowableArray<jweak> {
public:
MemberNameTable();
~MemberNameTable();
void add_member_name(jweak mem_name_ref);
private:
int find_member_name(oop mem_name);
#if INCLUDE_JVMTI
public:
// RedefineClasses() API support:
// If a MemberName refers to old_method then update it
// to refer to new_method.
void adjust_method_entries(Method** old_methods, Method** new_methods,
int methods_length, bool *trace_name_printed);
private:
oop find_member_name_by_method(Method* old_method);
#endif // INCLUDE_JVMTI
};
#endif // SHARE_VM_PRIMS_METHODHANDLES_HPP

View File

@ -1901,7 +1901,7 @@ bool Arguments::check_vm_args_consistency() {
// Divide by bucket size to prevent a large size from causing rollover when
// calculating amount of memory needed to be allocated for the String table.
status = status && verify_interval(StringTableSize, defaultStringTableSize,
status = status && verify_interval(StringTableSize, minimumStringTableSize,
(max_uintx / StringTable::bucket_size()), "StringTable size");
if (MinHeapFreeRatio > MaxHeapFreeRatio) {

View File

@ -46,6 +46,7 @@ Mutex* VMStatistic_lock = NULL;
Mutex* JNIGlobalHandle_lock = NULL;
Mutex* JNIHandleBlockFreeList_lock = NULL;
Mutex* JNICachedItableIndex_lock = NULL;
Mutex* MemberNameTable_lock = NULL;
Mutex* JmethodIdCreation_lock = NULL;
Mutex* JfieldIdCreation_lock = NULL;
Monitor* JNICritical_lock = NULL;
@ -252,6 +253,7 @@ void mutex_init() {
def(Heap_lock , Monitor, nonleaf+1, false);
def(JfieldIdCreation_lock , Mutex , nonleaf+1, true ); // jfieldID, Used in VM_Operation
def(JNICachedItableIndex_lock , Mutex , nonleaf+1, false); // Used to cache an itable index during JNI invoke
def(MemberNameTable_lock , Mutex , nonleaf+1, false); // Used to protect MemberNameTable
def(CompiledIC_lock , Mutex , nonleaf+2, false); // locks VtableStubs_lock, InlineCacheBuffer_lock
def(CompileTaskAlloc_lock , Mutex , nonleaf+2, true );

View File

@ -51,6 +51,7 @@ extern Mutex* VMStatistic_lock; // a lock used to guard statist
extern Mutex* JNIGlobalHandle_lock; // a lock on creating JNI global handles
extern Mutex* JNIHandleBlockFreeList_lock; // a lock on the JNI handle block free list
extern Mutex* JNICachedItableIndex_lock; // a lock on caching an itable index during JNI invoke
extern Mutex* MemberNameTable_lock; // a lock on the MemberNameTable updates
extern Mutex* JmethodIdCreation_lock; // a lock on creating JNI method identifiers
extern Mutex* JfieldIdCreation_lock; // a lock on creating JNI static field identifiers
extern Monitor* JNICritical_lock; // a lock used while entering and exiting JNI critical regions, allows GC to sometimes get in

View File

@ -2126,7 +2126,7 @@ JVM_ENTRY(jint, jmm_DumpHeap0(JNIEnv *env, jstring outputfile, jboolean live))
THROW_MSG_(vmSymbols::java_lang_NullPointerException(),
"Output file name cannot be null.", -1);
}
char* name = java_lang_String::as_utf8_string(on);
char* name = java_lang_String::as_platform_dependent_str(on, CHECK_(-1));
if (name == NULL) {
THROW_MSG_(vmSymbols::java_lang_NullPointerException(),
"Output file name cannot be null.", -1);

View File

@ -133,7 +133,7 @@ typedef struct _memType2Name {
// This class aggregates malloc'd records by memory type
class MallocMem : public _ValueObj {
class MallocMem VALUE_OBJ_CLASS_SPEC {
private:
MEMFLAGS _type;
@ -211,7 +211,7 @@ class ArenaMem : public MallocMem {
};
// This class aggregates virtual memory by its memory type
class VMMem : public _ValueObj {
class VMMem VALUE_OBJ_CLASS_SPEC {
private:
MEMFLAGS _type;
@ -296,7 +296,7 @@ class BaselineComparisonReporter;
* aggregates memory usage by callsites when detail tracking
* is on.
*/
class MemBaseline : public _ValueObj {
class MemBaseline VALUE_OBJ_CLASS_SPEC {
friend class BaselineReporter;
friend class BaselineComparisonReporter;

View File

@ -89,7 +89,7 @@ class SequenceGenerator : AllStatic {
* the memory pointer either points to a malloc'd
* memory block, or a mmap'd memory block
*/
class MemPointer : public _ValueObj {
class MemPointer VALUE_OBJ_CLASS_SPEC {
public:
MemPointer(): _addr(0) { }
MemPointer(address addr): _addr(addr) { }

View File

@ -308,7 +308,7 @@ class VMRecordIterator : public MemPointerArrayIterator {
}
};
class StagingArea : public _ValueObj {
class StagingArea VALUE_OBJ_CLASS_SPEC {
private:
MemPointerArray* _malloc_data;
MemPointerArray* _vm_data;

View File

@ -32,7 +32,7 @@
// Maximum MAX_GENERATIONS generation data can be tracked.
#define MAX_GENERATIONS 512
class GenerationData : public _ValueObj {
class GenerationData VALUE_OBJ_CLASS_SPEC {
private:
int _number_of_classes;
MemRecorder* _recorder_list;

View File

@ -328,9 +328,10 @@ const int max_method_code_size = 64*K - 1; // JVM spec, 2nd ed. section 4.8.1 (
//----------------------------------------------------------------------------------------------------
// Minimum StringTableSize value
// Default and minimum StringTableSize values
const int defaultStringTableSize=1009;
const int defaultStringTableSize = NOT_LP64(1009) LP64_ONLY(60013);
const int minimumStringTableSize=1009;
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8011901
* @summary instruct xaddL_no_res shouldn't allow 64 bit constants.
* @run main/othervm -XX:-BackgroundCompilation Test8011901
*
*/
import java.lang.reflect.*;
import sun.misc.*;
public class Test8011901 {
private long ctl;
private static final sun.misc.Unsafe U;
private static final long CTL;
static {
try {
Field unsafe = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
unsafe.setAccessible(true);
U = (sun.misc.Unsafe) unsafe.get(null);
CTL = U.objectFieldOffset(Test8011901.class.getDeclaredField("ctl"));
} catch (Exception e) {
throw new Error(e);
}
}
public static void main(String[] args) {
for(int c = 0; c < 20000; c++) {
new Test8011901().makeTest();
}
System.out.println("Test Passed");
}
public static final long EXPECTED = 1L << 42;
public void makeTest() {
U.getAndAddLong(this, CTL, EXPECTED);
if (ctl != EXPECTED) {
throw new RuntimeException("Test failed. Expected: " + EXPECTED + ", but got = " + ctl);
}
}
}

View File

@ -207,3 +207,5 @@ d5a58291f09a5081eaf22c2a6ab2f9ced4b78882 jdk8-b82
a46d69a1a8ec9652a48114823535372e1c980799 jdk8-b83
f5f40094ffcc1230e2a5f76ea4c968645369be6c jdk8-b84
41b50e2c5ea3f4aa1af729e1deb1678cb3e1ef9c jdk8-b85
ca71ec37b2efc9c3f0971ebabb3a6eb1213d76de jdk8-b86
eddbc8ad2435a89f64729512337c9f2669e4dd85 jdk8-b87

View File

@ -63,6 +63,7 @@ import com.sun.org.apache.bcel.internal.util.SyntheticRepository;
import com.sun.org.apache.bcel.internal.util.ClassVector;
import com.sun.org.apache.bcel.internal.util.ClassQueue;
import com.sun.org.apache.bcel.internal.generic.Type;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.io.*;
import java.util.StringTokenizer;
@ -77,6 +78,7 @@ import java.util.StringTokenizer;
* class file. Those interested in programatically generating classes
* should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
* @version $Id: JavaClass.java,v 1.4 2007-07-19 04:34:42 ofung Exp $
* @see com.sun.org.apache.bcel.internal.generic.ClassGen
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
@ -451,9 +453,9 @@ public class JavaClass extends AccessFlags implements Cloneable, Node {
String debug = null, sep = null;
try {
debug = System.getProperty("JavaClass.debug");
debug = SecuritySupport.getSystemProperty("JavaClass.debug");
// Get path separator either / or \ usually
sep = System.getProperty("file.separator");
sep = SecuritySupport.getSystemProperty("file.separator");
}
catch (SecurityException e) {
// falls through

View File

@ -82,6 +82,7 @@ import com.sun.org.apache.bcel.internal.Constants;
* method in the Method's frame will jump to the appropiate method in
* the Code frame.
*
* @version $Id: Class2HTML.java,v 1.3 2007-07-19 04:34:52 ofung Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public class Class2HTML implements Constants
@ -137,7 +138,7 @@ public class Class2HTML implements Constants
ClassParser parser=null;
JavaClass java_class=null;
String zip_file = null;
char sep = System.getProperty("file.separator").toCharArray()[0];
char sep = SecuritySupport.getSystemProperty("file.separator").toCharArray()[0];
String dir = "." + sep; // Where to store HTML files
try {

View File

@ -66,6 +66,7 @@ import java.io.*;
* Responsible for loading (class) files from the CLASSPATH. Inspired by
* sun.tools.ClassPath.
*
* @version $Id: ClassPath.java,v 1.4 2007-07-19 04:34:52 ofung Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public class ClassPath implements Serializable {
@ -83,7 +84,7 @@ public class ClassPath implements Serializable {
ArrayList vec = new ArrayList();
for(StringTokenizer tok=new StringTokenizer(class_path,
System.getProperty("path.separator"));
SecuritySupport.getSystemProperty("path.separator"));
tok.hasMoreTokens();)
{
String path = tok.nextToken();
@ -92,7 +93,7 @@ public class ClassPath implements Serializable {
File file = new File(path);
try {
if(file.exists()) {
if(SecuritySupport.getFileExists(file)) {
if(file.isDirectory())
vec.add(new Dir(path));
else
@ -143,8 +144,9 @@ public class ClassPath implements Serializable {
String name = tok.nextToken();
File file = new File(name);
if(file.exists())
if(SecuritySupport.getFileExists(file)) {
list.add(name);
}
}
}
}
@ -159,9 +161,9 @@ public class ClassPath implements Serializable {
String class_path, boot_path, ext_path;
try {
class_path = System.getProperty("java.class.path");
boot_path = System.getProperty("sun.boot.class.path");
ext_path = System.getProperty("java.ext.dirs");
class_path = SecuritySupport.getSystemProperty("java.class.path");
boot_path = SecuritySupport.getSystemProperty("sun.boot.class.path");
ext_path = SecuritySupport.getSystemProperty("java.ext.dirs");
}
catch (SecurityException e) {
return "";
@ -176,8 +178,8 @@ public class ClassPath implements Serializable {
getPathComponents(ext_path, dirs);
for(Iterator e = dirs.iterator(); e.hasNext(); ) {
File ext_dir = new File((String)e.next());
String[] extensions = ext_dir.list(new FilenameFilter() {
File ext_dir = new File((String)e.next());
String[] extensions = SecuritySupport.getFileList(ext_dir, new FilenameFilter() {
public boolean accept(File dir, String name) {
name = name.toLowerCase();
return name.endsWith(".zip") || name.endsWith(".jar");
@ -342,7 +344,7 @@ public class ClassPath implements Serializable {
final File file = new File(dir + File.separatorChar +
name.replace('.', File.separatorChar) + suffix);
return file.exists()? new ClassFile() {
return SecuritySupport.getFileExists(file)? new ClassFile() {
public InputStream getInputStream() throws IOException { return new FileInputStream(file); }
public String getPath() { try {

View File

@ -72,6 +72,7 @@ import java.lang.reflect.*;
* <pre>java com.sun.org.apache.bcel.internal.util.JavaWrapper -Dbcel.classloader=foo.MyLoader &lt;real.class.name&gt; [arguments]</pre>
* </p>
*
* @version $Id: JavaWrapper.java,v 1.3 2007-07-19 04:34:52 ofung Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see ClassLoader
*/
@ -79,7 +80,7 @@ public class JavaWrapper {
private java.lang.ClassLoader loader;
private static java.lang.ClassLoader getClassLoader() {
String s = System.getProperty("bcel.classloader");
String s = SecuritySupport.getSystemProperty("bcel.classloader");
if((s == null) || "".equals(s))
s = "com.sun.org.apache.bcel.internal.util.ClassLoader";

View File

@ -0,0 +1,223 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.bcel.internal.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.lang.ClassLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* This class is duplicated for each subpackage so keep it in sync. It is
* package private and therefore is not exposed as part of any API.
*
* @xerces.internal
*/
public final class SecuritySupport {
private static final SecuritySupport securitySupport = new SecuritySupport();
/**
* Return an instance of this class.
*/
public static SecuritySupport getInstance() {
return securitySupport;
}
static ClassLoader getContextClassLoader() {
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
} catch (SecurityException ex) {
}
return cl;
}
});
}
static ClassLoader getSystemClassLoader() {
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
try {
cl = ClassLoader.getSystemClassLoader();
} catch (SecurityException ex) {
}
return cl;
}
});
}
static ClassLoader getParentClassLoader(final ClassLoader cl) {
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader parent = null;
try {
parent = cl.getParent();
} catch (SecurityException ex) {
}
// eliminate loops in case of the boot
// ClassLoader returning itself as a parent
return (parent == cl) ? null : parent;
}
});
}
public static String getSystemProperty(final String propName) {
return (String) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty(propName);
}
});
}
static FileInputStream getFileInputStream(final File file)
throws FileNotFoundException {
try {
return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws FileNotFoundException {
return new FileInputStream(file);
}
});
} catch (PrivilegedActionException e) {
throw (FileNotFoundException) e.getException();
}
}
/**
* Return resource using the same classloader for the ObjectFactory by
* default or bootclassloader when Security Manager is in place
*/
public static InputStream getResourceAsStream(final String name) {
if (System.getSecurityManager() != null) {
return getResourceAsStream(null, name);
} else {
return getResourceAsStream(findClassLoader(), name);
}
}
public static InputStream getResourceAsStream(final ClassLoader cl,
final String name) {
return (InputStream) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
InputStream ris;
if (cl == null) {
ris = Object.class.getResourceAsStream("/" + name);
} else {
ris = cl.getResourceAsStream(name);
}
return ris;
}
});
}
/**
* Gets a resource bundle using the specified base name, the default locale,
* and the caller's class loader.
*
* @param bundle the base name of the resource bundle, a fully qualified
* class name
* @return a resource bundle for the given base name and the default locale
*/
public static ListResourceBundle getResourceBundle(String bundle) {
return getResourceBundle(bundle, Locale.getDefault());
}
/**
* Gets a resource bundle using the specified base name and locale, and the
* caller's class loader.
*
* @param bundle the base name of the resource bundle, a fully qualified
* class name
* @param locale the locale for which a resource bundle is desired
* @return a resource bundle for the given base name and locale
*/
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
public ListResourceBundle run() {
try {
return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
} catch (MissingResourceException e) {
try {
return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
} catch (MissingResourceException e2) {
throw new MissingResourceException(
"Could not load any resource bundle by " + bundle, bundle, "");
}
}
}
});
}
public static String[] getFileList(final File f, final FilenameFilter filter) {
return ((String[]) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return f.list(filter);
}
}));
}
public static boolean getFileExists(final File f) {
return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return f.exists() ? Boolean.TRUE : Boolean.FALSE;
}
})).booleanValue();
}
static long getLastModified(final File f) {
return ((Long) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return new Long(f.lastModified());
}
})).longValue();
}
/**
* Figure out which ClassLoader to use.
*/
public static ClassLoader findClassLoader()
{
if (System.getSecurityManager()!=null) {
//this will ensure bootclassloader is used
return null;
} else {
return SecuritySupport.class.getClassLoader();
}
} // findClassLoader():ClassLoader
private SecuritySupport() {
}
}

View File

@ -22,68 +22,72 @@
*/
package com.sun.org.apache.xalan.internal.res;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.util.ListResourceBundle;
import com.sun.org.apache.xpath.internal.res.XPATHMessages;
/**
* Sets things up for issuing error messages. This class is misnamed, and
* should be called XalanMessages, or some such.
* Sets things up for issuing error messages. This class is misnamed, and should
* be called XalanMessages, or some such.
*
* @xsl.usage internal
*/
public class XSLMessages extends XPATHMessages
{
public class XSLMessages extends XPATHMessages {
/** The language specific resource object for Xalan messages. */
private static ListResourceBundle XSLTBundle = null;
/**
* The language specific resource object for Xalan messages.
*/
private static ListResourceBundle XSLTBundle = null;
/**
* The class name of the Xalan error message string table.
*/
private static final String XSLT_ERROR_RESOURCES =
"com.sun.org.apache.xalan.internal.res.XSLTErrorResources";
/** The class name of the Xalan error message string table. */
private static final String XSLT_ERROR_RESOURCES =
"com.sun.org.apache.xalan.internal.res.XSLTErrorResources";
/**
* Creates a message from the specified key and replacement
* arguments, localized to the given locale.
*
* @param msgKey The key for the message text.
* @param args The arguments to be used as replacement text
* in the message created.
*
* @return The formatted message string.
*/
public static final String createMessage(String msgKey, Object args[]) //throws Exception
{
if (XSLTBundle == null)
XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
if (XSLTBundle != null)
/**
* Creates a message from the specified key and replacement arguments,
* localized to the given locale.
*
* @param msgKey The key for the message text.
* @param args The arguments to be used as replacement text in the message
* created.
*
* @return The formatted message string.
*/
public static String createMessage(String msgKey, Object args[]) //throws Exception
{
return createMsg(XSLTBundle, msgKey, args);
if (XSLTBundle == null) {
XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES);
}
if (XSLTBundle != null) {
return createMsg(XSLTBundle, msgKey, args);
} else {
return "Could not load any resource bundles.";
}
}
else
return "Could not load any resource bundles.";
}
/**
* Creates a message from the specified key and replacement
* arguments, localized to the given locale.
*
* @param msgKey The key for the message text.
* @param args The arguments to be used as replacement text
* in the message created.
*
* @return The formatted warning string.
*/
public static final String createWarning(String msgKey, Object args[]) //throws Exception
{
if (XSLTBundle == null)
XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
if (XSLTBundle != null)
/**
* Creates a message from the specified key and replacement arguments,
* localized to the given locale.
*
* @param msgKey The key for the message text.
* @param args The arguments to be used as replacement text in the message
* created.
*
* @return The formatted warning string.
*/
public static String createWarning(String msgKey, Object args[]) //throws Exception
{
return createMsg(XSLTBundle, msgKey, args);
if (XSLTBundle == null) {
XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES);
}
if (XSLTBundle != null) {
return createMsg(XSLTBundle, msgKey, args);
} else {
return "Could not load any resource bundles.";
}
}
else
return "Could not load any resource bundles.";
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_de extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_es extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_fr extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_it extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_ja extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_ko extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1449,68 +1449,5 @@ public class XSLTErrorResources_pt_BR extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_sv extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_zh_CN extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -1448,68 +1448,4 @@ public class XSLTErrorResources_zh_TW extends ListResourceBundle
public static final String QUERY_HEADER = "PATTERN ";
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -54,6 +54,8 @@ public class ObjectFactory {
//
// Constants
//
private static final String XALAN_INTERNAL = "com.sun.org.apache.xalan.internal";
private static final String XERCES_INTERNAL = "com.sun.org.apache.xerces.internal";
// name of default properties file to look for in JDK's jre/lib directory
private static final String DEFAULT_PROPERTIES_FILENAME =
@ -514,12 +516,17 @@ public class ObjectFactory {
//class. Restrict the access to the package classes as specified in java.security policy.
SecurityManager security = System.getSecurityManager();
try{
if (security != null){
if (security != null){
if (className.startsWith(XALAN_INTERNAL) ||
className.startsWith(XERCES_INTERNAL)) {
cl = null;
} else {
final int lastDot = className.lastIndexOf(".");
String packageName = className;
if (lastDot != -1) packageName = className.substring(0, lastDot);
security.checkPackageAccess(packageName);
}
}
}
}catch(SecurityException e){
throw e;
}

View File

@ -32,10 +32,14 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* This class is duplicated for each subpackage so keep it in sync.
* It is package private and therefore is not exposed as part of any API.
* This class is duplicated for each subpackage so keep it in sync. It is
* package private and therefore is not exposed as part of any API.
*
* @xerces.internal
*/
@ -51,39 +55,39 @@ public final class SecuritySupport {
}
static ClassLoader getContextClassLoader() {
return (ClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
} catch (SecurityException ex) { }
} catch (SecurityException ex) {
}
return cl;
}
});
}
static ClassLoader getSystemClassLoader() {
return (ClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
try {
cl = ClassLoader.getSystemClassLoader();
} catch (SecurityException ex) {}
} catch (SecurityException ex) {
}
return cl;
}
});
}
static ClassLoader getParentClassLoader(final ClassLoader cl) {
return (ClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader parent = null;
try {
parent = cl.getParent();
} catch (SecurityException ex) {}
} catch (SecurityException ex) {
}
// eliminate loops in case of the boot
// ClassLoader returning itself as a parent
@ -93,20 +97,25 @@ public final class SecuritySupport {
}
public static String getSystemProperty(final String propName) {
return (String)
AccessController.doPrivileged(new PrivilegedAction() {
return (String) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty(propName);
}
});
}
public static String getSystemProperty(final String propName, final String def) {
return (String) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty(propName, def);
}
});
}
static FileInputStream getFileInputStream(final File file)
throws FileNotFoundException
{
throws FileNotFoundException {
try {
return (FileInputStream)
AccessController.doPrivileged(new PrivilegedExceptionAction() {
return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws FileNotFoundException {
return new FileInputStream(file);
}
@ -115,9 +124,10 @@ public final class SecuritySupport {
throw (FileNotFoundException)e.getException();
}
}
/**
* Return resource using the same classloader for the ObjectFactory by default
* or bootclassloader when Security Manager is in place
* Return resource using the same classloader for the ObjectFactory by
* default or bootclassloader when Security Manager is in place
*/
public static InputStream getResourceAsStream(final String name) {
if (System.getSecurityManager()!=null) {
@ -128,10 +138,8 @@ public final class SecuritySupport {
}
public static InputStream getResourceAsStream(final ClassLoader cl,
final String name)
{
return (InputStream)
AccessController.doPrivileged(new PrivilegedAction() {
final String name) {
return (InputStream) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
InputStream ris;
if (cl == null) {
@ -144,9 +152,40 @@ public final class SecuritySupport {
});
}
static boolean getFileExists(final File f) {
return ((Boolean)
AccessController.doPrivileged(new PrivilegedAction() {
/**
* Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.
* @param bundle the base name of the resource bundle, a fully qualified class name
* @return a resource bundle for the given base name and the default locale
*/
public static ListResourceBundle getResourceBundle(String bundle) {
return getResourceBundle(bundle, Locale.getDefault());
}
/**
* Gets a resource bundle using the specified base name and locale, and the caller's class loader.
* @param bundle the base name of the resource bundle, a fully qualified class name
* @param locale the locale for which a resource bundle is desired
* @return a resource bundle for the given base name and locale
*/
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
public ListResourceBundle run() {
try {
return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
} catch (MissingResourceException e) {
try {
return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
} catch (MissingResourceException e2) {
throw new MissingResourceException(
"Could not load any resource bundle by " + bundle, bundle, "");
}
}
}
});
}
public static boolean getFileExists(final File f) {
return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return f.exists() ? Boolean.TRUE : Boolean.FALSE;
}
@ -154,13 +193,14 @@ public final class SecuritySupport {
}
static long getLastModified(final File f) {
return ((Long)
AccessController.doPrivileged(new PrivilegedAction() {
return ((Long) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return new Long(f.lastModified());
}
})).longValue();
}
private SecuritySupport () {}
private SecuritySupport() {
}
}

View File

@ -23,6 +23,7 @@
package com.sun.org.apache.xalan.internal.xslt;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.io.File;
import java.io.FileWriter;
@ -574,7 +575,7 @@ public class EnvironmentCheck
// Grab java version for later use
try
{
String javaVersion = System.getProperty("java.version");
String javaVersion = SecuritySupport.getSystemProperty("java.version");
h.put("java.version", javaVersion);
}
@ -593,7 +594,7 @@ public class EnvironmentCheck
{
// This is present in all JVM's
String cp = System.getProperty("java.class.path");
String cp = SecuritySupport.getSystemProperty("java.class.path");
h.put("java.class.path", cp);
@ -603,7 +604,7 @@ public class EnvironmentCheck
h.put(FOUNDCLASSES + "java.class.path", classpathJars);
// Also check for JDK 1.2+ type classpaths
String othercp = System.getProperty("sun.boot.class.path");
String othercp = SecuritySupport.getSystemProperty("sun.boot.class.path");
if (null != othercp)
{
@ -617,7 +618,7 @@ public class EnvironmentCheck
//@todo NOTE: We don't actually search java.ext.dirs for
// *.jar files therein! This should be updated
othercp = System.getProperty("java.ext.dirs");
othercp = SecuritySupport.getSystemProperty("java.ext.dirs");
if (null != othercp)
{

View File

@ -57,6 +57,7 @@ import com.sun.org.apache.xalan.internal.res.XSLMessages;
import com.sun.org.apache.xalan.internal.res.XSLTErrorResources;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.ConfigurationError;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
//J2SE does not support Xalan interpretive
/*
@ -180,7 +181,7 @@ public class Process
java.io.PrintWriter diagnosticsWriter = new PrintWriter(System.err, true);
java.io.PrintWriter dumpWriter = diagnosticsWriter;
ResourceBundle resbundle =
(XSLMessages.loadResourceBundle(
(SecuritySupport.getResourceBundle(
com.sun.org.apache.xml.internal.utils.res.XResourceBundle.ERROR_RESOURCES));
String flavor = "s2s";

View File

@ -410,7 +410,7 @@ public class Parser implements Constants, ContentHandler {
}
}
catch (TypeCheckError e) {
reportError(ERROR, new ErrorMsg(e));
reportError(ERROR, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
}
}
@ -430,7 +430,7 @@ public class Parser implements Constants, ContentHandler {
}
catch (IOException e) {
if (_xsltc.debug()) e.printStackTrace();
reportError(ERROR,new ErrorMsg(e));
reportError(ERROR,new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
}
catch (SAXException e) {
Throwable ex = e.getException();
@ -438,15 +438,15 @@ public class Parser implements Constants, ContentHandler {
e.printStackTrace();
if (ex != null) ex.printStackTrace();
}
reportError(ERROR, new ErrorMsg(e));
reportError(ERROR, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
}
catch (CompilerException e) {
if (_xsltc.debug()) e.printStackTrace();
reportError(ERROR, new ErrorMsg(e));
reportError(ERROR, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
}
catch (Exception e) {
if (_xsltc.debug()) e.printStackTrace();
reportError(ERROR, new ErrorMsg(e));
reportError(ERROR, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
}
return null;
}

View File

@ -41,10 +41,12 @@ import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@ -278,7 +280,7 @@ public final class XSLTC {
return compile(input, _className);
}
catch (IOException e) {
_parser.reportError(Constants.FATAL, new ErrorMsg(e));
_parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
return false;
}
}
@ -297,7 +299,7 @@ public final class XSLTC {
return compile(input, name);
}
catch (IOException e) {
_parser.reportError(Constants.FATAL, new ErrorMsg(e));
_parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
return false;
}
}
@ -382,11 +384,11 @@ public final class XSLTC {
}
catch (Exception e) {
/*if (_debug)*/ e.printStackTrace();
_parser.reportError(Constants.FATAL, new ErrorMsg(e));
_parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
}
catch (Error e) {
if (_debug) e.printStackTrace();
_parser.reportError(Constants.FATAL, new ErrorMsg(e));
_parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
}
finally {
_reader = null; // reset this here to be sure it is not re-used
@ -594,7 +596,7 @@ public final class XSLTC {
*/
public boolean setDestDirectory(String dstDirName) {
final File dir = new File(dstDirName);
if (dir.exists() || dir.mkdirs()) {
if (SecuritySupport.getFileExists(dir) || dir.mkdirs()) {
_destDir = dir;
return true;
}
@ -767,7 +769,7 @@ public final class XSLTC {
String parentDir = outFile.getParent();
if (parentDir != null) {
File parentFile = new File(parentDir);
if (!parentFile.exists())
if (!SecuritySupport.getFileExists(parentFile))
parentFile.mkdirs();
}
}

View File

@ -997,7 +997,12 @@ public class ErrorMessages extends ListResourceBundle {
"kilobytes. This is usually caused by templates in a stylesheet " +
"that are very large. Try restructuring your stylesheet to use " +
"smaller templates."
}
},
{ErrorMsg.DESERIALIZE_TRANSLET_ERR, "When Java security is enabled, " +
"support for deserializing TemplatesImpl is disabled." +
"This can be overridden by setting the jdk.xml.enableTemplatesImplDeserialization" +
" system property to true."}
};

View File

@ -23,6 +23,7 @@
package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;
@ -46,6 +47,8 @@ public final class ErrorMsg {
Object[] _params = null;
private boolean _isWarningError;
Throwable _cause;
// Compiler error messages
public static final String MULTIPLE_STYLESHEET_ERR = "MULTIPLE_STYLESHEET_ERR";
public static final String TEMPLATE_REDEF_ERR = "TEMPLATE_REDEF_ERR";
@ -165,6 +168,8 @@ public final class ErrorMsg {
public static final String OUTLINE_ERR_METHOD_TOO_BIG =
"OUTLINE_ERR_METHOD_TOO_BIG";
public static final String DESERIALIZE_TRANSLET_ERR = "DESERIALIZE_TEMPLATES_ERR";
// All error messages are localized and are stored in resource bundles.
// This array and the following 4 strings are read from that bundle.
private static ResourceBundle _bundle;
@ -175,7 +180,7 @@ public final class ErrorMsg {
public final static String RUNTIME_ERROR_KEY = "RUNTIME_ERROR_KEY";
static {
_bundle = ResourceBundle.getBundle(
_bundle = SecuritySupport.getResourceBundle(
"com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMessages",
Locale.getDefault());
}
@ -185,10 +190,11 @@ public final class ErrorMsg {
_line = 0;
}
public ErrorMsg(Throwable e) {
_code = null;
public ErrorMsg(String code, Throwable e) {
_code = code;
_message = e.getMessage();
_line = 0;
_cause = e;
}
public ErrorMsg(String message, int line) {
@ -240,6 +246,10 @@ public final class ErrorMsg {
_params[1] = param2;
}
public Throwable getCause() {
return _cause;
}
private String getFileName(SyntaxTreeNode node) {
Stylesheet stylesheet = node.getStylesheet();
if (stylesheet != null)

View File

@ -26,6 +26,7 @@ package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
import java.util.StringTokenizer;
import com.sun.org.apache.bcel.internal.generic.Type;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
import com.sun.org.apache.xml.internal.utils.XML11Char;
@ -37,7 +38,7 @@ public final class Util {
private static char filesep;
static {
String temp = System.getProperty("file.separator", "/");
String temp = SecuritySupport.getSystemProperty("file.separator", "/");
filesep = temp.charAt(0);
}

View File

@ -33,6 +33,7 @@ import com.sun.org.apache.xalan.internal.xsltc.TransletException;
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
import com.sun.org.apache.xml.internal.utils.StringComparable;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
/**
* Base class for sort records containing application specific sort keys
@ -112,7 +113,7 @@ public abstract class NodeSortRecord {
try {
// -- W. Eliot Kimber (eliot@isogen.com)
colFactClassname =
System.getProperty("com.sun.org.apache.xalan.internal.xsltc.COLLATOR_FACTORY");
SecuritySupport.getSystemProperty("com.sun.org.apache.xalan.internal.xsltc.COLLATOR_FACTORY");
}
catch (SecurityException e) {
// If we can't read the propery, just use default collator

View File

@ -23,6 +23,7 @@
package com.sun.org.apache.xalan.internal.xsltc.runtime;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.FieldPosition;
@ -1583,7 +1584,7 @@ public final class BasisLibrary {
static {
String resource = "com.sun.org.apache.xalan.internal.xsltc.runtime.ErrorMessages";
m_bundle = ResourceBundle.getBundle(resource);
m_bundle = SecuritySupport.getResourceBundle(resource);
}
/**

View File

@ -23,6 +23,7 @@
package com.sun.org.apache.xalan.internal.xsltc.runtime.output;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Writer;
@ -36,7 +37,7 @@ class WriterOutputBuffer implements OutputBuffer {
static {
// Set a larger buffer size for Solaris
final String osName = System.getProperty("os.name");
final String osName = SecuritySupport.getSystemProperty("os.name");
if (osName.equalsIgnoreCase("solaris")) {
BUFFER_SIZE = 32 * KB;
}

View File

@ -43,6 +43,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
/**
* @author Morten Jorgensen
@ -52,6 +53,8 @@ import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
*/
public final class TemplatesImpl implements Templates, Serializable {
static final long serialVersionUID = 673094361519270707L;
public final static String DESERIALIZE_TRANSLET = "jdk.xml.enableTemplatesImplDeserialization";
/**
* Name of the superclass of all translets. This is needed to
* determine which, among all classes comprising a translet,
@ -186,6 +189,15 @@ public final class TemplatesImpl implements Templates, Serializable {
private void readObject(ObjectInputStream is)
throws IOException, ClassNotFoundException
{
SecurityManager security = System.getSecurityManager();
if (security != null){
String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
throw new UnsupportedOperationException(err.toString());
}
}
is.defaultReadObject();
if (is.readBoolean()) {
_uriResolver = (URIResolver) is.readObject();

View File

@ -73,7 +73,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import org.xml.sax.InputSource;
import org.xml.sax.XMLFilter;
@ -881,8 +881,14 @@ public class TransformerFactoryImpl
// Check that the transformation went well before returning
if (bytecodes == null) {
ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
TransformerConfigurationException exc = new TransformerConfigurationException(err.toString());
Vector errs = xsltc.getErrors();
ErrorMsg err = null;
if (errs != null) {
err = (ErrorMsg)errs.get(errs.size()-1);
} else {
err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
}
TransformerConfigurationException exc = new TransformerConfigurationException(err.toString(), err.getCause());
// Pass compiler errors to the error listener
if (_errorListener != null) {
@ -1229,7 +1235,7 @@ public class TransformerFactoryImpl
// Find the parent directory of the translet.
String transletParentDir = transletFile.getParent();
if (transletParentDir == null)
transletParentDir = System.getProperty("user.dir");
transletParentDir = SecuritySupport.getSystemProperty("user.dir");
File transletParentFile = new File(transletParentDir);

View File

@ -20,10 +20,10 @@
package com.sun.org.apache.xerces.internal.dom;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
/**
* Used to format DOM error messages, using the system locale.
@ -31,6 +31,7 @@ import java.util.PropertyResourceBundle;
* @xerces.internal
*
* @author Sandy Gao, IBM
* @version $Id: DOMMessageFormatter.java,v 1.6 2010-11-01 04:39:38 joehw Exp $
*/
public class DOMMessageFormatter {
public static final String DOM_DOMAIN = "http://www.w3.org/dom/DOMTR";
@ -122,13 +123,13 @@ public class DOMMessageFormatter {
*/
public static void init(){
if (locale != null) {
domResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages", locale);
serResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages", locale);
xmlResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages", locale);
serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages", locale);
xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
}else{
domResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages");
serResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages");
xmlResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages");
serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages");
xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
}

View File

@ -51,6 +51,7 @@ import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.parser.*;
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import com.sun.xml.internal.stream.Entity;
import com.sun.org.apache.xerces.internal.xni.Augmentations;
@ -1727,7 +1728,7 @@ protected static final String PARSER_SETTINGS =
// get the user.dir property
String userDir = "";
try {
userDir = System.getProperty("user.dir");
userDir = SecuritySupport.getSystemProperty("user.dir");
}
catch (SecurityException se) {
}

View File

@ -20,6 +20,7 @@
package com.sun.org.apache.xerces.internal.impl.dv;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import java.util.MissingResourceException;
@ -34,6 +35,7 @@ import java.util.MissingResourceException;
*
* @author Sandy Gao, IBM
*
* @version $Id: DatatypeException.java,v 1.6 2010-11-01 04:39:43 joehw Exp $
*/
public class DatatypeException extends Exception {
@ -84,7 +86,7 @@ public class DatatypeException extends Exception {
*/
public String getMessage() {
ResourceBundle resourceBundle = null;
resourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
resourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
if (resourceBundle == null)
throw new MissingResourceException("Property file not found!", "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);

View File

@ -20,12 +20,11 @@
package com.sun.org.apache.xerces.internal.impl.msg;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +33,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter.java 3020 2011-02-28 23:51:33Z joehw $
* @version $Id: XMLMessageFormatter.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter implements MessageFormatter {
@ -72,12 +71,12 @@ public class XMLMessageFormatter implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_de.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_de.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_de implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_de implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_es.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_es.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_es implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_es implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_fr.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_fr.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_fr implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_fr implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_it.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_it.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_it implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_it implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_ja.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_ja.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_ja implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_ja implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_ko.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_ko.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_ko implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_ko implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_pt_BR.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_pt_BR.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_pt_BR implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_pt_BR implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_sv.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_sv.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_sv implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_sv implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_zh_CN.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_zh_CN.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_zh_CN implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_zh_CN implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -26,6 +26,7 @@ import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
@ -34,7 +35,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Eric Ye, IBM
* @version $Id: XMLMessageFormatter_zh_TW.java 3021 2011-03-01 00:12:28Z joehw $
* @version $Id: XMLMessageFormatter_zh_TW.java 3094 2012-03-21 05:50:01Z joehw $
*
*/
public class XMLMessageFormatter_zh_TW implements MessageFormatter {
@ -72,12 +73,12 @@ public class XMLMessageFormatter_zh_TW implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
}
// format message

View File

@ -20,6 +20,7 @@
package com.sun.org.apache.xerces.internal.impl.xpath.regex;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@ -95,10 +96,10 @@ class RegexParser {
public void setLocale(Locale locale) {
try {
if (locale != null) {
this.resources = ResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
}
else {
this.resources = ResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
}
}
catch (MissingResourceException mre) {

View File

@ -20,11 +20,11 @@
package com.sun.org.apache.xerces.internal.impl.xs;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
/**
@ -34,6 +34,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
* @xerces.internal
*
* @author Elena Litani, IBM
* @version $Id: XSMessageFormatter.java,v 1.6 2010-11-01 04:39:55 joehw Exp $
*/
public class XSMessageFormatter implements MessageFormatter {
/**
@ -66,12 +67,12 @@ public class XSMessageFormatter implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
}
String msg = fResourceBundle.getString(key);

View File

@ -20,15 +20,16 @@
package com.sun.org.apache.xerces.internal.jaxp.validation;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
/**
* <p>Used to format JAXP Validation API error messages using a specified locale.</p>
*
* @author Michael Glavassevich, IBM
* @version $Id: JAXPValidationMessageFormatter.java,v 1.5 2010-11-01 04:40:08 joehw Exp $
*/
final class JAXPValidationMessageFormatter {
@ -54,11 +55,11 @@ final class JAXPValidationMessageFormatter {
ResourceBundle resourceBundle = null;
if (locale != null) {
resourceBundle =
PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.JAXPValidationMessages", locale);
SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.JAXPValidationMessages", locale);
}
else {
resourceBundle =
PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.JAXPValidationMessages");
SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.JAXPValidationMessages");
}
// format message

View File

@ -20,15 +20,16 @@
package com.sun.org.apache.xerces.internal.util;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
/**
* <p>Used to format JAXP 1.3 Datatype API error messages using a specified locale.</p>
*
* @author Neeraj Bajaj, Sun Microsystems
* @version $Id: DatatypeMessageFormatter.java,v 1.6 2010-11-01 04:40:14 joehw Exp $
*/
public class DatatypeMessageFormatter {
@ -56,11 +57,11 @@ public class DatatypeMessageFormatter {
ResourceBundle resourceBundle = null;
if (locale != null) {
resourceBundle =
PropertyResourceBundle.getBundle(BASE_NAME, locale);
SecuritySupport.getResourceBundle(BASE_NAME, locale);
}
else {
resourceBundle =
PropertyResourceBundle.getBundle(BASE_NAME);
SecuritySupport.getResourceBundle(BASE_NAME);
}
// format message

View File

@ -19,16 +19,17 @@
*/
package com.sun.org.apache.xerces.internal.util;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
/**
* Used to format SAX error messages using a specified locale.
*
* @author Michael Glavassevich, IBM
*
* @version $Id: SAXMessageFormatter.java,v 1.6 2010-11-01 04:40:14 joehw Exp $
*/
public class SAXMessageFormatter {
@ -54,11 +55,11 @@ public class SAXMessageFormatter {
ResourceBundle resourceBundle = null;
if (locale != null) {
resourceBundle =
PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.SAXMessages", locale);
SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.SAXMessages", locale);
}
else {
resourceBundle =
PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.SAXMessages");
SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.SAXMessages");
}
// format message

View File

@ -61,6 +61,8 @@
package com.sun.org.apache.xerces.internal.util;
import com.sun.org.apache.xerces.internal.impl.Constants;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* This class is a container for parser settings that relate to
* security, or more specifically, it is intended to be used to prevent denial-of-service
@ -77,6 +79,7 @@ import com.sun.org.apache.xerces.internal.impl.Constants;
*
* @author Neil Graham, IBM
*
* @version $Id: SecurityManager.java,v 1.5 2010-11-01 04:40:14 joehw Exp $
*/
public final class SecurityManager {
@ -176,41 +179,48 @@ public final class SecurityManager {
private void readSystemProperties(){
//TODO: also read SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT
try {
String value = System.getProperty(Constants.ENTITY_EXPANSION_LIMIT);
if(value != null && !value.equals("")){
entityExpansionLimit = Integer.parseInt(value);
if (entityExpansionLimit < 0)
entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
}
else
entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
}catch(Exception ex){}
//TODO: also read SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT
try {
String value = getSystemProperty(Constants.ENTITY_EXPANSION_LIMIT);
if(value != null && !value.equals("")){
entityExpansionLimit = Integer.parseInt(value);
if (entityExpansionLimit < 0)
entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
}
else
entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
}catch(Exception ex){}
try {
String value = System.getProperty(Constants.MAX_OCCUR_LIMIT);
if(value != null && !value.equals("")){
maxOccurLimit = Integer.parseInt(value);
if (maxOccurLimit < 0)
maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
}
else
maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
}catch(Exception ex){}
try {
String value = getSystemProperty(Constants.MAX_OCCUR_LIMIT);
if(value != null && !value.equals("")){
maxOccurLimit = Integer.parseInt(value);
if (maxOccurLimit < 0)
maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
}
else
maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
}catch(Exception ex){}
try {
String value = System.getProperty(Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
if(value != null && !value.equals("")){
fElementAttributeLimit = Integer.parseInt(value);
if ( fElementAttributeLimit < 0)
fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
}
else
fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
try {
String value = getSystemProperty(Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
if(value != null && !value.equals("")){
fElementAttributeLimit = Integer.parseInt(value);
if ( fElementAttributeLimit < 0)
fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
}
else
fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
}catch(Exception ex){}
}
private String getSystemProperty(final String propName) {
return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty(propName);
}
});
}
} // class SecurityManager

View File

@ -48,6 +48,7 @@ public final class ObjectFactory {
//
// Constants
//
private static final String DEFAULT_INTERNAL_CLASSES = "com.sun.org.apache.";
// name of default properties file to look for in JDK's jre/lib directory
private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties";
@ -305,10 +306,14 @@ public final class ObjectFactory {
//restrict the access to package as speicified in java.security policy
SecurityManager security = System.getSecurityManager();
if (security != null) {
final int lastDot = className.lastIndexOf(".");
String packageName = className;
if (lastDot != -1) packageName = className.substring(0, lastDot);
security.checkPackageAccess(packageName);
if (className.startsWith(DEFAULT_INTERNAL_CLASSES)) {
cl = null;
} else {
final int lastDot = className.lastIndexOf(".");
String packageName = className;
if (lastDot != -1) packageName = className.substring(0, lastDot);
security.checkPackageAccess(packageName);
}
}
Class providerClass;
if (cl == null) {

View File

@ -29,6 +29,10 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
/**
* This class is duplicated for each subpackage so keep it in sync.
@ -141,6 +145,38 @@ public final class SecuritySupport {
});
}
/**
* Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.
* @param bundle the base name of the resource bundle, a fully qualified class name
* @return a resource bundle for the given base name and the default locale
*/
public static ResourceBundle getResourceBundle(String bundle) {
return getResourceBundle(bundle, Locale.getDefault());
}
/**
* Gets a resource bundle using the specified base name and locale, and the caller's class loader.
* @param bundle the base name of the resource bundle, a fully qualified class name
* @param locale the locale for which a resource bundle is desired
* @return a resource bundle for the given base name and locale
*/
public static ResourceBundle getResourceBundle(final String bundle, final Locale locale) {
return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() {
public ResourceBundle run() {
try {
return PropertyResourceBundle.getBundle(bundle, locale);
} catch (MissingResourceException e) {
try {
return PropertyResourceBundle.getBundle(bundle, new Locale("en", "US"));
} catch (MissingResourceException e2) {
throw new MissingResourceException(
"Could not load any resource bundle by " + bundle, bundle, "");
}
}
}
});
}
static boolean getFileExists(final File f) {
return ((Boolean)
AccessController.doPrivileged(new PrivilegedAction() {

View File

@ -20,11 +20,11 @@
package com.sun.org.apache.xerces.internal.xinclude;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
// TODO: fix error messages in XIncludeMessages.properties
/**
@ -32,6 +32,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
*
* @author Peter McCracken, IBM
*
* @version $Id: XIncludeMessageFormatter.java,v 1.7 2010-11-01 04:40:18 joehw Exp $
*/
public class XIncludeMessageFormatter implements MessageFormatter {
@ -61,12 +62,12 @@ public class XIncludeMessageFormatter implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale);
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages");
fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages");
}
String msg = fResourceBundle.getString(key);

View File

@ -24,6 +24,7 @@ import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
/**
* XPointerMessageFormatter provides error messages for the XPointer Framework
@ -31,6 +32,7 @@ import com.sun.org.apache.xerces.internal.util.MessageFormatter;
*
* @xerces.internal
*
* @version $Id: XPointerMessageFormatter.java,v 1.5 2010-11-01 04:40:26 joehw Exp $
*/
class XPointerMessageFormatter implements MessageFormatter {
@ -64,14 +66,14 @@ class XPointerMessageFormatter implements MessageFormatter {
if (fResourceBundle == null || locale != fLocale) {
if (locale != null) {
fResourceBundle = PropertyResourceBundle.getBundle(
fResourceBundle = SecuritySupport.getResourceBundle(
"com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", locale);
// memorize the most-recent locale
fLocale = locale;
}
if (fResourceBundle == null)
fResourceBundle = PropertyResourceBundle
.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
fResourceBundle = SecuritySupport.getResourceBundle(
"com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
}
String msg = fResourceBundle.getString(key);

View File

@ -27,6 +27,7 @@ import com.sun.org.apache.xml.internal.res.XMLMessages;
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
/**
* A DTMManager instance can be used to create DTM and
@ -383,7 +384,7 @@ public abstract class DTMManager
{
try
{
debug = System.getProperty("dtm.debug") != null;
debug = SecuritySupport.getSystemProperty("dtm.debug") != null;
}
catch (SecurityException ex){}
}

View File

@ -24,9 +24,6 @@ package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Set up error messages.
@ -453,67 +450,4 @@ public class XMLErrorResources extends ListResourceBundle
return contents;
}
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XMLErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XMLErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XMLErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -24,9 +24,6 @@ package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Set up error messages.
@ -443,67 +440,4 @@ public class XMLErrorResources_ca extends ListResourceBundle
return _contents;
}
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XMLErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XMLErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XMLErrorResources) ResourceBundle.getBundle(className,
new Locale("ca", "ES"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -24,9 +24,6 @@ package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Set up error messages.
@ -443,67 +440,4 @@ public class XMLErrorResources_cs extends ListResourceBundle
return _contents;
}
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XMLErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XMLErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XMLErrorResources) ResourceBundle.getBundle(className,
new Locale("cs", "CZ"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

View File

@ -24,9 +24,6 @@ package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Set up error messages.
@ -453,67 +450,4 @@ public class XMLErrorResources_de extends ListResourceBundle
return _contents;
}
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XMLErrorResources loadResourceBundle(String className)
throws MissingResourceException
{
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try
{
// first try with the given locale
return (XMLErrorResources) ResourceBundle.getBundle(className
+ suffix, locale);
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
return (XMLErrorResources) ResourceBundle.getBundle(className,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles.", className, "");
}
}
}
/**
* Return the resource file suffic for the indicated locale
* For most locales, this will be based the language code. However
* for Chinese, we do distinguish between Taiwan and PRC
*
* @param locale the locale
* @return an String suffix which canbe appended to a resource name
*/
private static final String getResourceSuffix(Locale locale)
{
String suffix = "_" + locale.getLanguage();
String country = locale.getCountry();
if (country.equals("TW"))
suffix += "_" + country;
return suffix;
}
}

Some files were not shown because too many files have changed in this diff Show More