Merge
This commit is contained in:
commit
0278846eaa
make
src
hotspot/share
java.base/share/classes
com/sun/crypto/provider
java
io
lang/invoke
math
net
nio
ByteBufferAs-X-Buffer.java.templateDirect-X-Buffer.java.templateHeap-X-Buffer.java.templateStringCharBuffer.java
util
sun
java.desktop
macosx/native
libawt_lwawt
libjsound
libosxui
share/native
unix/native
common/java2d/x11
libawt_xawt
windows/native
libawt
libjsound
java.instrument
share
unix/native/libinstrument
java.security.jgss/share/classes/sun/security/krb5
java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom
jdk.crypto.cryptoki/share/native/libj2pkcs11
jdk.crypto.ec/share/native/libsunec/impl
jdk.httpserver/share/classes/com/sun/net/httpserver
jdk.jdi
jdk.jdwp.agent/share/native/libjdwp
jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp
test/jdk
build
java
math/BigInteger
net
@ -37,10 +37,22 @@ ifeq ($(call isTargetOs, windows), true)
|
||||
$(call install-file)
|
||||
endif
|
||||
|
||||
prepare-test-image: $(FIXPATH_COPY)
|
||||
BUILD_INFO_PROPERTIES := $(TEST_IMAGE_DIR)/build-info.properties
|
||||
|
||||
FIXPATH_ECHO := $(FIXPATH) $(call FixPath, $(ECHO))
|
||||
|
||||
$(BUILD_INFO_PROPERTIES):
|
||||
$(call MakeTargetDir)
|
||||
$(ECHO) "# Build info properties for JDK tests" > $@
|
||||
$(FIXPATH_ECHO) "build.workspace.root=$(WORKSPACE_ROOT)" >> $@
|
||||
$(FIXPATH_ECHO) "build.output.root=$(OUTPUTDIR)" >> $@
|
||||
|
||||
prepare-test-image: $(FIXPATH_COPY) $(BUILD_INFO_PROPERTIES)
|
||||
$(call MakeDir, $(TEST_IMAGE_DIR))
|
||||
$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'
|
||||
|
||||
################################################################################
|
||||
|
||||
all: prepare-test-image
|
||||
|
||||
.PHONY: default all prepare-test-image
|
||||
|
@ -86,6 +86,13 @@ AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
|
||||
AC_SUBST(TOPDIR)
|
||||
AC_SUBST(CONFIGURE_START_DIR)
|
||||
|
||||
if test "x$CUSTOM_ROOT" != x; then
|
||||
WORKSPACE_ROOT="${CUSTOM_ROOT}"
|
||||
else
|
||||
WORKSPACE_ROOT="${TOPDIR}"
|
||||
fi
|
||||
AC_SUBST(WORKSPACE_ROOT)
|
||||
|
||||
# We can only call UTIL_FIXUP_PATH after BASIC_CHECK_PATHS_WINDOWS.
|
||||
UTIL_FIXUP_PATH(CONFIGURE_START_DIR)
|
||||
UTIL_FIXUP_PATH(TOPDIR)
|
||||
@ -315,11 +322,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
|
||||
AC_MSG_RESULT([in build directory with custom name])
|
||||
fi
|
||||
|
||||
if test "x$CUSTOM_ROOT" != x; then
|
||||
WORKSPACE_ROOT="${CUSTOM_ROOT}"
|
||||
else
|
||||
WORKSPACE_ROOT="${TOPDIR}"
|
||||
fi
|
||||
OUTPUTDIR="${WORKSPACE_ROOT}/build/${CONF_NAME}"
|
||||
$MKDIR -p "$OUTPUTDIR"
|
||||
if test ! -d "$OUTPUTDIR"; then
|
||||
@ -376,7 +378,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
|
||||
AC_SUBST(SPEC)
|
||||
AC_SUBST(CONF_NAME)
|
||||
AC_SUBST(OUTPUTDIR)
|
||||
AC_SUBST(WORKSPACE_ROOT)
|
||||
AC_SUBST(CONFIGURESUPPORT_OUTPUTDIR)
|
||||
|
||||
# The spec.gmk file contains all variables for the make system.
|
||||
|
@ -97,6 +97,9 @@ HOTSPOT_SETUP_JVM_VARIANTS
|
||||
# With basic setup done, call the custom early hook.
|
||||
CUSTOM_EARLY_HOOK
|
||||
|
||||
# This only needs debug level to be setup
|
||||
JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT
|
||||
|
||||
# Check if we have devkits, extra paths or sysroot set.
|
||||
BASIC_SETUP_DEVKIT
|
||||
|
||||
|
@ -641,6 +641,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
|
||||
# Where does this really belong??
|
||||
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
|
||||
PICFLAG="-fPIC"
|
||||
PIEFLAG="-fPIE"
|
||||
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
||||
PICFLAG="-KPIC"
|
||||
elif test "x$TOOLCHAIN_TYPE" = xxlc; then
|
||||
@ -854,18 +855,27 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
|
||||
$1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
|
||||
fi
|
||||
|
||||
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
|
||||
# Check if compiler supports -fmacro-prefix-map. If so, use that to make
|
||||
# the __FILE__ macro resolve to paths relative to the workspace root.
|
||||
workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
|
||||
FILE_MACRO_CFLAGS="-fmacro-prefix-map=${workspace_root_trailing_slash}="
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}],
|
||||
PREFIX: $3,
|
||||
IF_FALSE: [
|
||||
FILE_MACRO_CFLAGS=
|
||||
]
|
||||
)
|
||||
# Prevent the __FILE__ macro from generating absolute paths into the built
|
||||
# binaries. Depending on toolchain, different mitigations are possible.
|
||||
# * GCC and Clang of new enough versions have -fmacro-prefix-map.
|
||||
# * For most other toolchains, supplying all source files and -I flags as
|
||||
# relative paths fixes the issue.
|
||||
FILE_MACRO_CFLAGS=
|
||||
if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
|
||||
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
|
||||
# Check if compiler supports -fmacro-prefix-map. If so, use that to make
|
||||
# the __FILE__ macro resolve to paths relative to the workspace root.
|
||||
workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
|
||||
FILE_MACRO_CFLAGS="-fmacro-prefix-map=${workspace_root_trailing_slash}="
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}],
|
||||
PREFIX: $3,
|
||||
IF_FALSE: [
|
||||
FILE_MACRO_CFLAGS=
|
||||
]
|
||||
)
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(FILE_MACRO_CFLAGS)
|
||||
|
||||
# EXPORT to API
|
||||
CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM \
|
||||
@ -894,10 +904,12 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
|
||||
|
||||
$2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
|
||||
|
||||
$2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
|
||||
$2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
|
||||
$2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
|
||||
$2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
|
||||
$2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK} $PIEFLAG"
|
||||
$2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK} $PIEFLAG"
|
||||
$2CFLAGS_JDKLIB="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK} \
|
||||
$JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
|
||||
$2CXXFLAGS_JDKLIB="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK} \
|
||||
$JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
|
||||
|
||||
AC_SUBST($2JVM_CFLAGS)
|
||||
AC_SUBST($2CFLAGS_JDKLIB)
|
||||
|
@ -152,6 +152,17 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER],
|
||||
# Setup LDFLAGS for linking executables
|
||||
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
||||
EXECUTABLE_LDFLAGS="$EXECUTABLE_LDFLAGS -Wl,--allow-shlib-undefined"
|
||||
# Enabling pie on 32 bit builds prevents the JVM from allocating a continuous
|
||||
# java heap.
|
||||
if test "x$OPENJDK_TARGET_CPU_BITS" != "x32"; then
|
||||
EXECUTABLE_LDFLAGS="$EXECUTABLE_LDFLAGS -pie"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
|
||||
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
||||
BASIC_LDFLAGS="$BASIC_LDFLAGS -pdbaltpath:%_PDB%"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Export some intermediate variables for compatibility
|
||||
|
@ -598,3 +598,35 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE],
|
||||
])
|
||||
AC_SUBST(BUILD_CDS_ARCHIVE)
|
||||
])
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Disallow any output from containing absolute paths from the build system.
|
||||
# This setting defaults to allowed on debug builds and not allowed on release
|
||||
# builds.
|
||||
#
|
||||
AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT],
|
||||
[
|
||||
AC_ARG_ENABLE([absolute-paths-in-output],
|
||||
[AS_HELP_STRING([--disable-absolute-paths-in-output],
|
||||
[Set to disable to prevent any absolute paths from the build to end up in
|
||||
any of the build output. @<:@disabled in release builds, otherwise enabled@:>@])
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([if absolute paths should be allowed in the build output])
|
||||
if test "x$enable_absolute_paths_in_output" = "xno"; then
|
||||
AC_MSG_RESULT([no, forced])
|
||||
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false"
|
||||
elif test "x$enable_absolute_paths_in_output" = "xyes"; then
|
||||
AC_MSG_RESULT([yes, forced])
|
||||
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true"
|
||||
elif test "x$DEBUG_LEVEL" = "xrelease"; then
|
||||
AC_MSG_RESULT([no, release build])
|
||||
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false"
|
||||
else
|
||||
AC_MSG_RESULT([yes, debug build])
|
||||
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true"
|
||||
fi
|
||||
|
||||
AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT)
|
||||
])
|
||||
|
@ -338,6 +338,8 @@ BUILD_MANPAGES := @BUILD_MANPAGES@
|
||||
|
||||
BUILD_CDS_ARCHIVE := @BUILD_CDS_ARCHIVE@
|
||||
|
||||
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT := @ALLOW_ABSOLUTE_PATHS_IN_OUTPUT@
|
||||
|
||||
# The boot jdk to use. This is overridden in bootcycle-spec.gmk. Make sure to keep
|
||||
# it in sync.
|
||||
BOOT_JDK:=@BOOT_JDK@
|
||||
@ -381,6 +383,7 @@ LIBFFI_CFLAGS:=@LIBFFI_CFLAGS@
|
||||
ENABLE_LIBFFI_BUNDLING:=@ENABLE_LIBFFI_BUNDLING@
|
||||
LIBFFI_LIB_FILE:=@LIBFFI_LIB_FILE@
|
||||
GRAALUNIT_LIB := @GRAALUNIT_LIB@
|
||||
FILE_MACRO_CFLAGS := @FILE_MACRO_CFLAGS@
|
||||
|
||||
STATIC_LIBS_CFLAGS := @STATIC_LIBS_CFLAGS@
|
||||
|
||||
|
@ -204,6 +204,68 @@ DEPENDENCY_TARGET_SED_PATTERN := \
|
||||
-e 's/$$$$/ :/' \
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# When absolute paths are not allowed in the output, and the compiler does not
|
||||
# support any options to avoid it, we need to rewrite compile commands to use
|
||||
# relative paths. By doing this, the __FILE__ macro will resolve to relative
|
||||
# paths. The relevant input paths on the command line are the -I flags and the
|
||||
# path to the source file itself.
|
||||
#
|
||||
# The macro MakeCommandRelative is used to rewrite the command line like this:
|
||||
# 'CD $(WORKSPACE_ROOT) && <cmd>'
|
||||
# and changes all paths in cmd to be relative to the workspace root. This only
|
||||
# works properly if the build dir is inside the workspace root. If it's not,
|
||||
# relative paths are still calculated, but depending on the distance between the
|
||||
# dirs, paths in the build dir may end up as essentially absolute anyway.
|
||||
#
|
||||
# The fix-deps-file macro is used to adjust the contents of the generated make
|
||||
# dependency files to contain paths compatible with make.
|
||||
#
|
||||
ifeq ($(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT)-$(FILE_MACRO_CFLAGS), false-)
|
||||
# Need to handle -I flags as both '-Ifoo' and '-I foo'.
|
||||
MakeCommandRelative = \
|
||||
$(CD) $(WORKSPACE_ROOT) && \
|
||||
$(foreach o, $1, \
|
||||
$(if $(filter $(WORKSPACE_ROOT)/% $(OUTPUTDIR)/%, $o), \
|
||||
$(call RelativePath, $o, $(WORKSPACE_ROOT)) \
|
||||
, \
|
||||
$(if $(filter -I$(WORKSPACE_ROOT)/%, $o), \
|
||||
-I$(call RelativePath, $(patsubst -I%, %, $o), $(WORKSPACE_ROOT)) \
|
||||
, \
|
||||
$o \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
# When compiling with relative paths, the deps file comes out with relative
|
||||
# paths.
|
||||
ifeq ($(TOOLCHAIN_TYPE), solstudio)
|
||||
define fix-deps-file
|
||||
$(SED) -e 's|\./|$(WORKSPACE_ROOT)/|g' $1.tmp > $1
|
||||
endef
|
||||
else
|
||||
define fix-deps-file
|
||||
$(SED) -e 's|^\([ ]*\)|\1$(WORKSPACE_ROOT)|' $1.tmp > $1
|
||||
endef
|
||||
endif
|
||||
else
|
||||
# By default the MakeCommandRelative macro does nothing.
|
||||
MakeCommandRelative = $1
|
||||
|
||||
# Even with absolute paths on the command line, the Solaris studio compiler
|
||||
# doesn't output the full path to the object file in the generated deps files.
|
||||
# For other toolchains, no adjustment is needed.
|
||||
ifeq ($(TOOLCHAIN_TYPE), solstudio)
|
||||
define fix-deps-file
|
||||
$(SED) 's|^$$(@F):|$$@:|' $1.tmp > $1
|
||||
endef
|
||||
else
|
||||
define fix-deps-file
|
||||
$(MV) $1.tmp $1
|
||||
endef
|
||||
endif
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# Create the recipe needed to compile a single native source file.
|
||||
#
|
||||
@ -214,7 +276,6 @@ DEPENDENCY_TARGET_SED_PATTERN := \
|
||||
# Remaining parameters are named arguments:
|
||||
# FILE - The full path of the source file to compiler
|
||||
# BASE - The name of the rule for the entire binary to build ($1)
|
||||
# DISABLE_THIS_FILE_DEFINE - Set to true to disable the THIS_FILE define.
|
||||
#
|
||||
SetupCompileNativeFile = $(NamedParamsMacroTemplate)
|
||||
define SetupCompileNativeFileBody
|
||||
@ -236,12 +297,6 @@ define SetupCompileNativeFileBody
|
||||
# This is the definite source file to use for $1_FILENAME.
|
||||
$1_SRC_FILE := $$($1_FILE)
|
||||
|
||||
ifneq ($$($1_DEFINE_THIS_FILE), false)
|
||||
ifneq ($$($$($1_BASE)_DEFINE_THIS_FILE), false)
|
||||
$1_THIS_FILE = -DTHIS_FILE='"$$($1_FILENAME)"'
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($$($1_OPTIMIZATION), )
|
||||
$1_OPT_CFLAGS := $$($$($1_BASE)_OPT_CFLAGS)
|
||||
$1_OPT_CXXFLAGS := $$($$($1_BASE)_OPT_CXXFLAGS)
|
||||
@ -284,13 +339,13 @@ define SetupCompileNativeFileBody
|
||||
ifneq ($$(filter %.c, $$($1_FILENAME)), )
|
||||
# Compile as a C file
|
||||
$1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CFLAGS) \
|
||||
$$($1_OPT_CFLAGS) $$($1_CFLAGS) $$($1_THIS_FILE) -c
|
||||
$$($1_OPT_CFLAGS) $$($1_CFLAGS) -c
|
||||
$1_COMPILER := $$($$($1_BASE)_CC)
|
||||
$1_DEP_FLAG := $(C_FLAG_DEPS)
|
||||
else ifneq ($$(filter %.m, $$($1_FILENAME)), )
|
||||
# Compile as an Objective-C file
|
||||
$1_FLAGS := -x objective-c $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) \
|
||||
$$($1_BASE_CFLAGS) $$($1_OPT_CFLAGS) $$($1_CFLAGS) $$($1_THIS_FILE) -c
|
||||
$$($1_BASE_CFLAGS) $$($1_OPT_CFLAGS) $$($1_CFLAGS) -c
|
||||
$1_COMPILER := $$($$($1_BASE)_CC)
|
||||
$1_DEP_FLAG := $(C_FLAG_DEPS)
|
||||
else ifneq ($$(filter %.s %.S, $$($1_FILENAME)), )
|
||||
@ -301,7 +356,7 @@ define SetupCompileNativeFileBody
|
||||
else ifneq ($$(filter %.cpp %.cc %.mm, $$($1_FILENAME)), )
|
||||
# Compile as a C++ or Objective-C++ file
|
||||
$1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CXXFLAGS) \
|
||||
$$($1_OPT_CXXFLAGS) $$($1_CXXFLAGS) $$($1_THIS_FILE) -c
|
||||
$$($1_OPT_CXXFLAGS) $$($1_CXXFLAGS) -c
|
||||
$1_COMPILER := $$($$($1_BASE)_CXX)
|
||||
$1_DEP_FLAG := $(CXX_FLAG_DEPS)
|
||||
else
|
||||
@ -341,21 +396,17 @@ define SetupCompileNativeFileBody
|
||||
$$(call LogInfo, Compiling $$($1_FILENAME) (for $$($$($1_BASE)_BASENAME)))
|
||||
$$(call MakeDir, $$(@D))
|
||||
ifneq ($(TOOLCHAIN_TYPE), microsoft)
|
||||
ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $$($1_FILENAME)), solstudio)
|
||||
# The Solaris 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.
|
||||
$$(call ExecuteWithLog, $$@, \
|
||||
$$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEPS_FILE).tmp $$($1_COMPILE_OPTIONS))
|
||||
$(SED) 's|^$$(@F):|$$@:|' $$($1_DEPS_FILE).tmp > $$($1_DEPS_FILE)
|
||||
else
|
||||
$$(call ExecuteWithLog, $$@, \
|
||||
$$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEPS_FILE) $$($1_COMPILE_OPTIONS))
|
||||
endif
|
||||
# Create a dependency target file from the dependency file.
|
||||
# Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
|
||||
$$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \
|
||||
$$($1_COMPILER) $$($1_DEP_FLAG) \
|
||||
$$(addsuffix .tmp, $$($1_DEPS_FILE)) \
|
||||
$$($1_COMPILE_OPTIONS)))
|
||||
ifneq ($$($1_DEPS_FILE), )
|
||||
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEPS_FILE) > $$($1_DEPS_TARGETS_FILE)
|
||||
$$(call fix-deps-file, $$($1_DEPS_FILE))
|
||||
# Create a dependency target file from the dependency file.
|
||||
# Solution suggested by:
|
||||
# http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
|
||||
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEPS_FILE) \
|
||||
> $$($1_DEPS_TARGETS_FILE)
|
||||
endif
|
||||
else
|
||||
# The Visual Studio compiler lacks a feature for generating make
|
||||
@ -365,8 +416,8 @@ define SetupCompileNativeFileBody
|
||||
# Keep as much as possible on one execution line for best performance
|
||||
# on Windows. No need to save exit code from compilation since
|
||||
# pipefail is always active on Windows.
|
||||
$$(call ExecuteWithLog, $$@, \
|
||||
$$($1_COMPILER) -showIncludes $$($1_COMPILE_OPTIONS)) \
|
||||
$$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \
|
||||
$$($1_COMPILER) -showIncludes $$($1_COMPILE_OPTIONS))) \
|
||||
| $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \
|
||||
-e "^$$($1_FILENAME)$$$$" || test "$$$$?" = "1" ; \
|
||||
$(ECHO) $$@: \\ > $$($1_DEPS_FILE) ; \
|
||||
@ -430,7 +481,6 @@ endef
|
||||
# STRIPFLAGS Optionally change the flags given to the strip command
|
||||
# PRECOMPILED_HEADER Header file to use as precompiled header
|
||||
# PRECOMPILED_HEADER_EXCLUDE List of source files that should not use PCH
|
||||
# DEFINE_THIS_FILE Set to false to not set the THIS_FILE preprocessor macro
|
||||
#
|
||||
# After being called, some variables are exported from this macro, all prefixed
|
||||
# with parameter 1 followed by a '_':
|
||||
@ -734,7 +784,6 @@ define SetupNativeCompilationBody
|
||||
FILE := $$($1_GENERATED_PCH_SRC), \
|
||||
BASE := $1, \
|
||||
EXTRA_CXXFLAGS := -Fp$$($1_PCH_FILE) -Yc$$(notdir $$($1_PRECOMPILED_HEADER)), \
|
||||
DEFINE_THIS_FILE := false, \
|
||||
))
|
||||
|
||||
$1_USE_PCH_FLAGS := \
|
||||
@ -769,7 +818,8 @@ define SetupNativeCompilationBody
|
||||
$$($1_PCH_FILE): $$($1_PRECOMPILED_HEADER) $$($1_COMPILE_VARDEPS_FILE)
|
||||
$$(call LogInfo, Generating precompiled header)
|
||||
$$(call MakeDir, $$(@D))
|
||||
$$(call ExecuteWithLog, $$@, $$($1_PCH_COMMAND) $$< -o $$@)
|
||||
$$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \
|
||||
$$($1_PCH_COMMAND) $$< -o $$@))
|
||||
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_PCH_DEPS_FILE) \
|
||||
> $$($1_PCH_DEPS_TARGETS_FILE)
|
||||
|
||||
@ -825,9 +875,9 @@ define SetupNativeCompilationBody
|
||||
$$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
|
||||
$$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$($1_BASENAME)))
|
||||
$$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
|
||||
$$(call ExecuteWithLog, $$@, \
|
||||
$$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \
|
||||
$$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
|
||||
$$($1_VERSIONINFO_RESOURCE) 2>&1 )
|
||||
$$($1_VERSIONINFO_RESOURCE) 2>&1 ))
|
||||
# Windows RC compiler does not support -showIncludes, so we mis-use CL
|
||||
# for this. Filter out RC specific arguments that are unknown to CL.
|
||||
# For some unknown reason, in this case CL actually outputs the show
|
||||
|
@ -38,6 +38,7 @@ define SetupCharacterData
|
||||
$$(call LogInfo, Generating $1.java)
|
||||
$$(call MakeDir, $$(@D))
|
||||
$(TOOL_GENERATECHARACTER) $2 \
|
||||
$(if $(call equals, $(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), true), -d) \
|
||||
-template $(CHARACTERDATA)/$1.java.template \
|
||||
-spec $(UNICODEDATA)/UnicodeData.txt \
|
||||
-specialcasing $(UNICODEDATA)/SpecialCasing.txt \
|
||||
|
@ -81,7 +81,9 @@ ifneq ($(MOD_FILES), )
|
||||
$(call DependOnVariable, ALL_MODULES)
|
||||
$(call MakeTargetDir)
|
||||
$(RM) $@ $@.tmp
|
||||
$(TOOL_GENMODULEINFOSOURCE) -o $@.tmp \
|
||||
$(TOOL_GENMODULEINFOSOURCE) \
|
||||
$(if $(call equals, $(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), true), -d) \
|
||||
-o $@.tmp \
|
||||
--source-file $< \
|
||||
--modules $(call CommaList, $(ALL_MODULES)) \
|
||||
$(MOD_FILES)
|
||||
|
@ -75,7 +75,6 @@ ifeq ($(call check-jvm-feature, compiler2), true)
|
||||
OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc, \
|
||||
DEBUG_SYMBOLS := false, \
|
||||
DISABLED_WARNINGS_clang := tautological-compare, \
|
||||
DEFINE_THIS_FILE := false, \
|
||||
))
|
||||
|
||||
ADLC_TOOL := $(BUILD_ADLC_TARGET)
|
||||
@ -201,6 +200,9 @@ ifeq ($(call check-jvm-feature, compiler2), true)
|
||||
$(NAWK) \
|
||||
'BEGIN { print "#line 1 \"$*\""; } \
|
||||
/^#line 999999$$/ {print "#line " (NR+1) " \"$*\""; next} \
|
||||
$(if $(call equals, $(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), false), \
|
||||
/^#line .*$$/ {sub("$(WORKSPACE_ROOT)/","")} \
|
||||
) \
|
||||
{print}' \
|
||||
< $(ADLC_SUPPORT_DIR)/$* > $@
|
||||
|
||||
|
@ -80,7 +80,6 @@ ifeq ($(call check-jvm-feature, dtrace), true)
|
||||
EXTRA_DEPS := $(JVMTI_H) $(JFR_FILES), \
|
||||
OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets/objs, \
|
||||
OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets, \
|
||||
DEFINE_THIS_FILE := false, \
|
||||
))
|
||||
|
||||
DTRACE_GEN_OFFSETS_TOOL := $(BUILD_DTRACE_GEN_OFFSETS_TARGET)
|
||||
|
@ -42,7 +42,6 @@ ifeq ($(call check-jvm-feature, dtrace), true)
|
||||
LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
|
||||
LIBS := $(LIBDL) -lthread -ldoor, \
|
||||
OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
|
||||
DEFINE_THIS_FILE := false, \
|
||||
))
|
||||
|
||||
# Note that libjvm_db.c has tests for COMPILER2, but this was never set by
|
||||
@ -55,7 +54,6 @@ ifeq ($(call check-jvm-feature, dtrace), true)
|
||||
CFLAGS := -I$(DTRACE_GENSRC_DIR) $(JNI_INCLUDE_FLAGS) -m64 -G -mt -KPIC -xldscope=hidden, \
|
||||
LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
|
||||
OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \
|
||||
DEFINE_THIS_FILE := false, \
|
||||
))
|
||||
|
||||
TARGETS += $(BUILD_LIBJVM_DTRACE) $(BUILD_LIBJVM_DB)
|
||||
|
@ -96,7 +96,6 @@ $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \
|
||||
STRIP_SYMBOLS := false, \
|
||||
PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
|
||||
PRECOMPILED_HEADER_EXCLUDE := gtest-all.cc gmock-all.cc gtestMain.cpp, \
|
||||
DEFINE_THIS_FILE := false, \
|
||||
))
|
||||
|
||||
TARGETS += $(BUILD_GTEST_LIBJVM)
|
||||
@ -123,7 +122,6 @@ $(eval $(call SetupNativeCompilation, BUILD_GTEST_LAUNCHER, \
|
||||
LIBS_windows := $(JVM_OUTPUTDIR)/gtest/objs/jvm.lib, \
|
||||
COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \
|
||||
ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \
|
||||
DEFINE_THIS_FILE := false, \
|
||||
))
|
||||
|
||||
$(BUILD_GTEST_LAUNCHER): $(BUILD_GTEST_LIBJVM)
|
||||
|
@ -208,7 +208,6 @@ $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
|
||||
VERSIONINFO_RESOURCE := $(TOPDIR)/src/hotspot/os/windows/version.rc, \
|
||||
PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
|
||||
PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
|
||||
DEFINE_THIS_FILE := false, \
|
||||
))
|
||||
|
||||
# Always recompile abstract_vm_version.cpp if libjvm needs to be relinked. This ensures
|
||||
|
@ -942,14 +942,15 @@ OUTER: for (int i = 0; i < n; i += m) {
|
||||
int n = sizes.length;
|
||||
StringBuffer result = new StringBuffer();
|
||||
// liu : Add a comment showing the source of this table
|
||||
result.append(commentStart + " The following tables and code generated using:" +
|
||||
commentEnd + "\n ");
|
||||
result.append(commentStart + ' ' + commandLineDescription + commentEnd + "\n ");
|
||||
|
||||
if (plane == 0 && bLatin1 == false) {
|
||||
if (debug) {
|
||||
result.append(commentStart + " The following tables and code generated using:" +
|
||||
commentEnd + "\n ");
|
||||
result.append(commentStart + ' ' + commandLineDescription + commentEnd + "\n ");
|
||||
}
|
||||
if (plane == 0 && bLatin1 == false) {
|
||||
genCaseMapTableDeclaration(result);
|
||||
genCaseMapTable(initializers, specialCaseMaps);
|
||||
}
|
||||
}
|
||||
int totalBytes = 0;
|
||||
for (int k = 0; k < n - 1; k++) {
|
||||
genTable(result, tableNames[k], tables[k], 0, bytes[k]<<3, sizes[k], preshifted[k],
|
||||
@ -1612,6 +1613,7 @@ OUTER: for (int i = 0; i < n; i += m) {
|
||||
*/
|
||||
|
||||
static boolean verbose = false;
|
||||
static boolean debug = false;
|
||||
static boolean nobidi = false;
|
||||
static boolean nomirror = false;
|
||||
static boolean identifiers = false;
|
||||
@ -1692,6 +1694,8 @@ OUTER: for (int i = 0; i < n; i += m) {
|
||||
for (int j = 0; j < args.length; j++) {
|
||||
if (args[j].equals("-verbose") || args[j].equals("-v"))
|
||||
verbose = true;
|
||||
else if (args[j].equals("-d"))
|
||||
debug = true;
|
||||
else if (args[j].equals("-nobidi"))
|
||||
nobidi = true;
|
||||
else if (args[j].equals("-nomirror"))
|
||||
|
@ -59,11 +59,14 @@ import static java.util.stream.Collectors.*;
|
||||
*/
|
||||
public class GenModuleInfoSource {
|
||||
private final static String USAGE =
|
||||
"Usage: GenModuleInfoSource -o <output file> \n" +
|
||||
" --source-file <module-info-java>\n" +
|
||||
" --modules <module-name>[,<module-name>...]\n" +
|
||||
" <module-info.java.extra> ...\n";
|
||||
"Usage: GenModuleInfoSource \n" +
|
||||
" [-d]\n" +
|
||||
" -o <output file>\n" +
|
||||
" --source-file <module-info-java>\n" +
|
||||
" --modules <module-name>[,<module-name>...]\n" +
|
||||
" <module-info.java.extra> ...\n";
|
||||
|
||||
static boolean debug = false;
|
||||
static boolean verbose = false;
|
||||
public static void main(String... args) throws Exception {
|
||||
Path outfile = null;
|
||||
@ -75,6 +78,9 @@ public class GenModuleInfoSource {
|
||||
String option = args[i];
|
||||
String arg = i+1 < args.length ? args[i+1] : null;
|
||||
switch (option) {
|
||||
case "-d":
|
||||
debug = true;
|
||||
break;
|
||||
case "-o":
|
||||
outfile = Paths.get(arg);
|
||||
i++;
|
||||
@ -148,10 +154,12 @@ public class GenModuleInfoSource {
|
||||
for (String l : lines) {
|
||||
writer.println(l);
|
||||
if (l.trim().startsWith("module ")) {
|
||||
// print URI rather than file path to avoid escape
|
||||
writer.format(" // source file: %s%n", sourceFile.toUri());
|
||||
for (Path file: extraFiles) {
|
||||
writer.format(" // %s%n", file.toUri());
|
||||
if (debug) {
|
||||
// print URI rather than file path to avoid escape
|
||||
writer.format(" // source file: %s%n", sourceFile.toUri());
|
||||
for (Path file : extraFiles) {
|
||||
writer.format(" // %s%n", file.toUri());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -143,7 +143,6 @@ define SetupBuildLauncherBody
|
||||
-DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \
|
||||
-DPROGNAME='"$1"' \
|
||||
$$($1_CFLAGS), \
|
||||
CFLAGS_linux := -fPIC, \
|
||||
CFLAGS_solaris := -KPIC, \
|
||||
CFLAGS_windows := $$($1_CFLAGS_windows), \
|
||||
DISABLED_WARNINGS_gcc := unused-function, \
|
||||
|
@ -3162,7 +3162,7 @@ oop java_lang_reflect_RecordComponent::create(InstanceKlass* holder, RecordCompo
|
||||
char* sig = NEW_RESOURCE_ARRAY(char, sig_len);
|
||||
jio_snprintf(sig, sig_len, "%c%c%s", JVM_SIGNATURE_FUNC, JVM_SIGNATURE_ENDFUNC, type->as_C_string());
|
||||
TempNewSymbol full_sig = SymbolTable::new_symbol(sig);
|
||||
accessor_method = holder->find_instance_method(name, full_sig);
|
||||
accessor_method = holder->find_instance_method(name, full_sig, Klass::find_private);
|
||||
}
|
||||
|
||||
if (accessor_method != NULL) {
|
||||
|
@ -1207,7 +1207,7 @@ class ClassHierarchyWalker {
|
||||
ClassHierarchyWalker wf(_participants, _num_participants);
|
||||
Klass* w = wf.find_witness_subtype(k);
|
||||
if (w != NULL) {
|
||||
Method* wm = InstanceKlass::cast(w)->find_instance_method(_name, _signature);
|
||||
Method* wm = InstanceKlass::cast(w)->find_instance_method(_name, _signature, Klass::skip_private);
|
||||
if (!Dependencies::is_concrete_method(wm, w)) {
|
||||
// Found a concrete subtype 'w' which does not override abstract method 'm'.
|
||||
// Bail out because 'm' could be called with 'w' as receiver (leading to an
|
||||
|
@ -610,11 +610,11 @@ public:
|
||||
|
||||
// find a local method, but skip static methods
|
||||
Method* find_instance_method(const Symbol* name, const Symbol* signature,
|
||||
PrivateLookupMode private_mode = find_private) const;
|
||||
PrivateLookupMode private_mode) const;
|
||||
static Method* find_instance_method(const Array<Method*>* methods,
|
||||
const Symbol* name,
|
||||
const Symbol* signature,
|
||||
PrivateLookupMode private_mode = find_private);
|
||||
PrivateLookupMode private_mode);
|
||||
|
||||
// find a local method (returns NULL if not found)
|
||||
Method* find_local_method(const Symbol* name,
|
||||
|
@ -81,6 +81,12 @@ public final class JceKeyStore extends KeyStoreSpi {
|
||||
private static final class SecretKeyEntry {
|
||||
Date date; // the creation date of this entry
|
||||
SealedObject sealedKey;
|
||||
|
||||
// Maximum possible length of sealedKey. Used to detect malicious
|
||||
// input data. This field is set to the file length of the keystore
|
||||
// at loading. It is useless when creating a new SecretKeyEntry
|
||||
// to be store in a keystore.
|
||||
int maxLength;
|
||||
}
|
||||
|
||||
// Trusted certificate
|
||||
@ -136,8 +142,8 @@ public final class JceKeyStore extends KeyStoreSpi {
|
||||
}
|
||||
key = keyProtector.recover(encrInfo);
|
||||
} else {
|
||||
key =
|
||||
keyProtector.unseal(((SecretKeyEntry)entry).sealedKey);
|
||||
SecretKeyEntry ske = ((SecretKeyEntry)entry);
|
||||
key = keyProtector.unseal(ske.sealedKey, ske.maxLength);
|
||||
}
|
||||
|
||||
return key;
|
||||
@ -282,6 +288,7 @@ public final class JceKeyStore extends KeyStoreSpi {
|
||||
|
||||
// seal and store the key
|
||||
entry.sealedKey = keyProtector.seal(key);
|
||||
entry.maxLength = Integer.MAX_VALUE;
|
||||
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
|
||||
}
|
||||
|
||||
@ -691,6 +698,10 @@ public final class JceKeyStore extends KeyStoreSpi {
|
||||
if (stream == null)
|
||||
return;
|
||||
|
||||
byte[] allData = stream.readAllBytes();
|
||||
int fullLength = allData.length;
|
||||
|
||||
stream = new ByteArrayInputStream(allData);
|
||||
if (password != null) {
|
||||
md = getPreKeyedHash(password);
|
||||
dis = new DataInputStream(new DigestInputStream(stream, md));
|
||||
@ -829,10 +840,11 @@ public final class JceKeyStore extends KeyStoreSpi {
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<Void>)() -> {
|
||||
ois2.setObjectInputFilter(
|
||||
new DeserializationChecker());
|
||||
new DeserializationChecker(fullLength));
|
||||
return null;
|
||||
});
|
||||
entry.sealedKey = (SealedObject)ois.readObject();
|
||||
entry.maxLength = fullLength;
|
||||
// NOTE: don't close ois here since we are still
|
||||
// using dis!!!
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
@ -926,8 +938,17 @@ public final class JceKeyStore extends KeyStoreSpi {
|
||||
* deserialized.
|
||||
*/
|
||||
private static class DeserializationChecker implements ObjectInputFilter {
|
||||
|
||||
private static final int MAX_NESTED_DEPTH = 2;
|
||||
|
||||
// Full length of keystore, anything inside a SecretKeyEntry should not
|
||||
// be bigger. Otherwise, must be illegal.
|
||||
private final int fullLength;
|
||||
|
||||
public DeserializationChecker(int fullLength) {
|
||||
this.fullLength = fullLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectInputFilter.Status
|
||||
checkInput(ObjectInputFilter.FilterInfo info) {
|
||||
@ -936,6 +957,7 @@ public final class JceKeyStore extends KeyStoreSpi {
|
||||
long nestedDepth = info.depth();
|
||||
if ((nestedDepth == 1 &&
|
||||
info.serialClass() != SealedObjectForKeyProtector.class) ||
|
||||
info.arrayLength() > fullLength ||
|
||||
(nestedDepth > MAX_NESTED_DEPTH &&
|
||||
info.serialClass() != null &&
|
||||
info.serialClass() != Object.class)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2019, 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
|
||||
@ -352,8 +352,11 @@ final class KeyProtector {
|
||||
|
||||
/**
|
||||
* Unseals the sealed key.
|
||||
*
|
||||
* @param maxLength Maximum possible length of so.
|
||||
* If bigger, must be illegal.
|
||||
*/
|
||||
Key unseal(SealedObject so)
|
||||
Key unseal(SealedObject so, int maxLength)
|
||||
throws NoSuchAlgorithmException, UnrecoverableKeyException {
|
||||
SecretKey sKey = null;
|
||||
try {
|
||||
@ -389,7 +392,7 @@ final class KeyProtector {
|
||||
SunJCE.getInstance(),
|
||||
"PBEWithMD5AndTripleDES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, sKey, params);
|
||||
return soForKeyProtector.getKey(cipher);
|
||||
return soForKeyProtector.getKey(cipher, maxLength);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
// Note: this catch needed to be here because of the
|
||||
// later catch of GeneralSecurityException
|
||||
|
@ -73,7 +73,7 @@ final class SealedObjectForKeyProtector extends SealedObject {
|
||||
return params;
|
||||
}
|
||||
|
||||
final Key getKey(Cipher c)
|
||||
final Key getKey(Cipher c, int maxLength)
|
||||
throws IOException, ClassNotFoundException, IllegalBlockSizeException,
|
||||
BadPaddingException {
|
||||
|
||||
@ -81,7 +81,7 @@ final class SealedObjectForKeyProtector extends SealedObject {
|
||||
.getExtObjectInputStream(this, c)) {
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<Void>) () -> {
|
||||
ois.setObjectInputFilter(DeserializationChecker.ONE_FILTER);
|
||||
ois.setObjectInputFilter(new DeserializationChecker(maxLength));
|
||||
return null;
|
||||
});
|
||||
try {
|
||||
@ -109,7 +109,7 @@ final class SealedObjectForKeyProtector extends SealedObject {
|
||||
*/
|
||||
private static class DeserializationChecker implements ObjectInputFilter {
|
||||
|
||||
private static final ObjectInputFilter ONE_FILTER;
|
||||
private static final ObjectInputFilter OWN_FILTER;
|
||||
|
||||
static {
|
||||
String prop = AccessController.doPrivileged(
|
||||
@ -121,26 +121,32 @@ final class SealedObjectForKeyProtector extends SealedObject {
|
||||
return Security.getProperty(KEY_SERIAL_FILTER);
|
||||
}
|
||||
});
|
||||
ONE_FILTER = new DeserializationChecker(prop == null ? null
|
||||
: ObjectInputFilter.Config.createFilter(prop));
|
||||
OWN_FILTER = prop == null
|
||||
? null
|
||||
: ObjectInputFilter.Config.createFilter(prop);
|
||||
}
|
||||
|
||||
private final ObjectInputFilter base;
|
||||
// Maximum possible length of anything inside
|
||||
private final int maxLength;
|
||||
|
||||
private DeserializationChecker(ObjectInputFilter base) {
|
||||
this.base = base;
|
||||
private DeserializationChecker(int maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectInputFilter.Status checkInput(
|
||||
ObjectInputFilter.FilterInfo info) {
|
||||
|
||||
if (info.arrayLength() > maxLength) {
|
||||
return Status.REJECTED;
|
||||
}
|
||||
|
||||
if (info.serialClass() == Object.class) {
|
||||
return Status.UNDECIDED;
|
||||
}
|
||||
|
||||
if (base != null) {
|
||||
Status result = base.checkInput(info);
|
||||
if (OWN_FILTER != null) {
|
||||
Status result = OWN_FILTER.checkInput(info);
|
||||
if (result != Status.UNDECIDED) {
|
||||
return result;
|
||||
}
|
||||
|
@ -1858,6 +1858,8 @@ public class ObjectInputStream
|
||||
break;
|
||||
case TC_REFERENCE:
|
||||
descriptor = (ObjectStreamClass) readHandle(unshared);
|
||||
// Should only reference initialized class descriptors
|
||||
descriptor.checkInitialized();
|
||||
break;
|
||||
case TC_PROXYCLASSDESC:
|
||||
descriptor = readProxyDesc(unshared);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2020, 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
|
||||
@ -885,6 +885,17 @@ public class ObjectStreamClass implements Serializable {
|
||||
throw new InternalError("Unexpected call when not initialized");
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws InvalidClassException if not initialized.
|
||||
* To be called in cases where an uninitialized class descriptor indicates
|
||||
* a problem in the serialization stream.
|
||||
*/
|
||||
final void checkInitialized() throws InvalidClassException {
|
||||
if (!initialized) {
|
||||
throw new InvalidClassException("Class descriptor should be initialized");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an InvalidClassException if object instances referencing this
|
||||
* class descriptor should not be allowed to deserialize. This method does
|
||||
@ -1150,6 +1161,10 @@ public class ObjectStreamClass implements Serializable {
|
||||
} catch (IllegalAccessException ex) {
|
||||
// should not occur, as access checks have been suppressed
|
||||
throw new InternalError(ex);
|
||||
} catch (InstantiationError err) {
|
||||
var ex = new InstantiationException();
|
||||
ex.initCause(err);
|
||||
throw ex;
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -116,7 +116,8 @@ class MethodType
|
||||
|
||||
// The remaining fields are caches of various sorts:
|
||||
private @Stable MethodTypeForm form; // erased form, plus cached data about primitives
|
||||
private @Stable MethodType wrapAlt; // alternative wrapped/unwrapped version
|
||||
private @Stable Object wrapAlt; // alternative wrapped/unwrapped version and
|
||||
// private communication for readObject and readResolve
|
||||
private @Stable Invokers invokers; // cache of handy higher-order adapters
|
||||
private @Stable String methodDescriptor; // cache for toMethodDescriptorString
|
||||
|
||||
@ -711,7 +712,7 @@ class MethodType
|
||||
|
||||
private static MethodType wrapWithPrims(MethodType pt) {
|
||||
assert(pt.hasPrimitives());
|
||||
MethodType wt = pt.wrapAlt;
|
||||
MethodType wt = (MethodType)pt.wrapAlt;
|
||||
if (wt == null) {
|
||||
// fill in lazily
|
||||
wt = MethodTypeForm.canonicalize(pt, MethodTypeForm.WRAP, MethodTypeForm.WRAP);
|
||||
@ -723,7 +724,7 @@ class MethodType
|
||||
|
||||
private static MethodType unwrapWithNoPrims(MethodType wt) {
|
||||
assert(!wt.hasPrimitives());
|
||||
MethodType uwt = wt.wrapAlt;
|
||||
MethodType uwt = (MethodType)wt.wrapAlt;
|
||||
if (uwt == null) {
|
||||
// fill in lazily
|
||||
uwt = MethodTypeForm.canonicalize(wt, MethodTypeForm.UNWRAP, MethodTypeForm.UNWRAP);
|
||||
@ -1248,27 +1249,18 @@ s.writeObject(this.parameterArray());
|
||||
*/
|
||||
@java.io.Serial
|
||||
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
|
||||
// Assign temporary defaults in case this object escapes
|
||||
MethodType_init(void.class, NO_PTYPES);
|
||||
// Assign defaults in case this object escapes
|
||||
UNSAFE.putReference(this, OffsetHolder.rtypeOffset, void.class);
|
||||
UNSAFE.putReference(this, OffsetHolder.ptypesOffset, NO_PTYPES);
|
||||
|
||||
s.defaultReadObject(); // requires serialPersistentFields to be an empty array
|
||||
|
||||
Class<?> returnType = (Class<?>) s.readObject();
|
||||
Class<?>[] parameterArray = (Class<?>[]) s.readObject();
|
||||
parameterArray = parameterArray.clone(); // make sure it is unshared
|
||||
|
||||
// Assign deserialized values
|
||||
MethodType_init(returnType, parameterArray);
|
||||
}
|
||||
|
||||
// Initialization of state for deserialization only
|
||||
private void MethodType_init(Class<?> rtype, Class<?>[] ptypes) {
|
||||
// In order to communicate these values to readResolve, we must
|
||||
// store them into the implementation-specific final fields.
|
||||
checkRtype(rtype);
|
||||
checkPtypes(ptypes);
|
||||
UNSAFE.putReference(this, OffsetHolder.rtypeOffset, rtype);
|
||||
UNSAFE.putReference(this, OffsetHolder.ptypesOffset, ptypes);
|
||||
// Verify all operands, and make sure ptypes is unshared
|
||||
// Cache the new MethodType for readResolve
|
||||
wrapAlt = new MethodType[]{MethodType.methodType(returnType, parameterArray)};
|
||||
}
|
||||
|
||||
// Support for resetting final fields while deserializing. Implement Holder
|
||||
@ -1291,12 +1283,10 @@ s.writeObject(this.parameterArray());
|
||||
// Do not use a trusted path for deserialization:
|
||||
// return makeImpl(rtype, ptypes, true);
|
||||
// Verify all operands, and make sure ptypes is unshared:
|
||||
try {
|
||||
return methodType(rtype, ptypes);
|
||||
} finally {
|
||||
// Re-assign defaults in case this object escapes
|
||||
MethodType_init(void.class, NO_PTYPES);
|
||||
}
|
||||
// Return a new validated MethodType for the rtype and ptypes passed from readObject.
|
||||
MethodType mt = ((MethodType[])wrapAlt)[0];
|
||||
wrapAlt = null;
|
||||
return mt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2178,8 +2178,8 @@ class MutableBigInteger {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the multiplicative inverse of this mod mod, where mod is odd.
|
||||
* This and mod are not changed by the calculation.
|
||||
* Calculate the multiplicative inverse of this modulo mod, where the mod
|
||||
* argument is odd. This and mod are not changed by the calculation.
|
||||
*
|
||||
* This method implements an algorithm due to Richard Schroeppel, that uses
|
||||
* the same intermediate representation as Montgomery Reduction
|
||||
@ -2233,8 +2233,18 @@ class MutableBigInteger {
|
||||
k += trailingZeros;
|
||||
}
|
||||
|
||||
while (c.sign < 0)
|
||||
c.signedAdd(p);
|
||||
if (c.compare(p) >= 0) { // c has a larger magnitude than p
|
||||
MutableBigInteger remainder = c.divide(p,
|
||||
new MutableBigInteger());
|
||||
// The previous line ignores the sign so we copy the data back
|
||||
// into c which will restore the sign as needed (and converts
|
||||
// it back to a SignedMutableBigInteger)
|
||||
c.copyValue(remainder);
|
||||
}
|
||||
|
||||
if (c.sign < 0) {
|
||||
c.signedAdd(p);
|
||||
}
|
||||
|
||||
return fixup(c, p, k);
|
||||
}
|
||||
@ -2272,8 +2282,8 @@ class MutableBigInteger {
|
||||
}
|
||||
|
||||
// In theory, c may be greater than p at this point (Very rare!)
|
||||
while (c.compare(p) >= 0)
|
||||
c.subtract(p);
|
||||
if (c.compare(p) >= 0)
|
||||
c = c.divide(p, new MutableBigInteger());
|
||||
|
||||
return c;
|
||||
}
|
||||
|
@ -37,12 +37,12 @@ import java.security.PermissionCollection;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.Security;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
import sun.net.PortConfig;
|
||||
import sun.security.util.RegisteredDomain;
|
||||
@ -1349,16 +1349,13 @@ final class SocketPermissionCollection extends PermissionCollection
|
||||
implements Serializable
|
||||
{
|
||||
// Not serialized; see serialization section at end of class
|
||||
// A ConcurrentSkipListMap is used to preserve order, so that most
|
||||
// recently added permissions are checked first (see JDK-4301064).
|
||||
private transient ConcurrentSkipListMap<String, SocketPermission> perms;
|
||||
private transient Map<String, SocketPermission> perms;
|
||||
|
||||
/**
|
||||
* Create an empty SocketPermissions object.
|
||||
*
|
||||
* Create an empty SocketPermissionCollection object.
|
||||
*/
|
||||
public SocketPermissionCollection() {
|
||||
perms = new ConcurrentSkipListMap<>(new SPCComparator());
|
||||
perms = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1431,6 +1428,18 @@ final class SocketPermissionCollection extends PermissionCollection
|
||||
int effective = 0;
|
||||
int needed = desired;
|
||||
|
||||
var hit = perms.get(np.getName());
|
||||
if (hit != null) {
|
||||
// fastpath, if the host was explicitly listed
|
||||
if (((needed & hit.getMask()) != 0) && hit.impliesIgnoreMask(np)) {
|
||||
effective |= hit.getMask();
|
||||
if ((effective & desired) == desired) {
|
||||
return true;
|
||||
}
|
||||
needed = (desired & ~effective);
|
||||
}
|
||||
}
|
||||
|
||||
//System.out.println("implies "+np);
|
||||
for (SocketPermission x : perms.values()) {
|
||||
//System.out.println(" trying "+x);
|
||||
@ -1512,22 +1521,9 @@ final class SocketPermissionCollection extends PermissionCollection
|
||||
// Get the one we want
|
||||
@SuppressWarnings("unchecked")
|
||||
Vector<SocketPermission> permissions = (Vector<SocketPermission>)gfields.get("permissions", null);
|
||||
perms = new ConcurrentSkipListMap<>(new SPCComparator());
|
||||
perms = new ConcurrentHashMap<>(permissions.size());
|
||||
for (SocketPermission sp : permissions) {
|
||||
perms.put(sp.getName(), sp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple comparator that orders new non-equal entries at the beginning.
|
||||
*/
|
||||
private static class SPCComparator implements Comparator<String> {
|
||||
@Override
|
||||
public int compare(String s1, String s2) {
|
||||
if (s1.equals(s2)) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,6 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
||||
public $Type$Buffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
long addr = byteOffset(pos);
|
||||
return new ByteBufferAs$Type$Buffer$RW$$BO$(bb, -1, 0, rem, rem, addr, segment);
|
||||
|
@ -213,7 +213,6 @@ class Direct$Type$Buffer$RW$$BO$
|
||||
public $Type$Buffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << $LG_BYTES_PER_VALUE$);
|
||||
assert (off >= 0);
|
||||
|
@ -105,13 +105,15 @@ class Heap$Type$Buffer$RW$
|
||||
}
|
||||
|
||||
public $Type$Buffer slice() {
|
||||
int rem = this.remaining();
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new Heap$Type$Buffer$RW$(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
this.position() + offset, segment);
|
||||
pos + offset, segment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,12 +43,15 @@ class StringCharBuffer // package-private
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new StringCharBuffer(str,
|
||||
-1,
|
||||
0,
|
||||
this.remaining(),
|
||||
this.remaining(),
|
||||
offset + this.position());
|
||||
rem,
|
||||
rem,
|
||||
offset + pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -428,7 +428,7 @@ public final class Scanner implements Iterator<String>, Closeable {
|
||||
// here but what can we do? The final authority will be
|
||||
// whatever parse method is invoked, so ultimately the
|
||||
// Scanner will do the right thing
|
||||
String digit = "((?i)["+radixDigits+"]|\\p{javaDigit})";
|
||||
String digit = "((?i)["+radixDigits+"\\p{javaDigit}])";
|
||||
String groupedNumeral = "("+non0Digit+digit+"?"+digit+"?("+
|
||||
groupSeparator+digit+digit+digit+")+)";
|
||||
// digit++ is the possessive form which is necessary for reducing
|
||||
@ -478,7 +478,7 @@ public final class Scanner implements Iterator<String>, Closeable {
|
||||
private Pattern decimalPattern;
|
||||
private void buildFloatAndDecimalPattern() {
|
||||
// \\p{javaDigit} may not be perfect, see above
|
||||
String digit = "([0-9]|(\\p{javaDigit}))";
|
||||
String digit = "(([0-9\\p{javaDigit}]))";
|
||||
String exponent = "([eE][+-]?"+digit+"+)?";
|
||||
String groupedNumeral = "("+non0Digit+digit+"?"+digit+"?("+
|
||||
groupSeparator+digit+digit+digit+")+)";
|
||||
@ -1289,25 +1289,25 @@ public final class Scanner implements Iterator<String>, Closeable {
|
||||
|
||||
// These must be literalized to avoid collision with regex
|
||||
// metacharacters such as dot or parenthesis
|
||||
groupSeparator = "\\" + dfs.getGroupingSeparator();
|
||||
decimalSeparator = "\\" + dfs.getDecimalSeparator();
|
||||
groupSeparator = "\\x{" + Integer.toHexString(dfs.getGroupingSeparator()) + "}";
|
||||
decimalSeparator = "\\x{" + Integer.toHexString(dfs.getDecimalSeparator()) + "}";
|
||||
|
||||
// Quoting the nonzero length locale-specific things
|
||||
// to avoid potential conflict with metacharacters
|
||||
nanString = "\\Q" + dfs.getNaN() + "\\E";
|
||||
infinityString = "\\Q" + dfs.getInfinity() + "\\E";
|
||||
nanString = Pattern.quote(dfs.getNaN());
|
||||
infinityString = Pattern.quote(dfs.getInfinity());
|
||||
positivePrefix = df.getPositivePrefix();
|
||||
if (!positivePrefix.isEmpty())
|
||||
positivePrefix = "\\Q" + positivePrefix + "\\E";
|
||||
positivePrefix = Pattern.quote(positivePrefix);
|
||||
negativePrefix = df.getNegativePrefix();
|
||||
if (!negativePrefix.isEmpty())
|
||||
negativePrefix = "\\Q" + negativePrefix + "\\E";
|
||||
negativePrefix = Pattern.quote(negativePrefix);
|
||||
positiveSuffix = df.getPositiveSuffix();
|
||||
if (!positiveSuffix.isEmpty())
|
||||
positiveSuffix = "\\Q" + positiveSuffix + "\\E";
|
||||
positiveSuffix = Pattern.quote(positiveSuffix);
|
||||
negativeSuffix = df.getNegativeSuffix();
|
||||
if (!negativeSuffix.isEmpty())
|
||||
negativeSuffix = "\\Q" + negativeSuffix + "\\E";
|
||||
negativeSuffix = Pattern.quote(negativeSuffix);
|
||||
|
||||
// Force rebuilding and recompilation of locale dependent
|
||||
// primitive patterns
|
||||
|
@ -166,13 +166,23 @@ public class DatagramSocketAdaptor
|
||||
|
||||
@Override
|
||||
public SocketAddress getLocalSocketAddress() {
|
||||
try {
|
||||
return dc.getLocalAddress();
|
||||
} catch (ClosedChannelException e) {
|
||||
InetSocketAddress local = dc.localAddress();
|
||||
if (local == null || isClosed())
|
||||
return null;
|
||||
} catch (Exception x) {
|
||||
throw new Error(x);
|
||||
|
||||
InetAddress addr = local.getAddress();
|
||||
if (addr.isAnyLocalAddress())
|
||||
return local;
|
||||
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
try {
|
||||
sm.checkConnect(addr.getHostAddress(), -1);
|
||||
} catch (SecurityException x) {
|
||||
return new InetSocketAddress(local.getPort());
|
||||
}
|
||||
}
|
||||
return local;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -265,7 +265,7 @@ enum Alert {
|
||||
// It's OK to get a no_certificate alert from a client of
|
||||
// which we requested client authentication. However,
|
||||
// if we required it, then this is not acceptable.
|
||||
if (tc.sslConfig.isClientMode ||
|
||||
if (tc.sslConfig.isClientMode ||
|
||||
alert != Alert.NO_CERTIFICATE ||
|
||||
(tc.sslConfig.clientAuthType !=
|
||||
ClientAuthType.CLIENT_AUTH_REQUESTED)) {
|
||||
@ -273,8 +273,10 @@ enum Alert {
|
||||
"received handshake warning: " + alert.description);
|
||||
} else {
|
||||
// Otherwise ignore the warning but remove the
|
||||
// CertificateVerify handshake consumer so the state
|
||||
// machine doesn't expect it.
|
||||
// Certificate and CertificateVerify handshake
|
||||
// consumer so the state machine doesn't expect it.
|
||||
tc.handshakeContext.handshakeConsumers.remove(
|
||||
SSLHandshake.CERTIFICATE.id);
|
||||
tc.handshakeContext.handshakeConsumers.remove(
|
||||
SSLHandshake.CERTIFICATE_VERIFY.id);
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ final class ClientHello {
|
||||
ProtocolVersion maxProtocolVersion = chc.maximumActiveProtocol;
|
||||
|
||||
// session ID of the ClientHello message
|
||||
SessionId sessionId = SSLSessionImpl.nullSession.getSessionId();
|
||||
SessionId sessionId = new SessionId(new byte[0]);
|
||||
|
||||
// a list of cipher suites sent by the client
|
||||
List<CipherSuite> cipherSuites = chc.activeCipherSuites;
|
||||
|
@ -90,6 +90,16 @@ final class ClientKeyExchange {
|
||||
ServerHandshakeContext shc = (ServerHandshakeContext)context;
|
||||
// clean up this consumer
|
||||
shc.handshakeConsumers.remove(SSLHandshake.CLIENT_KEY_EXCHANGE.id);
|
||||
|
||||
// Check for an unprocessed client Certificate message. If that
|
||||
// handshake consumer is still present then that expected message
|
||||
// was not sent.
|
||||
if (shc.handshakeConsumers.containsKey(
|
||||
SSLHandshake.CERTIFICATE.id)) {
|
||||
throw shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
|
||||
"Unexpected ClientKeyExchange handshake message.");
|
||||
}
|
||||
|
||||
SSLKeyExchange ke = SSLKeyExchange.valueOf(
|
||||
shc.negotiatedCipherSuite.keyExchange,
|
||||
shc.negotiatedProtocol);
|
||||
|
@ -897,6 +897,8 @@ final class Finished {
|
||||
// has been received and processed.
|
||||
if (!chc.isResumption) {
|
||||
if (chc.handshakeConsumers.containsKey(
|
||||
SSLHandshake.CERTIFICATE.id) ||
|
||||
chc.handshakeConsumers.containsKey(
|
||||
SSLHandshake.CERTIFICATE_VERIFY.id)) {
|
||||
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
|
||||
"Unexpected Finished handshake message");
|
||||
@ -1029,6 +1031,8 @@ final class Finished {
|
||||
// has been received and processed.
|
||||
if (!shc.isResumption) {
|
||||
if (shc.handshakeConsumers.containsKey(
|
||||
SSLHandshake.CERTIFICATE.id) ||
|
||||
shc.handshakeConsumers.containsKey(
|
||||
SSLHandshake.CERTIFICATE_VERIFY.id)) {
|
||||
throw shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
|
||||
"Unexpected Finished handshake message");
|
||||
|
@ -164,8 +164,10 @@ abstract class HandshakeContext implements ConnectionContext {
|
||||
this.conContext = conContext;
|
||||
this.sslConfig = (SSLConfiguration)conContext.sslConfig.clone();
|
||||
|
||||
this.algorithmConstraints = new SSLAlgorithmConstraints(
|
||||
sslConfig.userSpecifiedAlgorithmConstraints);
|
||||
this.activeProtocols = getActiveProtocols(sslConfig.enabledProtocols,
|
||||
sslConfig.enabledCipherSuites, sslConfig.algorithmConstraints);
|
||||
sslConfig.enabledCipherSuites, algorithmConstraints);
|
||||
if (activeProtocols.isEmpty()) {
|
||||
throw new SSLHandshakeException(
|
||||
"No appropriate protocol (protocol is disabled or " +
|
||||
@ -181,12 +183,10 @@ abstract class HandshakeContext implements ConnectionContext {
|
||||
}
|
||||
this.maximumActiveProtocol = maximumVersion;
|
||||
this.activeCipherSuites = getActiveCipherSuites(this.activeProtocols,
|
||||
sslConfig.enabledCipherSuites, sslConfig.algorithmConstraints);
|
||||
sslConfig.enabledCipherSuites, algorithmConstraints);
|
||||
if (activeCipherSuites.isEmpty()) {
|
||||
throw new SSLHandshakeException("No appropriate cipher suite");
|
||||
}
|
||||
this.algorithmConstraints =
|
||||
new SSLAlgorithmConstraints(sslConfig.algorithmConstraints);
|
||||
|
||||
this.handshakeConsumers = new LinkedHashMap<>();
|
||||
this.handshakeProducers = new HashMap<>();
|
||||
@ -209,7 +209,7 @@ abstract class HandshakeContext implements ConnectionContext {
|
||||
/**
|
||||
* Constructor for PostHandshakeContext
|
||||
*/
|
||||
HandshakeContext(TransportContext conContext) {
|
||||
protected HandshakeContext(TransportContext conContext) {
|
||||
this.sslContext = conContext.sslContext;
|
||||
this.conContext = conContext;
|
||||
this.sslConfig = conContext.sslConfig;
|
||||
@ -219,6 +219,7 @@ abstract class HandshakeContext implements ConnectionContext {
|
||||
this.handshakeOutput = new HandshakeOutStream(conContext.outputRecord);
|
||||
this.delegatedActions = new LinkedList<>();
|
||||
|
||||
this.handshakeConsumers = new LinkedHashMap<>();
|
||||
this.handshakeProducers = null;
|
||||
this.handshakeHash = null;
|
||||
this.activeProtocols = null;
|
||||
|
@ -336,7 +336,7 @@ final class KeyShareExtension {
|
||||
for (KeyShareEntry entry : spec.clientShares) {
|
||||
NamedGroup ng = NamedGroup.valueOf(entry.namedGroupId);
|
||||
if (ng == null || !SupportedGroups.isActivatable(
|
||||
shc.sslConfig.algorithmConstraints, ng)) {
|
||||
shc.algorithmConstraints, ng)) {
|
||||
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
|
||||
SSLLogger.fine(
|
||||
"Ignore unsupported named group: " +
|
||||
@ -620,7 +620,7 @@ final class KeyShareExtension {
|
||||
KeyShareEntry keyShare = spec.serverShare;
|
||||
NamedGroup ng = NamedGroup.valueOf(keyShare.namedGroupId);
|
||||
if (ng == null || !SupportedGroups.isActivatable(
|
||||
chc.sslConfig.algorithmConstraints, ng)) {
|
||||
chc.algorithmConstraints, ng)) {
|
||||
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
|
||||
"Unsupported named group: " +
|
||||
NamedGroup.nameOf(keyShare.namedGroupId));
|
||||
@ -762,7 +762,7 @@ final class KeyShareExtension {
|
||||
NamedGroup selectedGroup = null;
|
||||
for (NamedGroup ng : shc.clientRequestedNamedGroups) {
|
||||
if (SupportedGroups.isActivatable(
|
||||
shc.sslConfig.algorithmConstraints, ng)) {
|
||||
shc.algorithmConstraints, ng)) {
|
||||
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
|
||||
SSLLogger.fine(
|
||||
"HelloRetryRequest selected named group: " +
|
||||
|
@ -30,17 +30,11 @@ import java.nio.BufferOverflowException;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A compact implementation of HandshakeContext for post-handshake messages
|
||||
*/
|
||||
final class PostHandshakeContext extends HandshakeContext {
|
||||
private final static Map<Byte, SSLConsumer> consumers = Map.of(
|
||||
SSLHandshake.KEY_UPDATE.id, SSLHandshake.KEY_UPDATE,
|
||||
SSLHandshake.NEW_SESSION_TICKET.id, SSLHandshake.NEW_SESSION_TICKET);
|
||||
|
||||
PostHandshakeContext(TransportContext context) throws IOException {
|
||||
super(context);
|
||||
|
||||
@ -49,10 +43,23 @@ final class PostHandshakeContext extends HandshakeContext {
|
||||
"Post-handshake not supported in " + negotiatedProtocol.name);
|
||||
}
|
||||
|
||||
this.localSupportedSignAlgs = new ArrayList<SignatureScheme>(
|
||||
this.localSupportedSignAlgs = new ArrayList<>(
|
||||
context.conSession.getLocalSupportedSignatureSchemes());
|
||||
|
||||
handshakeConsumers = new LinkedHashMap<>(consumers);
|
||||
// Add the potential post-handshake consumers.
|
||||
if (context.sslConfig.isClientMode) {
|
||||
handshakeConsumers.putIfAbsent(
|
||||
SSLHandshake.KEY_UPDATE.id,
|
||||
SSLHandshake.KEY_UPDATE);
|
||||
handshakeConsumers.putIfAbsent(
|
||||
SSLHandshake.NEW_SESSION_TICKET.id,
|
||||
SSLHandshake.NEW_SESSION_TICKET);
|
||||
} else {
|
||||
handshakeConsumers.putIfAbsent(
|
||||
SSLHandshake.KEY_UPDATE.id,
|
||||
SSLHandshake.KEY_UPDATE);
|
||||
}
|
||||
|
||||
handshakeFinished = true;
|
||||
handshakeSession = context.conSession;
|
||||
}
|
||||
@ -83,4 +90,21 @@ final class PostHandshakeContext extends HandshakeContext {
|
||||
SSLHandshake.nameOf(handshakeType), be);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isConsumable(TransportContext context, byte handshakeType) {
|
||||
if (handshakeType == SSLHandshake.KEY_UPDATE.id) {
|
||||
// The KeyUpdate handshake message does not apply to TLS 1.2 and
|
||||
// previous protocols.
|
||||
return context.protocolVersion.useTLS13PlusSpec();
|
||||
}
|
||||
|
||||
if (handshakeType == SSLHandshake.NEW_SESSION_TICKET.id) {
|
||||
// The new session ticket handshake message could be consumer in
|
||||
// client side only.
|
||||
return context.sslConfig.isClientMode;
|
||||
}
|
||||
|
||||
// No more post-handshake message supported currently.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -71,21 +71,21 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
|
||||
|
||||
SSLAlgorithmConstraints(SSLSocket socket,
|
||||
boolean withDefaultCertPathConstraints) {
|
||||
this.userSpecifiedConstraints = getConstraints(socket);
|
||||
this.userSpecifiedConstraints = getUserSpecifiedConstraints(socket);
|
||||
this.peerSpecifiedConstraints = null;
|
||||
this.enabledX509DisabledAlgConstraints = withDefaultCertPathConstraints;
|
||||
}
|
||||
|
||||
SSLAlgorithmConstraints(SSLEngine engine,
|
||||
boolean withDefaultCertPathConstraints) {
|
||||
this.userSpecifiedConstraints = getConstraints(engine);
|
||||
this.userSpecifiedConstraints = getUserSpecifiedConstraints(engine);
|
||||
this.peerSpecifiedConstraints = null;
|
||||
this.enabledX509DisabledAlgConstraints = withDefaultCertPathConstraints;
|
||||
}
|
||||
|
||||
SSLAlgorithmConstraints(SSLSocket socket, String[] supportedAlgorithms,
|
||||
boolean withDefaultCertPathConstraints) {
|
||||
this.userSpecifiedConstraints = getConstraints(socket);
|
||||
this.userSpecifiedConstraints = getUserSpecifiedConstraints(socket);
|
||||
this.peerSpecifiedConstraints =
|
||||
new SupportedSignatureAlgorithmConstraints(supportedAlgorithms);
|
||||
this.enabledX509DisabledAlgConstraints = withDefaultCertPathConstraints;
|
||||
@ -93,13 +93,14 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
|
||||
|
||||
SSLAlgorithmConstraints(SSLEngine engine, String[] supportedAlgorithms,
|
||||
boolean withDefaultCertPathConstraints) {
|
||||
this.userSpecifiedConstraints = getConstraints(engine);
|
||||
this.userSpecifiedConstraints = getUserSpecifiedConstraints(engine);
|
||||
this.peerSpecifiedConstraints =
|
||||
new SupportedSignatureAlgorithmConstraints(supportedAlgorithms);
|
||||
this.enabledX509DisabledAlgConstraints = withDefaultCertPathConstraints;
|
||||
}
|
||||
|
||||
private static AlgorithmConstraints getConstraints(SSLEngine engine) {
|
||||
private static AlgorithmConstraints getUserSpecifiedConstraints(
|
||||
SSLEngine engine) {
|
||||
if (engine != null) {
|
||||
// Note that the KeyManager or TrustManager implementation may be
|
||||
// not implemented in the same provider as SSLSocket/SSLEngine.
|
||||
@ -108,17 +109,18 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
|
||||
HandshakeContext hc =
|
||||
((SSLEngineImpl)engine).conContext.handshakeContext;
|
||||
if (hc != null) {
|
||||
return hc.sslConfig.algorithmConstraints;
|
||||
return hc.sslConfig.userSpecifiedAlgorithmConstraints;
|
||||
}
|
||||
} else {
|
||||
return engine.getSSLParameters().getAlgorithmConstraints();
|
||||
}
|
||||
|
||||
return engine.getSSLParameters().getAlgorithmConstraints();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static AlgorithmConstraints getConstraints(SSLSocket socket) {
|
||||
private static AlgorithmConstraints getUserSpecifiedConstraints(
|
||||
SSLSocket socket) {
|
||||
if (socket != null) {
|
||||
// Note that the KeyManager or TrustManager implementation may be
|
||||
// not implemented in the same provider as SSLSocket/SSLEngine.
|
||||
@ -127,11 +129,11 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
|
||||
HandshakeContext hc =
|
||||
((SSLSocketImpl)socket).conContext.handshakeContext;
|
||||
if (hc != null) {
|
||||
return hc.sslConfig.algorithmConstraints;
|
||||
return hc.sslConfig.userSpecifiedAlgorithmConstraints;
|
||||
}
|
||||
} else {
|
||||
return socket.getSSLParameters().getAlgorithmConstraints();
|
||||
}
|
||||
|
||||
return socket.getSSLParameters().getAlgorithmConstraints();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -51,7 +51,7 @@ import sun.security.ssl.SSLExtension.ServerExtensions;
|
||||
*/
|
||||
final class SSLConfiguration implements Cloneable {
|
||||
// configurations with SSLParameters
|
||||
AlgorithmConstraints algorithmConstraints;
|
||||
AlgorithmConstraints userSpecifiedAlgorithmConstraints;
|
||||
List<ProtocolVersion> enabledProtocols;
|
||||
List<CipherSuite> enabledCipherSuites;
|
||||
ClientAuthType clientAuthType;
|
||||
@ -116,7 +116,8 @@ final class SSLConfiguration implements Cloneable {
|
||||
SSLConfiguration(SSLContextImpl sslContext, boolean isClientMode) {
|
||||
|
||||
// Configurations with SSLParameters, default values.
|
||||
this.algorithmConstraints = SSLAlgorithmConstraints.DEFAULT;
|
||||
this.userSpecifiedAlgorithmConstraints =
|
||||
SSLAlgorithmConstraints.DEFAULT;
|
||||
this.enabledProtocols =
|
||||
sslContext.getDefaultProtocolVersions(!isClientMode);
|
||||
this.enabledCipherSuites =
|
||||
@ -153,7 +154,7 @@ final class SSLConfiguration implements Cloneable {
|
||||
SSLParameters getSSLParameters() {
|
||||
SSLParameters params = new SSLParameters();
|
||||
|
||||
params.setAlgorithmConstraints(this.algorithmConstraints);
|
||||
params.setAlgorithmConstraints(this.userSpecifiedAlgorithmConstraints);
|
||||
params.setProtocols(ProtocolVersion.toStringArray(enabledProtocols));
|
||||
params.setCipherSuites(CipherSuite.namesOf(enabledCipherSuites));
|
||||
switch (this.clientAuthType) {
|
||||
@ -193,7 +194,7 @@ final class SSLConfiguration implements Cloneable {
|
||||
void setSSLParameters(SSLParameters params) {
|
||||
AlgorithmConstraints ac = params.getAlgorithmConstraints();
|
||||
if (ac != null) {
|
||||
this.algorithmConstraints = ac;
|
||||
this.userSpecifiedAlgorithmConstraints = ac;
|
||||
} // otherwise, use the default value
|
||||
|
||||
String[] sa = params.getCipherSuites();
|
||||
|
@ -77,11 +77,6 @@ import javax.net.ssl.SSLSessionContext;
|
||||
*/
|
||||
final class SSLSessionImpl extends ExtendedSSLSession {
|
||||
|
||||
/*
|
||||
* we only really need a single null session
|
||||
*/
|
||||
static final SSLSessionImpl nullSession = new SSLSessionImpl();
|
||||
|
||||
/*
|
||||
* The state of a single session, as described in section 7.1
|
||||
* of the SSLv3 spec.
|
||||
@ -153,7 +148,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
|
||||
* be used either by a client or by a server, as a connection is
|
||||
* first opened and before handshaking begins.
|
||||
*/
|
||||
private SSLSessionImpl() {
|
||||
SSLSessionImpl() {
|
||||
this.protocolVersion = ProtocolVersion.NONE;
|
||||
this.cipherSuite = CipherSuite.C_NULL;
|
||||
this.sessionId = new SessionId(false, null);
|
||||
@ -1222,15 +1217,6 @@ final class SSLSessionImpl extends ExtendedSSLSession {
|
||||
public void invalidate() {
|
||||
sessionLock.lock();
|
||||
try {
|
||||
//
|
||||
// Can't invalidate the NULL session -- this would be
|
||||
// attempted when we get a handshaking error on a brand
|
||||
// new connection, with no "real" session yet.
|
||||
//
|
||||
if (this == nullSession) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
context.remove(sessionId);
|
||||
context = null;
|
||||
|
@ -360,7 +360,7 @@ public final class SSLSocketImpl
|
||||
SSLLogger.severe("handshake failed", ioe);
|
||||
}
|
||||
|
||||
return SSLSessionImpl.nullSession;
|
||||
return new SSLSessionImpl();
|
||||
}
|
||||
|
||||
return conContext.conSession;
|
||||
|
@ -173,12 +173,24 @@ interface SSLTransport {
|
||||
|
||||
if (plainText == null) {
|
||||
plainText = Plaintext.PLAINTEXT_NULL;
|
||||
} else {
|
||||
// Fill the destination buffers.
|
||||
if ((dsts != null) && (dstsLength > 0) &&
|
||||
(plainText.contentType ==
|
||||
ContentType.APPLICATION_DATA.id)) {
|
||||
} else if (plainText.contentType ==
|
||||
ContentType.APPLICATION_DATA.id) {
|
||||
// check handshake status
|
||||
//
|
||||
// Note that JDK does not support 0-RTT yet. Otherwise, it is
|
||||
// needed to check early_data.
|
||||
if (!context.isNegotiated) {
|
||||
if (SSLLogger.isOn && SSLLogger.isOn("ssl,verbose")) {
|
||||
SSLLogger.warning("unexpected application data " +
|
||||
"before handshake completion");
|
||||
}
|
||||
|
||||
throw context.fatal(Alert.UNEXPECTED_MESSAGE,
|
||||
"Receiving application data before handshake complete");
|
||||
}
|
||||
|
||||
// Fill the destination buffers.
|
||||
if ((dsts != null) && (dstsLength > 0)) {
|
||||
ByteBuffer fragment = plainText.fragment;
|
||||
int remains = fragment.remaining();
|
||||
|
||||
|
@ -130,7 +130,7 @@ final class TransportContext implements ConnectionContext {
|
||||
this.isUnsureMode = isUnsureMode;
|
||||
|
||||
// initial security parameters
|
||||
this.conSession = SSLSessionImpl.nullSession;
|
||||
this.conSession = new SSLSessionImpl();
|
||||
this.protocolVersion = this.sslConfig.maximumProtocolVersion;
|
||||
this.clientVerifyData = emptyByteArray;
|
||||
this.serverVerifyData = emptyByteArray;
|
||||
@ -164,12 +164,13 @@ final class TransportContext implements ConnectionContext {
|
||||
" message: " +
|
||||
SSLHandshake.nameOf(type));
|
||||
}
|
||||
if (type == SSLHandshake.KEY_UPDATE.id &&
|
||||
!protocolVersion.useTLS13PlusSpec()) {
|
||||
|
||||
if (!PostHandshakeContext.isConsumable(this, type)) {
|
||||
throw fatal(Alert.UNEXPECTED_MESSAGE,
|
||||
"Unexpected post-handshake message: " +
|
||||
SSLHandshake.nameOf(type));
|
||||
}
|
||||
|
||||
handshakeContext = new PostHandshakeContext(this);
|
||||
} else {
|
||||
handshakeContext = sslConfig.isClientMode ?
|
||||
|
@ -33,11 +33,6 @@
|
||||
|
||||
#import "ThreadUtilities.h"
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
NSColor **sColors = nil;
|
||||
NSColor **appleColors = nil;
|
||||
|
||||
@ -135,7 +130,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol
|
||||
result = (useAppleColor ? appleColors : sColors)[colorIndex];
|
||||
}
|
||||
else {
|
||||
NSLog(@"%s: %s %sColor: %ld not found, returning black.", THIS_FILE, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
|
||||
NSLog(@"%s: %s %sColor: %ld not found, returning black.", __FILE__, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
|
||||
result = [NSColor blackColor];
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,6 @@
|
||||
#import "QuartzSurfaceData.h"
|
||||
#include "AWTStrike.h"
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
static const CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
|
||||
|
||||
|
||||
@ -531,7 +526,7 @@ static inline void doDrawGlyphsPipe_getGlyphVectorLengthAndAlloc
|
||||
if (glyphs == NULL || uniChars == NULL || advances == NULL)
|
||||
{
|
||||
(*env)->DeleteLocalRef(env, glyphsArray);
|
||||
[NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__];
|
||||
[NSException raise:NSMallocException format:@"%s-%s:%d", __FILE__, __FUNCTION__, __LINE__];
|
||||
if (glyphs)
|
||||
{
|
||||
free(glyphs);
|
||||
|
@ -32,11 +32,6 @@
|
||||
#import "CoreTextSupport.h"
|
||||
#include "fontscalerdefs.h"
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
@implementation AWTStrike
|
||||
|
||||
static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
|
||||
@ -107,7 +102,7 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
|
||||
#define AWT_FONT_CLEANUP_FINISH \
|
||||
if (_fontThrowJavaException == YES) { \
|
||||
char s[512]; \
|
||||
sprintf(s, "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__); \
|
||||
sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__); \
|
||||
[JNFException raise:env as:kRuntimeException reason:s]; \
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,6 @@
|
||||
//#define USE_ERROR
|
||||
//#define USE_TRACE
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#if USE_PLATFORM_MIDI_OUT == TRUE
|
||||
|
||||
#include "PLATFORM_API_MacOSX_MidiUtils.h"
|
||||
@ -133,7 +128,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT
|
||||
case 0xF7:
|
||||
// System exclusive
|
||||
fprintf(stderr, "%s: %d->internal error: sysex message status=0x%X while sending short message\n",
|
||||
THIS_FILE, __LINE__, data[0]);
|
||||
__FILE__, __LINE__, data[0]);
|
||||
byteIsInvalid = TRUE;
|
||||
break;
|
||||
|
||||
@ -159,7 +154,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT
|
||||
default:
|
||||
// Invalid message
|
||||
fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
|
||||
THIS_FILE, __LINE__, data[0]);
|
||||
__FILE__, __LINE__, data[0]);
|
||||
byteIsInvalid = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -169,7 +164,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT
|
||||
default:
|
||||
// This can't happen, but handle it anyway.
|
||||
fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
|
||||
THIS_FILE, __LINE__, data[0]);
|
||||
__FILE__, __LINE__, data[0]);
|
||||
byteIsInvalid = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -42,11 +42,6 @@
|
||||
//#define USE_ERROR
|
||||
//#define USE_TRACE
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#if (USE_PLATFORM_MIDI_IN == TRUE) || (USE_PLATFORM_MIDI_OUT == TRUE)
|
||||
|
||||
#include "PLATFORM_API_MacOSX_MidiUtils.h"
|
||||
@ -322,7 +317,7 @@ static void processMessagesForPacket(const MIDIPacket* packet, MacMidiDeviceHand
|
||||
packedMsg = pendingMessageStatus | pendingData[0] << 8;
|
||||
} else {
|
||||
fprintf(stderr, "%s: %d->internal error: pendingMessageStatus=0x%X, pendingDataLength=%d\n",
|
||||
THIS_FILE, __LINE__, pendingMessageStatus, pendingDataLength);
|
||||
__FILE__, __LINE__, pendingMessageStatus, pendingDataLength);
|
||||
byteIsInvalid = TRUE;
|
||||
}
|
||||
pendingDataLength = 0;
|
||||
|
@ -37,11 +37,6 @@
|
||||
#import "ThreadUtilities.h"
|
||||
#import "CMenuBar.h"
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_ScreenMenu, "com/apple/laf/ScreenMenu");
|
||||
|
||||
static jint ns2awtModifiers(NSUInteger keyMods) {
|
||||
@ -101,7 +96,7 @@ static jint ns2awtMouseButton(NSInteger mouseButton) {
|
||||
{
|
||||
if (self.javaObjectWrapper == nil) {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
|
||||
NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -119,7 +114,7 @@ JNF_COCOA_EXIT(env);
|
||||
{
|
||||
if (self.javaObjectWrapper == nil) {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
|
||||
NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -137,7 +132,7 @@ JNF_COCOA_EXIT(env);
|
||||
{
|
||||
if (self.javaObjectWrapper == nil) {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
|
||||
NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -32,22 +32,17 @@ extern "C" {
|
||||
|
||||
#include "debug_util.h"
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
||||
#define DASSERT(_expr) \
|
||||
if ( !(_expr) ) { \
|
||||
DAssert_Impl( #_expr, THIS_FILE, __LINE__); \
|
||||
DAssert_Impl( #_expr, __FILE__, __LINE__); \
|
||||
} else { \
|
||||
}
|
||||
|
||||
#define DASSERTMSG(_expr, _msg) \
|
||||
if ( !(_expr) ) { \
|
||||
DAssert_Impl( (_msg), THIS_FILE, __LINE__); \
|
||||
DAssert_Impl( (_msg), __FILE__, __LINE__); \
|
||||
} else { \
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,6 @@
|
||||
|
||||
#include "debug_util.h"
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#define DMEM_MIN(a,b) (a) < (b) ? (a) : (b)
|
||||
#define DMEM_MAX(a,b) (a) > (b) ? (a) : (b)
|
||||
|
||||
@ -296,7 +291,7 @@ void DMem_ReportLeaks() {
|
||||
DMutex_Enter(DMemMutex);
|
||||
|
||||
/* Force memory leaks to be output regardless of trace settings */
|
||||
DTrace_EnableFile(THIS_FILE, TRUE);
|
||||
DTrace_EnableFile(__FILE__, TRUE);
|
||||
DTRACE_PRINTLN("--------------------------");
|
||||
DTRACE_PRINTLN("Debug Memory Manager Leaks");
|
||||
DTRACE_PRINTLN("--------------------------");
|
||||
|
@ -34,11 +34,6 @@ extern "C" {
|
||||
|
||||
#include "debug_util.h"
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
typedef int dtrace_id;
|
||||
enum {
|
||||
UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */
|
||||
@ -75,7 +70,7 @@ static dtrace_id _Dt_FileTraceId = UNDEFINED_TRACE_ID;
|
||||
#define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
|
||||
{ \
|
||||
static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \
|
||||
DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, THIS_FILE, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
|
||||
DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, __FILE__, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
|
||||
}
|
||||
|
||||
/* printf style trace macros */
|
||||
|
@ -206,7 +206,7 @@ initRect(ImageRect * pRect, int x, int y, int width, int height, int jump,
|
||||
int depthBytes = format->depthBytes;
|
||||
|
||||
pRect->pBits = pBits;
|
||||
INCPN(byte_t, pRect->pBits, y * stride + x * depthBytes);
|
||||
INCPN(byte_t, pRect->pBits, (intptr_t) y * stride + x * depthBytes);
|
||||
pRect->numLines = height;
|
||||
pRect->numSamples = width;
|
||||
pRect->stride = stride * jump;
|
||||
|
@ -263,7 +263,7 @@ Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask
|
||||
return;
|
||||
}
|
||||
dstScan = image->bytes_per_line;
|
||||
image->data = malloc(dstScan * height);
|
||||
image->data = malloc((size_t) dstScan * height);
|
||||
if (image->data == NULL) {
|
||||
XFree(image);
|
||||
AWT_UNLOCK();
|
||||
|
@ -154,7 +154,7 @@ static void FillBitmap(XImage *theImage,
|
||||
height = bottom - top;
|
||||
top -= clipTop;
|
||||
left -= clipLeft;
|
||||
pPix = ((jubyte *) theImage->data) + (left >> 3) + top * scan;
|
||||
pPix = ((jubyte *) theImage->data) + (left >> 3) + (intptr_t) top * scan;
|
||||
left &= 0x07;
|
||||
if (theImage->bitmap_bit_order == MSBFirst) {
|
||||
left = 0x80 >> left;
|
||||
|
@ -2523,7 +2523,7 @@ static gboolean gtk2_get_drawable_data(JNIEnv *env, jintArray pixelArray, jint x
|
||||
int index;
|
||||
for (_y = 0; _y < height; _y++) {
|
||||
for (_x = 0; _x < width; _x++) {
|
||||
p = pix + _y * stride + _x * nchan;
|
||||
p = pix + (intptr_t) _y * stride + _x * nchan;
|
||||
|
||||
index = (_y + dy) * jwidth + (_x + dx);
|
||||
ary[index] = 0xff000000
|
||||
|
@ -2943,7 +2943,7 @@ static gboolean gtk3_get_drawable_data(JNIEnv *env, jintArray pixelArray,
|
||||
int index;
|
||||
for (_y = 0; _y < height; _y++) {
|
||||
for (_x = 0; _x < width; _x++) {
|
||||
p = pix + _y * stride + _x * nchan;
|
||||
p = pix + (intptr_t) _y * stride + _x * nchan;
|
||||
|
||||
index = (_y + dy) * jwidth + (_x + dx);
|
||||
ary[index] = 0xff000000
|
||||
|
@ -437,9 +437,9 @@ ReadRegionsInList(Display *disp, Visual *fakeVis, int depth, int format,
|
||||
bytes_per_line = ximage->bytes_per_line;
|
||||
|
||||
if (format == ZPixmap)
|
||||
ximage->data = malloc(height*bytes_per_line);
|
||||
ximage->data = malloc((size_t) height * bytes_per_line);
|
||||
else
|
||||
ximage->data = malloc(height*bytes_per_line*depth);
|
||||
ximage->data = malloc((size_t) height * bytes_per_line * depth);
|
||||
|
||||
ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/
|
||||
|
||||
|
@ -771,7 +771,7 @@ Java_sun_java2d_xr_XRBackendNative_putMaskNative
|
||||
if (ea != 1.0f) {
|
||||
for (line=0; line < height; line++) {
|
||||
for (pix=0; pix < width; pix++) {
|
||||
int index = maskScan*line + pix + maskOff;
|
||||
size_t index = (size_t) maskScan * line + pix + maskOff;
|
||||
mask[index] = (((unsigned char) mask[index])*ea);
|
||||
}
|
||||
}
|
||||
@ -796,8 +796,8 @@ Java_sun_java2d_xr_XRBackendNative_putMaskNative
|
||||
if (imageFits) {
|
||||
for (line=0; line < height; line++) {
|
||||
for (pix=0; pix < width; pix++) {
|
||||
img->data[line*img->bytes_per_line + pix] =
|
||||
(unsigned char) (mask[maskScan*line + pix + maskOff]);
|
||||
img->data[(size_t) line * img->bytes_per_line + pix] =
|
||||
(unsigned char) (mask[(size_t) maskScan * line + pix + maskOff]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -28,11 +28,6 @@
|
||||
#define D3D_DEBUG_INFO
|
||||
#endif // DEBUG
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE THIS_FILE
|
||||
#endif
|
||||
|
||||
#ifdef D3D_PPL_DLL
|
||||
|
||||
|
||||
@ -109,7 +104,7 @@ do { \
|
||||
#define ACT_IF_NULL(ACTION, value) \
|
||||
if ((value) == NULL) { \
|
||||
J2dTraceLn3(J2D_TRACE_ERROR, \
|
||||
"%s is null in %s:%d", #value, THIS_FILE, __LINE__); \
|
||||
"%s is null in %s:%d", #value, __FILE__, __LINE__); \
|
||||
ACTION; \
|
||||
} else do { } while (0)
|
||||
#define RETURN_IF_NULL(value) ACT_IF_NULL(return, value)
|
||||
@ -119,12 +114,12 @@ do { \
|
||||
|
||||
#define RETURN_STATUS_IF_EXP_FAILED(EXPR) \
|
||||
if (FAILED(res = (EXPR))) { \
|
||||
DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## THIS_FILE); \
|
||||
DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \
|
||||
return res; \
|
||||
} else do { } while (0)
|
||||
|
||||
#define RETURN_STATUS_IF_FAILED(status) \
|
||||
if (FAILED((status))) { \
|
||||
DebugPrintD3DError((status), " failed in " ## THIS_FILE ## ", return;");\
|
||||
DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\
|
||||
return (status); \
|
||||
} else do { } while (0)
|
||||
|
@ -26,11 +26,6 @@
|
||||
#ifndef _ALLOC_H_
|
||||
#define _ALLOC_H_
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#include "stdhdrs.h"
|
||||
|
||||
// By defining std::bad_alloc in a local header file instead of including
|
||||
@ -135,12 +130,12 @@ void handle_bad_alloc(void);
|
||||
throw (std::bad_alloc);
|
||||
|
||||
#define safe_Malloc(size) \
|
||||
safe_Malloc_outofmem(size, THIS_FILE, __LINE__)
|
||||
safe_Malloc_outofmem(size, __FILE__, __LINE__)
|
||||
#define safe_Calloc(num, size) \
|
||||
safe_Calloc_outofmem(num, size, THIS_FILE, __LINE__)
|
||||
safe_Calloc_outofmem(num, size, __FILE__, __LINE__)
|
||||
#define safe_Realloc(memblock, size) \
|
||||
safe_Realloc_outofmem(memblock, size, THIS_FILE, __LINE__)
|
||||
#define new new(THIS_FILE, __LINE__)
|
||||
safe_Realloc_outofmem(memblock, size, __FILE__, __LINE__)
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif /* OUTOFMEM_TEST */
|
||||
|
||||
#define TRY \
|
||||
|
@ -63,12 +63,7 @@
|
||||
#define AWT_DUMP_CLIP_RECTANGLE(_msg, _hwnd) \
|
||||
_DTrace_Template(DumpClipRectangle, 2, "", (_msg), (_hwnd), 0, 0, 0, 0, 0, 0)
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#define new new(THIS_FILE, __LINE__)
|
||||
#define new new(__FILE__, __LINE__)
|
||||
|
||||
#define VERIFY(exp) DASSERT(exp)
|
||||
#define UNIMPLEMENTED() DASSERT(FALSE)
|
||||
|
@ -133,29 +133,24 @@ class CriticalSection {
|
||||
// Macros for using CriticalSection objects that help trace
|
||||
// lock/unlock actions
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_ENTER(cs) { \
|
||||
J2dTraceLn4(J2D_TRACE_VERBOSE2, \
|
||||
"CS.Wait: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
|
||||
GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
|
||||
GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
|
||||
(cs).Enter(); \
|
||||
J2dTraceLn4(J2D_TRACE_VERBOSE2, \
|
||||
"CS.Enter: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
|
||||
GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
|
||||
GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
|
||||
}
|
||||
|
||||
#define CRITICAL_SECTION_LEAVE(cs) { \
|
||||
J2dTraceLn4(J2D_TRACE_VERBOSE2, \
|
||||
"CS.Leave: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
|
||||
GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
|
||||
GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
|
||||
(cs).Leave(); \
|
||||
J2dTraceLn4(J2D_TRACE_VERBOSE2, \
|
||||
"CS.Left: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
|
||||
GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
|
||||
GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
|
||||
}
|
||||
|
||||
// Redefine WinAPI values related to touch input, if OS < Windows 7.
|
||||
|
@ -39,14 +39,9 @@ extern "C" {
|
||||
#ifdef USE_ERROR
|
||||
#include <stdio.h>
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#define MIDIIN_CHECK_ERROR { \
|
||||
if (err != MMSYSERR_NOERROR) \
|
||||
ERROR3("MIDI IN Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
|
||||
ERROR3("MIDI IN Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
|
||||
}
|
||||
#else
|
||||
#define MIDIIN_CHECK_ERROR
|
||||
|
@ -37,14 +37,9 @@
|
||||
#ifdef USE_ERROR
|
||||
#include <stdio.h>
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#define MIDIOUT_CHECK_ERROR { \
|
||||
if (err != MMSYSERR_NOERROR) \
|
||||
ERROR3("MIDI OUT Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
|
||||
ERROR3("MIDI OUT Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
|
||||
}
|
||||
#else
|
||||
#define MIDIOUT_CHECK_ERROR
|
||||
|
@ -32,6 +32,13 @@
|
||||
* programs running on the JVM. The mechanism for instrumentation is modification
|
||||
* of the byte-codes of methods.
|
||||
*
|
||||
* <p> Note: developers/admininstrators are responsible for verifying
|
||||
* the trustworthiness of content and structure of the Java Agents they deploy,
|
||||
* since those are able to arbitrarily transform the bytecode from other JAR files.
|
||||
* Since that happens after the Jars containing the bytecode have been verified
|
||||
* as trusted, the trustworthiness of a Java Agent can determine the trust towards
|
||||
* the entire program.
|
||||
*
|
||||
* <p> An agent is deployed as a JAR file. An attribute in the JAR file manifest
|
||||
* specifies the agent class which will be loaded to start the agent. Agents can
|
||||
* be started in several ways:
|
||||
|
@ -202,6 +202,17 @@ DEF_Agent_OnLoad(JavaVM *vm, char *tail, void * reserved) {
|
||||
*/
|
||||
oldLen = (int)strlen(premainClass);
|
||||
newLen = modifiedUtf8LengthOfUtf8(premainClass, oldLen);
|
||||
/*
|
||||
* According to JVMS class name is represented as CONSTANT_Utf8_info,
|
||||
* so its length is u2 (i.e. must be <= 0xFFFF).
|
||||
*/
|
||||
if (newLen > 0xFFFF) {
|
||||
fprintf(stderr, "-javaagent: Premain-Class value is too big\n");
|
||||
free(jarfile);
|
||||
if (options != NULL) free(options);
|
||||
freeAttributes(attributes);
|
||||
return JNI_ERR;
|
||||
}
|
||||
if (newLen == oldLen) {
|
||||
premainClass = strdup(premainClass);
|
||||
} else {
|
||||
@ -360,6 +371,17 @@ DEF_Agent_OnAttach(JavaVM* vm, char *args, void * reserved) {
|
||||
*/
|
||||
oldLen = (int)strlen(agentClass);
|
||||
newLen = modifiedUtf8LengthOfUtf8(agentClass, oldLen);
|
||||
/*
|
||||
* According to JVMS class name is represented as CONSTANT_Utf8_info,
|
||||
* so its length is u2 (i.e. must be <= 0xFFFF).
|
||||
*/
|
||||
if (newLen > 0xFFFF) {
|
||||
fprintf(stderr, "Agent-Class value is too big\n");
|
||||
free(jarfile);
|
||||
if (options != NULL) free(options);
|
||||
freeAttributes(attributes);
|
||||
return AGENT_ERROR_BADJAR;
|
||||
}
|
||||
if (newLen == oldLen) {
|
||||
agentClass = strdup(agentClass);
|
||||
} else {
|
||||
@ -485,6 +507,13 @@ jint loadAgent(JNIEnv* env, jstring path) {
|
||||
// The value of Launcher-Agent-Class is in UTF-8, convert it to modified UTF-8
|
||||
oldLen = (int) strlen(agentClass);
|
||||
newLen = modifiedUtf8LengthOfUtf8(agentClass, oldLen);
|
||||
/*
|
||||
* According to JVMS class name is represented as CONSTANT_Utf8_info,
|
||||
* so its length is u2 (i.e. must be <= 0xFFFF).
|
||||
*/
|
||||
if (newLen > 0xFFFF) {
|
||||
goto releaseAndReturn;
|
||||
}
|
||||
if (newLen == oldLen) {
|
||||
agentClass = strdup(agentClass);
|
||||
} else {
|
||||
|
@ -49,14 +49,9 @@ extern "C" {
|
||||
#define JPLISASSERT_ENABLEASSERTIONS (0)
|
||||
#endif
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#if JPLISASSERT_ENABLEASSERTIONS
|
||||
#define jplis_assert(x) JPLISAssertCondition((jboolean)(x), #x, THIS_FILE, __LINE__)
|
||||
#define jplis_assert_msg(x, msg) JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, THIS_FILE, __LINE__)
|
||||
#define jplis_assert(x) JPLISAssertCondition((jboolean)(x), #x, __FILE__, __LINE__)
|
||||
#define jplis_assert_msg(x, msg) JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, __FILE__, __LINE__)
|
||||
#else
|
||||
#define jplis_assert(x)
|
||||
#define jplis_assert_msg(x, msg)
|
||||
|
@ -33,13 +33,8 @@
|
||||
|
||||
/* Routines to convert back and forth between Platform Encoding and UTF-8 */
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
/* Error and assert macros */
|
||||
#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__, m)
|
||||
#define UTF_ERROR(m) utfError(__FILE__, __LINE__, m)
|
||||
#define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
|
||||
#define UTF_DEBUG(x)
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class Checksum {
|
||||
if (DEBUG) {
|
||||
System.out.println("Exception in getting safe default " +
|
||||
"checksum value " +
|
||||
"from the configuration Setting. " +
|
||||
"from the configuration. " +
|
||||
"No safe default checksum set.");
|
||||
exc.printStackTrace();
|
||||
}
|
||||
|
@ -170,9 +170,15 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory {
|
||||
"support DOM Level 2 and be namespace aware");
|
||||
}
|
||||
if ("KeyInfo".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
return new DOMKeyInfo(element, new UnmarshalContext(), getProvider());
|
||||
try {
|
||||
return new DOMKeyInfo(element, new UnmarshalContext(), getProvider());
|
||||
} catch (MarshalException me) {
|
||||
throw me;
|
||||
} catch (Exception e) {
|
||||
throw new MarshalException(e);
|
||||
}
|
||||
} else {
|
||||
throw new MarshalException("invalid KeyInfo tag: " + namespace + ":" + tag);
|
||||
throw new MarshalException("Invalid KeyInfo tag: " + namespace + ":" + tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,9 +192,15 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory {
|
||||
"support DOM Level 2 and be namespace aware");
|
||||
}
|
||||
if ("Signature".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
|
||||
return new DOMXMLSignature(element, context, getProvider());
|
||||
try {
|
||||
return new DOMXMLSignature(element, context, getProvider());
|
||||
} catch (MarshalException me) {
|
||||
throw me;
|
||||
} catch (Exception e) {
|
||||
throw new MarshalException(e);
|
||||
}
|
||||
} else {
|
||||
throw new MarshalException("invalid Signature tag: " + namespace + ":" + tag);
|
||||
throw new MarshalException("Invalid Signature tag: " + namespace + ":" + tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,14 +477,9 @@ void *p11malloc(size_t c, char *file, int line);
|
||||
void *p11calloc(size_t c, size_t s, char *file, int line);
|
||||
void p11free(void *p, char *file, int line);
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#define malloc(c) (p11malloc((c), THIS_FILE, __LINE__))
|
||||
#define calloc(c, s) (p11calloc((c), (s), THIS_FILE, __LINE__))
|
||||
#define free(c) (p11free((c), THIS_FILE, __LINE__))
|
||||
#define malloc(c) (p11malloc((c), __FILE__, __LINE__))
|
||||
#define calloc(c, s) (p11calloc((c), (s), __FILE__, __LINE__))
|
||||
#define free(c) (p11free((c), __FILE__, __LINE__))
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -34,7 +34,7 @@
|
||||
* Netscape Communications Corporation
|
||||
* Douglas Stebila <douglas@stebila.ca> of Sun Laboratories.
|
||||
*
|
||||
* Last Modified Date from the Original Code: Nov 2016
|
||||
* Last Modified Date from the Original Code: Nov 2019
|
||||
*********************************************************************** */
|
||||
|
||||
/* Arbitrary precision integer arithmetic library */
|
||||
@ -2136,7 +2136,10 @@ mp_err s_mp_almost_inverse(const mp_int *a, const mp_int *p, mp_int *c)
|
||||
}
|
||||
}
|
||||
if (res >= 0) {
|
||||
while (MP_SIGN(c) != MP_ZPOS) {
|
||||
if (s_mp_cmp(c, p) >= 0) {
|
||||
MP_CHECKOK( mp_div(c, p, NULL, c));
|
||||
}
|
||||
if (MP_SIGN(c) != MP_ZPOS) {
|
||||
MP_CHECKOK( mp_add(c, p, c) );
|
||||
}
|
||||
res = k;
|
||||
|
@ -82,11 +82,14 @@ public class Headers implements Map<String,List<String>> {
|
||||
char[] b = key.toCharArray();
|
||||
if (b[0] >= 'a' && b[0] <= 'z') {
|
||||
b[0] = (char)(b[0] - ('a' - 'A'));
|
||||
}
|
||||
} else if (b[0] == '\r' || b[0] == '\n')
|
||||
throw new IllegalArgumentException("illegal character in key");
|
||||
|
||||
for (int i=1; i<len; i++) {
|
||||
if (b[i] >= 'A' && b[i] <= 'Z') {
|
||||
b[i] = (char) (b[i] + ('a' - 'A'));
|
||||
}
|
||||
} else if (b[i] == '\r' || b[i] == '\n')
|
||||
throw new IllegalArgumentException("illegal character in key");
|
||||
}
|
||||
return new String(b);
|
||||
}
|
||||
@ -128,6 +131,8 @@ public class Headers implements Map<String,List<String>> {
|
||||
}
|
||||
|
||||
public List<String> put(String key, List<String> value) {
|
||||
for (String v : value)
|
||||
checkValue(v);
|
||||
return map.put (normalize(key), value);
|
||||
}
|
||||
|
||||
@ -139,6 +144,7 @@ public class Headers implements Map<String,List<String>> {
|
||||
* @param value the header value to add to the header
|
||||
*/
|
||||
public void add (String key, String value) {
|
||||
checkValue(value);
|
||||
String k = normalize(key);
|
||||
List<String> l = map.get(k);
|
||||
if (l == null) {
|
||||
@ -148,6 +154,30 @@ public class Headers implements Map<String,List<String>> {
|
||||
l.add (value);
|
||||
}
|
||||
|
||||
private static void checkValue(String value) {
|
||||
int len = value.length();
|
||||
for (int i=0; i<len; i++) {
|
||||
char c = value.charAt(i);
|
||||
if (c == '\r') {
|
||||
// is allowed if it is followed by \n and a whitespace char
|
||||
if (i >= len - 2) {
|
||||
throw new IllegalArgumentException("Illegal CR found in header");
|
||||
}
|
||||
char c1 = value.charAt(i+1);
|
||||
char c2 = value.charAt(i+2);
|
||||
if (c1 != '\n') {
|
||||
throw new IllegalArgumentException("Illegal char found after CR in header");
|
||||
}
|
||||
if (c2 != ' ' && c2 != '\t') {
|
||||
throw new IllegalArgumentException("No whitespace found after CRLF in header");
|
||||
}
|
||||
i+=2;
|
||||
} else if (c == '\n') {
|
||||
throw new IllegalArgumentException("Illegal LF found in header");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the given value as the sole header value
|
||||
* for the given key. If the mapping does not
|
||||
|
@ -49,16 +49,11 @@ jint shmemBase_receivePacket(SharedMemoryConnection *, jdwpPacket *packet);
|
||||
jint shmemBase_name(SharedMemoryTransport *, char **name);
|
||||
jint shmemBase_getlasterror(char *msg, jint size);
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define SHMEM_ASSERT(expression) \
|
||||
do { \
|
||||
if (!(expression)) { \
|
||||
exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
|
||||
exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
@ -68,7 +63,7 @@ do { \
|
||||
#define SHMEM_GUARANTEE(expression) \
|
||||
do { \
|
||||
if (!(expression)) { \
|
||||
exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
|
||||
exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -30,11 +30,6 @@
|
||||
#include "sysShmem.h"
|
||||
#include "shmemBase.h" /* for exitTransportWithError */
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These functions are not completely universal. For now, they are used
|
||||
* exclusively for Jbug's shared memory transport mechanism. They have
|
||||
@ -49,7 +44,7 @@ static HANDLE memHandle = NULL;
|
||||
if (!(expression)) { \
|
||||
exitTransportWithError \
|
||||
("\"%s\", line %d: assertion failure\n", \
|
||||
THIS_FILE, __DATE__, __LINE__); \
|
||||
__FILE__, __DATE__, __LINE__); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
|
@ -42,36 +42,31 @@ const char * jvmtiErrorText(jvmtiError);
|
||||
const char * eventText(int);
|
||||
const char * jdwpErrorText(jdwpError);
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#define EXIT_ERROR(error, msg) \
|
||||
{ \
|
||||
print_message(stderr, "JDWP exit error ", "\n", \
|
||||
"%s(%d): %s [%s:%d]", \
|
||||
jvmtiErrorText((jvmtiError)error), error, (msg==NULL?"":msg), \
|
||||
THIS_FILE, __LINE__); \
|
||||
__FILE__, __LINE__); \
|
||||
debugInit_exit((jvmtiError)error, msg); \
|
||||
}
|
||||
|
||||
#define JDI_ASSERT(expression) \
|
||||
do { \
|
||||
if (gdata && gdata->assertOn && !(expression)) { \
|
||||
jdiAssertionFailed(THIS_FILE, __LINE__, #expression); \
|
||||
jdiAssertionFailed(__FILE__, __LINE__, #expression); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define JDI_ASSERT_MSG(expression, msg) \
|
||||
do { \
|
||||
if (gdata && gdata->assertOn && !(expression)) { \
|
||||
jdiAssertionFailed(THIS_FILE, __LINE__, msg); \
|
||||
jdiAssertionFailed(__FILE__, __LINE__, msg); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define JDI_ASSERT_FAILED(msg) \
|
||||
jdiAssertionFailed(THIS_FILE, __LINE__, msg)
|
||||
jdiAssertionFailed(__FILE__, __LINE__, msg)
|
||||
|
||||
void do_pause(void);
|
||||
|
||||
|
@ -33,15 +33,10 @@ void finish_logging();
|
||||
|
||||
#define LOG_NULL ((void)0)
|
||||
|
||||
/* Use THIS_FILE when it is available. */
|
||||
#ifndef THIS_FILE
|
||||
#define THIS_FILE __FILE__
|
||||
#endif
|
||||
|
||||
#ifdef JDWP_LOGGING
|
||||
|
||||
#define _LOG(flavor,args) \
|
||||
(log_message_begin(flavor,THIS_FILE,__LINE__), \
|
||||
(log_message_begin(flavor,__FILE__,__LINE__), \
|
||||
log_message_end args)
|
||||
|
||||
#define LOG_TEST(flag) (gdata->log_flags & (flag))
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2019, 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
|
||||
@ -141,14 +141,14 @@ final class RegExpScanner extends Scanner {
|
||||
throw new PatternSyntaxException(e.getMessage(), string, scanner.position);
|
||||
}
|
||||
|
||||
scanner.processForwardReferences();
|
||||
|
||||
// Throw syntax error unless we parsed the entire JavaScript regexp without syntax errors
|
||||
if (scanner.position != string.length()) {
|
||||
final String p = scanner.getStringBuilder().toString();
|
||||
throw new PatternSyntaxException(string, p, p.length() + 1);
|
||||
}
|
||||
|
||||
scanner.processForwardReferences();
|
||||
|
||||
return scanner;
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ class Parser extends Lexer {
|
||||
private Node parseExp(final TokenType term) {
|
||||
if (token.type == term)
|
||||
{
|
||||
return StringNode.EMPTY; // goto end_of_token
|
||||
return StringNode.createEmpty(); // goto end_of_token
|
||||
}
|
||||
|
||||
Node node = null;
|
||||
@ -461,7 +461,7 @@ class Parser extends Lexer {
|
||||
switch(token.type) {
|
||||
case ALT:
|
||||
case EOT:
|
||||
return StringNode.EMPTY; // end_of_token:, node_new_empty
|
||||
return StringNode.createEmpty(); // end_of_token:, node_new_empty
|
||||
|
||||
case SUBEXP_OPEN:
|
||||
node = parseEnclose(TokenType.SUBEXP_CLOSE);
|
||||
@ -569,7 +569,7 @@ class Parser extends Lexer {
|
||||
if (syntax.contextInvalidRepeatOps()) {
|
||||
throw new SyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED);
|
||||
}
|
||||
node = StringNode.EMPTY; // node_new_empty
|
||||
node = StringNode.createEmpty(); // node_new_empty
|
||||
} else {
|
||||
return parseExpTkByte(group); // goto tk_byte
|
||||
}
|
||||
|
16
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java
16
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java
@ -27,7 +27,6 @@ public final class StringNode extends Node implements StringType {
|
||||
|
||||
private static final int NODE_STR_MARGIN = 16;
|
||||
private static final int NODE_STR_BUF_SIZE = 24;
|
||||
public static final StringNode EMPTY = new StringNode(null, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
|
||||
public char[] chars;
|
||||
public int p;
|
||||
@ -36,7 +35,13 @@ public final class StringNode extends Node implements StringType {
|
||||
public int flag;
|
||||
|
||||
public StringNode() {
|
||||
this.chars = new char[NODE_STR_BUF_SIZE];
|
||||
this(NODE_STR_BUF_SIZE);
|
||||
}
|
||||
|
||||
private StringNode(int size) {
|
||||
this.chars = new char[size];
|
||||
this.p = 0;
|
||||
this.end = 0;
|
||||
}
|
||||
|
||||
public StringNode(final char[] chars, final int p, final int end) {
|
||||
@ -51,6 +56,13 @@ public final class StringNode extends Node implements StringType {
|
||||
chars[end++] = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new empty StringNode.
|
||||
*/
|
||||
public static StringNode createEmpty() {
|
||||
return new StringNode(0);
|
||||
}
|
||||
|
||||
/* Ensure there is ahead bytes available in node's buffer
|
||||
* (assumes that the node is not shared)
|
||||
*/
|
||||
|
237
test/jdk/build/AbsPathsInImage.java
Normal file
237
test/jdk/build/AbsPathsInImage.java
Normal file
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8226346
|
||||
* @summary Check all output files for absolute path fragments
|
||||
* @requires !vm.debug
|
||||
* @run main AbsPathsInImage
|
||||
*/
|
||||
public class AbsPathsInImage {
|
||||
|
||||
// Set this property on command line to scan an alternate dir or file:
|
||||
// JTREG=JAVA_OPTIONS=-Djdk.test.build.AbsPathInImage.dir=/path/to/dir
|
||||
public static final String DIR_PROPERTY = "jdk.test.build.AbsPathsInImage.dir";
|
||||
|
||||
private boolean matchFound = false;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String jdkPathString = System.getProperty("test.jdk");
|
||||
Path jdkHome = Paths.get(jdkPathString);
|
||||
|
||||
Path dirToScan = jdkHome;
|
||||
String overrideDir = System.getProperty(DIR_PROPERTY);
|
||||
if (overrideDir != null) {
|
||||
dirToScan = Paths.get(overrideDir);
|
||||
}
|
||||
|
||||
String buildWorkspaceRoot = null;
|
||||
String buildOutputRoot = null;
|
||||
String testImageDirString = System.getenv("TEST_IMAGE_DIR");
|
||||
if (testImageDirString != null) {
|
||||
Path testImageDir = Paths.get(testImageDirString);
|
||||
Path buildInfoPropertiesFile = testImageDir.resolve("build-info.properties");
|
||||
System.out.println("Getting patterns from " + buildInfoPropertiesFile.toString());
|
||||
Properties buildInfoProperties = new Properties();
|
||||
try (InputStream inStream = Files.newInputStream(buildInfoPropertiesFile)) {
|
||||
buildInfoProperties.load(inStream);
|
||||
}
|
||||
buildWorkspaceRoot = buildInfoProperties.getProperty("build.workspace.root");
|
||||
buildOutputRoot = buildInfoProperties.getProperty("build.output.root");
|
||||
} else {
|
||||
System.out.println("Getting patterns from local environment");
|
||||
// Try to resolve the workspace root based on the jtreg test root dir
|
||||
String testRootDirString = System.getProperty("test.root");
|
||||
if (testRootDirString != null) {
|
||||
Path testRootDir = Paths.get(testRootDirString);
|
||||
// Remove /test/jdk suffix
|
||||
buildWorkspaceRoot = testRootDir.getParent().getParent().toString();
|
||||
}
|
||||
// Remove /jdk
|
||||
Path buildOutputRootPath = jdkHome.getParent();
|
||||
if (buildOutputRootPath.endsWith("images")) {
|
||||
buildOutputRootPath = buildOutputRootPath.getParent();
|
||||
}
|
||||
buildOutputRoot = buildOutputRootPath.toString();
|
||||
}
|
||||
if (buildWorkspaceRoot == null) {
|
||||
throw new Error("Could not find workspace root, test cannot run");
|
||||
}
|
||||
if (buildOutputRoot == null) {
|
||||
throw new Error("Could not find build output root, test cannot run");
|
||||
}
|
||||
|
||||
List<byte[]> searchPatterns = new ArrayList<>();
|
||||
expandPatterns(searchPatterns, buildWorkspaceRoot);
|
||||
expandPatterns(searchPatterns, buildOutputRoot);
|
||||
|
||||
System.out.println("Looking for:");
|
||||
for (byte[] searchPattern : searchPatterns) {
|
||||
System.out.println(new String(searchPattern));
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
AbsPathsInImage absPathsInImage = new AbsPathsInImage();
|
||||
absPathsInImage.scanFiles(dirToScan, searchPatterns);
|
||||
|
||||
if (absPathsInImage.matchFound) {
|
||||
throw new Exception("Test failed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add path pattern to list of patterns to search for. Create all possible
|
||||
* variants depending on platform.
|
||||
*/
|
||||
private static void expandPatterns(List<byte[]> searchPatterns, String pattern) {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
||||
String forward = pattern.replace('\\', '/');
|
||||
String back = pattern.replace('/', '\\');
|
||||
if (pattern.charAt(1) == ':') {
|
||||
String forwardUpper = String.valueOf(pattern.charAt(0)).toUpperCase() + forward.substring(1);
|
||||
String forwardLower = String.valueOf(pattern.charAt(0)).toLowerCase() + forward.substring(1);
|
||||
String backUpper = String.valueOf(pattern.charAt(0)).toUpperCase() + back.substring(1);
|
||||
String backLower = String.valueOf(pattern.charAt(0)).toLowerCase() + back.substring(1);
|
||||
searchPatterns.add(forwardUpper.getBytes());
|
||||
searchPatterns.add(forwardLower.getBytes());
|
||||
searchPatterns.add(backUpper.getBytes());
|
||||
searchPatterns.add(backLower.getBytes());
|
||||
} else {
|
||||
searchPatterns.add(forward.getBytes());
|
||||
searchPatterns.add(back.getBytes());
|
||||
}
|
||||
} else {
|
||||
searchPatterns.add(pattern.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
private void scanFiles(Path root, List<byte[]> searchPatterns) throws IOException {
|
||||
Files.walkFileTree(root, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
String fileName = file.toString();
|
||||
if (Files.isSymbolicLink(file)) {
|
||||
return super.visitFile(file, attrs);
|
||||
} else if (fileName.endsWith(".debuginfo") || fileName.endsWith(".pdb")) {
|
||||
// Do nothing
|
||||
} else if (fileName.endsWith("jvm.dll")) {
|
||||
// On Windows, the Microsoft toolchain does not provide a way
|
||||
// to reliably remove all absolute paths from __FILE__ usage.
|
||||
// Until that is fixed, we simply exclude jvm.dll from this
|
||||
// test.
|
||||
} else if (fileName.endsWith(".zip")) {
|
||||
scanZipFile(file, searchPatterns);
|
||||
} else {
|
||||
scanFile(file, searchPatterns);
|
||||
}
|
||||
return super.visitFile(file, attrs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void scanFile(Path file, List<byte[]> searchPatterns) throws IOException {
|
||||
List<String> matches = scanBytes(Files.readAllBytes(file), searchPatterns);
|
||||
if (matches.size() > 0) {
|
||||
System.out.println(file + ":");
|
||||
for (String match : matches) {
|
||||
System.out.println(match);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
private void scanZipFile(Path zipFile, List<byte[]> searchPatterns) throws IOException {
|
||||
try (ZipInputStream zipInputStream = new ZipInputStream(Files.newInputStream(zipFile))) {
|
||||
ZipEntry zipEntry;
|
||||
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
|
||||
List<String> matches = scanBytes(zipInputStream.readAllBytes(), searchPatterns);
|
||||
if (matches.size() > 0) {
|
||||
System.out.println(zipFile + ", " + zipEntry.getName() + ":");
|
||||
for (String match : matches) {
|
||||
System.out.println(match);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> scanBytes(byte[] data, List<byte[]> searchPatterns) {
|
||||
List<String> matches = new ArrayList<>();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
for (byte[] searchPattern : searchPatterns) {
|
||||
boolean found = true;
|
||||
for (int j = 0; j < searchPattern.length; j++) {
|
||||
if ((i + j >= data.length || data[i + j] != searchPattern[j])) {
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
matchFound = true;
|
||||
matches.add(new String(data, charsStart(data, i), charsOffset(data, i, searchPattern.length)));
|
||||
// No need to search the same string for multiple patterns
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
private int charsStart(byte[] data, int startIndex) {
|
||||
int index = startIndex;
|
||||
while (--index > 0) {
|
||||
byte datum = data[index];
|
||||
if (datum < 32 || datum > 126) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index + 1;
|
||||
}
|
||||
|
||||
private int charsOffset(byte[] data, int startIndex, int startOffset) {
|
||||
int offset = startOffset;
|
||||
while (startIndex + ++offset < data.length) {
|
||||
byte datum = data[startIndex + offset];
|
||||
if (datum < 32 || datum > 126) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
}
|
57
test/jdk/java/math/BigInteger/ModInvTime.java
Normal file
57
test/jdk/java/math/BigInteger/ModInvTime.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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 8225603
|
||||
* @summary Tests whether modInverse() completes in a reasonable time
|
||||
* @run main/othervm ModInvTime
|
||||
*/
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class ModInvTime {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
BigInteger prime = new BigInteger("39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942643");
|
||||
BigInteger s = new BigInteger("9552729729729327851382626410162104591956625415831952158766936536163093322096473638446154604799898109762512409920799");
|
||||
System.out.format("int length: %d, modulus length: %d%n",
|
||||
s.bitLength(), prime.bitLength());
|
||||
|
||||
System.out.println("Computing modular inverse ...");
|
||||
BigInteger mi = s.modInverse(prime);
|
||||
System.out.format("Modular inverse: %s%n", mi);
|
||||
check(s, prime, mi);
|
||||
|
||||
BigInteger ns = s.negate();
|
||||
BigInteger nmi = ns.modInverse(prime);
|
||||
System.out.format("Modular inverse of negation: %s%n", nmi);
|
||||
check(ns, prime, nmi);
|
||||
}
|
||||
|
||||
public static void check(BigInteger val, BigInteger mod, BigInteger inv) {
|
||||
BigInteger r = inv.multiply(val).remainder(mod);
|
||||
if (r.signum() == -1)
|
||||
r = r.add(mod);
|
||||
if (!r.equals(BigInteger.ONE))
|
||||
throw new RuntimeException("Numerically incorrect modular inverse");
|
||||
}
|
||||
}
|
144
test/jdk/java/net/DatagramSocket/GetLocalAddress.java
Normal file
144
test/jdk/java/net/DatagramSocket/GetLocalAddress.java
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.MulticastSocket;
|
||||
import java.nio.channels.DatagramChannel;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @run main/othervm GetLocalAddress
|
||||
* @summary Check that getLocalAddress() and getLocalSocketAddress()
|
||||
* work as specified
|
||||
*/
|
||||
|
||||
public class GetLocalAddress {
|
||||
static final Map<DatagramSocket, InetAddress> addressMap = new LinkedHashMap<>();
|
||||
static final Set<DatagramSocket> toClose = new LinkedHashSet<>();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
testAllSockets();
|
||||
} finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
static void testAllSockets() throws IOException {
|
||||
var address = new InetSocketAddress(InetAddress.getLocalHost(), 0);
|
||||
bindAndAddToMap(new DatagramSocket(null), address);
|
||||
bindAndAddToMap(new MulticastSocket(null), address);
|
||||
bindAndAddToMap(DatagramChannel.open().socket(), address);
|
||||
addToMap(new DatagramSocket(address));
|
||||
addToMap(new MulticastSocket(address));
|
||||
addToMap(DatagramChannel.open().bind(address).socket());
|
||||
testSocket();
|
||||
testAfterClose();
|
||||
}
|
||||
|
||||
static void bindAndAddToMap(DatagramSocket socket, InetSocketAddress address)
|
||||
throws IOException
|
||||
{
|
||||
toClose.add(socket);
|
||||
testNullAddress(socket, socket.getLocalSocketAddress(), "before bind");
|
||||
testWildcardAddress(socket, socket.getLocalAddress(), "before bind");
|
||||
socket.bind(address);
|
||||
addressMap.put(socket, ((InetSocketAddress)socket.getLocalSocketAddress())
|
||||
.getAddress());
|
||||
}
|
||||
|
||||
static void addToMap(DatagramSocket socket) throws IOException {
|
||||
toClose.add(socket);
|
||||
addressMap.put(socket, ((InetSocketAddress)socket.getLocalSocketAddress())
|
||||
.getAddress());
|
||||
}
|
||||
|
||||
static void testSocket() throws IOException {
|
||||
for (var entry : addressMap.entrySet()) {
|
||||
var socket = entry.getKey();
|
||||
checkAddresses(socket, entry.getValue(),
|
||||
((InetSocketAddress)entry.getKey().getLocalSocketAddress())
|
||||
.getAddress());
|
||||
checkAddresses(socket, entry.getValue(),
|
||||
entry.getKey().getLocalAddress());
|
||||
}
|
||||
}
|
||||
|
||||
static void testAfterClose() throws IOException {
|
||||
for (var entry : addressMap.entrySet()) {
|
||||
var socket = entry.getKey();
|
||||
socket.close();
|
||||
toClose.remove(socket);
|
||||
testNullAddress(socket, socket.getLocalSocketAddress(), "after close");
|
||||
testNullAddress(socket, socket.getLocalAddress(), "after close");
|
||||
}
|
||||
}
|
||||
|
||||
static void checkAddresses(DatagramSocket socket, InetAddress a1, InetAddress a2) {
|
||||
System.out.println(socket.getClass() + ": Address1: "
|
||||
+ a1.toString() + " Address2: " + a2.toString());
|
||||
if (!a1.getHostAddress().equals(a2.getHostAddress()))
|
||||
{
|
||||
throw new RuntimeException("Local address don't match for " + socket.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
static void testNullAddress(DatagramSocket socket, Object address, String when) {
|
||||
System.out.println(socket.getClass() + ": Checking address " + when);
|
||||
if (address != null) {
|
||||
throw new RuntimeException("Expected null address " + when + ", got: "
|
||||
+ address + " for " + socket.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
static void testWildcardAddress(DatagramSocket socket, InetAddress address, String when) {
|
||||
System.out.println(socket.getClass() + ": Checking address " + when);
|
||||
if (address == null || !address.isAnyLocalAddress()) {
|
||||
throw new RuntimeException("Expected wildcard address " + when + ", got: "
|
||||
+ address + " for " + socket.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
static void cleanup() {
|
||||
// Some socket might not have been closed if
|
||||
// the test failed in exception.
|
||||
// forcing cleanup here.
|
||||
toClose.forEach(GetLocalAddress::close);
|
||||
toClose.clear();
|
||||
addressMap.clear();
|
||||
}
|
||||
|
||||
static void close(DatagramSocket socket) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (Throwable ignore) { }
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8056179
|
||||
* @bug 8056179 8231785
|
||||
* @summary Unit test for PermissionCollection subclasses
|
||||
*/
|
||||
|
||||
@ -126,8 +126,10 @@ public class SocketPermissionCollection {
|
||||
testFail++;
|
||||
}
|
||||
|
||||
// test 13
|
||||
System.out.println("test 13: elements returns correct number of perms");
|
||||
|
||||
// test 10
|
||||
System.out.println("test 10: elements returns correct number of perms");
|
||||
perms.add(new SocketPermission("www.example.us", "resolve"));
|
||||
int numPerms = 0;
|
||||
Enumeration<Permission> e = perms.elements();
|
||||
while (e.hasMoreElements()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user