Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4040381c
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4040381c
编写于
12月 29, 2014
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
19dbb91f
9428953b
变更
46
隐藏空白更改
内联
并排
Showing
46 changed file
with
1352 addition
and
347 deletion
+1352
-347
make/CreateJars.gmk
make/CreateJars.gmk
+25
-14
make/Images.gmk
make/Images.gmk
+6
-4
make/Import.gmk
make/Import.gmk
+7
-1
make/Profiles.gmk
make/Profiles.gmk
+0
-1
make/Tools.gmk
make/Tools.gmk
+2
-2
make/mapfiles/libnet/mapfile-vers
make/mapfiles/libnet/mapfile-vers
+2
-0
make/profile-includes.txt
make/profile-includes.txt
+234
-67
make/profile-rtjar-includes.txt
make/profile-rtjar-includes.txt
+3
-0
make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java
make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java
+1
-1
src/share/classes/sun/nio/ch/FileChannelImpl.java
src/share/classes/sun/nio/ch/FileChannelImpl.java
+57
-24
src/share/classes/sun/nio/ch/FileDispatcher.java
src/share/classes/sun/nio/ch/FileDispatcher.java
+7
-1
src/share/classes/sun/nio/ch/Net.java
src/share/classes/sun/nio/ch/Net.java
+49
-27
src/share/classes/sun/reflect/generics/repository/ClassRepository.java
...sses/sun/reflect/generics/repository/ClassRepository.java
+10
-8
src/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java
...un/reflect/generics/repository/GenericDeclRepository.java
+8
-9
src/share/classes/sun/reflect/generics/scope/AbstractScope.java
...are/classes/sun/reflect/generics/scope/AbstractScope.java
+3
-1
src/share/native/java/net/net_util.h
src/share/native/java/net/net_util.h
+4
-0
src/solaris/classes/sun/awt/X11/XClipboard.java
src/solaris/classes/sun/awt/X11/XClipboard.java
+7
-2
src/solaris/classes/sun/nio/ch/FileDispatcherImpl.java
src/solaris/classes/sun/nio/ch/FileDispatcherImpl.java
+11
-3
src/solaris/native/java/net/net_util_md.c
src/solaris/native/java/net/net_util_md.c
+5
-0
src/solaris/native/sun/awt/awt_Event.c
src/solaris/native/sun/awt/awt_Event.c
+3
-3
src/solaris/native/sun/awt/awt_Font.c
src/solaris/native/sun/awt/awt_Font.c
+1
-0
src/solaris/native/sun/awt/awt_GraphicsEnv.c
src/solaris/native/sun/awt/awt_GraphicsEnv.c
+6
-3
src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
+9
-0
src/solaris/native/sun/nio/ch/FileChannelImpl.c
src/solaris/native/sun/nio/ch/FileChannelImpl.c
+5
-2
src/solaris/native/sun/nio/ch/Net.c
src/solaris/native/sun/nio/ch/Net.c
+1
-1
src/solaris/native/sun/xawt/XToolkit.c
src/solaris/native/sun/xawt/XToolkit.c
+1
-1
src/windows/classes/sun/nio/ch/FileDispatcherImpl.java
src/windows/classes/sun/nio/ch/FileDispatcherImpl.java
+37
-6
src/windows/native/java/net/net_util_md.c
src/windows/native/java/net/net_util_md.c
+22
-0
src/windows/native/sun/nio/ch/FileChannelImpl.c
src/windows/native/sun/nio/ch/FileChannelImpl.c
+40
-3
src/windows/native/sun/nio/ch/Net.c
src/windows/native/sun/nio/ch/Net.c
+15
-1
test/ProblemList.txt
test/ProblemList.txt
+0
-3
test/com/sun/corba/5036554/TestCorbaBug.sh
test/com/sun/corba/5036554/TestCorbaBug.sh
+2
-2
test/com/sun/corba/cachedSocket/7056731.sh
test/com/sun/corba/cachedSocket/7056731.sh
+2
-2
test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
...a/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
+405
-0
test/java/lang/Thread/ThreadStateController.java
test/java/lang/Thread/ThreadStateController.java
+54
-30
test/java/lang/management/MemoryMXBean/LowMemoryTest.java
test/java/lang/management/MemoryMXBean/LowMemoryTest.java
+11
-2
test/java/lang/management/ThreadMXBean/Locks.java
test/java/lang/management/ThreadMXBean/Locks.java
+43
-26
test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java
...ng/management/ThreadMXBean/SynchronizationStatistics.java
+88
-45
test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java
...a/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java
+8
-4
test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java
...io/channels/AsynchronousSocketChannel/StressLoopback.java
+2
-0
test/java/nio/channels/FileChannel/TransferToChannel.java
test/java/nio/channels/FileChannel/TransferToChannel.java
+2
-0
test/javax/management/monitor/CounterMonitorTest.java
test/javax/management/monitor/CounterMonitorTest.java
+1
-1
test/javax/management/remote/mandatory/notif/NotificationAccessControllerTest.java
...ote/mandatory/notif/NotificationAccessControllerTest.java
+49
-23
test/javax/management/standardmbean/DeadlockTest.java
test/javax/management/standardmbean/DeadlockTest.java
+6
-24
test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java
test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java
+90
-0
test/sun/util/calendar/zi/Rule.java
test/sun/util/calendar/zi/Rule.java
+8
-0
未找到文件。
make/CreateJars.gmk
浏览文件 @
4040381c
#
# Copyright (c) 2011, 201
3
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 201
4
, 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
...
...
@@ -267,10 +267,12 @@ $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents: $(IMAGES_OUTPUTDIR)/lib$
$(RM) $@ $@.tmp
$(GREP) -e '\.class$$' $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp
ifneq ($(PROFILE), )
# # Add back classes from excluded packages (fixing the $ substitution in the process)
for type in $(subst \$$,\, $(RT_JAR_INCLUDE_TYPES)) ; do \
$(ECHO) $$type >> $@.tmp ; \
done
ifneq ($(strip $(RT_JAR_INCLUDE_TYPES)), )
# Add back classes from excluded packages (fixing the $ substitution in the process)
for type in $(subst \$$,\, $(RT_JAR_INCLUDE_TYPES)) ; do \
$(ECHO) $$type >> $@.tmp ; \
done
endif
endif
$(MV) $@.tmp $@
...
...
@@ -281,15 +283,15 @@ $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents: $(IMAGES_OUTPUTDI
-e '/_the\.*' -e '^_the\.*' -e '\\_the\.*' -e 'javac_state' \
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp
ifneq ($(PROFILE), )
# # Strip out all META-INF/services/ entries
$(GREP) -v -e 'META-INF/services/' $@.tmp > $@.tmp2
# # Add back the required services
# # FIXME: On Solaris if PROFILE_INCLUDE_METAINF_SERVICES is not defined
# # we get a syntax error from sh. That doesn't happen on linux
for service in $(PROFILE_INCLUDE_METAINF_SERVICES) ; do
\
$(ECHO) $$service >> $@.tmp2; \
done
$(MV) $@.tmp2 $@.tmp
ifneq ($(strip $(PROFILE_INCLUDE_METAINF_SERVICES)), )
# Strip out all META-INF/services/ entries
$(GREP) -v -e 'META-INF/services/' $@.tmp > $@.tmp2
# Add back the required services
for service in $(PROFILE_INCLUDE_METAINF_SERVICES) ; do \
$(ECHO) $$service >> $@.tmp2;
\
done
$(MV) $@.tmp2 $@.tmp
endif
endif
$(MV) $@.tmp $@
...
...
@@ -309,6 +311,15 @@ $(BEANLESS_CLASSES)/%: $(JDK_OUTPUTDIR)/classes/%
$(MKDIR) -p $(@D)
$(TOOL_REMOVEMETHODS) '$<' $@ addPropertyChangeListener removePropertyChangeListener
# Code these targets explicitly because the target "%" expansion does
# not work with the inline "$" in the file name.
$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Packer.class: $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200$$Packer.class
$(MKDIR) -p $(@D)
$(TOOL_REMOVEMETHODS) '$<' $@ addPropertyChangeListener removePropertyChangeListener
$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Unpacker.class: $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200$$Unpacker.class
$(MKDIR) -p $(@D)
$(TOOL_REMOVEMETHODS) '$<' $@ addPropertyChangeListener removePropertyChangeListener
CLASSES_TO_DEBEAN = \
java/util/logging/LogManager.class \
java/util/jar/Pack200\$$Packer.class \
...
...
make/Images.gmk
浏览文件 @
4040381c
#
# Copyright (c) 2011, 201
3
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 201
4
, 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
...
...
@@ -161,11 +161,13 @@ JRE_BIN_LIST := $(filter-out $(addprefix %, $(WINDOWS_JDKJRE_BIN_FILES)), $(JDKJ
ifeq ($(OPENJDK_TARGET_OS), windows)
JDK_BIN_LIST := $(filter $(addprefix %, $(WINDOWS_JDK_BIN_FILES)), $(ALL_BIN_LIST))
# On windows x86, the server jvm is filtered out from the j2re image. This
could possibly
#
be handled by profiles in the future
. If no client jvm is built, leave server in.
# On windows x86, the server jvm is filtered out from the j2re image. This
is historical
#
and is not applied to compact profiles
. If no client jvm is built, leave server in.
ifeq ($(OPENJDK_TARGET_CPU), x86)
ifeq ($(JVM_VARIANT_CLIENT), true)
JRE_BIN_LIST := $(filter-out $(JDK_OUTPUTDIR)/bin/server/%, $(JRE_BIN_LIST))
ifeq ($(PROFILE), )
JRE_BIN_LIST := $(filter-out $(JDK_OUTPUTDIR)/bin/server/%, $(JRE_BIN_LIST))
endif
endif
endif
else
...
...
make/Import.gmk
浏览文件 @
4040381c
#
# Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 201
4
, 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
...
...
@@ -116,6 +116,12 @@ endef
#
HOTSPOT_IMPORT_FILES := $(addprefix $(LIBRARY_PREFIX), jvm.* saproc.* jsig.* sawindbg.* jvm_db.* jvm_dtrace.*) \
Xusage.txt sa-jdi.jar
ifeq ($(OPENJDK_TARGET_OS), macosx)
# additional debug file
HOTSPOT_IMPORT_FILES += Info.plist
endif
$(eval $(call CopyDir,HOTSPOT0, $(HOTSPOT_LIB_DIR), $(INSTALL_LIBRARIES_HERE), $(HOTSPOT_IMPORT_FILES)))
$(eval $(call CopyDir,HOTSPOT1, $(HOTSPOT_DIST)/lib, $(JDK_OUTPUTDIR)/lib, $(HOTSPOT_IMPORT_FILES)))
...
...
make/Profiles.gmk
浏览文件 @
4040381c
...
...
@@ -47,7 +47,6 @@ include profile-includes.txt
# Note that some jars may be optional depending on the type of build (jdk vs.
# openjdk) and the platform.
#
# WARNING: incoming lists are currently validated for linux only!
###############################################################################
# These are jar files for which the contents vary depending on the profile
...
...
make/Tools.gmk
浏览文件 @
4040381c
...
...
@@ -124,11 +124,11 @@ TOOL_CLDRCONVERTER = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \
build.tools.cldrconverter.CLDRConverter
TOOL_REMOVEMETHODS = $(JAVA_SMALL) -Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
-cp
$(JDK_OUTPUTDIR)/btclasses:$(JDK_OUTPUTDIR)
\
-cp
'$(JDK_OUTPUTDIR)/btclasses$(PATH_SEP)$(JDK_OUTPUTDIR)'
\
build.tools.classfile.RemoveMethods
TOOL_CHECKDEPS = $(JAVA_SMALL) -Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
-cp
$(JDK_OUTPUTDIR)/btclasses:$(JDK_OUTPUTDIR)
\
-cp
'$(JDK_OUTPUTDIR)/btclasses$(PATH_SEP)$(JDK_OUTPUTDIR)'
\
build.tools.deps.CheckDeps
TOOL_ADDTORESTRICTEDPKGS=$(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \
...
...
make/mapfiles/libnet/mapfile-vers
浏览文件 @
4040381c
...
...
@@ -110,6 +110,8 @@ SUNWprivate_1.1 {
NET_Bind;
NET_MapSocketOption;
NET_Wait;
NET_EnableFastTcpLoopback;
NET_ThrowNew;
ipv6_available;
local:
...
...
make/profile-includes.txt
浏览文件 @
4040381c
#
# Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 201
4
, 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
...
...
@@ -22,38 +22,150 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# These lists define where a file belongs if it exists. It is perfectly fine
# if a file does not exist on some platforms - we do not have to produce exact
# per-platform lists. However, for clarity, platform-unique files are handled
# in platform-specific conditionals.
# On different platforms the libraries are placed into different locations in the
# JRE:
ifeq (, $(findstring $(OPENJDK_TARGET_OS), windows macosx))
# On non-windows/OSX libraries go into jre/lib/<arch>
LIBS_PREFIX := $(OPENJDK_TARGET_CPU_LEGACY_LIB)/
else
# On OSX they go into jre/lib/ - on Windows they go into jre/bin/ and we won't use this
LIBS_PREFIX :=
endif
# Debug info files are tricky to deal with due to all the different platform variants
# and because they can be zipped.
ifeq ($(ZIP_DEBUGINFO_FILES), true)
# Common case and 'just works' on all platforms
DEBUG_SUFFIX := .diz
else
# It gets complicated ...
ifeq ($(OPENJDK_TARGET_OS), macosx)
# This is a directory, not a simple file, so
# it needs expanding explicitly later on
DEBUG_SUFFIX := $(SHARED_LIBRARY_SUFFIX).dSYM
else
ifeq ($(OPENJDK_TARGET_OS), windows)
DEBUG_SUFFIX := .map .pdb
else
DEBUG_SUFFIX := .debuginfo
endif
endif
endif
# Expand the contents of the .dSYM directories on macosx.
# Param 1 - debug files list eg libFoo.dylib.dSYM or libFoo.diz (if zipped)
# Param 2 - libraries list eg Foo
# On macosx if not zipping debuginfo files we expand the contents of the .dSYM directories,
# else we return the original list of .diz files.
# On other OS we return the original list of debuginfo files (whether zipped or not)
#
define expand-debuginfo
$(if $(and $(filter-out true, $(ZIP_DEBUGINFO_FILES)), $(filter macosx, $(OPENJDK_TARGET_OS))), \
$(foreach i, $1, $(addsuffix /Contents/Info.plist, $i)) \
$(foreach i, $2, $(addsuffix /Contents/Resources/DWARF/$i, $(filter $i.%, $1))), \
$1)
endef
# Common executable files
PROFILE_1_JRE_BIN_FILES := \
java$(EXE_SUFFIX) \
keytool$(EXE_SUFFIX)
PROFILE_1_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)j2pkcs11$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsig.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)net$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)nio$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sunec$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)verify$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)verify.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)zip$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/$(LIBRARY_PREFIX)jsig.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/$(LIBRARY_PREFIX)jvm.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/Xusage.txt \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/jli/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/jvm.cfg \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/$(LIBRARY_PREFIX)jsig.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/$(LIBRARY_PREFIX)jvm.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/Xusage.txt \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jsig.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
ifeq ($(OPENJDK_TARGET_OS), windows)
PROFILE_1_JRE_BIN_FILES += javaw$(EXE_SUFFIX)
endif
PROFILE_1_LIBRARIES := \
j2pkcs11 \
java \
jsig \
net \
nio \
sunec \
verify \
zip
ifeq ($(OPENJDK_TARGET_OS), windows)
PROFILE_1_LIBRARIES += msvcrt100
endif
PROFILE_1_LIBRARIES := $(addprefix $(LIBRARY_PREFIX), $(PROFILE_1_LIBRARIES))
PROFILE_1_DEBUG_FILES := $(foreach i, $(DEBUG_SUFFIX), $(addsuffix $i, $(PROFILE_1_LIBRARIES)))
PROFILE_1_LIBRARIES := $(addsuffix $(SHARED_LIBRARY_SUFFIX), $(PROFILE_1_LIBRARIES))
PROFILE_1_DEBUG_FILES := $(call expand-debuginfo, $(PROFILE_1_DEBUG_FILES), $(PROFILE_1_LIBRARIES))
PROFILE_1_LIBRARIES += $(PROFILE_1_DEBUG_FILES)
# Note: libjsig exists as both the real file and a symlink in the VM directory
# so we have to treat it with care when looking for the debuginfo files
VM_LIBRARIES := \
jvm
ifeq ($(OPENJDK_TARGET_OS), solaris)
VM_LIBRARIES += jvm_db jvm_dtrace
endif
VM_SYMLINKS := \
jsig
VM_LIBRARIES := $(addprefix $(LIBRARY_PREFIX), $(VM_LIBRARIES))
VM_DEBUG_FILES := $(foreach i, $(DEBUG_SUFFIX), $(addsuffix $i, $(VM_LIBRARIES)))
VM_SYMLINKS := $(addprefix $(LIBRARY_PREFIX), $(VM_SYMLINKS))
VM_LIBRARIES := $(addsuffix $(SHARED_LIBRARY_SUFFIX), $(VM_LIBRARIES))
VM_DEBUG_FILES := $(call expand-debuginfo, $(VM_DEBUG_FILES), $(VM_LIBRARIES))
VM_DEBUG_FILES += $(foreach i, $(DEBUG_SUFFIX), $(addsuffix $i, $(VM_SYMLINKS)))
VM_SYMLINKS := $(addsuffix $(SHARED_LIBRARY_SUFFIX), $(VM_SYMLINKS))
VM_LIBRARIES += $(VM_SYMLINKS)
VM_FILES := \
Xusage.txt
VM_DIRS := client server minimal
VM_FILES := $(foreach i, $(VM_DIRS), $(addprefix $i/, $(VM_LIBRARIES) $(VM_FILES) $(VM_DEBUG_FILES)))
JLI_LIBRARIES := \
jli
ifneq ($(OPENJDK_TARGET_OS), windows)
JLI_SUBDIR := jli/
else
JLI_SUBDIR :=
endif
JLI_LIBRARIES := $(addprefix $(JLI_SUBDIR)$(LIBRARY_PREFIX), $(JLI_LIBRARIES))
JLI_DEBUG_FILES := $(foreach i, $(DEBUG_SUFFIX), $(addsuffix $i, $(JLI_LIBRARIES)))
JLI_LIBRARIES := $(addsuffix $(SHARED_LIBRARY_SUFFIX), $(JLI_LIBRARIES))
JLI_DEBUG_FILES := $(call expand-debuginfo, $(JLI_DEBUG_FILES), $(JLI_LIBRARIES))
JLI_LIBRARIES += $(JLI_DEBUG_FILES)
ifneq ($(OPENJDK_TARGET_OS), windows)
PROFILE_1_JRE_LIB_FILES := \
$(addprefix $(LIBS_PREFIX), $(PROFILE_1_LIBRARIES) $(VM_FILES) $(JLI_LIBRARIES))
else
# On windows libraries go into jre/bin
PROFILE_1_JRE_BIN_FILES += $(PROFILE_1_LIBRARIES) $(VM_FILES) $(JLI_LIBRARIES)
endif
# Remaining jre/lib contents
# OSX doesn't use <arch> directory
#
ifeq ($(OPENJDK_TARGET_OS), macosx)
PROFILE_1_JRE_LIB_FILES += \
jvm.cfg \
jspawnhelper
else
PROFILE_1_JRE_LIB_FILES += \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/jvm.cfg \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/jspawnhelper
endif
PROFILE_1_JRE_LIB_FILES += \
calendars.properties \
classlist \
content-types.properties \
...
...
@@ -81,6 +193,14 @@ PROFILE_1_JRE_LIB_FILES := \
security/trusted.libraries \
tzdb.dat
ifeq ($(OPENJDK_TARGET_OS), windows)
PROFILE_1_JRE_LIB_FILES += tzmappings
else
ifeq ($(OPENJDK_TARGET_OS), solaris)
PROFILE_1_JRE_LIB_FILES += sdp/sdp.conf
endif
endif
PROFILE_1_JRE_OTHER_FILES := \
COPYRIGHT \
LICENSE \
...
...
@@ -106,32 +226,63 @@ PROFILE_2_JRE_BIN_FILES := \
rmid$(EXE_SUFFIX) \
rmiregistry$(EXE_SUFFIX)
ifeq ($(OPENJDK_TARGET_OS), windows)
PROFILE_2_JRE_BIN_FILES += java-rmi$(EXE_SUFFIX)
endif
# If you add libraries here, make sure you use the same techniques
# as used for the other profile's libraries regarding debug files etc
PROFILE_2_JRE_LIB_FILES :=
PROFILE_2_JRE_OTHER_FILES :=
PROFILE_2_JRE_JAR_FILES :=
ifeq ($(OPENJDK_TARGET_OS), windows)
PROFILE_3_JRE_BIN_FILES := \
kinit$(EXE_SUFFIX) \
klist$(EXE_SUFFIX) \
ktab$(EXE_SUFFIX)
else
PROFILE_3_JRE_BIN_FILES :=
endif
PROFILE_3_JRE_BIN_FILES :=
PROFILE_3_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)hprof$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)hprof.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)instrument$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)instrument.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)j2gss$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)j2pcsc$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jaas_unix$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)java_crw_demo$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)java_crw_demo.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsdt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsdt.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)management$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)management.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sctp$(SHARED_LIBRARY_SUFFIX) \
PROFILE_3_LIBRARIES := \
hprof \
instrument \
j2gss \
j2pcsc \
jaas_unix \
jaas_nt \
java_crw_demo \
jsdt \
management \
npt \
sctp
ifeq ($(OPENJDK_TARGET_OS), windows)
PROFILE_3_LIBRARIES += w2k_lsa_auth
else
ifeq ($(OPENJDK_TARGET_OS), macosx)
PROFILE_3_LIBRARIES += osxkrb5
endif
endif
PROFILE_3_LIBRARIES := $(addprefix $(LIBRARY_PREFIX), $(PROFILE_3_LIBRARIES))
PROFILE_3_DEBUG_FILES := $(foreach i, $(DEBUG_SUFFIX), $(addsuffix $i, $(PROFILE_3_LIBRARIES)))
PROFILE_3_LIBRARIES := $(addsuffix $(SHARED_LIBRARY_SUFFIX), $(PROFILE_3_LIBRARIES))
PROFILE_3_DEBUG_FILES := $(call expand-debuginfo, $(PROFILE_3_DEBUG_FILES), $(PROFILE_3_LIBRARIES))
PROFILE_3_LIBRARIES += $(PROFILE_3_DEBUG_FILES)
ifneq ($(OPENJDK_TARGET_OS), windows)
PROFILE_3_JRE_LIB_FILES := \
$(addprefix $(LIBS_PREFIX), $(PROFILE_3_LIBRARIES))
else
# On windows libraries go into jre/bin
PROFILE_3_JRE_BIN_FILES += $(PROFILE_3_LIBRARIES)
endif
PROFILE_3_JRE_LIB_FILES += \
jvm.hprof.txt \
management-agent.jar \
management/jmxremote.access \
...
...
@@ -153,25 +304,40 @@ FULL_JRE_BIN_FILES := \
tnameserv$(EXE_SUFFIX) \
unpack200$(EXE_SUFFIX)
FULL_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)dcpr$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)dt_socket$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)dt_socket.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)fontmanager$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jawt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jdwp$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jfr$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jpeg$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsound$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsoundalsa$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)kcms$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)mlib_image$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)splashscreen$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)t2k$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX) \
JRE_LIBRARIES := \
awt \
awt_headless \
awt_xawt \
dcpr \
dt_socket \
fontmanager \
jawt \
jdwp \
jfr \
jpeg \
jsound \
jsoundalsa \
kcms \
mlib_image \
splashscreen \
t2k \
unpack
JRE_LIBRARIES := $(addprefix $(LIBRARY_PREFIX), $(JRE_LIBRARIES))
JRE_DEBUG_FILES := $(foreach i, $(DEBUG_SUFFIX), $(addsuffix $i, $(JRE_LIBRARIES)))
JRE_LIBRARIES := $(addsuffix $(SHARED_LIBRARY_SUFFIX), $(JRE_LIBRARIES))
JRE_DEBUG_FILES := $(call expand-debuginfo, $(JRE_DEBUG_FILES), $(JRE_LIBRARIES))
JRE_LIBRARIES += $(JRE_DEBUG_FILES)
ifneq ($(OPENJDK_TARGET_OS), windows)
FULL_JRE_LIB_FILES := \
$(addprefix $(LIBS_PREFIX), $(JRE_LIBRARIES))
else
# On windows libraries go into jre/bin
FULL_JRE_BIN_FILES += $(JRE_LIBRARIES)
endif
FULL_JRE_LIB_FILES += \
charsets.jar \
cmm/CIEXYZ.pf \
cmm/GRAY.pf \
...
...
@@ -254,3 +420,4 @@ FULL_JRE_JAR_FILES := \
ext/nashorn.jar \
ext/zipfs.jar \
jfr.jar
make/profile-rtjar-includes.txt
浏览文件 @
4040381c
...
...
@@ -162,6 +162,8 @@ PROFILE_3_RTJAR_EXCLUDE_TYPES := \
javax/management/remote/rmi/_RMIServer_Stub.class
FULL_JRE_RTJAR_INCLUDE_PACKAGES := \
apple \
com/apple \
com/oracle \
com/sun/accessibility/internal/resources \
com/sun/activation/registries \
...
...
@@ -213,6 +215,7 @@ FULL_JRE_RTJAR_INCLUDE_PACKAGES := \
sun/dc \
sun/font \
sun/java2d \
sun/lwawt \
sun/net/ftp \
sun/net/smtp \
sun/net/www/content/audio \
...
...
make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java
浏览文件 @
4040381c
...
...
@@ -491,10 +491,10 @@ public class ZoneRulesBuilder {
TZRule
rule
=
new
TZRule
(
year
,
month
,
dayOfMonthIndicator
,
dayOfWeek
,
time
,
timeEndOfDay
,
timeDefinition
,
savingAmountSecs
);
if
(
lastRule
)
{
lastRuleList
.
add
(
rule
);
maxLastRuleStartYear
=
Math
.
max
(
startYear
,
maxLastRuleStartYear
);
}
else
{
ruleList
.
add
(
rule
);
}
maxLastRuleStartYear
=
Math
.
max
(
startYear
,
maxLastRuleStartYear
);
year
++;
}
}
...
...
src/share/classes/sun/nio/ch/FileChannelImpl.java
浏览文件 @
4040381c
...
...
@@ -38,6 +38,7 @@ import java.nio.channels.NonReadableChannelException;
import
java.nio.channels.NonWritableChannelException
;
import
java.nio.channels.OverlappingFileLockException
;
import
java.nio.channels.ReadableByteChannel
;
import
java.nio.channels.SelectableChannel
;
import
java.nio.channels.WritableByteChannel
;
import
java.security.AccessController
;
import
java.util.ArrayList
;
...
...
@@ -407,30 +408,13 @@ public class FileChannelImpl
//
private
static
volatile
boolean
fileSupported
=
true
;
private
long
transferToDirectly
(
long
position
,
int
icount
,
WritableByteChannel
target
)
private
long
transferToDirectlyInternal
(
long
position
,
int
icount
,
WritableByteChannel
target
,
FileDescriptor
targetFD
)
throws
IOException
{
if
(!
transferSupported
)
return
IOStatus
.
UNSUPPORTED
;
FileDescriptor
targetFD
=
null
;
if
(
target
instanceof
FileChannelImpl
)
{
if
(!
fileSupported
)
return
IOStatus
.
UNSUPPORTED_CASE
;
targetFD
=
((
FileChannelImpl
)
target
).
fd
;
}
else
if
(
target
instanceof
SelChImpl
)
{
// Direct transfer to pipe causes EINVAL on some configurations
if
((
target
instanceof
SinkChannelImpl
)
&&
!
pipeSupported
)
return
IOStatus
.
UNSUPPORTED_CASE
;
targetFD
=
((
SelChImpl
)
target
).
getFD
();
}
if
(
targetFD
==
null
)
return
IOStatus
.
UNSUPPORTED
;
int
thisFDVal
=
IOUtil
.
fdVal
(
fd
);
int
targetFDVal
=
IOUtil
.
fdVal
(
targetFD
);
if
(
thisFDVal
==
targetFDVal
)
// Not supported on some configurations
return
IOStatus
.
UNSUPPORTED
;
assert
!
nd
.
transferToDirectlyNeedsPositionLock
()
||
Thread
.
holdsLock
(
positionLock
);
long
n
=
-
1
;
int
ti
=
-
1
;
...
...
@@ -440,7 +424,7 @@ public class FileChannelImpl
if
(!
isOpen
())
return
-
1
;
do
{
n
=
transferTo0
(
thisFDVal
,
position
,
icount
,
targetFDVal
);
n
=
transferTo0
(
fd
,
position
,
icount
,
targetFD
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
if
(
n
==
IOStatus
.
UNSUPPORTED_CASE
)
{
if
(
target
instanceof
SinkChannelImpl
)
...
...
@@ -461,6 +445,54 @@ public class FileChannelImpl
}
}
private
long
transferToDirectly
(
long
position
,
int
icount
,
WritableByteChannel
target
)
throws
IOException
{
if
(!
transferSupported
)
return
IOStatus
.
UNSUPPORTED
;
FileDescriptor
targetFD
=
null
;
if
(
target
instanceof
FileChannelImpl
)
{
if
(!
fileSupported
)
return
IOStatus
.
UNSUPPORTED_CASE
;
targetFD
=
((
FileChannelImpl
)
target
).
fd
;
}
else
if
(
target
instanceof
SelChImpl
)
{
// Direct transfer to pipe causes EINVAL on some configurations
if
((
target
instanceof
SinkChannelImpl
)
&&
!
pipeSupported
)
return
IOStatus
.
UNSUPPORTED_CASE
;
// Platform-specific restrictions. Now there is only one:
// Direct transfer to non-blocking channel could be forbidden
SelectableChannel
sc
=
(
SelectableChannel
)
target
;
if
(!
nd
.
canTransferToDirectly
(
sc
))
return
IOStatus
.
UNSUPPORTED_CASE
;
targetFD
=
((
SelChImpl
)
target
).
getFD
();
}
if
(
targetFD
==
null
)
return
IOStatus
.
UNSUPPORTED
;
int
thisFDVal
=
IOUtil
.
fdVal
(
fd
);
int
targetFDVal
=
IOUtil
.
fdVal
(
targetFD
);
if
(
thisFDVal
==
targetFDVal
)
// Not supported on some configurations
return
IOStatus
.
UNSUPPORTED
;
if
(
nd
.
transferToDirectlyNeedsPositionLock
())
{
synchronized
(
positionLock
)
{
long
pos
=
position
();
try
{
return
transferToDirectlyInternal
(
position
,
icount
,
target
,
targetFD
);
}
finally
{
position
(
pos
);
}
}
}
else
{
return
transferToDirectlyInternal
(
position
,
icount
,
target
,
targetFD
);
}
}
// Maximum size to map when using a mapped buffer
private
static
final
long
MAPPED_TRANSFER_SIZE
=
8L
*
1024L
*
1024L
;
...
...
@@ -1176,7 +1208,8 @@ public class FileChannelImpl
private
static
native
int
unmap0
(
long
address
,
long
length
);
// Transfers from src to dst, or returns -2 if kernel can't do that
private
native
long
transferTo0
(
int
src
,
long
position
,
long
count
,
int
dst
);
private
native
long
transferTo0
(
FileDescriptor
src
,
long
position
,
long
count
,
FileDescriptor
dst
);
// Sets or reports this file's position
// If offset is -1, the current position is returned
...
...
src/share/classes/sun/nio/ch/FileDispatcher.java
浏览文件 @
4040381c
...
...
@@ -25,7 +25,9 @@
package
sun.nio.ch
;
import
java.io.*
;
import
java.io.FileDescriptor
;
import
java.io.IOException
;
import
java.nio.channels.SelectableChannel
;
abstract
class
FileDispatcher
extends
NativeDispatcher
{
...
...
@@ -53,4 +55,8 @@ abstract class FileDispatcher extends NativeDispatcher {
*/
abstract
FileDescriptor
duplicateForMapping
(
FileDescriptor
fd
)
throws
IOException
;
abstract
boolean
canTransferToDirectly
(
SelectableChannel
sc
);
abstract
boolean
transferToDirectlyNeedsPositionLock
();
}
src/share/classes/sun/nio/ch/Net.java
浏览文件 @
4040381c
...
...
@@ -50,30 +50,8 @@ public class Net {
// set to true if exclusive binding is on for Windows
private
static
final
boolean
exclusiveBind
;
static
{
int
availLevel
=
isExclusiveBindAvailable
();
if
(
availLevel
>=
0
)
{
String
exclBindProp
=
java
.
security
.
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
String
>()
{
@Override
public
String
run
()
{
return
System
.
getProperty
(
"sun.net.useExclusiveBind"
);
}
});
if
(
exclBindProp
!=
null
)
{
exclusiveBind
=
exclBindProp
.
length
()
==
0
?
true
:
Boolean
.
parseBoolean
(
exclBindProp
);
}
else
if
(
availLevel
==
1
)
{
exclusiveBind
=
true
;
}
else
{
exclusiveBind
=
false
;
}
}
else
{
exclusiveBind
=
false
;
}
}
// set to true if the fast tcp loopback should be enabled on Windows
private
static
final
boolean
fastLoopback
;
// -- Miscellaneous utilities --
...
...
@@ -391,6 +369,23 @@ public class Net {
}
}
public
static
boolean
isFastTcpLoopbackRequested
()
{
String
loopbackProp
=
java
.
security
.
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
String
>()
{
@Override
public
String
run
()
{
return
System
.
getProperty
(
"jdk.net.useFastTcpLoopback"
);
}
});
boolean
enable
;
if
(
""
.
equals
(
loopbackProp
))
{
enable
=
true
;
}
else
{
enable
=
Boolean
.
parseBoolean
(
loopbackProp
);
}
return
enable
;
}
// -- Socket operations --
private
static
native
boolean
isIPv6Available0
();
...
...
@@ -413,15 +408,16 @@ public class Net {
throws
IOException
{
boolean
preferIPv6
=
isIPv6Available
()
&&
(
family
!=
StandardProtocolFamily
.
INET
);
return
IOUtil
.
newFD
(
socket0
(
preferIPv6
,
stream
,
false
));
return
IOUtil
.
newFD
(
socket0
(
preferIPv6
,
stream
,
false
,
fastLoopback
));
}
static
FileDescriptor
serverSocket
(
boolean
stream
)
{
return
IOUtil
.
newFD
(
socket0
(
isIPv6Available
(),
stream
,
true
));
return
IOUtil
.
newFD
(
socket0
(
isIPv6Available
(),
stream
,
true
,
fastLoopback
));
}
// Due to oddities SO_REUSEADDR on windows reuse is ignored
private
static
native
int
socket0
(
boolean
preferIPv6
,
boolean
stream
,
boolean
reuse
);
private
static
native
int
socket0
(
boolean
preferIPv6
,
boolean
stream
,
boolean
reuse
,
boolean
fastLoopback
);
public
static
void
bind
(
FileDescriptor
fd
,
InetAddress
addr
,
int
port
)
throws
IOException
...
...
@@ -634,4 +630,30 @@ public class Net {
POLLCONN
=
pollconnValue
();
}
static
{
int
availLevel
=
isExclusiveBindAvailable
();
if
(
availLevel
>=
0
)
{
String
exclBindProp
=
java
.
security
.
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
String
>()
{
@Override
public
String
run
()
{
return
System
.
getProperty
(
"sun.net.useExclusiveBind"
);
}
});
if
(
exclBindProp
!=
null
)
{
exclusiveBind
=
exclBindProp
.
length
()
==
0
?
true
:
Boolean
.
parseBoolean
(
exclBindProp
);
}
else
if
(
availLevel
==
1
)
{
exclusiveBind
=
true
;
}
else
{
exclusiveBind
=
false
;
}
}
else
{
exclusiveBind
=
false
;
}
fastLoopback
=
isFastTcpLoopbackRequested
();
}
}
src/share/classes/sun/reflect/generics/repository/ClassRepository.java
浏览文件 @
4040381c
...
...
@@ -42,8 +42,11 @@ public class ClassRepository extends GenericDeclRepository<ClassSignature> {
public
static
final
ClassRepository
NONE
=
ClassRepository
.
make
(
"Ljava/lang/Object;"
,
null
);
private
volatile
Type
superclass
;
// caches the generic superclass info
private
volatile
Type
[]
superInterfaces
;
// caches the generic superinterface info
/** The generic superclass info. Lazily initialized. */
private
volatile
Type
superclass
;
/** The generic superinterface info. Lazily initialized. */
private
volatile
Type
[]
superInterfaces
;
// private, to enforce use of static factory
private
ClassRepository
(
String
rawSig
,
GenericsFactory
f
)
{
...
...
@@ -79,7 +82,7 @@ public class ClassRepository extends GenericDeclRepository<ClassSignature> {
* with which the repository was created.
*/
public
Type
getSuperclass
(){
public
Type
getSuperclass
()
{
Type
superclass
=
this
.
superclass
;
if
(
superclass
==
null
)
{
// lazily initialize superclass
Reifier
r
=
getReifier
();
// obtain visitor
...
...
@@ -88,25 +91,24 @@ public class ClassRepository extends GenericDeclRepository<ClassSignature> {
// extract result from visitor and cache it
superclass
=
r
.
getResult
();
this
.
superclass
=
superclass
;
}
}
return
superclass
;
// return cached result
}
public
Type
[]
getSuperInterfaces
(){
public
Type
[]
getSuperInterfaces
()
{
Type
[]
superInterfaces
=
this
.
superInterfaces
;
if
(
superInterfaces
==
null
)
{
// lazily initialize super interfaces
// first, extract super interface subtree(s) from AST
TypeTree
[]
ts
=
getTree
().
getSuperInterfaces
();
// create array to store reified subtree(s)
Type
[]
si
s
=
new
Type
[
ts
.
length
];
superInterface
s
=
new
Type
[
ts
.
length
];
// reify all subtrees
for
(
int
i
=
0
;
i
<
ts
.
length
;
i
++)
{
Reifier
r
=
getReifier
();
// obtain visitor
ts
[
i
].
accept
(
r
);
// reify subtree
// extract result from visitor and store it
s
i
s
[
i
]
=
r
.
getResult
();
s
uperInterface
s
[
i
]
=
r
.
getResult
();
}
superInterfaces
=
sis
;
// cache overall result
this
.
superInterfaces
=
superInterfaces
;
}
return
superInterfaces
.
clone
();
// return cached result
...
...
src/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java
浏览文件 @
4040381c
...
...
@@ -42,7 +42,8 @@ import sun.reflect.generics.visitor.Reifier;
public
abstract
class
GenericDeclRepository
<
S
extends
Signature
>
extends
AbstractRepository
<
S
>
{
private
volatile
TypeVariable
<?>[]
typeParams
;
// caches the formal type parameters
/** The formal type parameters. Lazily initialized. */
private
volatile
TypeVariable
<?>[]
typeParams
;
protected
GenericDeclRepository
(
String
rawSig
,
GenericsFactory
f
)
{
super
(
rawSig
,
f
);
...
...
@@ -55,8 +56,7 @@ public abstract class GenericDeclRepository<S extends Signature>
* If the corresponding field is non-null, it is returned.
* If not, it is created lazily. This is done by selecting the appropriate
* part of the tree and transforming it into a reflective object
* using a visitor.
* a visitor, which is created by feeding it the factory
* using a visitor, which is created by feeding it the factory
* with which the repository was created.
*/
...
...
@@ -64,22 +64,21 @@ public abstract class GenericDeclRepository<S extends Signature>
* Return the formal type parameters of this generic declaration.
* @return the formal type parameters of this generic declaration
*/
public
TypeVariable
<?>[]
getTypeParameters
(){
TypeVariable
[]
typeParams
=
this
.
typeParams
;
public
TypeVariable
<?>[]
getTypeParameters
()
{
TypeVariable
<?>
[]
typeParams
=
this
.
typeParams
;
if
(
typeParams
==
null
)
{
// lazily initialize type parameters
// first, extract type parameter subtree(s) from AST
FormalTypeParameter
[]
ftps
=
getTree
().
getFormalTypeParameters
();
// create array to store reified subtree(s)
TypeVariable
<?>[]
tp
s
=
new
TypeVariable
<?>[
ftps
.
length
];
typeParam
s
=
new
TypeVariable
<?>[
ftps
.
length
];
// reify all subtrees
for
(
int
i
=
0
;
i
<
ftps
.
length
;
i
++)
{
Reifier
r
=
getReifier
();
// obtain visitor
ftps
[
i
].
accept
(
r
);
// reify subtree
// extract result from visitor and store it
t
p
s
[
i
]
=
(
TypeVariable
<?>)
r
.
getResult
();
t
ypeParam
s
[
i
]
=
(
TypeVariable
<?>)
r
.
getResult
();
}
typeParams
=
tps
;
// cache overall result
this
.
typeParams
=
typeParams
;
this
.
typeParams
=
typeParams
;
// cache overall result
}
return
typeParams
.
clone
();
// return cached result
}
...
...
src/share/classes/sun/reflect/generics/scope/AbstractScope.java
浏览文件 @
4040381c
...
...
@@ -42,7 +42,9 @@ public abstract class AbstractScope<D extends GenericDeclaration>
implements
Scope
{
private
final
D
recvr
;
// the declaration whose scope this instance represents
private
volatile
Scope
enclosingScope
;
// the enclosing scope of this scope
/** The enclosing scope of this scope. Lazily initialized. */
private
volatile
Scope
enclosingScope
;
/**
* Constructor. Takes a reflective object whose scope the newly
...
...
src/share/native/java/net/net_util.h
浏览文件 @
4040381c
...
...
@@ -182,9 +182,13 @@ NET_MapSocketOption(jint cmd, int *level, int *optname);
JNIEXPORT
int
JNICALL
NET_MapSocketOptionV6
(
jint
cmd
,
int
*
level
,
int
*
optname
);
JNIEXPORT
jint
JNICALL
NET_EnableFastTcpLoopback
(
int
fd
);
int
getScopeID
(
struct
sockaddr
*
);
int
cmpScopeID
(
unsigned
int
,
struct
sockaddr
*
);
unsigned
short
in_cksum
(
unsigned
short
*
addr
,
int
len
);
#endif
/* NET_UTILS_H */
src/solaris/classes/sun/awt/X11/XClipboard.java
浏览文件 @
4040381c
/*
* Copyright (c) 2003, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
4
, 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
...
...
@@ -281,6 +281,11 @@ public final class XClipboard extends SunClipboard implements OwnershipListener
}
}
checkChange
(
formats
);
XToolkit
.
awtUnlock
();
try
{
checkChange
(
formats
);
}
finally
{
XToolkit
.
awtLock
();
}
}
}
src/solaris/classes/sun/nio/ch/FileDispatcherImpl.java
浏览文件 @
4040381c
...
...
@@ -25,10 +25,10 @@
package
sun.nio.ch
;
import
java.io.*
;
import
java.io.FileDescriptor
;
import
java.io.IOException
;
class
FileDispatcherImpl
extends
FileDispatcher
{
class
FileDispatcherImpl
extends
FileDispatcher
{
static
{
IOUtil
.
load
();
...
...
@@ -108,6 +108,14 @@ class FileDispatcherImpl extends FileDispatcher
return
new
FileDescriptor
();
}
boolean
canTransferToDirectly
(
java
.
nio
.
channels
.
SelectableChannel
sc
)
{
return
true
;
}
boolean
transferToDirectlyNeedsPositionLock
()
{
return
false
;
}
// -- Native methods --
static
native
int
read0
(
FileDescriptor
fd
,
long
address
,
int
len
)
...
...
src/solaris/native/java/net/net_util_md.c
浏览文件 @
4040381c
...
...
@@ -777,6 +777,11 @@ void parseExclusiveBindProperty(JNIEnv *env) {
#endif
}
JNIEXPORT
jint
JNICALL
NET_EnableFastTcpLoopback
(
int
fd
)
{
return
0
;
}
/* In the case of an IPv4 Inetaddress this method will return an
* IPv4 mapped address where IPv6 is available and v4MappedAddress is TRUE.
* Otherwise it will return a sockaddr_in structure for an IPv4 InetAddress.
...
...
src/solaris/native/sun/awt/awt_Event.c
浏览文件 @
4040381c
...
...
@@ -42,7 +42,7 @@ struct EventIDs eventIDs;
JNIEXPORT
void
JNICALL
Java_java_awt_Event_initIDs
(
JNIEnv
*
env
,
jclass
cls
)
{
eventIDs
.
data
=
(
*
env
)
->
GetFieldID
(
env
,
cls
,
"data"
,
"J"
);
eventIDs
.
consumed
=
(
*
env
)
->
GetFieldID
(
env
,
cls
,
"consumed"
,
"Z"
);
eventIDs
.
id
=
(
*
env
)
->
GetFieldID
(
env
,
cls
,
"id"
,
"I"
);
CHECK_NULL
(
eventIDs
.
data
=
(
*
env
)
->
GetFieldID
(
env
,
cls
,
"data"
,
"J"
)
);
CHECK_NULL
(
eventIDs
.
consumed
=
(
*
env
)
->
GetFieldID
(
env
,
cls
,
"consumed"
,
"Z"
)
);
CHECK_NULL
(
eventIDs
.
id
=
(
*
env
)
->
GetFieldID
(
env
,
cls
,
"id"
,
"I"
)
);
}
src/solaris/native/sun/awt/awt_Font.c
浏览文件 @
4040381c
...
...
@@ -579,6 +579,7 @@ awtJNI_GetFontData(JNIEnv * env, jobject font, char **errmsg)
Disposer_AddRecord
(
env
,
font
,
pDataDisposeMethod
,
ptr_to_jlong
(
fdata
));
return
fdata
;
}
else
{
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
Display
*
display
=
NULL
;
struct
FontData
*
fdata
=
NULL
;
char
fontSpec
[
1024
];
...
...
src/solaris/native/sun/awt/awt_GraphicsEnv.c
浏览文件 @
4040381c
...
...
@@ -23,6 +23,7 @@
* questions.
*/
#include "jni_util.h"
#include "awt_p.h"
#include "awt.h"
#include "color.h"
...
...
@@ -763,6 +764,7 @@ awt_init_Display(JNIEnv *env, jobject this)
XSetIOErrorHandler
(
xioerror_handler
);
JNU_CallStaticMethodByName
(
env
,
NULL
,
"sun/awt/X11/XErrorHandlerUtil"
,
"init"
,
"(J)V"
,
ptr_to_jlong
(
awt_display
));
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
/* set awt_numScreens, and whether or not we're using Xinerama */
xineramaInit
();
...
...
@@ -789,6 +791,7 @@ awt_init_Display(JNIEnv *env, jobject this)
x11Screens
[
i
].
root
=
RootWindow
(
awt_display
,
i
);
}
x11Screens
[
i
].
defaultConfig
=
makeDefaultConfig
(
env
,
i
);
JNU_CHECK_EXCEPTION_RETURN
(
env
,
NULL
);
}
return
dpy
;
...
...
@@ -1495,7 +1498,7 @@ Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable
if
(
aData
==
NULL
)
{
return
JNI_FALSE
;
}
return
(
jboolean
)
aData
->
isTranslucencySupported
;
return
aData
->
isTranslucencySupported
?
JNI_TRUE
:
JNI_FALSE
;
#endif
}
...
...
@@ -1575,9 +1578,9 @@ Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama(JNIEnv *env,
jobject
this
)
{
#ifdef HEADLESS
return
false
;
return
JNI_FALSE
;
#else
return
usingXinerama
;
return
usingXinerama
?
JNI_TRUE
:
JNI_FALSE
;
#endif
/* HEADLESS */
}
...
...
src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
浏览文件 @
4040381c
...
...
@@ -72,6 +72,11 @@ static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gp
static
void
quit
(
JNIEnv
*
env
,
jobject
jpeer
,
gboolean
isSignalHandler
)
{
jthrowable
pendingException
;
if
(
pendingException
=
(
*
env
)
->
ExceptionOccurred
(
env
))
{
(
*
env
)
->
ExceptionClear
(
env
);
}
GtkWidget
*
dialog
=
(
GtkWidget
*
)
jlong_to_ptr
(
(
*
env
)
->
GetLongField
(
env
,
jpeer
,
widgetFieldID
));
...
...
@@ -95,6 +100,10 @@ static void quit(JNIEnv * env, jobject jpeer, gboolean isSignalHandler)
fp_gdk_threads_leave
();
}
}
if
(
pendingException
)
{
(
*
env
)
->
Throw
(
env
,
pendingException
);
}
}
/*
...
...
src/solaris/native/sun/nio/ch/FileChannelImpl.c
浏览文件 @
4040381c
...
...
@@ -154,10 +154,13 @@ Java_sun_nio_ch_FileChannelImpl_close0(JNIEnv *env, jobject this, jobject fdo)
JNIEXPORT
jlong
JNICALL
Java_sun_nio_ch_FileChannelImpl_transferTo0
(
JNIEnv
*
env
,
jobject
this
,
j
int
srcFD
,
j
object
srcFDO
,
jlong
position
,
jlong
count
,
j
int
dstFD
)
j
object
dstFDO
)
{
jint
srcFD
=
fdval
(
env
,
srcFDO
);
jint
dstFD
=
fdval
(
env
,
dstFDO
);
#if defined(__linux__)
off64_t
offset
=
(
off64_t
)
position
;
jlong
n
=
sendfile64
(
dstFD
,
srcFD
,
&
offset
,
(
size_t
)
count
);
...
...
src/solaris/native/sun/nio/ch/Net.c
浏览文件 @
4040381c
...
...
@@ -231,7 +231,7 @@ Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl)
JNIEXPORT
int
JNICALL
Java_sun_nio_ch_Net_socket0
(
JNIEnv
*
env
,
jclass
cl
,
jboolean
preferIPv6
,
jboolean
stream
,
jboolean
reuse
)
jboolean
stream
,
jboolean
reuse
,
jboolean
ignored
)
{
int
fd
;
int
type
=
(
stream
?
SOCK_STREAM
:
SOCK_DGRAM
);
...
...
src/solaris/native/sun/xawt/XToolkit.c
浏览文件 @
4040381c
...
...
@@ -77,7 +77,7 @@ struct MenuComponentIDs menuComponentIDs;
#ifndef HEADLESS
extern
Display
*
awt_init_Display
(
JNIEnv
*
env
,
jobject
this
);
extern
void
freeNativeStringArray
(
char
**
array
,
long
length
);
extern
void
freeNativeStringArray
(
char
**
array
,
jsize
length
);
extern
char
**
stringArrayToNative
(
JNIEnv
*
env
,
jobjectArray
array
,
jsize
*
ret_length
);
struct
XFontPeerIDs
xFontPeerIDs
;
...
...
src/windows/classes/sun/nio/ch/FileDispatcherImpl.java
浏览文件 @
4040381c
...
...
@@ -25,15 +25,16 @@
package
sun.nio.ch
;
import
java.io.*
;
import
java.io.FileDescriptor
;
import
java.io.IOException
;
import
java.security.PrivilegedAction
;
import
sun.misc.SharedSecrets
;
import
sun.misc.JavaIOFileDescriptorAccess
;
class
FileDispatcherImpl
extends
FileDispatcher
{
static
{
IOUtil
.
load
();
}
class
FileDispatcherImpl
extends
FileDispatcher
{
// set to true if fast file transmission (TransmitFile) is enabled
private
static
final
boolean
fastFileTransfer
;
/**
* Indicates if the dispatcher should first advance the file position
...
...
@@ -120,6 +121,36 @@ class FileDispatcherImpl extends FileDispatcher
return
result
;
}
boolean
canTransferToDirectly
(
java
.
nio
.
channels
.
SelectableChannel
sc
)
{
return
fastFileTransfer
&&
sc
.
isBlocking
();
}
boolean
transferToDirectlyNeedsPositionLock
()
{
return
true
;
}
static
boolean
isFastFileTransferRequested
()
{
String
fileTransferProp
=
java
.
security
.
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
String
>()
{
@Override
public
String
run
()
{
return
System
.
getProperty
(
"jdk.net.enableFastFileTransfer"
);
}
});
boolean
enable
;
if
(
""
.
equals
(
fileTransferProp
))
{
enable
=
true
;
}
else
{
enable
=
Boolean
.
parseBoolean
(
fileTransferProp
);
}
return
enable
;
}
static
{
IOUtil
.
load
();
fastFileTransfer
=
isFastFileTransferRequested
();
}
//-- Native methods
static
native
int
read0
(
FileDescriptor
fd
,
long
address
,
int
len
)
...
...
src/windows/native/java/net/net_util_md.c
浏览文件 @
4040381c
...
...
@@ -29,6 +29,9 @@
#include "net_util.h"
#include "jni.h"
// Taken from mstcpip.h in Windows SDK 8.0 or newer.
#define SIO_LOOPBACK_FAST_PATH _WSAIOW(IOC_VENDOR,16)
#ifndef IPTOS_TOS_MASK
#define IPTOS_TOS_MASK 0x1e
#endif
...
...
@@ -844,6 +847,25 @@ jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr)
}
}
/**
* Enables SIO_LOOPBACK_FAST_PATH
*/
JNIEXPORT
jint
JNICALL
NET_EnableFastTcpLoopback
(
int
fd
)
{
int
enabled
=
1
;
DWORD
result_byte_count
=
-
1
;
int
result
=
WSAIoctl
(
fd
,
SIO_LOOPBACK_FAST_PATH
,
&
enabled
,
sizeof
(
enabled
),
NULL
,
0
,
&
result_byte_count
,
NULL
,
NULL
);
return
result
==
SOCKET_ERROR
?
WSAGetLastError
()
:
0
;
}
/* If address types is IPv6, then IPv6 must be available. Otherwise
* no address can be generated. In the case of an IPv4 Inetaddress this
* method will return an IPv4 mapped address where IPv6 is available and
...
...
src/windows/native/sun/nio/ch/FileChannelImpl.c
浏览文件 @
4040381c
...
...
@@ -31,6 +31,10 @@
#include "nio.h"
#include "nio_util.h"
#include "sun_nio_ch_FileChannelImpl.h"
#include "java_lang_Integer.h"
#include <Mswsock.h>
#pragma comment(lib, "Mswsock.lib")
static
jfieldID
chan_fd
;
/* id for jobject 'fd' in java.io.FileChannel */
...
...
@@ -174,9 +178,42 @@ Java_sun_nio_ch_FileChannelImpl_close0(JNIEnv *env, jobject this, jobject fdo)
JNIEXPORT
jlong
JNICALL
Java_sun_nio_ch_FileChannelImpl_transferTo0
(
JNIEnv
*
env
,
jobject
this
,
j
in
t
srcFD
,
j
objec
t
srcFD
,
jlong
position
,
jlong
count
,
j
in
t
dstFD
)
j
objec
t
dstFD
)
{
return
IOS_UNSUPPORTED
;
const
int
PACKET_SIZE
=
524288
;
HANDLE
src
=
(
HANDLE
)(
handleval
(
env
,
srcFD
));
SOCKET
dst
=
(
SOCKET
)(
fdval
(
env
,
dstFD
));
DWORD
chunkSize
=
(
count
>
java_lang_Integer_MAX_VALUE
)
?
java_lang_Integer_MAX_VALUE
:
(
DWORD
)
count
;
BOOL
result
=
0
;
jlong
pos
=
Java_sun_nio_ch_FileChannelImpl_position0
(
env
,
this
,
srcFD
,
position
);
if
(
pos
==
IOS_THROWN
)
{
return
IOS_THROWN
;
}
result
=
TransmitFile
(
dst
,
src
,
chunkSize
,
PACKET_SIZE
,
NULL
,
NULL
,
TF_USE_KERNEL_APC
);
if
(
!
result
)
{
int
error
=
WSAGetLastError
();
if
(
WSAEINVAL
==
error
&&
count
>=
0
)
{
return
IOS_UNSUPPORTED_CASE
;
}
if
(
WSAENOTSOCK
==
error
)
{
return
IOS_UNSUPPORTED_CASE
;
}
JNU_ThrowIOExceptionWithLastError
(
env
,
"transfer failed"
);
return
IOS_THROWN
;
}
return
chunkSize
;
}
src/windows/native/sun/nio/ch/Net.c
浏览文件 @
4040381c
...
...
@@ -127,7 +127,7 @@ Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl)
JNIEXPORT
jint
JNICALL
Java_sun_nio_ch_Net_socket0
(
JNIEnv
*
env
,
jclass
cl
,
jboolean
preferIPv6
,
jboolean
stream
,
jboolean
reuse
)
jboolean
stream
,
jboolean
reuse
,
jboolean
fastLoopback
)
{
SOCKET
s
;
int
domain
=
(
preferIPv6
)
?
AF_INET6
:
AF_INET
;
...
...
@@ -152,6 +152,20 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
NET_ThrowNew
(
env
,
WSAGetLastError
(),
"socket"
);
}
if
(
stream
&&
fastLoopback
)
{
static
int
loopback_available
=
1
;
if
(
loopback_available
)
{
int
rv
=
NET_EnableFastTcpLoopback
((
jint
)
s
);
if
(
rv
)
{
if
(
rv
==
WSAEOPNOTSUPP
)
{
loopback_available
=
0
;
}
else
{
NET_ThrowNew
(
env
,
rv
,
"fastLoopback"
);
}
}
}
}
return
(
jint
)
s
;
}
...
...
test/ProblemList.txt
浏览文件 @
4040381c
...
...
@@ -272,7 +272,4 @@ tools/launcher/FXLauncherTest.java linux-all
# Filed 6772009
java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
# 8051641
sun/util/calendar/zi/TestZoneInfo310.java generic-all
############################################################################
test/com/sun/corba/5036554/TestCorbaBug.sh
浏览文件 @
4040381c
...
...
@@ -75,13 +75,13 @@ ${TESTJAVA}${FS}bin${FS}java -version
mkdir
bug
cp
${
TESTSRC
}${
FS
}
bug.idl
.
${
TEST
JAVA
}${
FS
}
bin
${
FS
}
idlj bug.idl
${
COMPILE
JAVA
}${
FS
}
bin
${
FS
}
idlj bug.idl
cp
${
TESTSRC
}${
FS
}
JavaBug.java bug
chmod
-fR
777 bug
${
TEST
JAVA
}${
FS
}
bin
${
FS
}
javac
-d
.
bug
${
FS
}*
.java
${
COMPILE
JAVA
}${
FS
}
bin
${
FS
}
javac
-d
.
bug
${
FS
}*
.java
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java
-cp
.
bug/JavaBug
>
test.out 2>&1
...
...
test/com/sun/corba/cachedSocket/7056731.sh
浏览文件 @
4040381c
...
...
@@ -55,8 +55,8 @@ PORT=1052
cp
-r
${
TESTSRC
}${
FS
}*
.java
${
TESTSRC
}${
FS
}
Hello.idl
.
echo
"Testing...please wait"
${
TEST
JAVA
}${
FS
}
bin
${
FS
}
idlj
-fall
Hello.idl
${
TEST
JAVA
}${
FS
}
bin
${
FS
}
javac
*
.java HelloApp/
*
.java
${
COMPILE
JAVA
}${
FS
}
bin
${
FS
}
idlj
-fall
Hello.idl
${
COMPILE
JAVA
}${
FS
}
bin
${
FS
}
javac
*
.java HelloApp/
*
.java
echo
"starting orbd"
${
TESTJAVA
}${
FS
}
bin
${
FS
}
orbd
-ORBInitialPort
$PORT
-ORBInitialHost
localhost &
...
...
test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
0 → 100644
浏览文件 @
4040381c
/*
* Copyright (c) 2014, 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.File
;
import
java.io.FilePermission
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.ReflectPermission
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.security.CodeSource
;
import
java.security.Permission
;
import
java.security.PermissionCollection
;
import
java.security.Permissions
;
import
java.security.Policy
;
import
java.security.ProtectionDomain
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.PropertyPermission
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarFile
;
import
java.util.stream.Stream
;
/**
* @test
* @bug 8065552
* @summary test that all fields returned by getDeclaredFields() can be
* set accessible if the right permission is granted; this test
* loads all the classes in the BCL, get their declared fields,
* and call setAccessible(false) followed by setAccessible(true);
* @run main/othervm FieldSetAccessibleTest UNSECURE
* @run main/othervm FieldSetAccessibleTest SECURE
*
* @author danielfuchs
*/
public
class
FieldSetAccessibleTest
{
static
final
List
<
String
>
skipped
=
new
ArrayList
<>();
static
final
List
<
String
>
cantread
=
new
ArrayList
<>();
static
final
List
<
String
>
failed
=
new
ArrayList
<>();
static
final
AtomicLong
classCount
=
new
AtomicLong
();
static
final
AtomicLong
fieldCount
=
new
AtomicLong
();
static
long
startIndex
=
0
;
static
long
maxSize
=
Long
.
MAX_VALUE
;
static
long
maxIndex
=
Long
.
MAX_VALUE
;
// Test that all fields for any given class can be made accessibles
static
void
testSetFieldsAccessible
(
Class
<?>
c
)
{
for
(
Field
f
:
c
.
getDeclaredFields
())
{
fieldCount
.
incrementAndGet
();
f
.
setAccessible
(
false
);
f
.
setAccessible
(
true
);
}
}
// Performs a series of test on the given class.
// At this time, we only call testSetFieldsAccessible(c)
public
static
boolean
test
(
Class
<?>
c
)
{
//System.out.println(c.getName());
classCount
.
incrementAndGet
();
// Call getDeclaredFields() and try to set their accessible flag.
testSetFieldsAccessible
(
c
);
// add more tests here...
return
c
==
Class
.
class
;
}
// Prints a summary at the end of the test.
static
void
printSummary
(
long
secs
,
long
millis
,
long
nanos
)
{
System
.
out
.
println
(
"Tested "
+
fieldCount
.
get
()
+
" fields of "
+
classCount
.
get
()
+
" classes in "
+
secs
+
"s "
+
millis
+
"ms "
+
nanos
+
"ns"
);
}
/**
* @param args the command line arguments:
*
* SECURE|UNSECURE [startIndex (default=0)] [maxSize (default=Long.MAX_VALUE)]
*
* @throws java.lang.Exception if the test fails
*/
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
==
null
||
args
.
length
==
0
)
{
args
=
new
String
[]
{
"SECURE"
,
"0"
};
}
else
if
(
args
.
length
>
3
)
{
throw
new
RuntimeException
(
"Expected at most one argument. Found "
+
Arrays
.
asList
(
args
));
}
try
{
if
(
args
.
length
>
1
)
{
startIndex
=
Long
.
parseLong
(
args
[
1
]);
if
(
startIndex
<
0
)
{
throw
new
IllegalArgumentException
(
"startIndex args[1]: "
+
startIndex
);
}
}
if
(
args
.
length
>
2
)
{
maxSize
=
Long
.
parseLong
(
args
[
2
]);
if
(
maxSize
<=
0
)
{
maxSize
=
Long
.
MAX_VALUE
;
}
maxIndex
=
(
Long
.
MAX_VALUE
-
startIndex
)
<
maxSize
?
Long
.
MAX_VALUE
:
startIndex
+
maxSize
;
}
TestCase
.
valueOf
(
args
[
0
]).
run
();
}
catch
(
OutOfMemoryError
oome
)
{
System
.
err
.
println
(
classCount
.
get
());
throw
oome
;
}
}
public
static
void
run
(
TestCase
test
)
{
System
.
out
.
println
(
"Testing "
+
test
);
test
(
listAllClassNames
());
System
.
out
.
println
(
"Passed "
+
test
);
}
static
Iterable
<
String
>
listAllClassNames
()
{
return
new
ClassNameStreamBuilder
();
}
static
void
test
(
Iterable
<
String
>
iterable
)
{
final
long
start
=
System
.
nanoTime
();
boolean
classFound
=
false
;
int
index
=
0
;
for
(
String
s:
iterable
)
{
if
(
index
==
maxIndex
)
break
;
try
{
if
(
index
<
startIndex
)
continue
;
if
(
test
(
s
))
{
classFound
=
true
;
}
}
finally
{
index
++;
}
}
long
elapsed
=
System
.
nanoTime
()
-
start
;
long
secs
=
elapsed
/
1000_000_000
;
long
millis
=
(
elapsed
%
1000_000_000
)
/
1000_000
;
long
nanos
=
elapsed
%
1000_000
;
System
.
out
.
println
(
"Unreadable path elements: "
+
cantread
);
System
.
out
.
println
(
"Skipped path elements: "
+
skipped
);
System
.
out
.
println
(
"Failed path elements: "
+
failed
);
printSummary
(
secs
,
millis
,
nanos
);
if
(!
failed
.
isEmpty
())
{
throw
new
RuntimeException
(
"Test failed for the following classes: "
+
failed
);
}
if
(!
classFound
&&
startIndex
==
0
&&
index
<
maxIndex
)
{
// this is just to verify that we have indeed parsed rt.jar
// (or the java.base module)
throw
new
RuntimeException
(
"Test failed: Class.class not found..."
);
}
if
(
classCount
.
get
()
==
0
&&
startIndex
==
0
)
{
throw
new
RuntimeException
(
"Test failed: no class found?"
);
}
}
static
boolean
test
(
String
s
)
{
try
{
if
(
s
.
startsWith
(
"WrapperGenerator"
))
{
System
.
out
.
println
(
"Skipping "
+
s
);
return
false
;
}
final
Class
<?>
c
=
Class
.
forName
(
s
.
replace
(
'/'
,
'.'
).
substring
(
0
,
s
.
length
()
-
6
),
false
,
null
);
return
test
(
c
);
}
catch
(
Exception
t
)
{
t
.
printStackTrace
(
System
.
err
);
failed
.
add
(
s
);
}
catch
(
NoClassDefFoundError
e
)
{
e
.
printStackTrace
(
System
.
err
);
failed
.
add
(
s
);
}
return
false
;
}
static
class
ClassNameStreamBuilder
implements
Iterable
<
String
>{
String
[]
bcp
;
ClassNameStreamBuilder
()
{
bcp
=
System
.
getProperty
(
"sun.boot.class.path"
).
split
(
File
.
pathSeparator
);
}
Stream
<
String
>
bcpElementToStream
(
String
s
)
{
return
s
.
endsWith
(
".jar"
)
?
jarToStream
(
s
)
:
folderToStream
(
s
);
}
Stream
<
String
>
jarToStream
(
String
jarName
)
{
File
f
=
new
File
(
jarName
);
if
(
f
.
canRead
()
&&
f
.
isFile
())
{
try
{
JarFile
jarFile
=
new
JarFile
(
f
);
return
jarFile
.
stream
()
.
filter
(
e
->
!
e
.
isDirectory
())
.
map
(
JarEntry:
:
getName
)
.
filter
(
s
->
s
.
endsWith
(
".class"
));
}
catch
(
IOException
x
)
{
x
.
printStackTrace
(
System
.
err
);
skipped
.
add
(
jarName
);
}
}
else
{
cantread
.
add
(
jarName
);
}
return
Collections
.<
String
>
emptyList
().
stream
();
}
Stream
<
String
>
folderToStream
(
String
folderName
)
{
final
File
root
=
new
File
(
folderName
);
if
(
root
.
canRead
()
&&
root
.
isDirectory
())
{
final
Path
rootPath
=
root
.
toPath
();
try
{
return
Files
.
walk
(
rootPath
)
.
filter
(
p
->
p
.
getFileName
().
toString
().
endsWith
(
".class"
))
.
map
(
rootPath:
:
relativize
)
.
map
(
p
->
p
.
toString
().
replace
(
File
.
separatorChar
,
'/'
));
}
catch
(
IOException
x
)
{
x
.
printStackTrace
(
System
.
err
);
skipped
.
add
(
folderName
);
}
}
else
{
cantread
.
add
(
folderName
);
}
return
Collections
.<
String
>
emptyList
().
stream
();
}
public
Stream
<
String
>
build
()
{
return
Stream
.
of
(
bcp
).
flatMap
(
this
::
bcpElementToStream
);
}
@Override
public
Iterator
<
String
>
iterator
()
{
return
build
().
iterator
();
}
}
// Test with or without a security manager
public
static
enum
TestCase
{
UNSECURE
,
SECURE
;
public
void
run
()
throws
Exception
{
System
.
out
.
println
(
"Running test case: "
+
name
());
Configure
.
setUp
(
this
);
FieldSetAccessibleTest
.
run
(
this
);
}
}
// A helper class to configure the security manager for the test,
// and bypass it when needed.
static
class
Configure
{
static
Policy
policy
=
null
;
static
final
ThreadLocal
<
AtomicBoolean
>
allowAll
=
new
ThreadLocal
<
AtomicBoolean
>()
{
@Override
protected
AtomicBoolean
initialValue
()
{
return
new
AtomicBoolean
(
false
);
}
};
static
void
setUp
(
TestCase
test
)
{
switch
(
test
)
{
case
SECURE:
if
(
policy
==
null
&&
System
.
getSecurityManager
()
!=
null
)
{
throw
new
IllegalStateException
(
"SecurityManager already set"
);
}
else
if
(
policy
==
null
)
{
policy
=
new
SimplePolicy
(
TestCase
.
SECURE
,
allowAll
);
Policy
.
setPolicy
(
policy
);
System
.
setSecurityManager
(
new
SecurityManager
());
}
if
(
System
.
getSecurityManager
()
==
null
)
{
throw
new
IllegalStateException
(
"No SecurityManager."
);
}
if
(
policy
==
null
)
{
throw
new
IllegalStateException
(
"policy not configured"
);
}
break
;
case
UNSECURE:
if
(
System
.
getSecurityManager
()
!=
null
)
{
throw
new
IllegalStateException
(
"SecurityManager already set"
);
}
break
;
default
:
throw
new
InternalError
(
"No such testcase: "
+
test
);
}
}
static
void
doPrivileged
(
Runnable
run
)
{
allowAll
.
get
().
set
(
true
);
try
{
run
.
run
();
}
finally
{
allowAll
.
get
().
set
(
false
);
}
}
}
// A Helper class to build a set of permissions.
final
static
class
PermissionsBuilder
{
final
Permissions
perms
;
public
PermissionsBuilder
()
{
this
(
new
Permissions
());
}
public
PermissionsBuilder
(
Permissions
perms
)
{
this
.
perms
=
perms
;
}
public
PermissionsBuilder
add
(
Permission
p
)
{
perms
.
add
(
p
);
return
this
;
}
public
PermissionsBuilder
addAll
(
PermissionCollection
col
)
{
if
(
col
!=
null
)
{
for
(
Enumeration
<
Permission
>
e
=
col
.
elements
();
e
.
hasMoreElements
();
)
{
perms
.
add
(
e
.
nextElement
());
}
}
return
this
;
}
public
Permissions
toPermissions
()
{
final
PermissionsBuilder
builder
=
new
PermissionsBuilder
();
builder
.
addAll
(
perms
);
return
builder
.
perms
;
}
}
// Policy for the test...
public
static
class
SimplePolicy
extends
Policy
{
final
Permissions
permissions
;
final
Permissions
allPermissions
;
final
ThreadLocal
<
AtomicBoolean
>
allowAll
;
public
SimplePolicy
(
TestCase
test
,
ThreadLocal
<
AtomicBoolean
>
allowAll
)
{
this
.
allowAll
=
allowAll
;
// Permission needed by the tested code exercised in the test
permissions
=
new
Permissions
();
permissions
.
add
(
new
RuntimePermission
(
"fileSystemProvider"
));
permissions
.
add
(
new
RuntimePermission
(
"createClassLoader"
));
permissions
.
add
(
new
RuntimePermission
(
"closeClassLoader"
));
permissions
.
add
(
new
RuntimePermission
(
"getClassLoader"
));
permissions
.
add
(
new
RuntimePermission
(
"accessDeclaredMembers"
));
permissions
.
add
(
new
ReflectPermission
(
"suppressAccessChecks"
));
permissions
.
add
(
new
PropertyPermission
(
"*"
,
"read"
));
permissions
.
add
(
new
FilePermission
(
"<<ALL FILES>>"
,
"read"
));
// these are used for configuring the test itself...
allPermissions
=
new
Permissions
();
allPermissions
.
add
(
new
java
.
security
.
AllPermission
());
}
@Override
public
boolean
implies
(
ProtectionDomain
domain
,
Permission
permission
)
{
if
(
allowAll
.
get
().
get
())
return
allPermissions
.
implies
(
permission
);
if
(
permissions
.
implies
(
permission
))
return
true
;
if
(
permission
instanceof
java
.
lang
.
RuntimePermission
)
{
if
(
permission
.
getName
().
startsWith
(
"accessClassInPackage."
))
{
// add these along to the set of permission we have, when we
// discover that we need them.
permissions
.
add
(
permission
);
return
true
;
}
}
return
false
;
}
@Override
public
PermissionCollection
getPermissions
(
CodeSource
codesource
)
{
return
new
PermissionsBuilder
().
addAll
(
allowAll
.
get
().
get
()
?
allPermissions
:
permissions
).
toPermissions
();
}
@Override
public
PermissionCollection
getPermissions
(
ProtectionDomain
domain
)
{
return
new
PermissionsBuilder
().
addAll
(
allowAll
.
get
().
get
()
?
allPermissions
:
permissions
).
toPermissions
();
}
}
}
test/java/lang/Thread/ThreadStateController.java
浏览文件 @
4040381c
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2014
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
...
...
@@ -27,6 +27,8 @@ import java.util.concurrent.TimeoutException;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.locks.LockSupport
;
import
jdk.testlibrary.LockFreeLogManager
;
/**
* ThreadStateController allows a thread to request this thread to transition
* to a specific thread state. The {@linkplain #transitionTo request} is
...
...
@@ -94,8 +96,12 @@ public class ThreadStateController extends Thread {
private
static
final
int
S_TERMINATE
=
8
;
// for debugging
private
AtomicInteger
iterations
=
new
AtomicInteger
();
private
AtomicInteger
interrupted
=
new
AtomicInteger
();
private
final
AtomicInteger
iterations
=
new
AtomicInteger
();
private
final
AtomicInteger
interrupted
=
new
AtomicInteger
();
private
final
LockFreeLogManager
logManager
=
new
LockFreeLogManager
();
@Override
public
void
run
()
{
// this thread has started
while
(!
done
)
{
...
...
@@ -119,13 +125,13 @@ public class ThreadStateController extends Thread {
break
;
}
case
S_BLOCKED:
{
System
.
out
.
format
(
"%d: %s is going to block (in
terations %d)%n"
,
getId
(),
getName
(),
iterations
.
get
());
log
(
"%d: %s is going to block (i
terations %d)%n"
,
getId
(),
getName
(),
iterations
.
get
());
stateChange
(
nextState
);
// going to block on lock
synchronized
(
lock
)
{
System
.
out
.
format
(
"%d: %s acquired the lock (in
terations %d)%n"
,
getId
(),
getName
(),
iterations
.
get
());
log
(
"%d: %s acquired the lock (i
terations %d)%n"
,
getId
(),
getName
(),
iterations
.
get
());
try
{
// this thread has escaped the BLOCKED state
// release the lock and a short wait before continue
...
...
@@ -139,13 +145,13 @@ public class ThreadStateController extends Thread {
}
case
S_WAITING:
{
synchronized
(
lock
)
{
System
.
out
.
format
(
"%d: %s is going to waiting (in
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
log
(
"%d: %s is going to waiting (i
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
try
{
stateChange
(
nextState
);
lock
.
wait
();
System
.
out
.
format
(
"%d: %s wakes up from waiting (in
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
log
(
"%d: %s wakes up from waiting (i
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
}
catch
(
InterruptedException
e
)
{
// ignore
interrupted
.
incrementAndGet
();
...
...
@@ -155,13 +161,13 @@ public class ThreadStateController extends Thread {
}
case
S_TIMED_WAITING:
{
synchronized
(
lock
)
{
System
.
out
.
format
(
"%d: %s is going to timed waiting (in
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
log
(
"%d: %s is going to timed waiting (i
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
try
{
stateChange
(
nextState
);
lock
.
wait
(
10000
);
System
.
out
.
format
(
"%d: %s wakes up from timed waiting (in
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
log
(
"%d: %s wakes up from timed waiting (i
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
}
catch
(
InterruptedException
e
)
{
// ignore
interrupted
.
incrementAndGet
();
...
...
@@ -170,23 +176,23 @@ public class ThreadStateController extends Thread {
break
;
}
case
S_PARKED:
{
System
.
out
.
format
(
"%d: %s is going to park (in
terations %d)%n"
,
getId
(),
getName
(),
iterations
.
get
());
log
(
"%d: %s is going to park (i
terations %d)%n"
,
getId
(),
getName
(),
iterations
.
get
());
stateChange
(
nextState
);
LockSupport
.
park
();
break
;
}
case
S_TIMED_PARKED:
{
System
.
out
.
format
(
"%d: %s is going to timed park (in
terations %d)%n"
,
getId
(),
getName
(),
iterations
.
get
());
log
(
"%d: %s is going to timed park (i
terations %d)%n"
,
getId
(),
getName
(),
iterations
.
get
());
long
deadline
=
System
.
currentTimeMillis
()
+
10000
*
1000
;
stateChange
(
nextState
);
LockSupport
.
parkUntil
(
deadline
);
break
;
}
case
S_SLEEPING:
{
System
.
out
.
format
(
"%d: %s is going to sleep (in
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
log
(
"%d: %s is going to sleep (i
terations %d interrupted %d)%n"
,
getId
(),
getName
(),
iterations
.
get
(),
interrupted
.
get
());
try
{
stateChange
(
nextState
);
Thread
.
sleep
(
1000000
);
...
...
@@ -219,8 +225,8 @@ public class ThreadStateController extends Thread {
if
(
newState
==
nextState
)
{
state
=
nextState
;
phaser
.
arrive
();
System
.
out
.
format
(
"%d: state change: %s %s%n"
,
getId
(),
toStateName
(
nextState
),
phaserToString
(
phaser
));
log
(
"%d: state change: %s %s%n"
,
getId
(),
toStateName
(
nextState
),
phaserToString
(
phaser
));
return
;
}
...
...
@@ -270,12 +276,12 @@ public class ThreadStateController extends Thread {
private
void
nextState
(
int
s
)
throws
InterruptedException
{
final
long
id
=
Thread
.
currentThread
().
getId
();
System
.
out
.
format
(
"%d: wait until the thread transitions to %s %s%n"
,
id
,
toStateName
(
s
),
phaserToString
(
phaser
));
log
(
"%d: wait until the thread transitions to %s %s%n"
,
id
,
toStateName
(
s
),
phaserToString
(
phaser
));
this
.
newState
=
s
;
int
phase
=
phaser
.
arrive
();
System
.
out
.
format
(
"%d: awaiting party arrive %s %s%n"
,
id
,
toStateName
(
s
),
phaserToString
(
phaser
));
log
(
"%d: awaiting party arrive %s %s%n"
,
id
,
toStateName
(
s
),
phaserToString
(
phaser
));
for
(;;)
{
// when this thread has changed its state before it waits or parks
// on a lock, a potential race might happen if it misses the notify
...
...
@@ -301,20 +307,22 @@ public class ThreadStateController extends Thread {
}
try
{
phaser
.
awaitAdvanceInterruptibly
(
phase
,
100
,
TimeUnit
.
MILLISECONDS
);
System
.
out
.
format
(
"%d: arrived at %s %s%n"
,
id
,
toStateName
(
s
),
phaserToString
(
phaser
));
log
(
"%d: arrived at %s %s%n"
,
id
,
toStateName
(
s
),
phaserToString
(
phaser
));
return
;
}
catch
(
TimeoutException
ex
)
{
// this thread hasn't arrived at this phase
System
.
out
.
format
(
"%d: Timeout: %s%n"
,
id
,
phaser
);
log
(
"%d: Timeout: %s%n"
,
id
,
phaser
);
}
}
}
private
String
phaserToString
(
Phaser
p
)
{
return
"[phase = "
+
p
.
getPhase
()
+
" parties = "
+
p
.
getRegisteredParties
()
+
" arrived = "
+
p
.
getArrivedParties
()
+
"]"
;
}
private
String
toStateName
(
int
state
)
{
switch
(
state
)
{
case
S_RUNNABLE:
...
...
@@ -337,4 +345,20 @@ public class ThreadStateController extends Thread {
return
"unknown "
+
state
;
}
}
private
void
log
(
String
msg
,
Object
...
params
)
{
logManager
.
log
(
msg
,
params
);
}
/**
* Waits for the controller to complete the test run and returns the
* generated log
* @return The controller log
* @throws InterruptedException
*/
public
String
getLog
()
throws
InterruptedException
{
this
.
join
();
return
logManager
.
toString
();
}
}
test/java/lang/management/MemoryMXBean/LowMemoryTest.java
浏览文件 @
4040381c
/*
* Copyright (c) 2003, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
4
, 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
...
...
@@ -35,11 +35,13 @@
* @run main/timeout=600 LowMemoryTest
*/
import
com.sun.management.DiagnosticCommandMBean
;
import
java.lang.management.*
;
import
java.util.*
;
import
java.util.concurrent.Phaser
;
import
javax.management.*
;
import
javax.management.openmbean.CompositeData
;
import
sun.management.ManagementFactoryHelper
;
public
class
LowMemoryTest
{
private
static
final
MemoryMXBean
mm
=
ManagementFactory
.
getMemoryMXBean
();
...
...
@@ -85,9 +87,15 @@ public class LowMemoryTest {
}
static
class
TestListener
implements
NotificationListener
{
private
boolean
isRelaxed
=
false
;
private
int
triggers
=
0
;
private
final
long
[]
count
=
new
long
[
NUM_TRIGGERS
*
2
];
private
final
long
[]
usedMemory
=
new
long
[
NUM_TRIGGERS
*
2
];
public
TestListener
()
{
isRelaxed
=
ManagementFactory
.
getRuntimeMXBean
().
getInputArguments
().
contains
(
"-XX:+UseConcMarkSweepGC"
);
}
@Override
public
void
handleNotification
(
Notification
notif
,
Object
handback
)
{
MemoryNotificationInfo
minfo
=
MemoryNotificationInfo
.
...
...
@@ -97,7 +105,8 @@ public class LowMemoryTest {
triggers
++;
}
public
void
checkResult
()
throws
Exception
{
if
(
triggers
!=
NUM_TRIGGERS
)
{
if
((!
isRelaxed
&&
triggers
!=
NUM_TRIGGERS
)
||
(
isRelaxed
&&
triggers
<
NUM_TRIGGERS
))
{
throw
new
RuntimeException
(
"Unexpected number of triggers = "
+
triggers
+
" but expected to be "
+
NUM_TRIGGERS
);
}
...
...
test/java/lang/management/ThreadMXBean/Locks.java
浏览文件 @
4040381c
...
...
@@ -29,17 +29,21 @@
* @author Mandy Chung
* @author Jaroslav Bachorik
*
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @run main/othervm Locks
*/
import
java.lang.management.*
;
import
java.util.concurrent.Phaser
;
import
jdk.testlibrary.LockFreeLogManager
;
public
class
Locks
{
private
static
final
Object
objA
=
new
Object
();
private
static
final
Object
objB
=
new
Object
();
private
static
final
Object
objC
=
new
Object
();
private
static
final
ThreadMXBean
tm
=
ManagementFactory
.
getThreadMXBean
();
private
static
final
LockFreeLogManager
logger
=
new
LockFreeLogManager
();
private
static
boolean
testFailed
=
false
;
...
...
@@ -126,14 +130,14 @@ public class Locks {
public
void
run
()
{
synchronized
(
objA
)
{
// stop here for LockBThread to hold objB
System
.
out
.
println
(
"LockAThread about to block on objB"
);
log
(
"LockAThread about to block on objB"
);
p
.
arriveAndAwaitAdvance
();
// Phase 1 (blocking)
synchronized
(
objB
)
{
dummyCounter
++;
};
}
p
.
arriveAndAwaitAdvance
();
// Phase 2 (blocking)
System
.
out
.
println
(
"LockAThread about to exit"
);
log
(
"LockAThread about to exit"
);
// Make sure the current thread is not holding any lock
assertNoLock
(
this
);
}
...
...
@@ -147,7 +151,7 @@ public class Locks {
}
public
void
run
()
{
synchronized
(
objB
)
{
System
.
out
.
println
(
"LockBThread about to block on objC"
);
log
(
"LockBThread about to block on objC"
);
p
.
arriveAndAwaitAdvance
();
// Phase 1 (blocking)
// Signal main thread about to block on objC
synchronized
(
objC
)
{
...
...
@@ -155,14 +159,14 @@ public class Locks {
};
}
p
.
arriveAndAwaitAdvance
();
// Phase 2 (blocking)
System
.
out
.
println
(
"LockBThread about to exit"
);
log
(
"LockBThread about to exit"
);
// Make sure the current thread is not holding any lock
assertNoLock
(
this
);
}
}
private
static
WaitingThread
waiter
;
private
static
Object
ready
=
new
Object
();
private
static
final
Object
ready
=
new
Object
();
private
static
CheckerThread
checker
;
static
class
WaitingThread
extends
Thread
{
private
final
Phaser
p
;
...
...
@@ -170,9 +174,10 @@ public class Locks {
super
(
"WaitingThread"
);
this
.
p
=
p
;
}
@Override
public
void
run
()
{
synchronized
(
objC
)
{
System
.
out
.
println
(
"WaitingThread about to wait on objC"
);
log
(
"WaitingThread about to wait on objC"
);
try
{
// Signal checker thread, about to wait on objC.
p
.
arriveAndAwaitAdvance
();
// Phase 1 (waiting)
...
...
@@ -183,13 +188,13 @@ public class Locks {
}
// block until CheckerThread finishes checking
System
.
out
.
println
(
"WaitingThread about to block on ready"
);
log
(
"WaitingThread about to block on ready"
);
// signal checker thread that it is about acquire
// object ready.
p
.
arriveAndAwaitAdvance
();
// Phase 2 (waiting)
synchronized
(
ready
)
{
dummyCounter
++;
}
;
}
}
synchronized
(
objC
)
{
try
{
...
...
@@ -201,7 +206,7 @@ public class Locks {
testFailed
=
true
;
}
}
System
.
out
.
println
(
"WaitingThread about to exit waiting on objC 2"
);
log
(
"WaitingThread about to exit waiting on objC 2"
);
}
}
static
class
CheckerThread
extends
Thread
{
...
...
@@ -304,10 +309,10 @@ public class Locks {
private
static
ThreadInfo
findOwnerInfo
(
ThreadInfo
[]
infos
,
String
lock
)
throws
Exception
{
ThreadInfo
ownerInfo
=
null
;
for
(
int
i
=
0
;
i
<
infos
.
length
;
i
++
)
{
String
blockedLock
=
info
s
[
i
]
.
getLockName
();
for
(
ThreadInfo
info
:
infos
)
{
String
blockedLock
=
info
.
getLockName
();
if
(
lock
.
equals
(
blockedLock
))
{
long
threadId
=
info
s
[
i
]
.
getLockOwnerId
();
long
threadId
=
info
.
getLockOwnerId
();
if
(
threadId
==
-
1
)
{
throw
new
RuntimeException
(
"TEST FAILED: "
+
lock
+
" expected to have owner"
);
...
...
@@ -338,14 +343,17 @@ public class Locks {
throws
Exception
{
ThreadInfo
ownerInfo
=
null
;
// Find the thread who is blocking on lock
for
(
int
i
=
0
;
i
<
infos
.
length
;
i
++
)
{
String
blockedLock
=
info
s
[
i
]
.
getLockName
();
for
(
ThreadInfo
info
:
infos
)
{
String
blockedLock
=
info
.
getLockName
();
if
(
lock
.
equals
(
blockedLock
))
{
System
.
out
.
print
(
infos
[
i
].
getThreadName
()
+
" blocked on "
+
blockedLock
);
ownerInfo
=
infos
[
i
];
log
(
"%s blocked on %s"
,
info
.
getThreadName
(),
blockedLock
);
ownerInfo
=
info
;
}
}
if
(
ownerInfo
==
null
)
{
throw
new
RuntimeException
(
"TEST FAILED: "
+
"Can't retrieve ThreadInfo for the blocked thread"
);
}
long
[]
threads
=
new
long
[
10
];
int
count
=
0
;
...
...
@@ -353,14 +361,18 @@ public class Locks {
while
(
ownerInfo
!=
null
&&
ownerInfo
.
getThreadState
()
==
Thread
.
State
.
BLOCKED
)
{
ownerInfo
=
findOwnerInfo
(
infos
,
lock
);
threads
[
count
++]
=
ownerInfo
.
getThreadId
();
System
.
out
.
println
(
" Owner = "
+
ownerInfo
.
getThreadName
()
+
" id = "
+
ownerInfo
.
getThreadId
());
log
(
" Owner = %s id = %d"
,
ownerInfo
.
getThreadName
(),
ownerInfo
.
getThreadId
()
);
lock
=
ownerInfo
.
getLockName
();
System
.
out
.
print
(
ownerInfo
.
getThreadName
()
+
" Id = "
+
ownerInfo
.
getThreadId
()
+
" blocked on "
+
lock
);
log
(
"%s Id = %d blocked on %s"
,
ownerInfo
.
getThreadName
(),
ownerInfo
.
getThreadId
(),
lock
);
}
System
.
out
.
println
(
);
log
(
""
);
if
(
count
!=
expectedThreads
.
length
)
{
throw
new
RuntimeException
(
"TEST FAILED: "
+
...
...
@@ -368,10 +380,15 @@ public class Locks {
}
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(
threads
[
i
]
!=
expectedThreads
[
i
])
{
System
.
out
.
println
(
"TEST FAILED: "
+
"Unexpected thread in the chain "
+
threads
[
i
]
+
" expected to be "
+
expectedThreads
[
i
]);
log
(
"TEST FAILED: Unexpected thread in the chain %s expected to be %s"
,
threads
[
i
],
expectedThreads
[
i
]
);
}
}
}
private
static
void
log
(
String
format
,
Object
...
args
)
{
logger
.
log
(
format
+
"%n"
,
args
);
}
}
test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java
浏览文件 @
4040381c
...
...
@@ -34,6 +34,7 @@
import
java.lang.management.*
;
import
java.util.concurrent.Phaser
;
import
java.util.function.Supplier
;
public
class
SynchronizationStatistics
{
private
static
class
LockerThread
extends
Thread
{
...
...
@@ -86,6 +87,8 @@ public class SynchronizationStatistics {
private
static
void
testBlockingOnSimpleMonitor
()
throws
Exception
{
System
.
out
.
println
(
"testBlockingOnSimpleMonitor"
);
final
Object
lock1
=
new
Object
();
System
.
out
.
println
(
"Lock1 = "
+
lock1
);
final
Phaser
p
=
new
Phaser
(
2
);
LockerThread
lt
=
newLockerThread
(
new
Runnable
()
{
@Override
...
...
@@ -110,12 +113,12 @@ public class SynchronizationStatistics {
}
p
.
arriveAndAwaitAdvance
();
// phase[2]
testBlocked
(
ti
,
mbean
.
getThreadInfo
(
tid
),
lockName
,
lock1
);
testBlocked
(
ti
,
()
->
mbean
.
getThreadInfo
(
tid
),
lockName
,
lock1
);
p
.
arriveAndDeregister
();
// phase[3]
lt
.
join
();
System
.
out
.
println
(
"OK"
);
printok
(
);
}
/**
...
...
@@ -128,6 +131,9 @@ public class SynchronizationStatistics {
final
Object
lock1
=
new
Object
();
final
Object
lock2
=
new
Object
();
System
.
out
.
println
(
"Lock1 = "
+
lock1
);
System
.
out
.
println
(
"Lock2 = "
+
lock2
);
final
Phaser
p
=
new
Phaser
(
2
);
LockerThread
lt
=
newLockerThread
(
new
Runnable
()
{
@Override
...
...
@@ -149,7 +155,6 @@ public class SynchronizationStatistics {
lt
.
start
();
long
tid
=
lt
.
getId
();
ThreadInfo
ti
=
mbean
.
getThreadInfo
(
tid
);
ThreadInfo
ti1
=
null
;
String
lockName
=
null
;
synchronized
(
lock1
)
{
p
.
arriveAndAwaitAdvance
();
// phase[1]
...
...
@@ -158,9 +163,7 @@ public class SynchronizationStatistics {
}
p
.
arriveAndAwaitAdvance
();
// phase[2]
ti1
=
mbean
.
getThreadInfo
(
tid
);
testBlocked
(
ti
,
ti1
,
lockName
,
lock1
);
ti
=
ti1
;
ti
=
testBlocked
(
ti
,
()
->
mbean
.
getThreadInfo
(
tid
),
lockName
,
lock1
);
synchronized
(
lock2
)
{
p
.
arriveAndAwaitAdvance
();
// phase [3]
...
...
@@ -168,12 +171,12 @@ public class SynchronizationStatistics {
lockName
=
mbean
.
getThreadInfo
(
tid
).
getLockName
();
}
p
.
arriveAndAwaitAdvance
();
// phase [4]
testBlocked
(
ti
,
mbean
.
getThreadInfo
(
tid
),
lockName
,
lock2
);
testBlocked
(
ti
,
()
->
mbean
.
getThreadInfo
(
tid
),
lockName
,
lock2
);
p
.
arriveAndDeregister
();
lt
.
join
();
System
.
out
.
println
(
"OK"
);
printok
(
);
}
/**
...
...
@@ -209,13 +212,12 @@ public class SynchronizationStatistics {
}
p
.
arriveAndAwaitAdvance
();
// phase[2]
ThreadInfo
ti2
=
mbean
.
getThreadInfo
(
lt
.
getId
()
);
testWaited
(
ti1
,
()
->
mbean
.
getThreadInfo
(
lt
.
getId
()),
1
);
p
.
arriveAndDeregister
();
// phase[3]
lt
.
join
();
testWaited
(
ti1
,
ti2
,
1
);
System
.
out
.
println
(
"OK"
);
printok
();
}
/**
...
...
@@ -256,12 +258,12 @@ public class SynchronizationStatistics {
int
phase
=
p
.
getPhase
();
while
((
p
.
arriveAndAwaitAdvance
()
-
phase
)
<
3
);
// phase[2-4]
ThreadInfo
ti2
=
mbean
.
getThreadInfo
(
lt
.
getId
()
);
testWaited
(
ti1
,
()
->
mbean
.
getThreadInfo
(
lt
.
getId
()),
3
);
p
.
arriveAndDeregister
();
// phase[5]
lt
.
join
();
testWaited
(
ti1
,
ti2
,
3
);
System
.
out
.
println
(
"OK"
);
printok
(
);
}
/**
...
...
@@ -331,44 +333,85 @@ public class SynchronizationStatistics {
}
p
.
arriveAndAwaitAdvance
();
// phase[4]
ThreadInfo
ti2
=
mbean
.
getThreadInfo
(
lt
.
getId
()
);
testWaited
(
ti1
,
()
->
mbean
.
getThreadInfo
(
lt
.
getId
()),
3
);
p
.
arriveAndDeregister
();
// phase[5]
lt
.
join
();
testWaited
(
ti1
,
ti2
,
3
);
System
.
out
.
println
(
"OK"
);
printok
();
}
private
static
void
testWaited
(
ThreadInfo
ti1
,
ThreadInfo
ti2
,
int
waited
)
throws
Error
{
long
waitCntDiff
=
ti2
.
getWaitedCount
()
-
ti1
.
getWaitedCount
();
long
waitTimeDiff
=
ti2
.
getWaitedTime
()
-
ti1
.
getWaitedTime
();
if
(
waitCntDiff
<
waited
)
{
throw
new
Error
(
"Unexpected diff in waited count. Expecting at least "
+
waited
+
" , got "
+
waitCntDiff
);
}
if
(
waitTimeDiff
<=
0
)
{
throw
new
Error
(
"Unexpected diff in waited time. Expecting increasing "
+
"value, got "
+
waitTimeDiff
+
"ms"
);
}
private
static
void
printok
()
{
System
.
out
.
println
(
"OK\n"
);
}
private
static
void
testBlocked
(
ThreadInfo
ti1
,
ThreadInfo
ti2
,
private
static
void
testWaited
(
ThreadInfo
ti1
,
Supplier
<
ThreadInfo
>
ti2
,
int
waited
)
throws
InterruptedException
{
boolean
error
;
do
{
error
=
false
;
ThreadInfo
ti
=
ti2
.
get
();
long
waitCntDiff
=
ti
.
getWaitedCount
()
-
ti1
.
getWaitedCount
();
long
waitTimeDiff
=
ti
.
getWaitedTime
()
-
ti1
.
getWaitedTime
();
if
(
waitCntDiff
<
waited
)
{
System
.
err
.
println
(
"Unexpected diff in waited count. Expecting at least "
+
waited
+
" , got "
+
waitCntDiff
);
error
=
true
;
}
if
(
waitTimeDiff
<=
0
)
{
System
.
err
.
println
(
"Unexpected diff in waited time. Expecting increasing "
+
"value, got "
+
waitTimeDiff
+
"ms"
);
error
=
true
;
}
if
(
error
)
{
System
.
err
.
println
(
"Retrying in 20ms ..."
);
Thread
.
sleep
(
20
);
}
}
while
(
error
);
}
private
static
ThreadInfo
testBlocked
(
ThreadInfo
ti1
,
Supplier
<
ThreadInfo
>
ti2
,
String
lockName
,
final
Object
lock
)
throws
Error
{
long
blkCntDiff
=
ti2
.
getBlockedCount
()
-
ti1
.
getBlockedCount
();
long
blkTimeDiff
=
ti2
.
getBlockedTime
()
-
ti1
.
getBlockedTime
();
if
(
blkCntDiff
<
1
)
{
throw
new
Error
(
"Unexpected diff in blocked count. Expecting at least 1, "
+
"got "
+
blkCntDiff
);
}
if
(
blkTimeDiff
<
0
)
{
throw
new
Error
(
"Unexpected diff in blocked time. Expecting a positive "
+
"number, got "
+
blkTimeDiff
);
}
if
(!
lockName
.
equals
(
lock
.
toString
()))
{
throw
new
Error
(
"Unexpected blocked monitor name. Expecting "
+
lock
.
toString
()
+
", got "
+
lockName
);
}
throws
InterruptedException
{
boolean
error
;
ThreadInfo
ti
=
null
;
do
{
error
=
false
;
ti
=
ti2
.
get
();
long
blkCntDiff
=
ti
.
getBlockedCount
()
-
ti1
.
getBlockedCount
();
long
blkTimeDiff
=
ti
.
getBlockedTime
()
-
ti1
.
getBlockedTime
();
System
.
out
.
println
(
"testBlocked: ["
+
blkCntDiff
+
", "
+
blkTimeDiff
+
", "
+
lockName
+
"]"
);
if
(
blkCntDiff
<
1
)
{
System
.
err
.
println
(
"Unexpected diff in blocked count. Expecting at least 1, "
+
"got "
+
blkCntDiff
);
error
=
true
;
}
if
(
blkTimeDiff
<
0
)
{
System
.
err
.
println
(
"Unexpected diff in blocked time. Expecting a positive "
+
"number, got "
+
blkTimeDiff
);
error
=
true
;
}
if
(!
lockName
.
equals
(
lock
.
toString
()))
{
System
.
err
.
println
(
"Unexpected blocked monitor name. Expecting "
+
lock
.
toString
()
+
", got "
+
lockName
);
error
=
true
;
}
if
(
error
)
{
System
.
err
.
println
(
"Retrying in 20ms ..."
);
Thread
.
sleep
(
20
);
}
}
while
(
error
);
return
ti
;
}
}
test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java
浏览文件 @
4040381c
/*
* Copyright (c) 2003, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
4
, 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
...
...
@@ -31,6 +31,8 @@
* @author Mandy Chung
*
* @library ../../Thread
* @library /lib/testlibrary
* @build jdk.testlibrary.LockFreeLogManager
* @build ThreadMXBeanStateTest ThreadStateController
* @run main ThreadMXBeanStateTest
*/
...
...
@@ -44,15 +46,17 @@ public class ThreadMXBeanStateTest {
private
static
final
ThreadMXBean
tm
=
ManagementFactory
.
getThreadMXBean
();
static
class
Lock
{
private
String
name
;
private
final
String
name
;
Lock
(
String
name
)
{
this
.
name
=
name
;
}
@Override
public
String
toString
()
{
return
name
;
}
}
private
static
Lock
globalLock
=
new
Lock
(
"my lock"
);
private
static
final
Lock
globalLock
=
new
Lock
(
"my lock"
);
public
static
void
main
(
String
[]
argv
)
throws
Exception
{
// Force thread state initialization now before the test
...
...
@@ -109,7 +113,7 @@ public class ThreadMXBeanStateTest {
thread
.
checkThreadState
(
TERMINATED
);
try
{
thread
.
join
(
);
System
.
out
.
println
(
thread
.
getLog
()
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"TEST FAILED: Unexpected exception."
);
...
...
test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java
浏览文件 @
4040381c
...
...
@@ -24,6 +24,8 @@
/* @test
* @bug 6834246 6842687
* @summary Stress test connections through the loopback interface
* @run main StressLoopback
* @run main/othervm -Djdk.net.useFastTcpLoopback StressLoopback
*/
import
java.nio.ByteBuffer
;
...
...
test/java/nio/channels/FileChannel/TransferToChannel.java
浏览文件 @
4040381c
...
...
@@ -24,6 +24,8 @@
/* @test
* @bug 4652496
* @summary Test transferTo with different target channels
* @run main TransferToChannel
* @run main/othervm -Djdk.net.enableFastFileTransfer TransferToChannel
*/
import
java.nio.channels.FileChannel
;
...
...
test/javax/management/monitor/CounterMonitorTest.java
浏览文件 @
4040381c
...
...
@@ -68,7 +68,7 @@ public class CounterMonitorTest implements NotificationListener {
observedValue
=
count
;
CounterMonitorTest
.
class
.
notifyAll
();
}
return
count
;
return
observedValue
;
}
public
void
setNbObjects
(
Object
n
)
{
echo
(
">>> StdObservedObject.setNbObjects: "
+
n
);
...
...
test/javax/management/remote/mandatory/notif/NotificationAccessControllerTest.java
浏览文件 @
4040381c
/*
* Copyright (c) 2005, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 20
14
, 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
...
...
@@ -37,6 +37,8 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.Semaphore
;
import
javax.management.MBeanServer
;
import
javax.management.MBeanServerConnection
;
import
javax.management.MBeanServerFactory
;
...
...
@@ -56,10 +58,12 @@ import javax.security.auth.Subject;
public
class
NotificationAccessControllerTest
{
public
class
NAC
implements
NotificationAccessController
{
private
boolean
throwException
;
private
final
boolean
throwException
;
public
NAC
(
boolean
throwException
)
{
this
.
throwException
=
throwException
;
}
@Override
public
void
addNotificationListener
(
String
connectionId
,
ObjectName
name
,
...
...
@@ -72,10 +76,14 @@ public class NotificationAccessControllerTest {
(
subject
==
null
?
null
:
subject
.
getPrincipals
()));
if
(
throwException
)
if
(
name
.
getCanonicalName
().
equals
(
"domain:name=1,type=NB"
)
&&
subject
!=
null
&&
subject
.
getPrincipals
().
contains
(
new
JMXPrincipal
(
"role"
)))
throw
new
SecurityException
();
}
@Override
public
void
removeNotificationListener
(
String
connectionId
,
ObjectName
name
,
...
...
@@ -88,10 +96,14 @@ public class NotificationAccessControllerTest {
(
subject
==
null
?
null
:
subject
.
getPrincipals
()));
if
(
throwException
)
if
(
name
.
getCanonicalName
().
equals
(
"domain:name=2,type=NB"
)
&&
subject
!=
null
&&
subject
.
getPrincipals
().
contains
(
new
JMXPrincipal
(
"role"
)))
throw
new
SecurityException
();
}
@Override
public
void
fetchNotification
(
String
connectionId
,
ObjectName
name
,
...
...
@@ -105,13 +117,17 @@ public class NotificationAccessControllerTest {
echo
(
"\tsubject: "
+
(
subject
==
null
?
null
:
subject
.
getPrincipals
()));
if
(!
throwException
)
if
(
name
.
getCanonicalName
().
equals
(
"domain:name=2,type=NB"
)
&&
if
(
name
.
getCanonicalName
().
equals
(
"domain:name=2,type=NB"
)
&&
subject
!=
null
&&
subject
.
getPrincipals
().
contains
(
new
JMXPrincipal
(
"role"
)))
throw
new
SecurityException
();
}
}
public
class
CustomJMXAuthenticator
implements
JMXAuthenticator
{
@Override
public
Subject
authenticate
(
Object
credentials
)
{
String
role
=
((
String
[])
credentials
)[
0
];
echo
(
"\nCreate principal with name = "
+
role
);
...
...
@@ -129,6 +145,7 @@ public class NotificationAccessControllerTest {
public
static
class
NB
extends
NotificationBroadcasterSupport
implements
NBMBean
{
@Override
public
void
emitNotification
(
int
seqnum
,
ObjectName
name
)
{
if
(
name
==
null
)
{
sendNotification
(
new
Notification
(
"nb"
,
this
,
seqnum
));
...
...
@@ -139,13 +156,20 @@ public class NotificationAccessControllerTest {
}
public
class
Listener
implements
NotificationListener
{
public
List
<
Notification
>
notifs
=
new
ArrayList
<
Notification
>();
public
final
List
<
Notification
>
notifs
=
new
CopyOnWriteArrayList
<>();
private
final
Semaphore
s
;
public
Listener
(
Semaphore
s
)
{
this
.
s
=
s
;
}
@Override
public
void
handleNotification
(
Notification
n
,
Object
h
)
{
echo
(
"handleNotification:"
);
echo
(
"\tNotification = "
+
n
);
echo
(
"\tNotification.SeqNum = "
+
n
.
getSequenceNumber
());
echo
(
"\tHandback = "
+
h
);
notifs
.
add
(
n
);
s
.
release
();
}
}
...
...
@@ -192,6 +216,17 @@ public class NotificationAccessControllerTest {
JMXConnectorServer
server
=
null
;
JMXConnector
client
=
null
;
/*
* (!enableChecks)
* - List must contain three notifs from sources nb1, nb2 and nb3
* (enableChecks && !throwException)
* - List must contain one notif from source nb1
* (enableChecks && throwException)
* - List must contain two notifs from sources nb2 and nb3
*/
final
int
expected_notifs
=
(!
enableChecks
?
3
:
(
throwException
?
2
:
1
));
// Create a new MBeanServer
//
final
MBeanServer
mbs
=
MBeanServerFactory
.
createMBeanServer
();
...
...
@@ -199,7 +234,7 @@ public class NotificationAccessControllerTest {
try
{
// Create server environment map
//
final
Map
<
String
,
Object
>
env
=
new
HashMap
<
String
,
Object
>();
final
Map
<
String
,
Object
>
env
=
new
HashMap
<>();
env
.
put
(
"jmx.remote.authenticator"
,
new
CustomJMXAuthenticator
());
if
(
enableChecks
)
{
env
.
put
(
"com.sun.jmx.remote.notification.access.controller"
,
...
...
@@ -222,7 +257,7 @@ public class NotificationAccessControllerTest {
// Create server environment map
//
final
Map
<
String
,
Object
>
cenv
=
new
HashMap
<
String
,
Object
>();
final
Map
<
String
,
Object
>
cenv
=
new
HashMap
<>();
String
[]
credentials
=
new
String
[]
{
"role"
,
"password"
};
cenv
.
put
(
"jmx.remote.credentials"
,
credentials
);
...
...
@@ -246,7 +281,9 @@ public class NotificationAccessControllerTest {
// Add notification listener
//
Listener
li
=
new
Listener
();
Semaphore
s
=
new
Semaphore
(
0
);
Listener
li
=
new
Listener
(
s
);
try
{
mbsc
.
addNotificationListener
(
nb1
,
li
,
null
,
null
);
if
(
enableChecks
&&
throwException
)
{
...
...
@@ -263,6 +300,9 @@ public class NotificationAccessControllerTest {
}
mbsc
.
addNotificationListener
(
nb2
,
li
,
null
,
null
);
System
.
out
.
println
(
"\n+++ Expecting to receive "
+
expected_notifs
+
" notification"
+
(
expected_notifs
>
1
?
"s"
:
""
)
+
" +++"
);
// Invoke the "sendNotification" method
//
mbsc
.
invoke
(
nb1
,
"emitNotification"
,
...
...
@@ -277,7 +317,7 @@ public class NotificationAccessControllerTest {
// Wait for notifications to be emitted
//
Thread
.
sleep
(
2000
);
s
.
acquire
(
expected_notifs
);
// Remove notification listener
//
...
...
@@ -303,21 +343,7 @@ public class NotificationAccessControllerTest {
sources
.
add
(
nb1
);
sources
.
add
(
nb2
);
sources
.
add
(
nb3
);
if
(!
enableChecks
)
{
// List must contain three notifs from sources nb1, nb2 and nb3
//
result
=
checkNotifs
(
3
,
li
.
notifs
,
sources
);
}
if
(
enableChecks
&&
!
throwException
)
{
// List must contain one notif from source nb1
//
result
=
checkNotifs
(
1
,
li
.
notifs
,
sources
);
}
if
(
enableChecks
&&
throwException
)
{
// List must contain two notifs from sources nb2 and nb3
//
result
=
checkNotifs
(
2
,
li
.
notifs
,
sources
);
}
result
=
checkNotifs
(
expected_notifs
,
li
.
notifs
,
sources
);
if
(
result
>
0
)
{
return
result
;
}
...
...
test/javax/management/standardmbean/DeadlockTest.java
浏览文件 @
4040381c
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005,
2014,
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
...
...
@@ -24,7 +24,7 @@
/*
* @test
* @bug 6331746
* @summary
Deadlock on synchronization problem
* @summary
Test a deadlock and will be blocked forever if the deadlock is present.
* @author Shanliang JIANG
* @run main DeadlockTest
*/
...
...
@@ -55,43 +55,25 @@ public class DeadlockTest extends StandardMBean {
BadBoy
bb
=
new
BadBoy
(
dt
);
bb
.
start
();
final
long
timeout
=
2000
;
long
stopTime
=
System
.
currentTimeMillis
()
+
timeout
;
long
timeToWait
=
timeout
;
synchronized
(
bb
)
{
while
(!
bb
.
gotLock
||
timeToWait
>
0
)
{
bb
.
wait
(
timeToWait
);
timeToWait
=
stopTime
-
System
.
currentTimeMillis
();
while
(!
bb
.
gotLock
)
{
bb
.
wait
();
// if blocked here, means failing to get lock, impossible.
}
}
if
(!
bb
.
gotLock
)
{
throw
new
RuntimeException
(
"Failed to get lock, impossible!"
);
}
System
.
out
.
println
(
"main: The BadBay is holding the lock forever."
);
System
.
out
.
println
(
"main: Create a WorkingBoy to see blocking ..."
);
WorkingBoy
wb
=
new
WorkingBoy
(
dt
);
stopTime
=
System
.
currentTimeMillis
()
+
timeout
;
timeToWait
=
timeout
;
synchronized
(
wb
)
{
wb
.
start
();
while
(!
wb
.
done
||
timeToWait
>
0
)
{
wb
.
wait
(
timeToWait
);
timeToWait
=
stopTime
-
System
.
currentTimeMillis
();
while
(!
wb
.
done
)
{
wb
.
wait
();
// if blocked here, the deadlock happends
}
}
if
(!
wb
.
done
)
{
throw
new
RuntimeException
(
"It is blocked!"
);
}
System
.
out
.
println
(
"main: OK, bye bye."
);
}
...
...
test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java
0 → 100644
浏览文件 @
4040381c
/*
* Copyright (c) 2014, 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.
*/
package
jdk.testlibrary
;
import
java.util.Collection
;
import
java.util.Formatter
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
/**
* A log manager designed specifically to allow collecting ordered log messages
* in a multi-threaded environment without involving any kind of locking.
* <p>
* It is particularly useful in situations when one needs to assert various
* details about the tested thread state or the locks it hold while also wanting
* to produce diagnostic log messages.
* <p>
* The log manager does not provide any guarantees about the completness of the
* logs written from different threads - it is up to the caller to make sure
* {@code toString()} method is called only when all the activity has ceased
* and the per-thread logs contain all the necessary data.
*
* @author Jaroslav Bachorik
**/
public
class
LockFreeLogManager
{
private
final
AtomicInteger
logCntr
=
new
AtomicInteger
(
0
);
private
final
Collection
<
Map
<
Integer
,
String
>>
allRecords
=
new
ConcurrentLinkedQueue
<>();
private
final
ThreadLocal
<
Map
<
Integer
,
String
>>
records
=
new
ThreadLocal
<
Map
<
Integer
,
String
>>()
{
@Override
protected
Map
<
Integer
,
String
>
initialValue
()
{
Map
<
Integer
,
String
>
m
=
new
ConcurrentHashMap
<>();
allRecords
.
add
(
m
);
return
m
;
}
};
/**
* Log a message
* @param format Message format
* @param params Message parameters
*/
public
void
log
(
String
format
,
Object
...
params
)
{
int
id
=
logCntr
.
getAndIncrement
();
try
(
Formatter
formatter
=
new
Formatter
())
{
records
.
get
().
put
(
id
,
formatter
.
format
(
format
,
params
).
toString
());
}
}
/**
* Will generate an aggregated log of chronologically ordered messages.
* <p>
* Make sure that you call this method only when all the related threads
* have finished; otherwise you might get incomplete data.
*
* @return An aggregated log of chronologically ordered messages
*/
@Override
public
String
toString
()
{
return
allRecords
.
stream
()
.
flatMap
(
m
->
m
.
entrySet
().
stream
())
.
sorted
((
l
,
r
)->
l
.
getKey
().
compareTo
(
r
.
getKey
()))
.
map
(
e
->
e
.
getValue
())
.
collect
(
Collectors
.
joining
());
}
}
test/sun/util/calendar/zi/Rule.java
浏览文件 @
4040381c
...
...
@@ -126,6 +126,14 @@ class Rule {
});
rules
.
clear
();
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
if
(
i
!=
0
&&
recs
[
i
-
1
].
getSave
()
==
recs
[
i
].
getSave
())
{
// we have two recs back to back with same saving for the same year.
if
(
recs
[
i
].
isLastRule
())
{
continue
;
}
else
if
(
recs
[
i
-
1
].
isLastRule
())
{
rules
.
remove
(
rules
.
size
()
-
1
);
}
}
rules
.
add
(
recs
[
i
]);
}
return
rules
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录