Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
cb0fea8f
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看板
提交
cb0fea8f
编写于
4月 18, 2012
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
433c74a6
3fa1612e
变更
103
显示空白变更内容
内联
并排
Showing
103 changed file
with
2045 addition
and
639 deletion
+2045
-639
make/com/sun/tools/attach/Makefile
make/com/sun/tools/attach/Makefile
+3
-1
make/common/Defs-linux.gmk
make/common/Defs-linux.gmk
+15
-5
make/common/Defs-solaris.gmk
make/common/Defs-solaris.gmk
+19
-5
make/common/Defs-windows.gmk
make/common/Defs-windows.gmk
+1
-3
make/common/Library.gmk
make/common/Library.gmk
+40
-0
make/common/Program.gmk
make/common/Program.gmk
+49
-0
make/common/Release.gmk
make/common/Release.gmk
+7
-3
make/java/instrument/Makefile
make/java/instrument/Makefile
+3
-1
make/java/java/reflect/Makefile
make/java/java/reflect/Makefile
+1
-1
make/java/java_crw_demo/Makefile
make/java/java_crw_demo/Makefile
+3
-1
make/java/java_hprof_demo/Makefile
make/java/java_hprof_demo/Makefile
+3
-1
make/java/main/java/Makefile
make/java/main/java/Makefile
+3
-1
make/java/management/Makefile
make/java/management/Makefile
+3
-1
make/java/npt/Makefile
make/java/npt/Makefile
+3
-1
make/java/verify/Makefile
make/java/verify/Makefile
+3
-1
make/jpda/jdwp/Makefile
make/jpda/jdwp/Makefile
+3
-1
make/jpda/transport/socket/Makefile
make/jpda/transport/socket/Makefile
+3
-1
make/launchers/Makefile.launcher
make/launchers/Makefile.launcher
+2
-0
make/mkdemo/jvmti/compiledMethodLoad/Makefile
make/mkdemo/jvmti/compiledMethodLoad/Makefile
+3
-1
make/mkdemo/jvmti/gctest/Makefile
make/mkdemo/jvmti/gctest/Makefile
+3
-1
make/mkdemo/jvmti/heapTracker/Makefile
make/mkdemo/jvmti/heapTracker/Makefile
+3
-1
make/mkdemo/jvmti/heapViewer/Makefile
make/mkdemo/jvmti/heapViewer/Makefile
+3
-1
make/mkdemo/jvmti/hprof/Makefile
make/mkdemo/jvmti/hprof/Makefile
+3
-1
make/mkdemo/jvmti/minst/Makefile
make/mkdemo/jvmti/minst/Makefile
+3
-1
make/mkdemo/jvmti/mtrace/Makefile
make/mkdemo/jvmti/mtrace/Makefile
+3
-1
make/mkdemo/jvmti/versionCheck/Makefile
make/mkdemo/jvmti/versionCheck/Makefile
+3
-1
make/mkdemo/jvmti/waiters/Makefile
make/mkdemo/jvmti/waiters/Makefile
+3
-1
make/sun/tracing/dtrace/Makefile
make/sun/tracing/dtrace/Makefile
+4
-1
src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
+4
-2
src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java
src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java
+5
-3
src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java
src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java
+58
-18
src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java
src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java
+3
-1
src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c
src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c
+3
-1
src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java
...classes/com/sun/tools/example/debug/tty/VMConnection.java
+163
-0
src/share/classes/java/net/HttpCookie.java
src/share/classes/java/net/HttpCookie.java
+1
-4
src/share/classes/java/nio/file/Files.java
src/share/classes/java/nio/file/Files.java
+1
-1
src/share/classes/java/security/CodeSource.java
src/share/classes/java/security/CodeSource.java
+82
-76
src/share/classes/java/util/AbstractCollection.java
src/share/classes/java/util/AbstractCollection.java
+13
-3
src/share/classes/java/util/AbstractList.java
src/share/classes/java/util/AbstractList.java
+1
-1
src/share/classes/java/util/AbstractMap.java
src/share/classes/java/util/AbstractMap.java
+4
-4
src/share/classes/java/util/AbstractSet.java
src/share/classes/java/util/AbstractSet.java
+1
-1
src/share/classes/java/util/ArrayDeque.java
src/share/classes/java/util/ArrayDeque.java
+3
-1
src/share/classes/java/util/ArrayList.java
src/share/classes/java/util/ArrayList.java
+1
-2
src/share/classes/java/util/Arrays.java
src/share/classes/java/util/Arrays.java
+13
-4
src/share/classes/java/util/Calendar.java
src/share/classes/java/util/Calendar.java
+2
-2
src/share/classes/java/util/Collections.java
src/share/classes/java/util/Collections.java
+30
-12
src/share/classes/java/util/ComparableTimSort.java
src/share/classes/java/util/ComparableTimSort.java
+5
-8
src/share/classes/java/util/Currency.java
src/share/classes/java/util/Currency.java
+1
-1
src/share/classes/java/util/EnumMap.java
src/share/classes/java/util/EnumMap.java
+19
-17
src/share/classes/java/util/EnumSet.java
src/share/classes/java/util/EnumSet.java
+11
-7
src/share/classes/java/util/HashMap.java
src/share/classes/java/util/HashMap.java
+54
-38
src/share/classes/java/util/HashSet.java
src/share/classes/java/util/HashSet.java
+4
-2
src/share/classes/java/util/Hashtable.java
src/share/classes/java/util/Hashtable.java
+69
-56
src/share/classes/java/util/IdentityHashMap.java
src/share/classes/java/util/IdentityHashMap.java
+22
-12
src/share/classes/java/util/IllegalFormatConversionException.java
...e/classes/java/util/IllegalFormatConversionException.java
+1
-1
src/share/classes/java/util/JumboEnumSet.java
src/share/classes/java/util/JumboEnumSet.java
+10
-9
src/share/classes/java/util/LinkedHashMap.java
src/share/classes/java/util/LinkedHashMap.java
+6
-4
src/share/classes/java/util/Observable.java
src/share/classes/java/util/Observable.java
+2
-2
src/share/classes/java/util/PriorityQueue.java
src/share/classes/java/util/PriorityQueue.java
+15
-5
src/share/classes/java/util/Properties.java
src/share/classes/java/util/Properties.java
+11
-11
src/share/classes/java/util/PropertyPermission.java
src/share/classes/java/util/PropertyPermission.java
+16
-11
src/share/classes/java/util/RegularEnumSet.java
src/share/classes/java/util/RegularEnumSet.java
+11
-10
src/share/classes/java/util/ResourceBundle.java
src/share/classes/java/util/ResourceBundle.java
+4
-3
src/share/classes/java/util/ServiceLoader.java
src/share/classes/java/util/ServiceLoader.java
+5
-5
src/share/classes/java/util/TimeZone.java
src/share/classes/java/util/TimeZone.java
+3
-3
src/share/classes/java/util/TreeMap.java
src/share/classes/java/util/TreeMap.java
+77
-72
src/share/classes/java/util/TreeSet.java
src/share/classes/java/util/TreeSet.java
+6
-8
src/share/classes/java/util/WeakHashMap.java
src/share/classes/java/util/WeakHashMap.java
+1
-1
src/share/classes/java/util/regex/Matcher.java
src/share/classes/java/util/regex/Matcher.java
+7
-4
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+3
-2
src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
+3
-2
src/share/classes/sun/nio/ch/SocketChannelImpl.java
src/share/classes/sun/nio/ch/SocketChannelImpl.java
+3
-2
src/share/classes/sun/nio/cs/ext/SJIS_0213.java
src/share/classes/sun/nio/cs/ext/SJIS_0213.java
+9
-3
src/share/classes/sun/security/ec/ECParameters.java
src/share/classes/sun/security/ec/ECParameters.java
+2
-2
src/share/classes/sun/security/krb5/Credentials.java
src/share/classes/sun/security/krb5/Credentials.java
+18
-11
src/share/classes/sun/security/ssl/AppOutputStream.java
src/share/classes/sun/security/ssl/AppOutputStream.java
+13
-2
src/share/classes/sun/security/ssl/EngineOutputRecord.java
src/share/classes/sun/security/ssl/EngineOutputRecord.java
+6
-4
src/share/classes/sun/security/ssl/OutputRecord.java
src/share/classes/sun/security/ssl/OutputRecord.java
+71
-6
src/share/classes/sun/security/ssl/SSLSocketImpl.java
src/share/classes/sun/security/ssl/SSLSocketImpl.java
+41
-6
src/share/classes/sun/tools/java/ClassPath.java
src/share/classes/sun/tools/java/ClassPath.java
+2
-2
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java
...io/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java
+1
-1
src/share/lib/security/java.security
src/share/lib/security/java.security
+1
-1
src/share/lib/security/java.security-macosx
src/share/lib/security/java.security-macosx
+1
-1
src/share/lib/security/java.security-solaris
src/share/lib/security/java.security-solaris
+1
-1
src/share/lib/security/java.security-windows
src/share/lib/security/java.security-windows
+1
-1
src/solaris/classes/sun/nio/ch/SinkChannelImpl.java
src/solaris/classes/sun/nio/ch/SinkChannelImpl.java
+3
-2
src/solaris/classes/sun/nio/ch/SourceChannelImpl.java
src/solaris/classes/sun/nio/ch/SourceChannelImpl.java
+3
-2
src/solaris/native/com/sun/management/MacosxOperatingSystem.c
...solaris/native/com/sun/management/MacosxOperatingSystem.c
+123
-3
src/solaris/native/com/sun/management/UnixOperatingSystem_md.c
...olaris/native/com/sun/management/UnixOperatingSystem_md.c
+104
-10
test/ProblemList.txt
test/ProblemList.txt
+25
-0
test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh
...com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh
+7
-0
test/demo/zipfs/ZFSTests.java
test/demo/zipfs/ZFSTests.java
+56
-0
test/java/lang/SecurityManager/CheckPackageAccess.java
test/java/lang/SecurityManager/CheckPackageAccess.java
+47
-0
test/java/nio/channels/Selector/OpRead.java
test/java/nio/channels/Selector/OpRead.java
+4
-1
test/java/nio/charset/coders/StreamTimeout.java
test/java/nio/charset/coders/StreamTimeout.java
+73
-62
test/java/security/CodeSource/Implies.java
test/java/security/CodeSource/Implies.java
+24
-7
test/java/util/AbstractCollection/ToArrayTest.java
test/java/util/AbstractCollection/ToArrayTest.java
+215
-0
test/java/util/regex/RegExTest.java
test/java/util/regex/RegExTest.java
+12
-0
test/sun/net/www/protocol/jar/B4957695.java
test/sun/net/www/protocol/jar/B4957695.java
+54
-29
test/sun/nio/ch/SelProvider.java
test/sun/nio/ch/SelProvider.java
+2
-13
test/sun/nio/cs/TestSJIS0213_SM.java
test/sun/nio/cs/TestSJIS0213_SM.java
+36
-0
test/sun/rmi/rmic/classpath/RMICClassPathTest.java
test/sun/rmi/rmic/classpath/RMICClassPathTest.java
+55
-0
test/sun/security/krb5/ccache/EmptyCC.java
test/sun/security/krb5/ccache/EmptyCC.java
+83
-0
未找到文件。
make/com/sun/tools/attach/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2005, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -24,6 +24,8 @@
...
@@ -24,6 +24,8 @@
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../../..
BUILDDIR
=
../../../..
PACKAGE
=
com.sun.tools.attach
PACKAGE
=
com.sun.tools.attach
LIBRARY
=
attach
LIBRARY
=
attach
...
...
make/common/Defs-linux.gmk
浏览文件 @
cb0fea8f
...
@@ -131,8 +131,9 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
...
@@ -131,8 +131,9 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
# Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
# JDK build to import .debuginfo or .diz files from the HotSpot build.
# JDK build to import .debuginfo or .diz files from the HotSpot build.
# However, adding FDS support to the JDK build will occur in phases
# However, adding FDS support to the JDK build will occur in phases
# so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
# so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
# is used to indicate that a particular library supports FDS.
# and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
# particular library or program supports FDS.
ifeq ($(OBJCOPY),)
ifeq ($(OBJCOPY),)
_JUNK_ := $(shell \
_JUNK_ := $(shell \
...
@@ -156,9 +157,7 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
...
@@ -156,9 +157,7 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
_JUNK_ := $(shell \
_JUNK_ := $(shell \
echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
# HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
ZIP_DEBUGINFO_FILES ?= 1
# changes are promoted
ZIP_DEBUGINFO_FILES ?= 0
_JUNK_ := $(shell \
_JUNK_ := $(shell \
echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
...
@@ -261,6 +260,17 @@ ifeq ($(DEBUG_BINARIES), true)
...
@@ -261,6 +260,17 @@ ifeq ($(DEBUG_BINARIES), true)
CFLAGS_REQUIRED += $(DEBUG_FLAG)
CFLAGS_REQUIRED += $(DEBUG_FLAG)
endif
endif
# If Full Debug Symbols is enabled, then we want the same debug and
# optimization flags as used by FASTDEBUG.
#
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
ifeq ($(VARIANT), OPT)
CC_OPT = $(DEBUG_FLAG) $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
endif
endif
endif
CFLAGS_OPT = $(CC_OPT)
CFLAGS_OPT = $(CC_OPT)
CFLAGS_DBG = $(DEBUG_FLAG)
CFLAGS_DBG = $(DEBUG_FLAG)
CFLAGS_COMMON += $(CFLAGS_REQUIRED)
CFLAGS_COMMON += $(CFLAGS_REQUIRED)
...
...
make/common/Defs-solaris.gmk
浏览文件 @
cb0fea8f
...
@@ -138,8 +138,9 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
...
@@ -138,8 +138,9 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
# Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
# JDK build to import .debuginfo or .diz files from the HotSpot build.
# JDK build to import .debuginfo or .diz files from the HotSpot build.
# However, adding FDS support to the JDK build will occur in phases
# However, adding FDS support to the JDK build will occur in phases
# so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
# so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
# is used to indicate that a particular library supports FDS.
# and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
# particular library or program supports FDS.
ifeq ($(OBJCOPY),)
ifeq ($(OBJCOPY),)
_JUNK_ := $(shell \
_JUNK_ := $(shell \
...
@@ -164,9 +165,7 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
...
@@ -164,9 +165,7 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
_JUNK_ := $(shell \
_JUNK_ := $(shell \
echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
# HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
ZIP_DEBUGINFO_FILES ?= 1
# changes are promoted
ZIP_DEBUGINFO_FILES ?= 0
_JUNK_ := $(shell \
_JUNK_ := $(shell \
echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
...
@@ -240,6 +239,21 @@ ifeq ($(FASTDEBUG), true)
...
@@ -240,6 +239,21 @@ ifeq ($(FASTDEBUG), true)
CXXFLAGS_DEBUG_OPTION = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
CXXFLAGS_DEBUG_OPTION = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
endif
endif
# If Full Debug Symbols is enabled, then we want the same debug and
# optimization flags as used by FASTDEBUG. We also want all the
# debug info in one place (-xs).
#
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
ifeq ($(VARIANT), OPT)
CC_OPT = -g -xs $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
CXX_OPT = -g0 -xs $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
endif
CFLAGS_DEBUG_OPTION += -xs
CXXFLAGS_DEBUG_OPTION += -xs
endif
endif
CFLAGS_COMMON = -L$(OBJDIR)
CFLAGS_COMMON = -L$(OBJDIR)
# Do not allow C99 language features like declarations in code etc.
# Do not allow C99 language features like declarations in code etc.
...
...
make/common/Defs-windows.gmk
浏览文件 @
cb0fea8f
...
@@ -113,9 +113,7 @@ _JUNK_ := $(shell \
...
@@ -113,9 +113,7 @@ _JUNK_ := $(shell \
echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
ZIP_DEBUGINFO_FILES ?= 1
# changes are promoted
ZIP_DEBUGINFO_FILES ?= 0
else
else
ZIP_DEBUGINFO_FILES=0
ZIP_DEBUGINFO_FILES=0
endif
endif
...
...
make/common/Library.gmk
浏览文件 @
cb0fea8f
...
@@ -181,8 +181,17 @@ $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
...
@@ -181,8 +181,17 @@ $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
$(CP) $(OBJDIR)/$(@F) $@
$(CP) $(OBJDIR)/$(@F) $@
@$(call binary_file_verification,$@)
@$(call binary_file_verification,$@)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(ZIP_DEBUGINFO_FILES),1)
(set -e ; \
$(CD) $(OBJDIR) ; \
$(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).map $(LIBRARY).pdb ; \
)
$(CP) $(OBJDIR)/$(LIBRARY).diz $(@D)
$(RM) $(OBJDIR)/$(LIBRARY).map $(OBJDIR)/$(LIBRARY).pdb
else
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
endif
endif
endif
endif # LIBRARY
endif # LIBRARY
...
@@ -248,6 +257,37 @@ else # LIBRARY
...
@@ -248,6 +257,37 @@ else # LIBRARY
ifeq ($(WRITE_LIBVERSION),true)
ifeq ($(WRITE_LIBVERSION),true)
$(MCS) -d -a "$(FULL_VERSION)" $@
$(MCS) -d -a "$(FULL_VERSION)" $@
endif # WRITE_LIBVERSION
endif # WRITE_LIBVERSION
ifneq ($(PLATFORM), macosx)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
(set -e ; \
$(CD) $(@D) ; \
$(OBJCOPY) --only-keep-debug $(@F) $(LIBRARY).debuginfo ; \
$(OBJCOPY) --add-gnu-debuglink=$(LIBRARY).debuginfo $(@F) ; \
)
ifeq ($(STRIP_POLICY),all_strip)
$(STRIP) $@
else
ifeq ($(STRIP_POLICY),min_strip)
ifeq ($(PLATFORM), solaris)
$(STRIP) -x $@
else
# assume Linux
$(STRIP) -g $@
endif
# implied else here is no stripping at all
endif
endif
ifeq ($(ZIP_DEBUGINFO_FILES),1)
(set -e ; \
$(CD) $(@D) ; \
$(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).debuginfo ; \
$(RM) $(LIBRARY).debuginfo ; \
)
endif
endif # LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
endif # ENABLE_FULL_DEBUG_SYMBOLS
endif # PLATFORM-!macosx
endif # LIBRARY
endif # LIBRARY
endif # PLATFORM
endif # PLATFORM
...
...
make/common/Program.gmk
浏览文件 @
cb0fea8f
...
@@ -189,6 +189,15 @@ endif
...
@@ -189,6 +189,15 @@ endif
$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
endif
endif
@$(call binary_file_verification,$@)
@$(call binary_file_verification,$@)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(ZIP_DEBUGINFO_FILES),1)
(set -e ; \
$(CD) $(OBJDIR) ; \
$(ZIPEXE) -q $(PROGRAM).diz $(PROGRAM).map $(PROGRAM).pdb ; \
$(RM) $(PROGRAM).map $(PROGRAM).pdb ; \
)
endif
endif
else
else
#
#
# Note that we have to link -lthread even when USE_PTHREADS is true.
# Note that we have to link -lthread even when USE_PTHREADS is true.
...
@@ -232,6 +241,42 @@ else
...
@@ -232,6 +241,42 @@ else
-codesign -s openjdk_codesign $@
-codesign -s openjdk_codesign $@
endif
endif
@$(call binary_file_verification,$@)
@$(call binary_file_verification,$@)
ifneq ($(PLATFORM), macosx)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
(set -e ; \
$(CD) $(@D) ; \
$(OBJCOPY) --only-keep-debug $(@F) $(@F).debuginfo ; \
$(OBJCOPY) --add-gnu-debuglink=$(@F).debuginfo $(@F) ; \
)
ifeq ($(STRIP_POLICY),all_strip)
$(STRIP) $@
else
ifeq ($(STRIP_POLICY),min_strip)
ifeq ($(PLATFORM), solaris)
$(STRIP) -x $@
else
# assume Linux
$(STRIP) -g $@
endif
# implied else here is no stripping at all
endif
endif
ifeq ($(ZIP_DEBUGINFO_FILES),1)
(set -e ; \
$(CD) $(@D) ; \
$(ZIPEXE) -q $(@F).diz $(@F).debuginfo ; \
$(RM) $(@F).debuginfo ; \
)
# save ZIP'ed debug info with rest of the program's build artifacts
$(MV) $@.diz $(OBJDIR)
else
# save debug info with rest of the program's build artifacts
$(MV) $@.debuginfo $(OBJDIR)
endif
endif # PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS
endif # ENABLE_FULL_DEBUG_SYMBOLS
endif # PLATFORM-!macosx
endif # PLATFORM
endif # PLATFORM
clean::
clean::
...
@@ -240,12 +285,16 @@ ifeq ($(PLATFORM), windows)
...
@@ -240,12 +285,16 @@ ifeq ($(PLATFORM), windows)
$(RM) $(OBJDIR)/$(PROGRAM).ico
$(RM) $(OBJDIR)/$(PROGRAM).ico
$(RM) $(OBJDIR)/$(PROGRAM).lcf
$(RM) $(OBJDIR)/$(PROGRAM).lcf
$(RM) $(OBJDIR)/$(PROGRAM).map
$(RM) $(OBJDIR)/$(PROGRAM).map
$(RM) $(OBJDIR)/$(PROGRAM).pdb
$(RM) $(OBJDIR)/$(PROGRAM).exp
$(RM) $(OBJDIR)/$(PROGRAM).exp
$(RM) $(OBJDIR)/$(PROGRAM).lib
$(RM) $(OBJDIR)/$(PROGRAM).lib
$(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
$(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
$(RM) $(OBJDIR)/$(PROGRAM).ilk
$(RM) $(OBJDIR)/$(PROGRAM).ilk
$(RM) *.pdb
$(RM) *.pdb
else
$(RM) $(OBJDIR)/$(PROGRAM).debuginfo
endif
endif
$(RM) $(OBJDIR)/$(PROGRAM).diz
clobber::
clobber::
...
...
make/common/Release.gmk
浏览文件 @
cb0fea8f
...
@@ -873,7 +873,9 @@ ifeq ($(PLATFORM), windows)
...
@@ -873,7 +873,9 @@ ifeq ($(PLATFORM), windows)
-o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
-o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
else
else
$(FIND) $(JRE_IMAGE_DIR)/lib -type f -name \*.$(LIB_SUFFIX) >> $@
$(FIND) $(JRE_IMAGE_DIR)/lib -type f -name \*.$(LIB_SUFFIX) >> $@
$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
# The FILE command reports .debuginfo files as "ELF", but we don't want
# those files in the JRE_BIN_LIST file. EXE_SUFFIX is empty on non-Windows.
$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
endif
endif
...
@@ -1140,9 +1142,11 @@ ifeq ($(PLATFORM), windows)
...
@@ -1140,9 +1142,11 @@ ifeq ($(PLATFORM), windows)
else
else
$(RM) $@
$(RM) $@
$(FIND) $(JDK_IMAGE_DIR)/jre/lib -type f -name \*.$(LIB_SUFFIX) >> $@
$(FIND) $(JDK_IMAGE_DIR)/jre/lib -type f -name \*.$(LIB_SUFFIX) >> $@
$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*$(EXE_SUFFIX)` \
# The FILE command reports .debuginfo files as "ELF", but we don't want
# those files in the JDK_BIN_LIST file. EXE_SUFFIX is empty on non-Windows.
$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f
! -name '*.debuginfo'
-name \*$(EXE_SUFFIX)` \
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
endif
endif
...
...
make/java/instrument/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2003, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2003, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
# Makefile for building the Java Programming Language Instrumentation Services
# Makefile for building the Java Programming Language Instrumentation Services
# agent, supporting java.lang.instrument
# agent, supporting java.lang.instrument
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../..
BUILDDIR
=
../..
PACKAGE
=
sun.instrument
PACKAGE
=
sun.instrument
LIBRARY
=
instrument
LIBRARY
=
instrument
...
...
make/java/java/reflect/Makefile
浏览文件 @
cb0fea8f
...
@@ -36,7 +36,7 @@ include $(BUILDDIR)/common/Defs.gmk
...
@@ -36,7 +36,7 @@ include $(BUILDDIR)/common/Defs.gmk
#
#
# Files to compile.
# Files to compile.
#
#
AUTO_FILES_JAVA_DIRS
=
java/lang/reflect sun/reflect
AUTO_FILES_JAVA_DIRS
=
java/lang/reflect sun/reflect
java/lang/annotation
#
#
# Install .lib file.
# Install .lib file.
...
...
make/java/java_crw_demo/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../..
BUILDDIR
=
../..
LIBRARY
=
java_crw_demo
LIBRARY
=
java_crw_demo
...
...
make/java/java_hprof_demo/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2003, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2003, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../..
BUILDDIR
=
../..
LIBRARY
=
hprof
LIBRARY
=
hprof
PRODUCT
=
sun
PRODUCT
=
sun
...
...
make/java/main/java/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 1996, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1996, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PROGRAM
=
java
PROGRAM
=
java
PRODUCT
=
java
PRODUCT
=
java
...
...
make/java/management/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2003, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2003, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../..
BUILDDIR
=
../..
PACKAGE
=
java.lang.management
PACKAGE
=
java.lang.management
LIBRARY
=
management
LIBRARY
=
management
...
...
make/java/npt/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../..
BUILDDIR
=
../..
# It's currently used by jpda and hprof. Put it in base module for now.
# It's currently used by jpda and hprof. Put it in base module for now.
...
...
make/java/verify/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 1999, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1999, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -27,6 +27,8 @@
...
@@ -27,6 +27,8 @@
# Build libverify.so
# Build libverify.so
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../..
BUILDDIR
=
../..
PRODUCT
=
java
PRODUCT
=
java
LIBRARY
=
verify
LIBRARY
=
verify
...
...
make/jpda/jdwp/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2000, 20
05
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2000, 20
12
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -27,6 +27,8 @@
...
@@ -27,6 +27,8 @@
# Makefile for building JDWP
# Makefile for building JDWP
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../..
BUILDDIR
=
../..
PACKAGE
=
com.sun.tools.jdwp
PACKAGE
=
com.sun.tools.jdwp
PRODUCT
=
jpda
PRODUCT
=
jpda
...
...
make/jpda/transport/socket/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 1998, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1998, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -27,6 +27,8 @@
...
@@ -27,6 +27,8 @@
# Makefile for building the JDI back-end implementation
# Makefile for building the JDI back-end implementation
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
LIBRARY
=
dt_socket
LIBRARY
=
dt_socket
PRODUCT
=
jbug
PRODUCT
=
jbug
...
...
make/launchers/Makefile.launcher
浏览文件 @
cb0fea8f
...
@@ -27,6 +27,8 @@
...
@@ -27,6 +27,8 @@
# Makefile for building simple launchers
# Makefile for building simple launchers
#
#
PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
..
BUILDDIR
=
..
PACKAGE
=
launcher
PACKAGE
=
launcher
PRODUCT
=
sun
PRODUCT
=
sun
...
...
make/mkdemo/jvmti/compiledMethodLoad/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2010,
2012,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
compiledMethodLoad
DEMONAME
=
compiledMethodLoad
...
...
make/mkdemo/jvmti/gctest/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004,
2012,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
gctest
DEMONAME
=
gctest
...
...
make/mkdemo/jvmti/heapTracker/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004,
2012,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
heapTracker
DEMONAME
=
heapTracker
...
...
make/mkdemo/jvmti/heapViewer/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004,
2012,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
heapViewer
DEMONAME
=
heapViewer
...
...
make/mkdemo/jvmti/hprof/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, 201
0
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
hprof
DEMONAME
=
hprof
...
...
make/mkdemo/jvmti/minst/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006,
2012,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
minst
DEMONAME
=
minst
...
...
make/mkdemo/jvmti/mtrace/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004,
2012,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
mtrace
DEMONAME
=
mtrace
...
...
make/mkdemo/jvmti/versionCheck/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004,
2012,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
versionCheck
DEMONAME
=
versionCheck
...
...
make/mkdemo/jvmti/waiters/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004,
2012,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
# questions.
# questions.
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PRODUCT
=
demo/jvmti
PRODUCT
=
demo/jvmti
DEMONAME
=
waiters
DEMONAME
=
waiters
...
...
make/sun/tracing/dtrace/Makefile
浏览文件 @
cb0fea8f
#
#
# Copyright (c) 2008, 201
1
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2008, 201
2
, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -26,6 +26,9 @@
...
@@ -26,6 +26,9 @@
#
#
# Makefile for building dtrace extension
# Makefile for building dtrace extension
#
#
LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
=
1
BUILDDIR
=
../../..
BUILDDIR
=
../../..
PACKAGE
=
sun.tracing.dtrace
PACKAGE
=
sun.tracing.dtrace
LIBRARY
=
jsdt
LIBRARY
=
jsdt
...
...
src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
浏览文件 @
cb0fea8f
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
*
*
* This code is free software; you can redistribute it and/or modify it
* 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
@@ -40,7 +42,7 @@ public class DefaultSelectorProvider {
...
@@ -40,7 +42,7 @@ public class DefaultSelectorProvider {
* Returns the default SelectorProvider.
* Returns the default SelectorProvider.
*/
*/
public
static
SelectorProvider
create
()
{
public
static
SelectorProvider
create
()
{
return
new
sun
.
nio
.
ch
.
Poll
SelectorProvider
();
return
new
sun
.
nio
.
ch
.
KQueue
SelectorProvider
();
}
}
}
}
src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java
浏览文件 @
cb0fea8f
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
*
*
* This code is free software; you can redistribute it and/or modify it
* 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
@@ -64,8 +66,8 @@ class KQueueArrayWrapper {
...
@@ -64,8 +66,8 @@ class KQueueArrayWrapper {
static
short
FD_OFFSET
;
static
short
FD_OFFSET
;
static
short
FILTER_OFFSET
;
static
short
FILTER_OFFSET
;
// kevent array size
(just under 1K bytes)
// kevent array size
static
final
int
NUM_KEVENTS
=
50
;
static
final
int
NUM_KEVENTS
=
128
;
// Are we in a 64-bit VM?
// Are we in a 64-bit VM?
static
boolean
is64bit
=
false
;
static
boolean
is64bit
=
false
;
...
...
src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java
浏览文件 @
cb0fea8f
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
*
*
* This code is free software; you can redistribute it and/or modify it
* 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
@@ -49,8 +51,8 @@ class KQueueSelectorImpl
...
@@ -49,8 +51,8 @@ class KQueueSelectorImpl
// Count of registered descriptors (including interrupt)
// Count of registered descriptors (including interrupt)
private
int
totalChannels
;
private
int
totalChannels
;
// Map from
file descriptors to selection keys
// Map from
a file descriptor to an entry containing the selection key
private
HashMap
<
Integer
,
SelectionKeyImpl
>
fdToKey
;
private
HashMap
<
Integer
,
MapEntry
>
fdMap
;
// True if this Selector has been closed
// True if this Selector has been closed
private
boolean
closed
=
false
;
private
boolean
closed
=
false
;
...
@@ -59,6 +61,20 @@ class KQueueSelectorImpl
...
@@ -59,6 +61,20 @@ class KQueueSelectorImpl
private
Object
interruptLock
=
new
Object
();
private
Object
interruptLock
=
new
Object
();
private
boolean
interruptTriggered
=
false
;
private
boolean
interruptTriggered
=
false
;
// used by updateSelectedKeys to handle cases where the same file
// descriptor is polled by more than one filter
private
long
updateCount
;
// Used to map file descriptors to a selection key and "update count"
// (see updateSelectedKeys for usage).
private
static
class
MapEntry
{
SelectionKeyImpl
ski
;
long
updateCount
;
MapEntry
(
SelectionKeyImpl
ski
)
{
this
.
ski
=
ski
;
}
}
/**
/**
* Package private constructor called by factory method in
* Package private constructor called by factory method in
* the abstract superclass Selector.
* the abstract superclass Selector.
...
@@ -70,7 +86,7 @@ class KQueueSelectorImpl
...
@@ -70,7 +86,7 @@ class KQueueSelectorImpl
fd1
=
(
int
)
fds
;
fd1
=
(
int
)
fds
;
kqueueWrapper
=
new
KQueueArrayWrapper
();
kqueueWrapper
=
new
KQueueArrayWrapper
();
kqueueWrapper
.
initInterrupt
(
fd0
,
fd1
);
kqueueWrapper
.
initInterrupt
(
fd0
,
fd1
);
fd
ToKey
=
new
HashMap
<>();
fd
Map
=
new
HashMap
<>();
totalChannels
=
1
;
totalChannels
=
1
;
}
}
...
@@ -82,8 +98,6 @@ class KQueueSelectorImpl
...
@@ -82,8 +98,6 @@ class KQueueSelectorImpl
if
(
closed
)
if
(
closed
)
throw
new
ClosedSelectorException
();
throw
new
ClosedSelectorException
();
processDeregisterQueue
();
processDeregisterQueue
();
if
(
timeout
==
0
&&
totalChannels
==
1
)
return
0
;
try
{
try
{
begin
();
begin
();
entries
=
kqueueWrapper
.
poll
(
timeout
);
entries
=
kqueueWrapper
.
poll
(
timeout
);
...
@@ -94,10 +108,9 @@ class KQueueSelectorImpl
...
@@ -94,10 +108,9 @@ class KQueueSelectorImpl
return
updateSelectedKeys
(
entries
);
return
updateSelectedKeys
(
entries
);
}
}
/**
/**
* Update the keys whose fd's have been selected by
the devpoll
* Update the keys whose fd's have been selected by
kqueue.
*
driver. Add the ready keys to the ready queue
.
*
Add the ready keys to the selected key set
.
* If the interrupt fd has been selected, drain it and clear the interrupt.
* If the interrupt fd has been selected, drain it and clear the interrupt.
*/
*/
private
int
updateSelectedKeys
(
int
entries
)
private
int
updateSelectedKeys
(
int
entries
)
...
@@ -106,24 +119,42 @@ class KQueueSelectorImpl
...
@@ -106,24 +119,42 @@ class KQueueSelectorImpl
int
numKeysUpdated
=
0
;
int
numKeysUpdated
=
0
;
boolean
interrupted
=
false
;
boolean
interrupted
=
false
;
// A file descriptor may be registered with kqueue with more than one
// filter and so there may be more than one event for a fd. The update
// count in the MapEntry tracks when the fd was last updated and this
// ensures that the ready ops are updated rather than replaced by a
// second or subsequent event.
updateCount
++;
for
(
int
i
=
0
;
i
<
entries
;
i
++)
{
for
(
int
i
=
0
;
i
<
entries
;
i
++)
{
int
nextFD
=
kqueueWrapper
.
getDescriptor
(
i
);
int
nextFD
=
kqueueWrapper
.
getDescriptor
(
i
);
if
(
nextFD
==
fd0
)
{
if
(
nextFD
==
fd0
)
{
interrupted
=
true
;
interrupted
=
true
;
}
else
{
}
else
{
SelectionKeyImpl
ski
=
fdToKey
.
get
(
new
Integer
(
nextFD
));
MapEntry
me
=
fdMap
.
get
(
Integer
.
valueOf
(
nextFD
));
// ski is null in the case of an interrupt
if
(
ski
!=
null
)
{
// entry is null in the case of an interrupt
if
(
me
!=
null
)
{
int
rOps
=
kqueueWrapper
.
getReventOps
(
i
);
int
rOps
=
kqueueWrapper
.
getReventOps
(
i
);
SelectionKeyImpl
ski
=
me
.
ski
;
if
(
selectedKeys
.
contains
(
ski
))
{
if
(
selectedKeys
.
contains
(
ski
))
{
// first time this file descriptor has been encountered on this
// update?
if
(
me
.
updateCount
!=
updateCount
)
{
if
(
ski
.
channel
.
translateAndSetReadyOps
(
rOps
,
ski
))
{
if
(
ski
.
channel
.
translateAndSetReadyOps
(
rOps
,
ski
))
{
numKeysUpdated
++;
numKeysUpdated
++;
me
.
updateCount
=
updateCount
;
}
}
else
{
// ready ops have already been set on this update
ski
.
channel
.
translateAndUpdateReadyOps
(
rOps
,
ski
);
}
}
}
else
{
}
else
{
ski
.
channel
.
translateAndSetReadyOps
(
rOps
,
ski
);
ski
.
channel
.
translateAndSetReadyOps
(
rOps
,
ski
);
if
((
ski
.
readyOps
()
&
ski
.
i
nterestOps
())
!=
0
)
{
if
((
ski
.
nioReadyOps
()
&
ski
.
nioI
nterestOps
())
!=
0
)
{
selectedKeys
.
add
(
ski
);
selectedKeys
.
add
(
ski
);
numKeysUpdated
++;
numKeysUpdated
++;
me
.
updateCount
=
updateCount
;
}
}
}
}
}
}
...
@@ -137,7 +168,6 @@ class KQueueSelectorImpl
...
@@ -137,7 +168,6 @@ class KQueueSelectorImpl
interruptTriggered
=
false
;
interruptTriggered
=
false
;
}
}
}
}
return
numKeysUpdated
;
return
numKeysUpdated
;
}
}
...
@@ -145,6 +175,12 @@ class KQueueSelectorImpl
...
@@ -145,6 +175,12 @@ class KQueueSelectorImpl
protected
void
implClose
()
throws
IOException
{
protected
void
implClose
()
throws
IOException
{
if
(!
closed
)
{
if
(!
closed
)
{
closed
=
true
;
closed
=
true
;
// prevent further wakeup
synchronized
(
interruptLock
)
{
interruptTriggered
=
true
;
}
FileDispatcherImpl
.
closeIntFD
(
fd0
);
FileDispatcherImpl
.
closeIntFD
(
fd0
);
FileDispatcherImpl
.
closeIntFD
(
fd1
);
FileDispatcherImpl
.
closeIntFD
(
fd1
);
if
(
kqueueWrapper
!=
null
)
{
if
(
kqueueWrapper
!=
null
)
{
...
@@ -172,8 +208,10 @@ class KQueueSelectorImpl
...
@@ -172,8 +208,10 @@ class KQueueSelectorImpl
protected
void
implRegister
(
SelectionKeyImpl
ski
)
{
protected
void
implRegister
(
SelectionKeyImpl
ski
)
{
if
(
closed
)
throw
new
ClosedSelectorException
();
int
fd
=
IOUtil
.
fdVal
(
ski
.
channel
.
getFD
());
int
fd
=
IOUtil
.
fdVal
(
ski
.
channel
.
getFD
());
fd
ToKey
.
put
(
new
Integer
(
fd
),
ski
);
fd
Map
.
put
(
Integer
.
valueOf
(
fd
),
new
MapEntry
(
ski
)
);
totalChannels
++;
totalChannels
++;
keys
.
add
(
ski
);
keys
.
add
(
ski
);
}
}
...
@@ -181,7 +219,7 @@ class KQueueSelectorImpl
...
@@ -181,7 +219,7 @@ class KQueueSelectorImpl
protected
void
implDereg
(
SelectionKeyImpl
ski
)
throws
IOException
{
protected
void
implDereg
(
SelectionKeyImpl
ski
)
throws
IOException
{
int
fd
=
ski
.
channel
.
getFDVal
();
int
fd
=
ski
.
channel
.
getFDVal
();
fd
ToKey
.
remove
(
new
Integer
(
fd
));
fd
Map
.
remove
(
Integer
.
valueOf
(
fd
));
kqueueWrapper
.
release
(
fd
);
kqueueWrapper
.
release
(
fd
);
totalChannels
--;
totalChannels
--;
keys
.
remove
(
ski
);
keys
.
remove
(
ski
);
...
@@ -194,6 +232,8 @@ class KQueueSelectorImpl
...
@@ -194,6 +232,8 @@ class KQueueSelectorImpl
public
void
putEventOps
(
SelectionKeyImpl
ski
,
int
ops
)
{
public
void
putEventOps
(
SelectionKeyImpl
ski
,
int
ops
)
{
if
(
closed
)
throw
new
ClosedSelectorException
();
int
fd
=
IOUtil
.
fdVal
(
ski
.
channel
.
getFD
());
int
fd
=
IOUtil
.
fdVal
(
ski
.
channel
.
getFD
());
kqueueWrapper
.
setInterest
(
fd
,
ops
);
kqueueWrapper
.
setInterest
(
fd
,
ops
);
}
}
...
...
src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java
浏览文件 @
cb0fea8f
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
*
*
* This code is free software; you can redistribute it and/or modify it
* 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c
浏览文件 @
cb0fea8f
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
*
*
* This code is free software; you can redistribute it and/or modify it
* 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java
浏览文件 @
cb0fea8f
...
@@ -114,6 +114,23 @@ class VMConnection {
...
@@ -114,6 +114,23 @@ class VMConnection {
String
value
=
token
.
substring
(
index
+
1
,
String
value
=
token
.
substring
(
index
+
1
,
token
.
length
()
-
1
);
// Remove comma delimiter
token
.
length
()
-
1
);
// Remove comma delimiter
/*
* for values enclosed in quotes (single and/or double quotes)
* strip off enclosing quote chars
* needed for quote enclosed delimited substrings
*/
if
(
name
.
equals
(
"options"
))
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
s
:
splitStringAtNonEnclosedWhiteSpace
(
value
))
{
while
(
isEnclosed
(
s
,
"\""
)
||
isEnclosed
(
s
,
"'"
))
{
s
=
s
.
substring
(
1
,
s
.
length
()
-
1
);
}
sb
.
append
(
s
);
sb
.
append
(
" "
);
}
value
=
sb
.
toString
();
}
Connector
.
Argument
argument
=
arguments
.
get
(
name
);
Connector
.
Argument
argument
=
arguments
.
get
(
name
);
if
(
argument
==
null
)
{
if
(
argument
==
null
)
{
throw
new
IllegalArgumentException
throw
new
IllegalArgumentException
...
@@ -136,6 +153,152 @@ class VMConnection {
...
@@ -136,6 +153,152 @@ class VMConnection {
return
arguments
;
return
arguments
;
}
}
private
static
boolean
isEnclosed
(
String
value
,
String
enclosingChar
)
{
if
(
value
.
indexOf
(
enclosingChar
)
==
0
)
{
int
lastIndex
=
value
.
lastIndexOf
(
enclosingChar
);
if
(
lastIndex
>
0
&&
lastIndex
==
value
.
length
()
-
1
)
{
return
true
;
}
}
return
false
;
}
private
static
List
<
String
>
splitStringAtNonEnclosedWhiteSpace
(
String
value
)
throws
IllegalArgumentException
{
List
<
String
>
al
=
new
ArrayList
<
String
>();
char
[]
arr
;
int
startPosition
=
0
;
int
endPosition
=
0
;
final
char
SPACE
=
' '
;
final
char
DOUBLEQ
=
'"'
;
final
char
SINGLEQ
=
'\''
;
/*
* An "open" or "active" enclosing state is where
* the first valid start quote qualifier is found,
* and there is a search in progress for the
* relevant end matching quote
*
* enclosingTargetChar set to SPACE
* is used to signal a non open enclosing state
*/
char
enclosingTargetChar
=
SPACE
;
if
(
value
==
null
)
{
throw
new
IllegalArgumentException
(
MessageOutput
.
format
(
"value string is null"
));
}
// split parameter string into individual chars
arr
=
value
.
toCharArray
();
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
switch
(
arr
[
i
])
{
case
SPACE:
{
// do nothing for spaces
// unless last in array
if
(
isLastChar
(
arr
,
i
))
{
endPosition
=
i
;
// break for substring creation
break
;
}
continue
;
}
case
DOUBLEQ:
case
SINGLEQ:
{
if
(
enclosingTargetChar
==
arr
[
i
])
{
// potential match to close open enclosing
if
(
isNextCharWhitespace
(
arr
,
i
))
{
// if peek next is whitespace
// then enclosing is a valid substring
endPosition
=
i
;
// reset enclosing target char
enclosingTargetChar
=
SPACE
;
// break for substring creation
break
;
}
}
if
(
enclosingTargetChar
==
SPACE
)
{
// no open enclosing state
// handle as normal char
if
(
isPreviousCharWhitespace
(
arr
,
i
))
{
startPosition
=
i
;
// peek forward for end candidates
if
(
value
.
indexOf
(
arr
[
i
],
i
+
1
)
>=
0
)
{
// set open enclosing state by
// setting up the target char
enclosingTargetChar
=
arr
[
i
];
}
else
{
// no more target chars left to match
// end enclosing, handle as normal char
if
(
isNextCharWhitespace
(
arr
,
i
))
{
endPosition
=
i
;
// break for substring creation
break
;
}
}
}
}
continue
;
}
default
:
{
// normal non-space, non-" and non-' chars
if
(
enclosingTargetChar
==
SPACE
)
{
// no open enclosing state
if
(
isPreviousCharWhitespace
(
arr
,
i
))
{
// start of space delim substring
startPosition
=
i
;
}
if
(
isNextCharWhitespace
(
arr
,
i
))
{
// end of space delim substring
endPosition
=
i
;
// break for substring creation
break
;
}
}
continue
;
}
}
// break's end up here
if
(
startPosition
>
endPosition
)
{
throw
new
IllegalArgumentException
(
MessageOutput
.
format
(
"Illegal option values"
));
}
// extract substring and add to List<String>
al
.
add
(
value
.
substring
(
startPosition
,
++
endPosition
));
// set new start position
i
=
startPosition
=
endPosition
;
}
// for loop
return
al
;
}
static
private
boolean
isPreviousCharWhitespace
(
char
[]
arr
,
int
curr_pos
)
{
return
isCharWhitespace
(
arr
,
curr_pos
-
1
);
}
static
private
boolean
isNextCharWhitespace
(
char
[]
arr
,
int
curr_pos
)
{
return
isCharWhitespace
(
arr
,
curr_pos
+
1
);
}
static
private
boolean
isCharWhitespace
(
char
[]
arr
,
int
pos
)
{
if
(
pos
<
0
||
pos
>=
arr
.
length
)
{
// outside arraybounds is considered an implicit space
return
true
;
}
if
(
arr
[
pos
]
==
' '
)
{
return
true
;
}
return
false
;
}
static
private
boolean
isLastChar
(
char
[]
arr
,
int
pos
)
{
return
(
pos
+
1
==
arr
.
length
);
}
VMConnection
(
String
connectSpec
,
int
traceFlags
)
{
VMConnection
(
String
connectSpec
,
int
traceFlags
)
{
String
nameString
;
String
nameString
;
String
argString
;
String
argString
;
...
...
src/share/classes/java/net/HttpCookie.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -616,9 +616,6 @@ public final class HttpCookie implements Cloneable {
...
@@ -616,9 +616,6 @@ public final class HttpCookie implements Cloneable {
* would be accepted.</li>
* would be accepted.</li>
* <li>A Set-Cookie2 with Domain=.com or Domain=.com., will always be
* <li>A Set-Cookie2 with Domain=.com or Domain=.com., will always be
* rejected, because there is no embedded dot.</li>
* rejected, because there is no embedded dot.</li>
* <li>A Set-Cookie2 with Domain=ajax.com will be accepted, and the
* value for Domain will be taken to be .ajax.com, because a dot
* gets prepended to the value.</li>
* <li>A Set-Cookie2 from request-host example for Domain=.local will
* <li>A Set-Cookie2 from request-host example for Domain=.local will
* be accepted, because the effective host name for the request-
* be accepted, because the effective host name for the request-
* host is example.local, and example.local domain-matches .local.</li>
* host is example.local, and example.local domain-matches .local.</li>
...
...
src/share/classes/java/nio/file/Files.java
浏览文件 @
cb0fea8f
...
@@ -269,7 +269,7 @@ public final class Files {
...
@@ -269,7 +269,7 @@ public final class Files {
* WritableByteChannel wbc = Files.newByteChannel(path, EnumSet.of(CREATE,APPEND));
* WritableByteChannel wbc = Files.newByteChannel(path, EnumSet.of(CREATE,APPEND));
*
*
* // create file with initial permissions, opening it for both reading and writing
* // create file with initial permissions, opening it for both reading and writing
* {@code FileAttribute<
<Set
PosixFilePermission>> perms = ...}
* {@code FileAttribute<
Set<
PosixFilePermission>> perms = ...}
* SeekableByteChannel sbc = Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms);
* SeekableByteChannel sbc = Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms);
* </pre>
* </pre>
*
*
...
...
src/share/classes/java/security/CodeSource.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 1997, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -114,7 +114,7 @@ public class CodeSource implements java.io.Serializable {
...
@@ -114,7 +114,7 @@ public class CodeSource implements java.io.Serializable {
*
*
* @return a hash code value for this object.
* @return a hash code value for this object.
*/
*/
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
if
(
location
!=
null
)
if
(
location
!=
null
)
return
location
.
hashCode
();
return
location
.
hashCode
();
...
@@ -133,6 +133,7 @@ public class CodeSource implements java.io.Serializable {
...
@@ -133,6 +133,7 @@ public class CodeSource implements java.io.Serializable {
*
*
* @return true if the objects are considered equal, false otherwise.
* @return true if the objects are considered equal, false otherwise.
*/
*/
@Override
public
boolean
equals
(
Object
obj
)
{
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
this
)
if
(
obj
==
this
)
return
true
;
return
true
;
...
@@ -231,10 +232,10 @@ public class CodeSource implements java.io.Serializable {
...
@@ -231,10 +232,10 @@ public class CodeSource implements java.io.Serializable {
/**
/**
* Returns true if this CodeSource object "implies" the specified CodeSource.
* Returns true if this CodeSource object "implies" the specified CodeSource.
* <
P
>
* <
p
>
* More specifically, this method makes the following checks
, in order
.
* More specifically, this method makes the following checks.
* If any fail, it returns false. If they all succeed, it returns true.<p>
* If any fail, it returns false. If they all succeed, it returns true.<p>
* <
o
l>
* <
u
l>
* <li> <i>codesource</i> must not be null.
* <li> <i>codesource</i> must not be null.
* <li> If this object's certificates are not null, then all
* <li> If this object's certificates are not null, then all
* of this object's certificates must be present in <i>codesource</i>'s
* of this object's certificates must be present in <i>codesource</i>'s
...
@@ -242,14 +243,14 @@ public class CodeSource implements java.io.Serializable {
...
@@ -242,14 +243,14 @@ public class CodeSource implements java.io.Serializable {
* <li> If this object's location (getLocation()) is not null, then the
* <li> If this object's location (getLocation()) is not null, then the
* following checks are made against this object's location and
* following checks are made against this object's location and
* <i>codesource</i>'s:<p>
* <i>codesource</i>'s:<p>
* <
o
l>
* <
u
l>
* <li> <i>codesource</i>'s location must not be null.
* <li> <i>codesource</i>'s location must not be null.
*
*
* <li> If this object's location
* <li> If this object's location
* equals <i>codesource</i>'s location, then return true.
* equals <i>codesource</i>'s location, then return true.
*
*
* <li> This object's protocol (getLocation().getProtocol()) must be
* <li> This object's protocol (getLocation().getProtocol()) must be
* equal to <i>codesource</i>'s protocol.
* equal to <i>codesource</i>'s protocol
, ignoring case
.
*
*
* <li> If this object's host (getLocation().getHost()) is not null,
* <li> If this object's host (getLocation().getHost()) is not null,
* then the SocketPermission
* then the SocketPermission
...
@@ -258,7 +259,8 @@ public class CodeSource implements java.io.Serializable {
...
@@ -258,7 +259,8 @@ public class CodeSource implements java.io.Serializable {
*
*
* <li> If this object's port (getLocation().getPort()) is not
* <li> If this object's port (getLocation().getPort()) is not
* equal to -1 (that is, if a port is specified), it must equal
* equal to -1 (that is, if a port is specified), it must equal
* <i>codesource</i>'s port.
* <i>codesource</i>'s port or default port
* (codesource.getLocation().getDefaultPort()).
*
*
* <li> If this object's file (getLocation().getFile()) doesn't equal
* <li> If this object's file (getLocation().getFile()) doesn't equal
* <i>codesource</i>'s file, then the following checks are made:
* <i>codesource</i>'s file, then the following checks are made:
...
@@ -275,8 +277,8 @@ public class CodeSource implements java.io.Serializable {
...
@@ -275,8 +277,8 @@ public class CodeSource implements java.io.Serializable {
* <li> If this object's reference (getLocation().getRef()) is
* <li> If this object's reference (getLocation().getRef()) is
* not null, it must equal <i>codesource</i>'s reference.
* not null, it must equal <i>codesource</i>'s reference.
*
*
* </
o
l>
* </
u
l>
* </
o
l>
* </
u
l>
* <p>
* <p>
* For example, the codesource objects with the following locations
* For example, the codesource objects with the following locations
* and null certificates all imply
* and null certificates all imply
...
@@ -369,11 +371,9 @@ public class CodeSource implements java.io.Serializable {
...
@@ -369,11 +371,9 @@ public class CodeSource implements java.io.Serializable {
*
*
* @param that CodeSource to compare against
* @param that CodeSource to compare against
*/
*/
private
boolean
matchLocation
(
CodeSource
that
)
private
boolean
matchLocation
(
CodeSource
that
)
{
{
if
(
location
==
null
)
if
(
location
==
null
)
{
return
true
;
return
true
;
}
if
((
that
==
null
)
||
(
that
.
location
==
null
))
if
((
that
==
null
)
||
(
that
.
location
==
null
))
return
false
;
return
false
;
...
@@ -381,34 +381,15 @@ public class CodeSource implements java.io.Serializable {
...
@@ -381,34 +381,15 @@ public class CodeSource implements java.io.Serializable {
if
(
location
.
equals
(
that
.
location
))
if
(
location
.
equals
(
that
.
location
))
return
true
;
return
true
;
if
(!
location
.
getProtocol
().
equals
(
that
.
location
.
getProtocol
()))
if
(!
location
.
getProtocol
().
equalsIgnoreCase
(
that
.
location
.
getProtocol
()))
return
false
;
return
false
;
String
thisHost
=
location
.
getHost
();
int
thisPort
=
location
.
getPort
();
String
thatHost
=
that
.
location
.
getHost
();
if
(
thisPort
!=
-
1
)
{
int
thatPort
=
that
.
location
.
getPort
();
if
(
thisHost
!=
null
)
{
int
port
=
thatPort
!=
-
1
?
thatPort
if
((
""
.
equals
(
thisHost
)
||
"localhost"
.
equals
(
thisHost
))
&&
:
that
.
location
.
getDefaultPort
();
(
""
.
equals
(
thatHost
)
||
"localhost"
.
equals
(
thatHost
)))
{
if
(
thisPort
!=
port
)
// ok
}
else
if
(!
thisHost
.
equals
(
thatHost
))
{
if
(
thatHost
==
null
)
{
return
false
;
}
if
(
this
.
sp
==
null
)
{
this
.
sp
=
new
SocketPermission
(
thisHost
,
"resolve"
);
}
if
(
that
.
sp
==
null
)
{
that
.
sp
=
new
SocketPermission
(
thatHost
,
"resolve"
);
}
if
(!
this
.
sp
.
implies
(
that
.
sp
))
{
return
false
;
}
}
}
if
(
location
.
getPort
()
!=
-
1
)
{
if
(
location
.
getPort
()
!=
that
.
location
.
getPort
())
return
false
;
return
false
;
}
}
...
@@ -443,10 +424,34 @@ public class CodeSource implements java.io.Serializable {
...
@@ -443,10 +424,34 @@ public class CodeSource implements java.io.Serializable {
}
}
}
}
if
(
location
.
getRef
()
==
null
)
if
(
location
.
getRef
()
!=
null
&&
!
location
.
getRef
().
equals
(
that
.
location
.
getRef
()))
{
return
false
;
}
String
thisHost
=
location
.
getHost
();
String
thatHost
=
that
.
location
.
getHost
();
if
(
thisHost
!=
null
)
{
if
((
""
.
equals
(
thisHost
)
||
"localhost"
.
equals
(
thisHost
))
&&
(
""
.
equals
(
thatHost
)
||
"localhost"
.
equals
(
thatHost
)))
{
// ok
}
else
if
(!
thisHost
.
equals
(
thatHost
))
{
if
(
thatHost
==
null
)
{
return
false
;
}
if
(
this
.
sp
==
null
)
{
this
.
sp
=
new
SocketPermission
(
thisHost
,
"resolve"
);
}
if
(
that
.
sp
==
null
)
{
that
.
sp
=
new
SocketPermission
(
thatHost
,
"resolve"
);
}
if
(!
this
.
sp
.
implies
(
that
.
sp
))
{
return
false
;
}
}
}
// everything matches
return
true
;
return
true
;
else
return
location
.
getRef
().
equals
(
that
.
location
.
getRef
());
}
}
/**
/**
...
@@ -455,6 +460,7 @@ public class CodeSource implements java.io.Serializable {
...
@@ -455,6 +460,7 @@ public class CodeSource implements java.io.Serializable {
*
*
* @return information about this CodeSource.
* @return information about this CodeSource.
*/
*/
@Override
public
String
toString
()
{
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"("
);
sb
.
append
(
"("
);
...
...
src/share/classes/java/util/AbstractCollection.java
浏览文件 @
cb0fea8f
...
@@ -170,6 +170,7 @@ public abstract class AbstractCollection<E> implements Collection<E> {
...
@@ -170,6 +170,7 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @throws ArrayStoreException {@inheritDoc}
* @throws ArrayStoreException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
// Estimate size of array; be prepared to see more or fewer elements
// Estimate size of array; be prepared to see more or fewer elements
int
size
=
size
();
int
size
=
size
();
...
@@ -180,13 +181,21 @@ public abstract class AbstractCollection<E> implements Collection<E> {
...
@@ -180,13 +181,21 @@ public abstract class AbstractCollection<E> implements Collection<E> {
for
(
int
i
=
0
;
i
<
r
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
r
.
length
;
i
++)
{
if
(!
it
.
hasNext
())
{
// fewer elements than expected
if
(!
it
.
hasNext
())
{
// fewer elements than expected
if
(
a
!=
r
)
if
(
a
==
r
)
{
return
Arrays
.
copyOf
(
r
,
i
);
r
[
i
]
=
null
;
// null-terminate
r
[
i
]
=
null
;
// null-terminate
return
r
;
}
else
if
(
a
.
length
<
i
)
{
return
Arrays
.
copyOf
(
r
,
i
);
}
else
{
System
.
arraycopy
(
r
,
0
,
a
,
0
,
i
);
if
(
a
.
length
>
i
)
{
a
[
i
]
=
null
;
}
}
return
a
;
}
}
r
[
i
]
=
(
T
)
it
.
next
();
r
[
i
]
=
(
T
)
it
.
next
();
}
}
// more elements than expected
return
it
.
hasNext
()
?
finishToArray
(
r
,
it
)
:
r
;
return
it
.
hasNext
()
?
finishToArray
(
r
,
it
)
:
r
;
}
}
...
@@ -208,6 +217,7 @@ public abstract class AbstractCollection<E> implements Collection<E> {
...
@@ -208,6 +217,7 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @return array containing the elements in the given array, plus any
* @return array containing the elements in the given array, plus any
* further elements returned by the iterator, trimmed to size
* further elements returned by the iterator, trimmed to size
*/
*/
@SuppressWarnings
(
"unchecked"
)
private
static
<
T
>
T
[]
finishToArray
(
T
[]
r
,
Iterator
<?>
it
)
{
private
static
<
T
>
T
[]
finishToArray
(
T
[]
r
,
Iterator
<?>
it
)
{
int
i
=
r
.
length
;
int
i
=
r
.
length
;
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
...
...
src/share/classes/java/util/AbstractList.java
浏览文件 @
cb0fea8f
...
@@ -516,7 +516,7 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
...
@@ -516,7 +516,7 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
return
false
;
return
false
;
ListIterator
<
E
>
e1
=
listIterator
();
ListIterator
<
E
>
e1
=
listIterator
();
ListIterator
e2
=
((
List
)
o
).
listIterator
();
ListIterator
<?>
e2
=
((
List
<?>
)
o
).
listIterator
();
while
(
e1
.
hasNext
()
&&
e2
.
hasNext
())
{
while
(
e1
.
hasNext
()
&&
e2
.
hasNext
())
{
E
o1
=
e1
.
next
();
E
o1
=
e1
.
next
();
Object
o2
=
e2
.
next
();
Object
o2
=
e2
.
next
();
...
...
src/share/classes/java/util/AbstractMap.java
浏览文件 @
cb0fea8f
...
@@ -443,7 +443,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
...
@@ -443,7 +443,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
if
(!(
o
instanceof
Map
))
if
(!(
o
instanceof
Map
))
return
false
;
return
false
;
Map
<
K
,
V
>
m
=
(
Map
<
K
,
V
>)
o
;
Map
<
?,?>
m
=
(
Map
<?,?
>)
o
;
if
(
m
.
size
()
!=
size
())
if
(
m
.
size
()
!=
size
())
return
false
;
return
false
;
...
@@ -534,7 +534,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
...
@@ -534,7 +534,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
* @return a shallow copy of this map
* @return a shallow copy of this map
*/
*/
protected
Object
clone
()
throws
CloneNotSupportedException
{
protected
Object
clone
()
throws
CloneNotSupportedException
{
AbstractMap
<
K
,
V
>
result
=
(
AbstractMap
<
K
,
V
>)
super
.
clone
();
AbstractMap
<
?,?>
result
=
(
AbstractMap
<?,?
>)
super
.
clone
();
result
.
keySet
=
null
;
result
.
keySet
=
null
;
result
.
values
=
null
;
result
.
values
=
null
;
return
result
;
return
result
;
...
@@ -652,7 +652,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
...
@@ -652,7 +652,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
public
boolean
equals
(
Object
o
)
{
public
boolean
equals
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
e
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
e
=
(
Map
.
Entry
<?,?>
)
o
;
return
eq
(
key
,
e
.
getKey
())
&&
eq
(
value
,
e
.
getValue
());
return
eq
(
key
,
e
.
getKey
())
&&
eq
(
value
,
e
.
getValue
());
}
}
...
@@ -783,7 +783,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
...
@@ -783,7 +783,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
public
boolean
equals
(
Object
o
)
{
public
boolean
equals
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
e
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
e
=
(
Map
.
Entry
<?,?>
)
o
;
return
eq
(
key
,
e
.
getKey
())
&&
eq
(
value
,
e
.
getValue
());
return
eq
(
key
,
e
.
getKey
())
&&
eq
(
value
,
e
.
getValue
());
}
}
...
...
src/share/classes/java/util/AbstractSet.java
浏览文件 @
cb0fea8f
...
@@ -88,7 +88,7 @@ public abstract class AbstractSet<E> extends AbstractCollection<E> implements Se
...
@@ -88,7 +88,7 @@ public abstract class AbstractSet<E> extends AbstractCollection<E> implements Se
if
(!(
o
instanceof
Set
))
if
(!(
o
instanceof
Set
))
return
false
;
return
false
;
Collection
c
=
(
Collection
)
o
;
Collection
<?>
c
=
(
Collection
<?>
)
o
;
if
(
c
.
size
()
!=
size
())
if
(
c
.
size
()
!=
size
())
return
false
;
return
false
;
try
{
try
{
...
...
src/share/classes/java/util/ArrayDeque.java
浏览文件 @
cb0fea8f
...
@@ -813,6 +813,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
...
@@ -813,6 +813,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
*/
*/
public
ArrayDeque
<
E
>
clone
()
{
public
ArrayDeque
<
E
>
clone
()
{
try
{
try
{
@SuppressWarnings
(
"unchecked"
)
ArrayDeque
<
E
>
result
=
(
ArrayDeque
<
E
>)
super
.
clone
();
ArrayDeque
<
E
>
result
=
(
ArrayDeque
<
E
>)
super
.
clone
();
result
.
elements
=
Arrays
.
copyOf
(
elements
,
elements
.
length
);
result
.
elements
=
Arrays
.
copyOf
(
elements
,
elements
.
length
);
return
result
;
return
result
;
...
@@ -849,6 +850,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
...
@@ -849,6 +850,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
/**
/**
* Deserialize this deque.
* Deserialize this deque.
*/
*/
@SuppressWarnings
(
"unchecked"
)
private
void
readObject
(
ObjectInputStream
s
)
private
void
readObject
(
ObjectInputStream
s
)
throws
IOException
,
ClassNotFoundException
{
throws
IOException
,
ClassNotFoundException
{
s
.
defaultReadObject
();
s
.
defaultReadObject
();
...
...
src/share/classes/java/util/ArrayList.java
浏览文件 @
cb0fea8f
...
@@ -300,8 +300,7 @@ public class ArrayList<E> extends AbstractList<E>
...
@@ -300,8 +300,7 @@ public class ArrayList<E> extends AbstractList<E>
*/
*/
public
Object
clone
()
{
public
Object
clone
()
{
try
{
try
{
@SuppressWarnings
(
"unchecked"
)
ArrayList
<?>
v
=
(
ArrayList
<?>)
super
.
clone
();
ArrayList
<
E
>
v
=
(
ArrayList
<
E
>)
super
.
clone
();
v
.
elementData
=
Arrays
.
copyOf
(
elementData
,
size
);
v
.
elementData
=
Arrays
.
copyOf
(
elementData
,
size
);
v
.
modCount
=
0
;
v
.
modCount
=
0
;
return
v
;
return
v
;
...
...
src/share/classes/java/util/Arrays.java
浏览文件 @
cb0fea8f
...
@@ -560,6 +560,7 @@ public class Arrays {
...
@@ -560,6 +560,7 @@ public class Arrays {
* off is the offset to generate corresponding low, high in src
* off is the offset to generate corresponding low, high in src
* To be removed in a future release.
* To be removed in a future release.
*/
*/
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
private
static
void
mergeSort
(
Object
[]
src
,
private
static
void
mergeSort
(
Object
[]
src
,
Object
[]
dest
,
Object
[]
dest
,
int
low
,
int
low
,
...
@@ -746,6 +747,7 @@ public class Arrays {
...
@@ -746,6 +747,7 @@ public class Arrays {
* off is the offset into src corresponding to low in dest
* off is the offset into src corresponding to low in dest
* To be removed in a future release.
* To be removed in a future release.
*/
*/
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
private
static
void
mergeSort
(
Object
[]
src
,
private
static
void
mergeSort
(
Object
[]
src
,
Object
[]
dest
,
Object
[]
dest
,
int
low
,
int
high
,
int
off
,
int
low
,
int
high
,
int
off
,
...
@@ -1477,7 +1479,9 @@ public class Arrays {
...
@@ -1477,7 +1479,9 @@ public class Arrays {
while
(
low
<=
high
)
{
while
(
low
<=
high
)
{
int
mid
=
(
low
+
high
)
>>>
1
;
int
mid
=
(
low
+
high
)
>>>
1
;
@SuppressWarnings
(
"rawtypes"
)
Comparable
midVal
=
(
Comparable
)
a
[
mid
];
Comparable
midVal
=
(
Comparable
)
a
[
mid
];
@SuppressWarnings
(
"unchecked"
)
int
cmp
=
midVal
.
compareTo
(
key
);
int
cmp
=
midVal
.
compareTo
(
key
);
if
(
cmp
<
0
)
if
(
cmp
<
0
)
...
@@ -2215,6 +2219,7 @@ public class Arrays {
...
@@ -2215,6 +2219,7 @@ public class Arrays {
* @throws NullPointerException if <tt>original</tt> is null
* @throws NullPointerException if <tt>original</tt> is null
* @since 1.6
* @since 1.6
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
[]
copyOf
(
T
[]
original
,
int
newLength
)
{
public
static
<
T
>
T
[]
copyOf
(
T
[]
original
,
int
newLength
)
{
return
(
T
[])
copyOf
(
original
,
newLength
,
original
.
getClass
());
return
(
T
[])
copyOf
(
original
,
newLength
,
original
.
getClass
());
}
}
...
@@ -2242,6 +2247,7 @@ public class Arrays {
...
@@ -2242,6 +2247,7 @@ public class Arrays {
* @since 1.6
* @since 1.6
*/
*/
public
static
<
T
,
U
>
T
[]
copyOf
(
U
[]
original
,
int
newLength
,
Class
<?
extends
T
[]>
newType
)
{
public
static
<
T
,
U
>
T
[]
copyOf
(
U
[]
original
,
int
newLength
,
Class
<?
extends
T
[]>
newType
)
{
@SuppressWarnings
(
"unchecked"
)
T
[]
copy
=
((
Object
)
newType
==
(
Object
)
Object
[].
class
)
T
[]
copy
=
((
Object
)
newType
==
(
Object
)
Object
[].
class
)
?
(
T
[])
new
Object
[
newLength
]
?
(
T
[])
new
Object
[
newLength
]
:
(
T
[])
Array
.
newInstance
(
newType
.
getComponentType
(),
newLength
);
:
(
T
[])
Array
.
newInstance
(
newType
.
getComponentType
(),
newLength
);
...
@@ -2470,8 +2476,9 @@ public class Arrays {
...
@@ -2470,8 +2476,9 @@ public class Arrays {
* @throws NullPointerException if <tt>original</tt> is null
* @throws NullPointerException if <tt>original</tt> is null
* @since 1.6
* @since 1.6
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
[]
copyOfRange
(
T
[]
original
,
int
from
,
int
to
)
{
public
static
<
T
>
T
[]
copyOfRange
(
T
[]
original
,
int
from
,
int
to
)
{
return
copyOfRange
(
original
,
from
,
to
,
(
Class
<
T
[]>)
original
.
getClass
());
return
copyOfRange
(
original
,
from
,
to
,
(
Class
<
?
extends
T
[]>)
original
.
getClass
());
}
}
/**
/**
...
@@ -2509,6 +2516,7 @@ public class Arrays {
...
@@ -2509,6 +2516,7 @@ public class Arrays {
int
newLength
=
to
-
from
;
int
newLength
=
to
-
from
;
if
(
newLength
<
0
)
if
(
newLength
<
0
)
throw
new
IllegalArgumentException
(
from
+
" > "
+
to
);
throw
new
IllegalArgumentException
(
from
+
" > "
+
to
);
@SuppressWarnings
(
"unchecked"
)
T
[]
copy
=
((
Object
)
newType
==
(
Object
)
Object
[].
class
)
T
[]
copy
=
((
Object
)
newType
==
(
Object
)
Object
[].
class
)
?
(
T
[])
new
Object
[
newLength
]
?
(
T
[])
new
Object
[
newLength
]
:
(
T
[])
Array
.
newInstance
(
newType
.
getComponentType
(),
newLength
);
:
(
T
[])
Array
.
newInstance
(
newType
.
getComponentType
(),
newLength
);
...
@@ -2851,6 +2859,7 @@ public class Arrays {
...
@@ -2851,6 +2859,7 @@ public class Arrays {
return
a
.
clone
();
return
a
.
clone
();
}
}
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
int
size
=
size
();
int
size
=
size
();
if
(
a
.
length
<
size
)
if
(
a
.
length
<
size
)
...
@@ -3634,7 +3643,7 @@ public class Arrays {
...
@@ -3634,7 +3643,7 @@ public class Arrays {
if
(
element
==
null
)
{
if
(
element
==
null
)
{
buf
.
append
(
"null"
);
buf
.
append
(
"null"
);
}
else
{
}
else
{
Class
eClass
=
element
.
getClass
();
Class
<?>
eClass
=
element
.
getClass
();
if
(
eClass
.
isArray
())
{
if
(
eClass
.
isArray
())
{
if
(
eClass
==
byte
[].
class
)
if
(
eClass
==
byte
[].
class
)
...
...
src/share/classes/java/util/Calendar.java
浏览文件 @
cb0fea8f
...
@@ -840,7 +840,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
...
@@ -840,7 +840,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
* of a Locale.
* of a Locale.
*/
*/
private
static
final
ConcurrentMap
<
Locale
,
int
[]>
cachedLocaleData
private
static
final
ConcurrentMap
<
Locale
,
int
[]>
cachedLocaleData
=
new
ConcurrentHashMap
<
Locale
,
int
[]
>(
3
);
=
new
ConcurrentHashMap
<>(
3
);
// Special values of stamp[]
// Special values of stamp[]
/**
/**
...
@@ -1499,7 +1499,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
...
@@ -1499,7 +1499,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
DateFormatSymbols
symbols
=
DateFormatSymbols
.
getInstance
(
locale
);
DateFormatSymbols
symbols
=
DateFormatSymbols
.
getInstance
(
locale
);
String
[]
strings
=
getFieldStrings
(
field
,
style
,
symbols
);
String
[]
strings
=
getFieldStrings
(
field
,
style
,
symbols
);
if
(
strings
!=
null
)
{
if
(
strings
!=
null
)
{
Map
<
String
,
Integer
>
names
=
new
HashMap
<
String
,
Integer
>();
Map
<
String
,
Integer
>
names
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
if
(
strings
[
i
].
length
()
==
0
)
{
if
(
strings
[
i
].
length
()
==
0
)
{
continue
;
continue
;
...
...
src/share/classes/java/util/Collections.java
浏览文件 @
cb0fea8f
...
@@ -150,6 +150,7 @@ public class Collections {
...
@@ -150,6 +150,7 @@ public class Collections {
* detects that the natural ordering of the list elements is
* detects that the natural ordering of the list elements is
* found to violate the {@link Comparable} contract
* found to violate the {@link Comparable} contract
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
extends
Comparable
<?
super
T
>>
void
sort
(
List
<
T
>
list
)
{
public
static
<
T
extends
Comparable
<?
super
T
>>
void
sort
(
List
<
T
>
list
)
{
Object
[]
a
=
list
.
toArray
();
Object
[]
a
=
list
.
toArray
();
Arrays
.
sort
(
a
);
Arrays
.
sort
(
a
);
...
@@ -212,13 +213,14 @@ public class Collections {
...
@@ -212,13 +213,14 @@ public class Collections {
* @throws IllegalArgumentException (optional) if the comparator is
* @throws IllegalArgumentException (optional) if the comparator is
* found to violate the {@link Comparator} contract
* found to violate the {@link Comparator} contract
*/
*/
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
static
<
T
>
void
sort
(
List
<
T
>
list
,
Comparator
<?
super
T
>
c
)
{
public
static
<
T
>
void
sort
(
List
<
T
>
list
,
Comparator
<?
super
T
>
c
)
{
Object
[]
a
=
list
.
toArray
();
Object
[]
a
=
list
.
toArray
();
Arrays
.
sort
(
a
,
(
Comparator
)
c
);
Arrays
.
sort
(
a
,
(
Comparator
)
c
);
ListIterator
i
=
list
.
listIterator
();
ListIterator
<
T
>
i
=
list
.
listIterator
();
for
(
int
j
=
0
;
j
<
a
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
a
.
length
;
j
++)
{
i
.
next
();
i
.
next
();
i
.
set
(
a
[
j
]);
i
.
set
(
(
T
)
a
[
j
]);
}
}
}
}
...
@@ -357,9 +359,10 @@ public class Collections {
...
@@ -357,9 +359,10 @@ public class Collections {
* or the search key is not mutually comparable with the
* or the search key is not mutually comparable with the
* elements of the list using this comparator.
* elements of the list using this comparator.
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
int
binarySearch
(
List
<?
extends
T
>
list
,
T
key
,
Comparator
<?
super
T
>
c
)
{
public
static
<
T
>
int
binarySearch
(
List
<?
extends
T
>
list
,
T
key
,
Comparator
<?
super
T
>
c
)
{
if
(
c
==
null
)
if
(
c
==
null
)
return
binarySearch
((
List
)
list
,
key
);
return
binarySearch
((
List
<?
extends
Comparable
<?
super
T
>>
)
list
,
key
);
if
(
list
instanceof
RandomAccess
||
list
.
size
()<
BINARYSEARCH_THRESHOLD
)
if
(
list
instanceof
RandomAccess
||
list
.
size
()<
BINARYSEARCH_THRESHOLD
)
return
Collections
.
indexedBinarySearch
(
list
,
key
,
c
);
return
Collections
.
indexedBinarySearch
(
list
,
key
,
c
);
...
@@ -406,9 +409,6 @@ public class Collections {
...
@@ -406,9 +409,6 @@ public class Collections {
return
-(
low
+
1
);
// key not found
return
-(
low
+
1
);
// key not found
}
}
private
interface
SelfComparable
extends
Comparable
<
SelfComparable
>
{}
/**
/**
* Reverses the order of the elements in the specified list.<p>
* Reverses the order of the elements in the specified list.<p>
*
*
...
@@ -418,12 +418,16 @@ public class Collections {
...
@@ -418,12 +418,16 @@ public class Collections {
* @throws UnsupportedOperationException if the specified list or
* @throws UnsupportedOperationException if the specified list or
* its list-iterator does not support the <tt>set</tt> operation.
* its list-iterator does not support the <tt>set</tt> operation.
*/
*/
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
static
void
reverse
(
List
<?>
list
)
{
public
static
void
reverse
(
List
<?>
list
)
{
int
size
=
list
.
size
();
int
size
=
list
.
size
();
if
(
size
<
REVERSE_THRESHOLD
||
list
instanceof
RandomAccess
)
{
if
(
size
<
REVERSE_THRESHOLD
||
list
instanceof
RandomAccess
)
{
for
(
int
i
=
0
,
mid
=
size
>>
1
,
j
=
size
-
1
;
i
<
mid
;
i
++,
j
--)
for
(
int
i
=
0
,
mid
=
size
>>
1
,
j
=
size
-
1
;
i
<
mid
;
i
++,
j
--)
swap
(
list
,
i
,
j
);
swap
(
list
,
i
,
j
);
}
else
{
}
else
{
// instead of using a raw type here, it's possible to capture
// the wildcard but it will require a call to a supplementary
// private method
ListIterator
fwd
=
list
.
listIterator
();
ListIterator
fwd
=
list
.
listIterator
();
ListIterator
rev
=
list
.
listIterator
(
size
);
ListIterator
rev
=
list
.
listIterator
(
size
);
for
(
int
i
=
0
,
mid
=
list
.
size
()>>
1
;
i
<
mid
;
i
++)
{
for
(
int
i
=
0
,
mid
=
list
.
size
()>>
1
;
i
<
mid
;
i
++)
{
...
@@ -493,6 +497,7 @@ public class Collections {
...
@@ -493,6 +497,7 @@ public class Collections {
* @throws UnsupportedOperationException if the specified list or its
* @throws UnsupportedOperationException if the specified list or its
* list-iterator does not support the <tt>set</tt> operation.
* list-iterator does not support the <tt>set</tt> operation.
*/
*/
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
static
void
shuffle
(
List
<?>
list
,
Random
rnd
)
{
public
static
void
shuffle
(
List
<?>
list
,
Random
rnd
)
{
int
size
=
list
.
size
();
int
size
=
list
.
size
();
if
(
size
<
SHUFFLE_THRESHOLD
||
list
instanceof
RandomAccess
)
{
if
(
size
<
SHUFFLE_THRESHOLD
||
list
instanceof
RandomAccess
)
{
...
@@ -506,6 +511,9 @@ public class Collections {
...
@@ -506,6 +511,9 @@ public class Collections {
swap
(
arr
,
i
-
1
,
rnd
.
nextInt
(
i
));
swap
(
arr
,
i
-
1
,
rnd
.
nextInt
(
i
));
// Dump array back into list
// Dump array back into list
// instead of using a raw type here, it's possible to capture
// the wildcard but it will require a call to a supplementary
// private method
ListIterator
it
=
list
.
listIterator
();
ListIterator
it
=
list
.
listIterator
();
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
it
.
next
();
it
.
next
();
...
@@ -527,7 +535,11 @@ public class Collections {
...
@@ -527,7 +535,11 @@ public class Collections {
* || j < 0 || j >= list.size()).
* || j < 0 || j >= list.size()).
* @since 1.4
* @since 1.4
*/
*/
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
static
void
swap
(
List
<?>
list
,
int
i
,
int
j
)
{
public
static
void
swap
(
List
<?>
list
,
int
i
,
int
j
)
{
// instead of using a raw type here, it's possible to capture
// the wildcard but it will require a call to a supplementary
// private method
final
List
l
=
list
;
final
List
l
=
list
;
l
.
set
(
i
,
l
.
set
(
j
,
l
.
get
(
i
)));
l
.
set
(
i
,
l
.
set
(
j
,
l
.
get
(
i
)));
}
}
...
@@ -657,9 +669,10 @@ public class Collections {
...
@@ -657,9 +669,10 @@ public class Collections {
* @throws NoSuchElementException if the collection is empty.
* @throws NoSuchElementException if the collection is empty.
* @see Comparable
* @see Comparable
*/
*/
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
static
<
T
>
T
min
(
Collection
<?
extends
T
>
coll
,
Comparator
<?
super
T
>
comp
)
{
public
static
<
T
>
T
min
(
Collection
<?
extends
T
>
coll
,
Comparator
<?
super
T
>
comp
)
{
if
(
comp
==
null
)
if
(
comp
==
null
)
return
(
T
)
min
((
Collection
<
SelfComparable
>)
(
Collection
)
coll
);
return
(
T
)
min
((
Collection
)
coll
);
Iterator
<?
extends
T
>
i
=
coll
.
iterator
();
Iterator
<?
extends
T
>
i
=
coll
.
iterator
();
T
candidate
=
i
.
next
();
T
candidate
=
i
.
next
();
...
@@ -727,9 +740,10 @@ public class Collections {
...
@@ -727,9 +740,10 @@ public class Collections {
* @throws NoSuchElementException if the collection is empty.
* @throws NoSuchElementException if the collection is empty.
* @see Comparable
* @see Comparable
*/
*/
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
static
<
T
>
T
max
(
Collection
<?
extends
T
>
coll
,
Comparator
<?
super
T
>
comp
)
{
public
static
<
T
>
T
max
(
Collection
<?
extends
T
>
coll
,
Comparator
<?
super
T
>
comp
)
{
if
(
comp
==
null
)
if
(
comp
==
null
)
return
(
T
)
max
((
Collection
<
SelfComparable
>)
(
Collection
)
coll
);
return
(
T
)
max
((
Collection
)
coll
);
Iterator
<?
extends
T
>
i
=
coll
.
iterator
();
Iterator
<?
extends
T
>
i
=
coll
.
iterator
();
T
candidate
=
i
.
next
();
T
candidate
=
i
.
next
();
...
@@ -1389,7 +1403,9 @@ public class Collections {
...
@@ -1389,7 +1403,9 @@ public class Collections {
extends
UnmodifiableSet
<
Map
.
Entry
<
K
,
V
>>
{
extends
UnmodifiableSet
<
Map
.
Entry
<
K
,
V
>>
{
private
static
final
long
serialVersionUID
=
7854390611657943733L
;
private
static
final
long
serialVersionUID
=
7854390611657943733L
;
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
UnmodifiableEntrySet
(
Set
<?
extends
Map
.
Entry
<?
extends
K
,
?
extends
V
>>
s
)
{
UnmodifiableEntrySet
(
Set
<?
extends
Map
.
Entry
<?
extends
K
,
?
extends
V
>>
s
)
{
// Need to cast to raw in order to work around a limitation in the type system
super
((
Set
)
s
);
super
((
Set
)
s
);
}
}
public
Iterator
<
Map
.
Entry
<
K
,
V
>>
iterator
()
{
public
Iterator
<
Map
.
Entry
<
K
,
V
>>
iterator
()
{
...
@@ -1408,13 +1424,15 @@ public class Collections {
...
@@ -1408,13 +1424,15 @@ public class Collections {
};
};
}
}
@SuppressWarnings
(
"unchecked"
)
public
Object
[]
toArray
()
{
public
Object
[]
toArray
()
{
Object
[]
a
=
c
.
toArray
();
Object
[]
a
=
c
.
toArray
();
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
a
[
i
]
=
new
UnmodifiableEntry
<>((
Map
.
Entry
<
K
,
V
>)
a
[
i
]);
a
[
i
]
=
new
UnmodifiableEntry
<>((
Map
.
Entry
<
?
extends
K
,
?
extends
V
>)
a
[
i
]);
return
a
;
return
a
;
}
}
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
// We don't pass a to c.toArray, to avoid window of
// We don't pass a to c.toArray, to avoid window of
// vulnerability wherein an unscrupulous multithreaded client
// vulnerability wherein an unscrupulous multithreaded client
...
@@ -1422,7 +1440,7 @@ public class Collections {
...
@@ -1422,7 +1440,7 @@ public class Collections {
Object
[]
arr
=
c
.
toArray
(
a
.
length
==
0
?
a
:
Arrays
.
copyOf
(
a
,
0
));
Object
[]
arr
=
c
.
toArray
(
a
.
length
==
0
?
a
:
Arrays
.
copyOf
(
a
,
0
));
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
arr
[
i
]
=
new
UnmodifiableEntry
<>((
Map
.
Entry
<
K
,
V
>)
arr
[
i
]);
arr
[
i
]
=
new
UnmodifiableEntry
<>((
Map
.
Entry
<
?
extends
K
,
?
extends
V
>)
arr
[
i
]);
if
(
arr
.
length
>
a
.
length
)
if
(
arr
.
length
>
a
.
length
)
return
(
T
[])
arr
;
return
(
T
[])
arr
;
...
@@ -1464,7 +1482,7 @@ public class Collections {
...
@@ -1464,7 +1482,7 @@ public class Collections {
if
(!(
o
instanceof
Set
))
if
(!(
o
instanceof
Set
))
return
false
;
return
false
;
Set
s
=
(
Set
)
o
;
Set
<?>
s
=
(
Set
<?>
)
o
;
if
(
s
.
size
()
!=
c
.
size
())
if
(
s
.
size
()
!=
c
.
size
())
return
false
;
return
false
;
return
containsAll
(
s
);
// Invokes safe containsAll() above
return
containsAll
(
s
);
// Invokes safe containsAll() above
...
@@ -1493,7 +1511,7 @@ public class Collections {
...
@@ -1493,7 +1511,7 @@ public class Collections {
return
true
;
return
true
;
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
t
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
t
=
(
Map
.
Entry
<?,?>
)
o
;
return
eq
(
e
.
getKey
(),
t
.
getKey
())
&&
return
eq
(
e
.
getKey
(),
t
.
getKey
())
&&
eq
(
e
.
getValue
(),
t
.
getValue
());
eq
(
e
.
getValue
(),
t
.
getValue
());
}
}
...
...
src/share/classes/java/util/ComparableTimSort.java
浏览文件 @
cb0fea8f
...
@@ -114,7 +114,6 @@ class ComparableTimSort {
...
@@ -114,7 +114,6 @@ class ComparableTimSort {
// Allocate temp storage (which may be increased later if necessary)
// Allocate temp storage (which may be increased later if necessary)
int
len
=
a
.
length
;
int
len
=
a
.
length
;
@SuppressWarnings
({
"unchecked"
,
"UnnecessaryLocalVariable"
})
Object
[]
newArray
=
new
Object
[
len
<
2
*
INITIAL_TMP_STORAGE_LENGTH
?
Object
[]
newArray
=
new
Object
[
len
<
2
*
INITIAL_TMP_STORAGE_LENGTH
?
len
>>>
1
:
INITIAL_TMP_STORAGE_LENGTH
];
len
>>>
1
:
INITIAL_TMP_STORAGE_LENGTH
];
tmp
=
newArray
;
tmp
=
newArray
;
...
@@ -209,14 +208,13 @@ class ComparableTimSort {
...
@@ -209,14 +208,13 @@ class ComparableTimSort {
* @param start the index of the first element in the range that is
* @param start the index of the first element in the range that is
* not already known to be sorted ({@code lo <= start <= hi})
* not already known to be sorted ({@code lo <= start <= hi})
*/
*/
@SuppressWarnings
(
"fallthrough"
)
@SuppressWarnings
(
{
"fallthrough"
,
"rawtypes"
,
"unchecked"
}
)
private
static
void
binarySort
(
Object
[]
a
,
int
lo
,
int
hi
,
int
start
)
{
private
static
void
binarySort
(
Object
[]
a
,
int
lo
,
int
hi
,
int
start
)
{
assert
lo
<=
start
&&
start
<=
hi
;
assert
lo
<=
start
&&
start
<=
hi
;
if
(
start
==
lo
)
if
(
start
==
lo
)
start
++;
start
++;
for
(
;
start
<
hi
;
start
++)
{
for
(
;
start
<
hi
;
start
++)
{
@SuppressWarnings
(
"unchecked"
)
Comparable
pivot
=
(
Comparable
)
a
[
start
];
Comparable
<
Object
>
pivot
=
(
Comparable
)
a
[
start
];
// Set left (and right) to the index where a[start] (pivot) belongs
// Set left (and right) to the index where a[start] (pivot) belongs
int
left
=
lo
;
int
left
=
lo
;
...
@@ -279,7 +277,7 @@ class ComparableTimSort {
...
@@ -279,7 +277,7 @@ class ComparableTimSort {
* @return the length of the run beginning at the specified position in
* @return the length of the run beginning at the specified position in
* the specified array
* the specified array
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
{
"unchecked"
,
"rawtypes"
}
)
private
static
int
countRunAndMakeAscending
(
Object
[]
a
,
int
lo
,
int
hi
)
{
private
static
int
countRunAndMakeAscending
(
Object
[]
a
,
int
lo
,
int
hi
)
{
assert
lo
<
hi
;
assert
lo
<
hi
;
int
runHi
=
lo
+
1
;
int
runHi
=
lo
+
1
;
...
@@ -614,7 +612,7 @@ class ComparableTimSort {
...
@@ -614,7 +612,7 @@ class ComparableTimSort {
* (must be aBase + aLen)
* (must be aBase + aLen)
* @param len2 length of second run to be merged (must be > 0)
* @param len2 length of second run to be merged (must be > 0)
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
{
"unchecked"
,
"rawtypes"
}
)
private
void
mergeLo
(
int
base1
,
int
len1
,
int
base2
,
int
len2
)
{
private
void
mergeLo
(
int
base1
,
int
len1
,
int
base2
,
int
len2
)
{
assert
len1
>
0
&&
len2
>
0
&&
base1
+
len1
==
base2
;
assert
len1
>
0
&&
len2
>
0
&&
base1
+
len1
==
base2
;
...
@@ -731,7 +729,7 @@ class ComparableTimSort {
...
@@ -731,7 +729,7 @@ class ComparableTimSort {
* (must be aBase + aLen)
* (must be aBase + aLen)
* @param len2 length of second run to be merged (must be > 0)
* @param len2 length of second run to be merged (must be > 0)
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
{
"unchecked"
,
"rawtypes"
}
)
private
void
mergeHi
(
int
base1
,
int
len1
,
int
base2
,
int
len2
)
{
private
void
mergeHi
(
int
base1
,
int
len1
,
int
base2
,
int
len2
)
{
assert
len1
>
0
&&
len2
>
0
&&
base1
+
len1
==
base2
;
assert
len1
>
0
&&
len2
>
0
&&
base1
+
len1
==
base2
;
...
@@ -865,7 +863,6 @@ class ComparableTimSort {
...
@@ -865,7 +863,6 @@ class ComparableTimSort {
else
else
newSize
=
Math
.
min
(
newSize
,
a
.
length
>>>
1
);
newSize
=
Math
.
min
(
newSize
,
a
.
length
>>>
1
);
@SuppressWarnings
({
"unchecked"
,
"UnnecessaryLocalVariable"
})
Object
[]
newArray
=
new
Object
[
newSize
];
Object
[]
newArray
=
new
Object
[
newSize
];
tmp
=
newArray
;
tmp
=
newArray
;
}
}
...
...
src/share/classes/java/util/Currency.java
浏览文件 @
cb0fea8f
...
@@ -404,7 +404,7 @@ public final class Currency implements Serializable {
...
@@ -404,7 +404,7 @@ public final class Currency implements Serializable {
public
static
Set
<
Currency
>
getAvailableCurrencies
()
{
public
static
Set
<
Currency
>
getAvailableCurrencies
()
{
synchronized
(
Currency
.
class
)
{
synchronized
(
Currency
.
class
)
{
if
(
available
==
null
)
{
if
(
available
==
null
)
{
available
=
new
HashSet
<
Currency
>(
256
);
available
=
new
HashSet
<>(
256
);
// Add simple currencies first
// Add simple currencies first
for
(
char
c1
=
'A'
;
c1
<=
'Z'
;
c1
++)
{
for
(
char
c1
=
'A'
;
c1
<=
'Z'
;
c1
++)
{
...
...
src/share/classes/java/util/EnumMap.java
浏览文件 @
cb0fea8f
...
@@ -120,11 +120,12 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -120,11 +120,12 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
return
(
value
==
null
?
NULL
:
value
);
return
(
value
==
null
?
NULL
:
value
);
}
}
@SuppressWarnings
(
"unchecked"
)
private
V
unmaskNull
(
Object
value
)
{
private
V
unmaskNull
(
Object
value
)
{
return
(
V
)
(
value
==
NULL
?
null
:
value
);
return
(
V
)(
value
==
NULL
?
null
:
value
);
}
}
private
static
final
Enum
[]
ZERO_LENGTH_ENUM_ARRAY
=
new
Enum
[
0
];
private
static
final
Enum
<?>[]
ZERO_LENGTH_ENUM_ARRAY
=
new
Enum
<?>
[
0
];
/**
/**
* Creates an empty enum map with the specified key type.
* Creates an empty enum map with the specified key type.
...
@@ -218,12 +219,12 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -218,12 +219,12 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
* key
* key
*/
*/
public
boolean
containsKey
(
Object
key
)
{
public
boolean
containsKey
(
Object
key
)
{
return
isValidKey
(
key
)
&&
vals
[((
Enum
)
key
).
ordinal
()]
!=
null
;
return
isValidKey
(
key
)
&&
vals
[((
Enum
<?>
)
key
).
ordinal
()]
!=
null
;
}
}
private
boolean
containsMapping
(
Object
key
,
Object
value
)
{
private
boolean
containsMapping
(
Object
key
,
Object
value
)
{
return
isValidKey
(
key
)
&&
return
isValidKey
(
key
)
&&
maskNull
(
value
).
equals
(
vals
[((
Enum
)
key
).
ordinal
()]);
maskNull
(
value
).
equals
(
vals
[((
Enum
<?>
)
key
).
ordinal
()]);
}
}
/**
/**
...
@@ -243,7 +244,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -243,7 +244,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
*/
*/
public
V
get
(
Object
key
)
{
public
V
get
(
Object
key
)
{
return
(
isValidKey
(
key
)
?
return
(
isValidKey
(
key
)
?
unmaskNull
(
vals
[((
Enum
)
key
).
ordinal
()])
:
null
);
unmaskNull
(
vals
[((
Enum
<?>
)
key
).
ordinal
()])
:
null
);
}
}
// Modification Operations
// Modification Operations
...
@@ -285,7 +286,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -285,7 +286,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
public
V
remove
(
Object
key
)
{
public
V
remove
(
Object
key
)
{
if
(!
isValidKey
(
key
))
if
(!
isValidKey
(
key
))
return
null
;
return
null
;
int
index
=
((
Enum
)
key
).
ordinal
();
int
index
=
((
Enum
<?>
)
key
).
ordinal
();
Object
oldValue
=
vals
[
index
];
Object
oldValue
=
vals
[
index
];
vals
[
index
]
=
null
;
vals
[
index
]
=
null
;
if
(
oldValue
!=
null
)
if
(
oldValue
!=
null
)
...
@@ -296,7 +297,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -296,7 +297,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
private
boolean
removeMapping
(
Object
key
,
Object
value
)
{
private
boolean
removeMapping
(
Object
key
,
Object
value
)
{
if
(!
isValidKey
(
key
))
if
(!
isValidKey
(
key
))
return
false
;
return
false
;
int
index
=
((
Enum
)
key
).
ordinal
();
int
index
=
((
Enum
<?>
)
key
).
ordinal
();
if
(
maskNull
(
value
).
equals
(
vals
[
index
]))
{
if
(
maskNull
(
value
).
equals
(
vals
[
index
]))
{
vals
[
index
]
=
null
;
vals
[
index
]
=
null
;
size
--;
size
--;
...
@@ -314,7 +315,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -314,7 +315,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
return
false
;
return
false
;
// Cheaper than instanceof Enum followed by getDeclaringClass
// Cheaper than instanceof Enum followed by getDeclaringClass
Class
keyClass
=
key
.
getClass
();
Class
<?>
keyClass
=
key
.
getClass
();
return
keyClass
==
keyType
||
keyClass
.
getSuperclass
()
==
keyType
;
return
keyClass
==
keyType
||
keyClass
.
getSuperclass
()
==
keyType
;
}
}
...
@@ -331,8 +332,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -331,8 +332,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
*/
*/
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
m
)
{
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
m
)
{
if
(
m
instanceof
EnumMap
)
{
if
(
m
instanceof
EnumMap
)
{
EnumMap
<?
extends
K
,
?
extends
V
>
em
=
EnumMap
<?,
?>
em
=
(
EnumMap
<?,
?>)
m
;
(
EnumMap
<?
extends
K
,
?
extends
V
>)
m
;
if
(
em
.
keyType
!=
keyType
)
{
if
(
em
.
keyType
!=
keyType
)
{
if
(
em
.
isEmpty
())
if
(
em
.
isEmpty
())
return
;
return
;
...
@@ -476,13 +476,13 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -476,13 +476,13 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
entry
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
entry
=
(
Map
.
Entry
<?,?>
)
o
;
return
containsMapping
(
entry
.
getKey
(),
entry
.
getValue
());
return
containsMapping
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
public
boolean
remove
(
Object
o
)
{
public
boolean
remove
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
entry
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
entry
=
(
Map
.
Entry
<?,?>
)
o
;
return
removeMapping
(
entry
.
getKey
(),
entry
.
getValue
());
return
removeMapping
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
public
int
size
()
{
public
int
size
()
{
...
@@ -610,7 +610,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -610,7 +610,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
e
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
e
=
(
Map
.
Entry
<?,?>
)
o
;
V
ourValue
=
unmaskNull
(
vals
[
index
]);
V
ourValue
=
unmaskNull
(
vals
[
index
]);
Object
hisValue
=
e
.
getValue
();
Object
hisValue
=
e
.
getValue
();
return
(
e
.
getKey
()
==
keyUniverse
[
index
]
&&
return
(
e
.
getKey
()
==
keyUniverse
[
index
]
&&
...
@@ -655,11 +655,11 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -655,11 +655,11 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
if
(
this
==
o
)
if
(
this
==
o
)
return
true
;
return
true
;
if
(
o
instanceof
EnumMap
)
if
(
o
instanceof
EnumMap
)
return
equals
((
EnumMap
)
o
);
return
equals
((
EnumMap
<?,?>
)
o
);
if
(!(
o
instanceof
Map
))
if
(!(
o
instanceof
Map
))
return
false
;
return
false
;
Map
<
K
,
V
>
m
=
(
Map
<
K
,
V
>)
o
;
Map
<
?,?>
m
=
(
Map
<?,?
>)
o
;
if
(
size
!=
m
.
size
())
if
(
size
!=
m
.
size
())
return
false
;
return
false
;
...
@@ -680,7 +680,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -680,7 +680,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
return
true
;
return
true
;
}
}
private
boolean
equals
(
EnumMap
em
)
{
private
boolean
equals
(
EnumMap
<?,?>
em
)
{
if
(
em
.
keyType
!=
keyType
)
if
(
em
.
keyType
!=
keyType
)
return
size
==
0
&&
em
.
size
==
0
;
return
size
==
0
&&
em
.
size
==
0
;
...
@@ -721,6 +721,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -721,6 +721,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
*
*
* @return a shallow copy of this enum map
* @return a shallow copy of this enum map
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
EnumMap
<
K
,
V
>
clone
()
{
public
EnumMap
<
K
,
V
>
clone
()
{
EnumMap
<
K
,
V
>
result
=
null
;
EnumMap
<
K
,
V
>
result
=
null
;
try
{
try
{
...
@@ -736,7 +737,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -736,7 +737,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
* Throws an exception if e is not of the correct type for this enum set.
* Throws an exception if e is not of the correct type for this enum set.
*/
*/
private
void
typeCheck
(
K
key
)
{
private
void
typeCheck
(
K
key
)
{
Class
keyClass
=
key
.
getClass
();
Class
<?>
keyClass
=
key
.
getClass
();
if
(
keyClass
!=
keyType
&&
keyClass
.
getSuperclass
()
!=
keyType
)
if
(
keyClass
!=
keyType
&&
keyClass
.
getSuperclass
()
!=
keyType
)
throw
new
ClassCastException
(
keyClass
+
" != "
+
keyType
);
throw
new
ClassCastException
(
keyClass
+
" != "
+
keyType
);
}
}
...
@@ -785,6 +786,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
...
@@ -785,6 +786,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
* Reconstitute the <tt>EnumMap</tt> instance from a stream (i.e.,
* Reconstitute the <tt>EnumMap</tt> instance from a stream (i.e.,
* deserialize it).
* deserialize it).
*/
*/
@SuppressWarnings
(
"unchecked"
)
private
void
readObject
(
java
.
io
.
ObjectInputStream
s
)
private
void
readObject
(
java
.
io
.
ObjectInputStream
s
)
throws
java
.
io
.
IOException
,
ClassNotFoundException
throws
java
.
io
.
IOException
,
ClassNotFoundException
{
{
...
...
src/share/classes/java/util/EnumSet.java
浏览文件 @
cb0fea8f
...
@@ -88,11 +88,11 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
...
@@ -88,11 +88,11 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
/**
/**
* All of the values comprising T. (Cached for performance.)
* All of the values comprising T. (Cached for performance.)
*/
*/
final
Enum
[]
universe
;
final
Enum
<?>
[]
universe
;
private
static
Enum
[]
ZERO_LENGTH_ENUM_ARRAY
=
new
Enum
[
0
];
private
static
Enum
<?>[]
ZERO_LENGTH_ENUM_ARRAY
=
new
Enum
<?>
[
0
];
EnumSet
(
Class
<
E
>
elementType
,
Enum
[]
universe
)
{
EnumSet
(
Class
<
E
>
elementType
,
Enum
<?>
[]
universe
)
{
this
.
elementType
=
elementType
;
this
.
elementType
=
elementType
;
this
.
universe
=
universe
;
this
.
universe
=
universe
;
}
}
...
@@ -105,7 +105,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
...
@@ -105,7 +105,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
* @throws NullPointerException if <tt>elementType</tt> is null
* @throws NullPointerException if <tt>elementType</tt> is null
*/
*/
public
static
<
E
extends
Enum
<
E
>>
EnumSet
<
E
>
noneOf
(
Class
<
E
>
elementType
)
{
public
static
<
E
extends
Enum
<
E
>>
EnumSet
<
E
>
noneOf
(
Class
<
E
>
elementType
)
{
Enum
[]
universe
=
getUniverse
(
elementType
);
Enum
<?>
[]
universe
=
getUniverse
(
elementType
);
if
(
universe
==
null
)
if
(
universe
==
null
)
throw
new
ClassCastException
(
elementType
+
" not an enum"
);
throw
new
ClassCastException
(
elementType
+
" not an enum"
);
...
@@ -358,6 +358,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
...
@@ -358,6 +358,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
*
*
* @return a copy of this set
* @return a copy of this set
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
EnumSet
<
E
>
clone
()
{
public
EnumSet
<
E
>
clone
()
{
try
{
try
{
return
(
EnumSet
<
E
>)
super
.
clone
();
return
(
EnumSet
<
E
>)
super
.
clone
();
...
@@ -375,7 +376,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
...
@@ -375,7 +376,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
* Throws an exception if e is not of the correct type for this enum set.
* Throws an exception if e is not of the correct type for this enum set.
*/
*/
final
void
typeCheck
(
E
e
)
{
final
void
typeCheck
(
E
e
)
{
Class
eClass
=
e
.
getClass
();
Class
<?>
eClass
=
e
.
getClass
();
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
throw
new
ClassCastException
(
eClass
+
" != "
+
elementType
);
throw
new
ClassCastException
(
eClass
+
" != "
+
elementType
);
}
}
...
@@ -413,16 +414,19 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
...
@@ -413,16 +414,19 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
*
*
* @serial
* @serial
*/
*/
private
final
Enum
[]
elements
;
private
final
Enum
<?>
[]
elements
;
SerializationProxy
(
EnumSet
<
E
>
set
)
{
SerializationProxy
(
EnumSet
<
E
>
set
)
{
elementType
=
set
.
elementType
;
elementType
=
set
.
elementType
;
elements
=
set
.
toArray
(
ZERO_LENGTH_ENUM_ARRAY
);
elements
=
set
.
toArray
(
ZERO_LENGTH_ENUM_ARRAY
);
}
}
// instead of cast to E, we should perhaps use elementType.cast()
// to avoid injection of forged stream, but it will slow the implementation
@SuppressWarnings
(
"unchecked"
)
private
Object
readResolve
()
{
private
Object
readResolve
()
{
EnumSet
<
E
>
result
=
EnumSet
.
noneOf
(
elementType
);
EnumSet
<
E
>
result
=
EnumSet
.
noneOf
(
elementType
);
for
(
Enum
e
:
elements
)
for
(
Enum
<?>
e
:
elements
)
result
.
add
((
E
)
e
);
result
.
add
((
E
)
e
);
return
result
;
return
result
;
}
}
...
...
src/share/classes/java/util/HashMap.java
浏览文件 @
cb0fea8f
...
@@ -146,7 +146,7 @@ public class HashMap<K,V>
...
@@ -146,7 +146,7 @@ public class HashMap<K,V>
/**
/**
* The table, resized as necessary. Length MUST Always be a power of two.
* The table, resized as necessary. Length MUST Always be a power of two.
*/
*/
transient
Entry
[]
table
;
transient
Entry
<?,?>
[]
table
;
/**
/**
* The number of key-value mappings contained in this map.
* The number of key-value mappings contained in this map.
...
@@ -311,16 +311,17 @@ public class HashMap<K,V>
...
@@ -311,16 +311,17 @@ public class HashMap<K,V>
*
*
* @see #put(Object, Object)
* @see #put(Object, Object)
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
V
get
(
Object
key
)
{
public
V
get
(
Object
key
)
{
if
(
key
==
null
)
if
(
key
==
null
)
return
getForNullKey
();
return
(
V
)
getForNullKey
();
int
hash
=
hash
(
key
.
hashCode
());
int
hash
=
hash
(
key
.
hashCode
());
for
(
Entry
<
K
,
V
>
e
=
table
[
indexFor
(
hash
,
table
.
length
)];
for
(
Entry
<
?,?
>
e
=
table
[
indexFor
(
hash
,
table
.
length
)];
e
!=
null
;
e
!=
null
;
e
=
e
.
next
)
{
e
=
e
.
next
)
{
Object
k
;
Object
k
;
if
(
e
.
hash
==
hash
&&
((
k
=
e
.
key
)
==
key
||
key
.
equals
(
k
)))
if
(
e
.
hash
==
hash
&&
((
k
=
e
.
key
)
==
key
||
key
.
equals
(
k
)))
return
e
.
value
;
return
(
V
)
e
.
value
;
}
}
return
null
;
return
null
;
}
}
...
@@ -332,8 +333,8 @@ public class HashMap<K,V>
...
@@ -332,8 +333,8 @@ public class HashMap<K,V>
* operations (get and put), but incorporated with conditionals in
* operations (get and put), but incorporated with conditionals in
* others.
* others.
*/
*/
private
V
getForNullKey
()
{
private
Object
getForNullKey
()
{
for
(
Entry
<
K
,
V
>
e
=
table
[
0
];
e
!=
null
;
e
=
e
.
next
)
{
for
(
Entry
<
?,?
>
e
=
table
[
0
];
e
!=
null
;
e
=
e
.
next
)
{
if
(
e
.
key
==
null
)
if
(
e
.
key
==
null
)
return
e
.
value
;
return
e
.
value
;
}
}
...
@@ -357,15 +358,16 @@ public class HashMap<K,V>
...
@@ -357,15 +358,16 @@ public class HashMap<K,V>
* HashMap. Returns null if the HashMap contains no mapping
* HashMap. Returns null if the HashMap contains no mapping
* for the key.
* for the key.
*/
*/
@SuppressWarnings
(
"unchecked"
)
final
Entry
<
K
,
V
>
getEntry
(
Object
key
)
{
final
Entry
<
K
,
V
>
getEntry
(
Object
key
)
{
int
hash
=
(
key
==
null
)
?
0
:
hash
(
key
.
hashCode
());
int
hash
=
(
key
==
null
)
?
0
:
hash
(
key
.
hashCode
());
for
(
Entry
<
K
,
V
>
e
=
table
[
indexFor
(
hash
,
table
.
length
)];
for
(
Entry
<
?,?
>
e
=
table
[
indexFor
(
hash
,
table
.
length
)];
e
!=
null
;
e
!=
null
;
e
=
e
.
next
)
{
e
=
e
.
next
)
{
Object
k
;
Object
k
;
if
(
e
.
hash
==
hash
&&
if
(
e
.
hash
==
hash
&&
((
k
=
e
.
key
)
==
key
||
(
key
!=
null
&&
key
.
equals
(
k
))))
((
k
=
e
.
key
)
==
key
||
(
key
!=
null
&&
key
.
equals
(
k
))))
return
e
;
return
(
Entry
<
K
,
V
>)
e
;
}
}
return
null
;
return
null
;
}
}
...
@@ -388,7 +390,9 @@ public class HashMap<K,V>
...
@@ -388,7 +390,9 @@ public class HashMap<K,V>
return
putForNullKey
(
value
);
return
putForNullKey
(
value
);
int
hash
=
hash
(
key
.
hashCode
());
int
hash
=
hash
(
key
.
hashCode
());
int
i
=
indexFor
(
hash
,
table
.
length
);
int
i
=
indexFor
(
hash
,
table
.
length
);
for
(
Entry
<
K
,
V
>
e
=
table
[
i
];
e
!=
null
;
e
=
e
.
next
)
{
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
table
[
i
];
for
(;
e
!=
null
;
e
=
e
.
next
)
{
Object
k
;
Object
k
;
if
(
e
.
hash
==
hash
&&
((
k
=
e
.
key
)
==
key
||
key
.
equals
(
k
)))
{
if
(
e
.
hash
==
hash
&&
((
k
=
e
.
key
)
==
key
||
key
.
equals
(
k
)))
{
V
oldValue
=
e
.
value
;
V
oldValue
=
e
.
value
;
...
@@ -407,7 +411,9 @@ public class HashMap<K,V>
...
@@ -407,7 +411,9 @@ public class HashMap<K,V>
* Offloaded version of put for null keys
* Offloaded version of put for null keys
*/
*/
private
V
putForNullKey
(
V
value
)
{
private
V
putForNullKey
(
V
value
)
{
for
(
Entry
<
K
,
V
>
e
=
table
[
0
];
e
!=
null
;
e
=
e
.
next
)
{
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
table
[
0
];
for
(;
e
!=
null
;
e
=
e
.
next
)
{
if
(
e
.
key
==
null
)
{
if
(
e
.
key
==
null
)
{
V
oldValue
=
e
.
value
;
V
oldValue
=
e
.
value
;
e
.
value
=
value
;
e
.
value
=
value
;
...
@@ -435,7 +441,8 @@ public class HashMap<K,V>
...
@@ -435,7 +441,8 @@ public class HashMap<K,V>
* clone or deserialize. It will only happen for construction if the
* clone or deserialize. It will only happen for construction if the
* input Map is a sorted map whose ordering is inconsistent w/ equals.
* input Map is a sorted map whose ordering is inconsistent w/ equals.
*/
*/
for
(
Entry
<
K
,
V
>
e
=
table
[
i
];
e
!=
null
;
e
=
e
.
next
)
{
for
(
@SuppressWarnings
(
"unchecked"
)
Entry
<?,
V
>
e
=
(
Entry
<?,
V
>)
table
[
i
];
e
!=
null
;
e
=
e
.
next
)
{
Object
k
;
Object
k
;
if
(
e
.
hash
==
hash
&&
if
(
e
.
hash
==
hash
&&
((
k
=
e
.
key
)
==
key
||
(
key
!=
null
&&
key
.
equals
(
k
))))
{
((
k
=
e
.
key
)
==
key
||
(
key
!=
null
&&
key
.
equals
(
k
))))
{
...
@@ -467,14 +474,14 @@ public class HashMap<K,V>
...
@@ -467,14 +474,14 @@ public class HashMap<K,V>
* is irrelevant).
* is irrelevant).
*/
*/
void
resize
(
int
newCapacity
)
{
void
resize
(
int
newCapacity
)
{
Entry
[]
oldTable
=
table
;
Entry
<?,?>
[]
oldTable
=
table
;
int
oldCapacity
=
oldTable
.
length
;
int
oldCapacity
=
oldTable
.
length
;
if
(
oldCapacity
==
MAXIMUM_CAPACITY
)
{
if
(
oldCapacity
==
MAXIMUM_CAPACITY
)
{
threshold
=
Integer
.
MAX_VALUE
;
threshold
=
Integer
.
MAX_VALUE
;
return
;
return
;
}
}
Entry
[]
newTable
=
new
Entry
[
newCapacity
];
Entry
<?,?>[]
newTable
=
new
Entry
<?,?>
[
newCapacity
];
transfer
(
newTable
);
transfer
(
newTable
);
table
=
newTable
;
table
=
newTable
;
threshold
=
(
int
)(
newCapacity
*
loadFactor
);
threshold
=
(
int
)(
newCapacity
*
loadFactor
);
...
@@ -483,17 +490,18 @@ public class HashMap<K,V>
...
@@ -483,17 +490,18 @@ public class HashMap<K,V>
/**
/**
* Transfers all entries from current table to newTable.
* Transfers all entries from current table to newTable.
*/
*/
void
transfer
(
Entry
[]
newTable
)
{
@SuppressWarnings
(
"unchecked"
)
Entry
[]
src
=
table
;
void
transfer
(
Entry
<?,?>[]
newTable
)
{
Entry
<?,?>[]
src
=
table
;
int
newCapacity
=
newTable
.
length
;
int
newCapacity
=
newTable
.
length
;
for
(
int
j
=
0
;
j
<
src
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
src
.
length
;
j
++)
{
Entry
<
K
,
V
>
e
=
src
[
j
];
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
src
[
j
];
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
src
[
j
]
=
null
;
src
[
j
]
=
null
;
do
{
do
{
Entry
<
K
,
V
>
next
=
e
.
next
;
Entry
<
K
,
V
>
next
=
e
.
next
;
int
i
=
indexFor
(
e
.
hash
,
newCapacity
);
int
i
=
indexFor
(
e
.
hash
,
newCapacity
);
e
.
next
=
newTable
[
i
];
e
.
next
=
(
Entry
<
K
,
V
>)
newTable
[
i
];
newTable
[
i
]
=
e
;
newTable
[
i
]
=
e
;
e
=
next
;
e
=
next
;
}
while
(
e
!=
null
);
}
while
(
e
!=
null
);
...
@@ -560,7 +568,8 @@ public class HashMap<K,V>
...
@@ -560,7 +568,8 @@ public class HashMap<K,V>
final
Entry
<
K
,
V
>
removeEntryForKey
(
Object
key
)
{
final
Entry
<
K
,
V
>
removeEntryForKey
(
Object
key
)
{
int
hash
=
(
key
==
null
)
?
0
:
hash
(
key
.
hashCode
());
int
hash
=
(
key
==
null
)
?
0
:
hash
(
key
.
hashCode
());
int
i
=
indexFor
(
hash
,
table
.
length
);
int
i
=
indexFor
(
hash
,
table
.
length
);
Entry
<
K
,
V
>
prev
=
table
[
i
];
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
prev
=
(
Entry
<
K
,
V
>)
table
[
i
];
Entry
<
K
,
V
>
e
=
prev
;
Entry
<
K
,
V
>
e
=
prev
;
while
(
e
!=
null
)
{
while
(
e
!=
null
)
{
...
@@ -591,11 +600,12 @@ public class HashMap<K,V>
...
@@ -591,11 +600,12 @@ public class HashMap<K,V>
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
null
;
return
null
;
Map
.
Entry
<
K
,
V
>
entry
=
(
Map
.
Entry
<
K
,
V
>)
o
;
Map
.
Entry
<
?,?>
entry
=
(
Map
.
Entry
<?,?
>)
o
;
Object
key
=
entry
.
getKey
();
Object
key
=
entry
.
getKey
();
int
hash
=
(
key
==
null
)
?
0
:
hash
(
key
.
hashCode
());
int
hash
=
(
key
==
null
)
?
0
:
hash
(
key
.
hashCode
());
int
i
=
indexFor
(
hash
,
table
.
length
);
int
i
=
indexFor
(
hash
,
table
.
length
);
Entry
<
K
,
V
>
prev
=
table
[
i
];
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
prev
=
(
Entry
<
K
,
V
>)
table
[
i
];
Entry
<
K
,
V
>
e
=
prev
;
Entry
<
K
,
V
>
e
=
prev
;
while
(
e
!=
null
)
{
while
(
e
!=
null
)
{
...
@@ -623,7 +633,7 @@ public class HashMap<K,V>
...
@@ -623,7 +633,7 @@ public class HashMap<K,V>
*/
*/
public
void
clear
()
{
public
void
clear
()
{
modCount
++;
modCount
++;
Entry
[]
tab
=
table
;
Entry
<?,?>
[]
tab
=
table
;
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
tab
[
i
]
=
null
;
tab
[
i
]
=
null
;
size
=
0
;
size
=
0
;
...
@@ -641,9 +651,9 @@ public class HashMap<K,V>
...
@@ -641,9 +651,9 @@ public class HashMap<K,V>
if
(
value
==
null
)
if
(
value
==
null
)
return
containsNullValue
();
return
containsNullValue
();
Entry
[]
tab
=
table
;
Entry
<?,?>
[]
tab
=
table
;
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
Entry
e
=
tab
[
i
]
;
e
!=
null
;
e
=
e
.
next
)
for
(
Entry
<?,?>
e
=
tab
[
i
]
;
e
!=
null
;
e
=
e
.
next
)
if
(
value
.
equals
(
e
.
value
))
if
(
value
.
equals
(
e
.
value
))
return
true
;
return
true
;
return
false
;
return
false
;
...
@@ -653,9 +663,9 @@ public class HashMap<K,V>
...
@@ -653,9 +663,9 @@ public class HashMap<K,V>
* Special-case code for containsValue with null argument
* Special-case code for containsValue with null argument
*/
*/
private
boolean
containsNullValue
()
{
private
boolean
containsNullValue
()
{
Entry
[]
tab
=
table
;
Entry
<?,?>
[]
tab
=
table
;
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
Entry
e
=
tab
[
i
]
;
e
!=
null
;
e
=
e
.
next
)
for
(
Entry
<?,?>
e
=
tab
[
i
]
;
e
!=
null
;
e
=
e
.
next
)
if
(
e
.
value
==
null
)
if
(
e
.
value
==
null
)
return
true
;
return
true
;
return
false
;
return
false
;
...
@@ -667,6 +677,7 @@ public class HashMap<K,V>
...
@@ -667,6 +677,7 @@ public class HashMap<K,V>
*
*
* @return a shallow copy of this map
* @return a shallow copy of this map
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
Object
clone
()
{
public
Object
clone
()
{
HashMap
<
K
,
V
>
result
=
null
;
HashMap
<
K
,
V
>
result
=
null
;
try
{
try
{
...
@@ -674,7 +685,7 @@ public class HashMap<K,V>
...
@@ -674,7 +685,7 @@ public class HashMap<K,V>
}
catch
(
CloneNotSupportedException
e
)
{
}
catch
(
CloneNotSupportedException
e
)
{
// assert false;
// assert false;
}
}
result
.
table
=
new
Entry
[
table
.
length
];
result
.
table
=
new
Entry
<?,?>
[
table
.
length
];
result
.
entrySet
=
null
;
result
.
entrySet
=
null
;
result
.
modCount
=
0
;
result
.
modCount
=
0
;
result
.
size
=
0
;
result
.
size
=
0
;
...
@@ -717,7 +728,7 @@ public class HashMap<K,V>
...
@@ -717,7 +728,7 @@ public class HashMap<K,V>
public
final
boolean
equals
(
Object
o
)
{
public
final
boolean
equals
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
e
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
e
=
(
Map
.
Entry
<?,?>
)
o
;
Object
k1
=
getKey
();
Object
k1
=
getKey
();
Object
k2
=
e
.
getKey
();
Object
k2
=
e
.
getKey
();
if
(
k1
==
k2
||
(
k1
!=
null
&&
k1
.
equals
(
k2
)))
{
if
(
k1
==
k2
||
(
k1
!=
null
&&
k1
.
equals
(
k2
)))
{
...
@@ -762,7 +773,8 @@ public class HashMap<K,V>
...
@@ -762,7 +773,8 @@ public class HashMap<K,V>
* Subclass overrides this to alter the behavior of put method.
* Subclass overrides this to alter the behavior of put method.
*/
*/
void
addEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
void
addEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
Entry
<
K
,
V
>
e
=
table
[
bucketIndex
];
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
table
[
bucketIndex
];
table
[
bucketIndex
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
table
[
bucketIndex
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
if
(
size
++
>=
threshold
)
if
(
size
++
>=
threshold
)
resize
(
2
*
table
.
length
);
resize
(
2
*
table
.
length
);
...
@@ -777,21 +789,22 @@ public class HashMap<K,V>
...
@@ -777,21 +789,22 @@ public class HashMap<K,V>
* clone, and readObject.
* clone, and readObject.
*/
*/
void
createEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
void
createEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
Entry
<
K
,
V
>
e
=
table
[
bucketIndex
];
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
table
[
bucketIndex
];
table
[
bucketIndex
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
table
[
bucketIndex
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
size
++;
size
++;
}
}
private
abstract
class
HashIterator
<
E
>
implements
Iterator
<
E
>
{
private
abstract
class
HashIterator
<
E
>
implements
Iterator
<
E
>
{
Entry
<
K
,
V
>
next
;
// next entry to return
Entry
<
?,?
>
next
;
// next entry to return
int
expectedModCount
;
// For fast-fail
int
expectedModCount
;
// For fast-fail
int
index
;
// current slot
int
index
;
// current slot
Entry
<
K
,
V
>
current
;
// current entry
Entry
<
?,?
>
current
;
// current entry
HashIterator
()
{
HashIterator
()
{
expectedModCount
=
modCount
;
expectedModCount
=
modCount
;
if
(
size
>
0
)
{
// advance to first entry
if
(
size
>
0
)
{
// advance to first entry
Entry
[]
t
=
table
;
Entry
<?,?>
[]
t
=
table
;
while
(
index
<
t
.
length
&&
(
next
=
t
[
index
++])
==
null
)
while
(
index
<
t
.
length
&&
(
next
=
t
[
index
++])
==
null
)
;
;
}
}
...
@@ -801,20 +814,21 @@ public class HashMap<K,V>
...
@@ -801,20 +814,21 @@ public class HashMap<K,V>
return
next
!=
null
;
return
next
!=
null
;
}
}
@SuppressWarnings
(
"unchecked"
)
final
Entry
<
K
,
V
>
nextEntry
()
{
final
Entry
<
K
,
V
>
nextEntry
()
{
if
(
modCount
!=
expectedModCount
)
if
(
modCount
!=
expectedModCount
)
throw
new
ConcurrentModificationException
();
throw
new
ConcurrentModificationException
();
Entry
<
K
,
V
>
e
=
next
;
Entry
<
?,?
>
e
=
next
;
if
(
e
==
null
)
if
(
e
==
null
)
throw
new
NoSuchElementException
();
throw
new
NoSuchElementException
();
if
((
next
=
e
.
next
)
==
null
)
{
if
((
next
=
e
.
next
)
==
null
)
{
Entry
[]
t
=
table
;
Entry
<?,?>
[]
t
=
table
;
while
(
index
<
t
.
length
&&
(
next
=
t
[
index
++])
==
null
)
while
(
index
<
t
.
length
&&
(
next
=
t
[
index
++])
==
null
)
;
;
}
}
current
=
e
;
current
=
e
;
return
e
;
return
(
Entry
<
K
,
V
>)
e
;
}
}
public
void
remove
()
{
public
void
remove
()
{
...
@@ -965,7 +979,7 @@ public class HashMap<K,V>
...
@@ -965,7 +979,7 @@ public class HashMap<K,V>
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
<
K
,
V
>
e
=
(
Map
.
Entry
<
K
,
V
>)
o
;
Map
.
Entry
<
?,?>
e
=
(
Map
.
Entry
<?,?
>)
o
;
Entry
<
K
,
V
>
candidate
=
getEntry
(
e
.
getKey
());
Entry
<
K
,
V
>
candidate
=
getEntry
(
e
.
getKey
());
return
candidate
!=
null
&&
candidate
.
equals
(
e
);
return
candidate
!=
null
&&
candidate
.
equals
(
e
);
}
}
...
@@ -1039,7 +1053,9 @@ public class HashMap<K,V>
...
@@ -1039,7 +1053,9 @@ public class HashMap<K,V>
// Read the keys and values, and put the mappings in the HashMap
// Read the keys and values, and put the mappings in the HashMap
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
@SuppressWarnings
(
"unchecked"
)
K
key
=
(
K
)
s
.
readObject
();
K
key
=
(
K
)
s
.
readObject
();
@SuppressWarnings
(
"unchecked"
)
V
value
=
(
V
)
s
.
readObject
();
V
value
=
(
V
)
s
.
readObject
();
putForCreate
(
key
,
value
);
putForCreate
(
key
,
value
);
}
}
...
...
src/share/classes/java/util/HashSet.java
浏览文件 @
cb0fea8f
...
@@ -247,6 +247,7 @@ public class HashSet<E>
...
@@ -247,6 +247,7 @@ public class HashSet<E>
*
*
* @return a shallow copy of this set
* @return a shallow copy of this set
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
Object
clone
()
{
public
Object
clone
()
{
try
{
try
{
HashSet
<
E
>
newSet
=
(
HashSet
<
E
>)
super
.
clone
();
HashSet
<
E
>
newSet
=
(
HashSet
<
E
>)
super
.
clone
();
...
@@ -296,7 +297,7 @@ public class HashSet<E>
...
@@ -296,7 +297,7 @@ public class HashSet<E>
// Read in HashMap capacity and load factor and create backing HashMap
// Read in HashMap capacity and load factor and create backing HashMap
int
capacity
=
s
.
readInt
();
int
capacity
=
s
.
readInt
();
float
loadFactor
=
s
.
readFloat
();
float
loadFactor
=
s
.
readFloat
();
map
=
(((
HashSet
)
this
)
instanceof
LinkedHashSet
?
map
=
(((
HashSet
<?>
)
this
)
instanceof
LinkedHashSet
?
new
LinkedHashMap
<
E
,
Object
>(
capacity
,
loadFactor
)
:
new
LinkedHashMap
<
E
,
Object
>(
capacity
,
loadFactor
)
:
new
HashMap
<
E
,
Object
>(
capacity
,
loadFactor
));
new
HashMap
<
E
,
Object
>(
capacity
,
loadFactor
));
...
@@ -305,6 +306,7 @@ public class HashSet<E>
...
@@ -305,6 +306,7 @@ public class HashSet<E>
// Read in all elements in the proper order.
// Read in all elements in the proper order.
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
@SuppressWarnings
(
"unchecked"
)
E
e
=
(
E
)
s
.
readObject
();
E
e
=
(
E
)
s
.
readObject
();
map
.
put
(
e
,
PRESENT
);
map
.
put
(
e
,
PRESENT
);
}
}
...
...
src/share/classes/java/util/Hashtable.java
浏览文件 @
cb0fea8f
...
@@ -129,7 +129,7 @@ public class Hashtable<K,V>
...
@@ -129,7 +129,7 @@ public class Hashtable<K,V>
/**
/**
* The hash table data.
* The hash table data.
*/
*/
private
transient
Entry
[]
table
;
private
transient
Entry
<?,?>
[]
table
;
/**
/**
* The total number of entries in the hash table.
* The total number of entries in the hash table.
...
@@ -182,7 +182,7 @@ public class Hashtable<K,V>
...
@@ -182,7 +182,7 @@ public class Hashtable<K,V>
if
(
initialCapacity
==
0
)
if
(
initialCapacity
==
0
)
initialCapacity
=
1
;
initialCapacity
=
1
;
this
.
loadFactor
=
loadFactor
;
this
.
loadFactor
=
loadFactor
;
table
=
new
Entry
[
initialCapacity
];
table
=
new
Entry
<?,?>
[
initialCapacity
];
threshold
=
(
int
)(
initialCapacity
*
loadFactor
);
threshold
=
(
int
)(
initialCapacity
*
loadFactor
);
}
}
...
@@ -288,9 +288,9 @@ public class Hashtable<K,V>
...
@@ -288,9 +288,9 @@ public class Hashtable<K,V>
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
Entry
tab
[]
=
table
;
Entry
<?,?>
tab
[]
=
table
;
for
(
int
i
=
tab
.
length
;
i
--
>
0
;)
{
for
(
int
i
=
tab
.
length
;
i
--
>
0
;)
{
for
(
Entry
<
K
,
V
>
e
=
tab
[
i
]
;
e
!=
null
;
e
=
e
.
next
)
{
for
(
Entry
<
?,?
>
e
=
tab
[
i
]
;
e
!=
null
;
e
=
e
.
next
)
{
if
(
e
.
value
.
equals
(
value
))
{
if
(
e
.
value
.
equals
(
value
))
{
return
true
;
return
true
;
}
}
...
@@ -326,10 +326,10 @@ public class Hashtable<K,V>
...
@@ -326,10 +326,10 @@ public class Hashtable<K,V>
* @see #contains(Object)
* @see #contains(Object)
*/
*/
public
synchronized
boolean
containsKey
(
Object
key
)
{
public
synchronized
boolean
containsKey
(
Object
key
)
{
Entry
tab
[]
=
table
;
Entry
<?,?>
tab
[]
=
table
;
int
hash
=
key
.
hashCode
();
int
hash
=
key
.
hashCode
();
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
for
(
Entry
<
K
,
V
>
e
=
tab
[
index
]
;
e
!=
null
;
e
=
e
.
next
)
{
for
(
Entry
<
?,?
>
e
=
tab
[
index
]
;
e
!=
null
;
e
=
e
.
next
)
{
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
return
true
;
return
true
;
}
}
...
@@ -352,13 +352,14 @@ public class Hashtable<K,V>
...
@@ -352,13 +352,14 @@ public class Hashtable<K,V>
* @throws NullPointerException if the specified key is null
* @throws NullPointerException if the specified key is null
* @see #put(Object, Object)
* @see #put(Object, Object)
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
synchronized
V
get
(
Object
key
)
{
public
synchronized
V
get
(
Object
key
)
{
Entry
tab
[]
=
table
;
Entry
<?,?>
tab
[]
=
table
;
int
hash
=
key
.
hashCode
();
int
hash
=
key
.
hashCode
();
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
for
(
Entry
<
K
,
V
>
e
=
tab
[
index
]
;
e
!=
null
;
e
=
e
.
next
)
{
for
(
Entry
<
?,?
>
e
=
tab
[
index
]
;
e
!=
null
;
e
=
e
.
next
)
{
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
return
e
.
value
;
return
(
V
)
e
.
value
;
}
}
}
}
return
null
;
return
null
;
...
@@ -379,9 +380,10 @@ public class Hashtable<K,V>
...
@@ -379,9 +380,10 @@ public class Hashtable<K,V>
* number of keys in the hashtable exceeds this hashtable's capacity
* number of keys in the hashtable exceeds this hashtable's capacity
* and load factor.
* and load factor.
*/
*/
@SuppressWarnings
(
"unchecked"
)
protected
void
rehash
()
{
protected
void
rehash
()
{
int
oldCapacity
=
table
.
length
;
int
oldCapacity
=
table
.
length
;
Entry
[]
oldMap
=
table
;
Entry
<?,?>
[]
oldMap
=
table
;
// overflow-conscious code
// overflow-conscious code
int
newCapacity
=
(
oldCapacity
<<
1
)
+
1
;
int
newCapacity
=
(
oldCapacity
<<
1
)
+
1
;
...
@@ -391,19 +393,19 @@ public class Hashtable<K,V>
...
@@ -391,19 +393,19 @@ public class Hashtable<K,V>
return
;
return
;
newCapacity
=
MAX_ARRAY_SIZE
;
newCapacity
=
MAX_ARRAY_SIZE
;
}
}
Entry
[]
newMap
=
new
Entry
[
newCapacity
];
Entry
<?,?>[]
newMap
=
new
Entry
<?,?>
[
newCapacity
];
modCount
++;
modCount
++;
threshold
=
(
int
)(
newCapacity
*
loadFactor
);
threshold
=
(
int
)(
newCapacity
*
loadFactor
);
table
=
newMap
;
table
=
newMap
;
for
(
int
i
=
oldCapacity
;
i
--
>
0
;)
{
for
(
int
i
=
oldCapacity
;
i
--
>
0
;)
{
for
(
Entry
<
K
,
V
>
old
=
oldMap
[
i
]
;
old
!=
null
;
)
{
for
(
Entry
<
K
,
V
>
old
=
(
Entry
<
K
,
V
>)
oldMap
[
i
]
;
old
!=
null
;
)
{
Entry
<
K
,
V
>
e
=
old
;
Entry
<
K
,
V
>
e
=
old
;
old
=
old
.
next
;
old
=
old
.
next
;
int
index
=
(
e
.
hash
&
0x7FFFFFFF
)
%
newCapacity
;
int
index
=
(
e
.
hash
&
0x7FFFFFFF
)
%
newCapacity
;
e
.
next
=
newMap
[
index
];
e
.
next
=
(
Entry
<
K
,
V
>)
newMap
[
index
];
newMap
[
index
]
=
e
;
newMap
[
index
]
=
e
;
}
}
}
}
...
@@ -433,13 +435,15 @@ public class Hashtable<K,V>
...
@@ -433,13 +435,15 @@ public class Hashtable<K,V>
}
}
// Makes sure the key is not already in the hashtable.
// Makes sure the key is not already in the hashtable.
Entry
tab
[]
=
table
;
Entry
<?,?>
tab
[]
=
table
;
int
hash
=
key
.
hashCode
();
int
hash
=
key
.
hashCode
();
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
for
(
Entry
<
K
,
V
>
e
=
tab
[
index
]
;
e
!=
null
;
e
=
e
.
next
)
{
@SuppressWarnings
(
"unchecked"
)
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
Entry
<
K
,
V
>
entry
=
(
Entry
<
K
,
V
>)
tab
[
index
];
V
old
=
e
.
value
;
for
(;
entry
!=
null
;
entry
=
entry
.
next
)
{
e
.
value
=
value
;
if
((
entry
.
hash
==
hash
)
&&
entry
.
key
.
equals
(
key
))
{
V
old
=
entry
.
value
;
entry
.
value
=
value
;
return
old
;
return
old
;
}
}
}
}
...
@@ -454,7 +458,8 @@ public class Hashtable<K,V>
...
@@ -454,7 +458,8 @@ public class Hashtable<K,V>
}
}
// Creates the new entry.
// Creates the new entry.
Entry
<
K
,
V
>
e
=
tab
[
index
];
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
tab
[
index
];
tab
[
index
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
tab
[
index
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
count
++;
count
++;
return
null
;
return
null
;
...
@@ -470,10 +475,12 @@ public class Hashtable<K,V>
...
@@ -470,10 +475,12 @@ public class Hashtable<K,V>
* @throws NullPointerException if the key is <code>null</code>
* @throws NullPointerException if the key is <code>null</code>
*/
*/
public
synchronized
V
remove
(
Object
key
)
{
public
synchronized
V
remove
(
Object
key
)
{
Entry
tab
[]
=
table
;
Entry
<?,?>
tab
[]
=
table
;
int
hash
=
key
.
hashCode
();
int
hash
=
key
.
hashCode
();
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
for
(
Entry
<
K
,
V
>
e
=
tab
[
index
],
prev
=
null
;
e
!=
null
;
prev
=
e
,
e
=
e
.
next
)
{
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
tab
[
index
];
for
(
Entry
<
K
,
V
>
prev
=
null
;
e
!=
null
;
prev
=
e
,
e
=
e
.
next
)
{
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
modCount
++;
modCount
++;
if
(
prev
!=
null
)
{
if
(
prev
!=
null
)
{
...
@@ -508,7 +515,7 @@ public class Hashtable<K,V>
...
@@ -508,7 +515,7 @@ public class Hashtable<K,V>
* Clears this hashtable so that it contains no keys.
* Clears this hashtable so that it contains no keys.
*/
*/
public
synchronized
void
clear
()
{
public
synchronized
void
clear
()
{
Entry
tab
[]
=
table
;
Entry
<?,?>
tab
[]
=
table
;
modCount
++;
modCount
++;
for
(
int
index
=
tab
.
length
;
--
index
>=
0
;
)
for
(
int
index
=
tab
.
length
;
--
index
>=
0
;
)
tab
[
index
]
=
null
;
tab
[
index
]
=
null
;
...
@@ -524,11 +531,11 @@ public class Hashtable<K,V>
...
@@ -524,11 +531,11 @@ public class Hashtable<K,V>
*/
*/
public
synchronized
Object
clone
()
{
public
synchronized
Object
clone
()
{
try
{
try
{
Hashtable
<
K
,
V
>
t
=
(
Hashtable
<
K
,
V
>)
super
.
clone
();
Hashtable
<
?,?>
t
=
(
Hashtable
<?,?>)
super
.
clone
();
t
.
table
=
new
Entry
[
table
.
length
];
t
.
table
=
new
Entry
<?,?>
[
table
.
length
];
for
(
int
i
=
table
.
length
;
i
--
>
0
;
)
{
for
(
int
i
=
table
.
length
;
i
--
>
0
;
)
{
t
.
table
[
i
]
=
(
table
[
i
]
!=
null
)
t
.
table
[
i
]
=
(
table
[
i
]
!=
null
)
?
(
Entry
<
K
,
V
>)
table
[
i
].
clone
()
:
null
;
?
(
Entry
<
?,?
>)
table
[
i
].
clone
()
:
null
;
}
}
t
.
keySet
=
null
;
t
.
keySet
=
null
;
t
.
entrySet
=
null
;
t
.
entrySet
=
null
;
...
@@ -675,13 +682,13 @@ public class Hashtable<K,V>
...
@@ -675,13 +682,13 @@ public class Hashtable<K,V>
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
entry
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
entry
=
(
Map
.
Entry
<?,?>
)
o
;
Object
key
=
entry
.
getKey
();
Object
key
=
entry
.
getKey
();
Entry
[]
tab
=
table
;
Entry
<?,?>
[]
tab
=
table
;
int
hash
=
key
.
hashCode
();
int
hash
=
key
.
hashCode
();
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
for
(
Entry
e
=
tab
[
index
];
e
!=
null
;
e
=
e
.
next
)
for
(
Entry
<?,?>
e
=
tab
[
index
];
e
!=
null
;
e
=
e
.
next
)
if
(
e
.
hash
==
hash
&&
e
.
equals
(
entry
))
if
(
e
.
hash
==
hash
&&
e
.
equals
(
entry
))
return
true
;
return
true
;
return
false
;
return
false
;
...
@@ -690,14 +697,15 @@ public class Hashtable<K,V>
...
@@ -690,14 +697,15 @@ public class Hashtable<K,V>
public
boolean
remove
(
Object
o
)
{
public
boolean
remove
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
<
K
,
V
>
entry
=
(
Map
.
Entry
<
K
,
V
>)
o
;
Map
.
Entry
<
?,?>
entry
=
(
Map
.
Entry
<?,?
>)
o
;
K
key
=
entry
.
getKey
();
Object
key
=
entry
.
getKey
();
Entry
[]
tab
=
table
;
Entry
<?,?>
[]
tab
=
table
;
int
hash
=
key
.
hashCode
();
int
hash
=
key
.
hashCode
();
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
for
(
Entry
<
K
,
V
>
e
=
tab
[
index
],
prev
=
null
;
e
!=
null
;
@SuppressWarnings
(
"unchecked"
)
prev
=
e
,
e
=
e
.
next
)
{
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
tab
[
index
];
for
(
Entry
<
K
,
V
>
prev
=
null
;
e
!=
null
;
prev
=
e
,
e
=
e
.
next
)
{
if
(
e
.
hash
==
hash
&&
e
.
equals
(
entry
))
{
if
(
e
.
hash
==
hash
&&
e
.
equals
(
entry
))
{
modCount
++;
modCount
++;
if
(
prev
!=
null
)
if
(
prev
!=
null
)
...
@@ -776,7 +784,7 @@ public class Hashtable<K,V>
...
@@ -776,7 +784,7 @@ public class Hashtable<K,V>
if
(!(
o
instanceof
Map
))
if
(!(
o
instanceof
Map
))
return
false
;
return
false
;
Map
<
K
,
V
>
t
=
(
Map
<
K
,
V
>)
o
;
Map
<
?,?>
t
=
(
Map
<?,?
>)
o
;
if
(
t
.
size
()
!=
size
())
if
(
t
.
size
()
!=
size
())
return
false
;
return
false
;
...
@@ -826,9 +834,9 @@ public class Hashtable<K,V>
...
@@ -826,9 +834,9 @@ public class Hashtable<K,V>
return
h
;
// Returns zero
return
h
;
// Returns zero
loadFactor
=
-
loadFactor
;
// Mark hashCode computation in progress
loadFactor
=
-
loadFactor
;
// Mark hashCode computation in progress
Entry
[]
tab
=
table
;
Entry
<?,?>
[]
tab
=
table
;
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
Entry
e
=
tab
[
i
];
e
!=
null
;
e
=
e
.
next
)
for
(
Entry
<?,?>
e
=
tab
[
i
];
e
!=
null
;
e
=
e
.
next
)
h
+=
e
.
key
.
hashCode
()
^
e
.
value
.
hashCode
();
h
+=
e
.
key
.
hashCode
()
^
e
.
value
.
hashCode
();
loadFactor
=
-
loadFactor
;
// Mark hashCode computation complete
loadFactor
=
-
loadFactor
;
// Mark hashCode computation complete
...
@@ -859,7 +867,7 @@ public class Hashtable<K,V>
...
@@ -859,7 +867,7 @@ public class Hashtable<K,V>
// Stack copies of the entries in the table
// Stack copies of the entries in the table
for
(
int
index
=
0
;
index
<
table
.
length
;
index
++)
{
for
(
int
index
=
0
;
index
<
table
.
length
;
index
++)
{
Entry
entry
=
table
[
index
];
Entry
<?,?>
entry
=
table
[
index
];
while
(
entry
!=
null
)
{
while
(
entry
!=
null
)
{
entryStack
=
entryStack
=
...
@@ -899,13 +907,14 @@ public class Hashtable<K,V>
...
@@ -899,13 +907,14 @@ public class Hashtable<K,V>
length
--;
length
--;
if
(
origlength
>
0
&&
length
>
origlength
)
if
(
origlength
>
0
&&
length
>
origlength
)
length
=
origlength
;
length
=
origlength
;
Entry
<?,?>[]
table
=
new
Entry
<?,?>[
length
];
Entry
[]
table
=
new
Entry
[
length
];
count
=
0
;
count
=
0
;
// Read the number of elements and then all the key/value objects
// Read the number of elements and then all the key/value objects
for
(;
elements
>
0
;
elements
--)
{
for
(;
elements
>
0
;
elements
--)
{
@SuppressWarnings
(
"unchecked"
)
K
key
=
(
K
)
s
.
readObject
();
K
key
=
(
K
)
s
.
readObject
();
@SuppressWarnings
(
"unchecked"
)
V
value
=
(
V
)
s
.
readObject
();
V
value
=
(
V
)
s
.
readObject
();
// synch could be eliminated for performance
// synch could be eliminated for performance
reconstitutionPut
(
table
,
key
,
value
);
reconstitutionPut
(
table
,
key
,
value
);
...
@@ -924,7 +933,7 @@ public class Hashtable<K,V>
...
@@ -924,7 +933,7 @@ public class Hashtable<K,V>
* because we are creating a new instance. Also, no return value
* because we are creating a new instance. Also, no return value
* is needed.
* is needed.
*/
*/
private
void
reconstitutionPut
(
Entry
[]
tab
,
K
key
,
V
value
)
private
void
reconstitutionPut
(
Entry
<?,?>
[]
tab
,
K
key
,
V
value
)
throws
StreamCorruptedException
throws
StreamCorruptedException
{
{
if
(
value
==
null
)
{
if
(
value
==
null
)
{
...
@@ -934,13 +943,14 @@ public class Hashtable<K,V>
...
@@ -934,13 +943,14 @@ public class Hashtable<K,V>
// This should not happen in deserialized version.
// This should not happen in deserialized version.
int
hash
=
key
.
hashCode
();
int
hash
=
key
.
hashCode
();
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
int
index
=
(
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
for
(
Entry
<
K
,
V
>
e
=
tab
[
index
]
;
e
!=
null
;
e
=
e
.
next
)
{
for
(
Entry
<
?,?
>
e
=
tab
[
index
]
;
e
!=
null
;
e
=
e
.
next
)
{
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
if
((
e
.
hash
==
hash
)
&&
e
.
key
.
equals
(
key
))
{
throw
new
java
.
io
.
StreamCorruptedException
();
throw
new
java
.
io
.
StreamCorruptedException
();
}
}
}
}
// Creates the new entry.
// Creates the new entry.
Entry
<
K
,
V
>
e
=
tab
[
index
];
@SuppressWarnings
(
"unchecked"
)
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
tab
[
index
];
tab
[
index
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
tab
[
index
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
count
++;
count
++;
}
}
...
@@ -961,6 +971,7 @@ public class Hashtable<K,V>
...
@@ -961,6 +971,7 @@ public class Hashtable<K,V>
this
.
next
=
next
;
this
.
next
=
next
;
}
}
@SuppressWarnings
(
"unchecked"
)
protected
Object
clone
()
{
protected
Object
clone
()
{
return
new
Entry
<>(
hash
,
key
,
value
,
return
new
Entry
<>(
hash
,
key
,
value
,
(
next
==
null
?
null
:
(
Entry
<
K
,
V
>)
next
.
clone
()));
(
next
==
null
?
null
:
(
Entry
<
K
,
V
>)
next
.
clone
()));
...
@@ -988,7 +999,7 @@ public class Hashtable<K,V>
...
@@ -988,7 +999,7 @@ public class Hashtable<K,V>
public
boolean
equals
(
Object
o
)
{
public
boolean
equals
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
e
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
e
=
(
Map
.
Entry
<?,?>
)
o
;
return
(
key
==
null
?
e
.
getKey
()==
null
:
key
.
equals
(
e
.
getKey
()))
&&
return
(
key
==
null
?
e
.
getKey
()==
null
:
key
.
equals
(
e
.
getKey
()))
&&
(
value
==
null
?
e
.
getValue
()==
null
:
value
.
equals
(
e
.
getValue
()));
(
value
==
null
?
e
.
getValue
()==
null
:
value
.
equals
(
e
.
getValue
()));
...
@@ -1016,10 +1027,10 @@ public class Hashtable<K,V>
...
@@ -1016,10 +1027,10 @@ public class Hashtable<K,V>
* by passing an Enumeration.
* by passing an Enumeration.
*/
*/
private
class
Enumerator
<
T
>
implements
Enumeration
<
T
>,
Iterator
<
T
>
{
private
class
Enumerator
<
T
>
implements
Enumeration
<
T
>,
Iterator
<
T
>
{
Entry
[]
table
=
Hashtable
.
this
.
table
;
Entry
<?,?>
[]
table
=
Hashtable
.
this
.
table
;
int
index
=
table
.
length
;
int
index
=
table
.
length
;
Entry
<
K
,
V
>
entry
=
null
;
Entry
<
?,?
>
entry
=
null
;
Entry
<
K
,
V
>
lastReturned
=
null
;
Entry
<
?,?
>
lastReturned
=
null
;
int
type
;
int
type
;
/**
/**
...
@@ -1041,9 +1052,9 @@ public class Hashtable<K,V>
...
@@ -1041,9 +1052,9 @@ public class Hashtable<K,V>
}
}
public
boolean
hasMoreElements
()
{
public
boolean
hasMoreElements
()
{
Entry
<
K
,
V
>
e
=
entry
;
Entry
<
?,?
>
e
=
entry
;
int
i
=
index
;
int
i
=
index
;
Entry
[]
t
=
table
;
Entry
<?,?>
[]
t
=
table
;
/* Use locals for faster loop iteration */
/* Use locals for faster loop iteration */
while
(
e
==
null
&&
i
>
0
)
{
while
(
e
==
null
&&
i
>
0
)
{
e
=
t
[--
i
];
e
=
t
[--
i
];
...
@@ -1053,10 +1064,11 @@ public class Hashtable<K,V>
...
@@ -1053,10 +1064,11 @@ public class Hashtable<K,V>
return
e
!=
null
;
return
e
!=
null
;
}
}
@SuppressWarnings
(
"unchecked"
)
public
T
nextElement
()
{
public
T
nextElement
()
{
Entry
<
K
,
V
>
et
=
entry
;
Entry
<
?,?
>
et
=
entry
;
int
i
=
index
;
int
i
=
index
;
Entry
[]
t
=
table
;
Entry
<?,?>
[]
t
=
table
;
/* Use locals for faster loop iteration */
/* Use locals for faster loop iteration */
while
(
et
==
null
&&
i
>
0
)
{
while
(
et
==
null
&&
i
>
0
)
{
et
=
t
[--
i
];
et
=
t
[--
i
];
...
@@ -1064,7 +1076,7 @@ public class Hashtable<K,V>
...
@@ -1064,7 +1076,7 @@ public class Hashtable<K,V>
entry
=
et
;
entry
=
et
;
index
=
i
;
index
=
i
;
if
(
et
!=
null
)
{
if
(
et
!=
null
)
{
Entry
<
K
,
V
>
e
=
lastReturned
=
entry
;
Entry
<
?,?
>
e
=
lastReturned
=
entry
;
entry
=
e
.
next
;
entry
=
e
.
next
;
return
type
==
KEYS
?
(
T
)
e
.
key
:
(
type
==
VALUES
?
(
T
)
e
.
value
:
(
T
)
e
);
return
type
==
KEYS
?
(
T
)
e
.
key
:
(
type
==
VALUES
?
(
T
)
e
.
value
:
(
T
)
e
);
}
}
...
@@ -1091,11 +1103,12 @@ public class Hashtable<K,V>
...
@@ -1091,11 +1103,12 @@ public class Hashtable<K,V>
throw
new
ConcurrentModificationException
();
throw
new
ConcurrentModificationException
();
synchronized
(
Hashtable
.
this
)
{
synchronized
(
Hashtable
.
this
)
{
Entry
[]
tab
=
Hashtable
.
this
.
table
;
Entry
<?,?>
[]
tab
=
Hashtable
.
this
.
table
;
int
index
=
(
lastReturned
.
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
int
index
=
(
lastReturned
.
hash
&
0x7FFFFFFF
)
%
tab
.
length
;
for
(
Entry
<
K
,
V
>
e
=
tab
[
index
],
prev
=
null
;
e
!=
null
;
@SuppressWarnings
(
"unchecked"
)
prev
=
e
,
e
=
e
.
next
)
{
Entry
<
K
,
V
>
e
=
(
Entry
<
K
,
V
>)
tab
[
index
];
for
(
Entry
<
K
,
V
>
prev
=
null
;
e
!=
null
;
prev
=
e
,
e
=
e
.
next
)
{
if
(
e
==
lastReturned
)
{
if
(
e
==
lastReturned
)
{
modCount
++;
modCount
++;
expectedModCount
++;
expectedModCount
++;
...
...
src/share/classes/java/util/IdentityHashMap.java
浏览文件 @
cb0fea8f
...
@@ -327,6 +327,7 @@ public class IdentityHashMap<K,V>
...
@@ -327,6 +327,7 @@ public class IdentityHashMap<K,V>
*
*
* @see #put(Object, Object)
* @see #put(Object, Object)
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
V
get
(
Object
key
)
{
public
V
get
(
Object
key
)
{
Object
k
=
maskNull
(
key
);
Object
k
=
maskNull
(
key
);
Object
[]
tab
=
table
;
Object
[]
tab
=
table
;
...
@@ -431,6 +432,7 @@ public class IdentityHashMap<K,V>
...
@@ -431,6 +432,7 @@ public class IdentityHashMap<K,V>
Object
item
;
Object
item
;
while
(
(
item
=
tab
[
i
])
!=
null
)
{
while
(
(
item
=
tab
[
i
])
!=
null
)
{
if
(
item
==
k
)
{
if
(
item
==
k
)
{
@SuppressWarnings
(
"unchecked"
)
V
oldValue
=
(
V
)
tab
[
i
+
1
];
V
oldValue
=
(
V
)
tab
[
i
+
1
];
tab
[
i
+
1
]
=
value
;
tab
[
i
+
1
]
=
value
;
return
oldValue
;
return
oldValue
;
...
@@ -524,6 +526,7 @@ public class IdentityHashMap<K,V>
...
@@ -524,6 +526,7 @@ public class IdentityHashMap<K,V>
if
(
item
==
k
)
{
if
(
item
==
k
)
{
modCount
++;
modCount
++;
size
--;
size
--;
@SuppressWarnings
(
"unchecked"
)
V
oldValue
=
(
V
)
tab
[
i
+
1
];
V
oldValue
=
(
V
)
tab
[
i
+
1
];
tab
[
i
+
1
]
=
null
;
tab
[
i
+
1
]
=
null
;
tab
[
i
]
=
null
;
tab
[
i
]
=
null
;
...
@@ -638,7 +641,7 @@ public class IdentityHashMap<K,V>
...
@@ -638,7 +641,7 @@ public class IdentityHashMap<K,V>
if
(
o
==
this
)
{
if
(
o
==
this
)
{
return
true
;
return
true
;
}
else
if
(
o
instanceof
IdentityHashMap
)
{
}
else
if
(
o
instanceof
IdentityHashMap
)
{
IdentityHashMap
m
=
(
IdentityHashMap
)
o
;
IdentityHashMap
<?,?>
m
=
(
IdentityHashMap
<?,?>
)
o
;
if
(
m
.
size
()
!=
size
)
if
(
m
.
size
()
!=
size
)
return
false
;
return
false
;
...
@@ -650,7 +653,7 @@ public class IdentityHashMap<K,V>
...
@@ -650,7 +653,7 @@ public class IdentityHashMap<K,V>
}
}
return
true
;
return
true
;
}
else
if
(
o
instanceof
Map
)
{
}
else
if
(
o
instanceof
Map
)
{
Map
m
=
(
Map
)
o
;
Map
<?,?>
m
=
(
Map
<?,?>
)
o
;
return
entrySet
().
equals
(
m
.
entrySet
());
return
entrySet
().
equals
(
m
.
entrySet
());
}
else
{
}
else
{
return
false
;
// o is not a Map
return
false
;
// o is not a Map
...
@@ -698,7 +701,7 @@ public class IdentityHashMap<K,V>
...
@@ -698,7 +701,7 @@ public class IdentityHashMap<K,V>
*/
*/
public
Object
clone
()
{
public
Object
clone
()
{
try
{
try
{
IdentityHashMap
<
K
,
V
>
m
=
(
IdentityHashMap
<
K
,
V
>)
super
.
clone
();
IdentityHashMap
<
?,?>
m
=
(
IdentityHashMap
<?,?
>)
super
.
clone
();
m
.
entrySet
=
null
;
m
.
entrySet
=
null
;
m
.
table
=
table
.
clone
();
m
.
table
=
table
.
clone
();
return
m
;
return
m
;
...
@@ -768,7 +771,7 @@ public class IdentityHashMap<K,V>
...
@@ -768,7 +771,7 @@ public class IdentityHashMap<K,V>
int
len
=
tab
.
length
;
int
len
=
tab
.
length
;
int
d
=
deletedSlot
;
int
d
=
deletedSlot
;
K
key
=
(
K
)
tab
[
d
];
Object
key
=
tab
[
d
];
tab
[
d
]
=
null
;
// vacate the slot
tab
[
d
]
=
null
;
// vacate the slot
tab
[
d
+
1
]
=
null
;
tab
[
d
+
1
]
=
null
;
...
@@ -818,12 +821,14 @@ public class IdentityHashMap<K,V>
...
@@ -818,12 +821,14 @@ public class IdentityHashMap<K,V>
}
}
private
class
KeyIterator
extends
IdentityHashMapIterator
<
K
>
{
private
class
KeyIterator
extends
IdentityHashMapIterator
<
K
>
{
@SuppressWarnings
(
"unchecked"
)
public
K
next
()
{
public
K
next
()
{
return
(
K
)
unmaskNull
(
traversalTable
[
nextIndex
()]);
return
(
K
)
unmaskNull
(
traversalTable
[
nextIndex
()]);
}
}
}
}
private
class
ValueIterator
extends
IdentityHashMapIterator
<
V
>
{
private
class
ValueIterator
extends
IdentityHashMapIterator
<
V
>
{
@SuppressWarnings
(
"unchecked"
)
public
V
next
()
{
public
V
next
()
{
return
(
V
)
traversalTable
[
nextIndex
()
+
1
];
return
(
V
)
traversalTable
[
nextIndex
()
+
1
];
}
}
...
@@ -854,16 +859,19 @@ public class IdentityHashMap<K,V>
...
@@ -854,16 +859,19 @@ public class IdentityHashMap<K,V>
this
.
index
=
index
;
this
.
index
=
index
;
}
}
@SuppressWarnings
(
"unchecked"
)
public
K
getKey
()
{
public
K
getKey
()
{
checkIndexForEntryUse
();
checkIndexForEntryUse
();
return
(
K
)
unmaskNull
(
traversalTable
[
index
]);
return
(
K
)
unmaskNull
(
traversalTable
[
index
]);
}
}
@SuppressWarnings
(
"unchecked"
)
public
V
getValue
()
{
public
V
getValue
()
{
checkIndexForEntryUse
();
checkIndexForEntryUse
();
return
(
V
)
traversalTable
[
index
+
1
];
return
(
V
)
traversalTable
[
index
+
1
];
}
}
@SuppressWarnings
(
"unchecked"
)
public
V
setValue
(
V
value
)
{
public
V
setValue
(
V
value
)
{
checkIndexForEntryUse
();
checkIndexForEntryUse
();
V
oldValue
=
(
V
)
traversalTable
[
index
+
1
];
V
oldValue
=
(
V
)
traversalTable
[
index
+
1
];
...
@@ -880,7 +888,7 @@ public class IdentityHashMap<K,V>
...
@@ -880,7 +888,7 @@ public class IdentityHashMap<K,V>
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
e
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
e
=
(
Map
.
Entry
<?,?>
)
o
;
return
(
e
.
getKey
()
==
unmaskNull
(
traversalTable
[
index
])
&&
return
(
e
.
getKey
()
==
unmaskNull
(
traversalTable
[
index
])
&&
e
.
getValue
()
==
traversalTable
[
index
+
1
]);
e
.
getValue
()
==
traversalTable
[
index
+
1
]);
}
}
...
@@ -1109,13 +1117,13 @@ public class IdentityHashMap<K,V>
...
@@ -1109,13 +1117,13 @@ public class IdentityHashMap<K,V>
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
entry
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
entry
=
(
Map
.
Entry
<?,?>
)
o
;
return
containsMapping
(
entry
.
getKey
(),
entry
.
getValue
());
return
containsMapping
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
public
boolean
remove
(
Object
o
)
{
public
boolean
remove
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
entry
=
(
Map
.
Entry
)
o
;
Map
.
Entry
<?,?>
entry
=
(
Map
.
Entry
<?,?>
)
o
;
return
removeMapping
(
entry
.
getKey
(),
entry
.
getValue
());
return
removeMapping
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
public
int
size
()
{
public
int
size
()
{
...
@@ -1213,7 +1221,9 @@ public class IdentityHashMap<K,V>
...
@@ -1213,7 +1221,9 @@ public class IdentityHashMap<K,V>
// Read the keys and values, and put the mappings in the table
// Read the keys and values, and put the mappings in the table
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
@SuppressWarnings
(
"unchecked"
)
K
key
=
(
K
)
s
.
readObject
();
K
key
=
(
K
)
s
.
readObject
();
@SuppressWarnings
(
"unchecked"
)
V
value
=
(
V
)
s
.
readObject
();
V
value
=
(
V
)
s
.
readObject
();
putForCreate
(
key
,
value
);
putForCreate
(
key
,
value
);
}
}
...
@@ -1226,7 +1236,7 @@ public class IdentityHashMap<K,V>
...
@@ -1226,7 +1236,7 @@ public class IdentityHashMap<K,V>
private
void
putForCreate
(
K
key
,
V
value
)
private
void
putForCreate
(
K
key
,
V
value
)
throws
IOException
throws
IOException
{
{
K
k
=
(
K
)
maskNull
(
key
);
Object
k
=
maskNull
(
key
);
Object
[]
tab
=
table
;
Object
[]
tab
=
table
;
int
len
=
tab
.
length
;
int
len
=
tab
.
length
;
int
i
=
hash
(
k
,
len
);
int
i
=
hash
(
k
,
len
);
...
...
src/share/classes/java/util/IllegalFormatConversionException.java
浏览文件 @
cb0fea8f
...
@@ -40,7 +40,7 @@ public class IllegalFormatConversionException extends IllegalFormatException {
...
@@ -40,7 +40,7 @@ public class IllegalFormatConversionException extends IllegalFormatException {
private
static
final
long
serialVersionUID
=
17000126L
;
private
static
final
long
serialVersionUID
=
17000126L
;
private
char
c
;
private
char
c
;
private
Class
arg
;
private
Class
<?>
arg
;
/**
/**
* Constructs an instance of this class with the mismatched conversion and
* Constructs an instance of this class with the mismatched conversion and
...
...
src/share/classes/java/util/JumboEnumSet.java
浏览文件 @
cb0fea8f
...
@@ -46,7 +46,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -46,7 +46,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
// Redundant - maintained for performance
// Redundant - maintained for performance
private
int
size
=
0
;
private
int
size
=
0
;
JumboEnumSet
(
Class
<
E
>
elementType
,
Enum
[]
universe
)
{
JumboEnumSet
(
Class
<
E
>
elementType
,
Enum
<?>
[]
universe
)
{
super
(
elementType
,
universe
);
super
(
elementType
,
universe
);
elements
=
new
long
[(
universe
.
length
+
63
)
>>>
6
];
elements
=
new
long
[(
universe
.
length
+
63
)
>>>
6
];
}
}
...
@@ -127,6 +127,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -127,6 +127,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
return
unseen
!=
0
;
return
unseen
!=
0
;
}
}
@Override
public
E
next
()
{
public
E
next
()
{
if
(!
hasNext
())
if
(!
hasNext
())
throw
new
NoSuchElementException
();
throw
new
NoSuchElementException
();
...
@@ -176,11 +177,11 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -176,11 +177,11 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
public
boolean
contains
(
Object
e
)
{
public
boolean
contains
(
Object
e
)
{
if
(
e
==
null
)
if
(
e
==
null
)
return
false
;
return
false
;
Class
eClass
=
e
.
getClass
();
Class
<?>
eClass
=
e
.
getClass
();
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
return
false
;
return
false
;
int
eOrdinal
=
((
Enum
)
e
).
ordinal
();
int
eOrdinal
=
((
Enum
<?>
)
e
).
ordinal
();
return
(
elements
[
eOrdinal
>>>
6
]
&
(
1L
<<
eOrdinal
))
!=
0
;
return
(
elements
[
eOrdinal
>>>
6
]
&
(
1L
<<
eOrdinal
))
!=
0
;
}
}
...
@@ -217,10 +218,10 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -217,10 +218,10 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
public
boolean
remove
(
Object
e
)
{
public
boolean
remove
(
Object
e
)
{
if
(
e
==
null
)
if
(
e
==
null
)
return
false
;
return
false
;
Class
eClass
=
e
.
getClass
();
Class
<?>
eClass
=
e
.
getClass
();
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
return
false
;
return
false
;
int
eOrdinal
=
((
Enum
)
e
).
ordinal
();
int
eOrdinal
=
((
Enum
<?>
)
e
).
ordinal
();
int
eWordNum
=
eOrdinal
>>>
6
;
int
eWordNum
=
eOrdinal
>>>
6
;
long
oldElements
=
elements
[
eWordNum
];
long
oldElements
=
elements
[
eWordNum
];
...
@@ -246,7 +247,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -246,7 +247,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
if
(!(
c
instanceof
JumboEnumSet
))
if
(!(
c
instanceof
JumboEnumSet
))
return
super
.
containsAll
(
c
);
return
super
.
containsAll
(
c
);
JumboEnumSet
es
=
(
JumboEnumSet
)
c
;
JumboEnumSet
<?>
es
=
(
JumboEnumSet
<?>
)
c
;
if
(
es
.
elementType
!=
elementType
)
if
(
es
.
elementType
!=
elementType
)
return
es
.
isEmpty
();
return
es
.
isEmpty
();
...
@@ -268,7 +269,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -268,7 +269,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
if
(!(
c
instanceof
JumboEnumSet
))
if
(!(
c
instanceof
JumboEnumSet
))
return
super
.
addAll
(
c
);
return
super
.
addAll
(
c
);
JumboEnumSet
es
=
(
JumboEnumSet
)
c
;
JumboEnumSet
<?>
es
=
(
JumboEnumSet
<?>
)
c
;
if
(
es
.
elementType
!=
elementType
)
{
if
(
es
.
elementType
!=
elementType
)
{
if
(
es
.
isEmpty
())
if
(
es
.
isEmpty
())
return
false
;
return
false
;
...
@@ -294,7 +295,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -294,7 +295,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
if
(!(
c
instanceof
JumboEnumSet
))
if
(!(
c
instanceof
JumboEnumSet
))
return
super
.
removeAll
(
c
);
return
super
.
removeAll
(
c
);
JumboEnumSet
es
=
(
JumboEnumSet
)
c
;
JumboEnumSet
<?>
es
=
(
JumboEnumSet
<?>
)
c
;
if
(
es
.
elementType
!=
elementType
)
if
(
es
.
elementType
!=
elementType
)
return
false
;
return
false
;
...
@@ -348,7 +349,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -348,7 +349,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
if
(!(
o
instanceof
JumboEnumSet
))
if
(!(
o
instanceof
JumboEnumSet
))
return
super
.
equals
(
o
);
return
super
.
equals
(
o
);
JumboEnumSet
es
=
(
JumboEnumSet
)
o
;
JumboEnumSet
<?>
es
=
(
JumboEnumSet
<?>
)
o
;
if
(
es
.
elementType
!=
elementType
)
if
(
es
.
elementType
!=
elementType
)
return
size
==
0
&&
es
.
size
==
0
;
return
size
==
0
&&
es
.
size
==
0
;
...
...
src/share/classes/java/util/LinkedHashMap.java
浏览文件 @
cb0fea8f
...
@@ -246,11 +246,12 @@ public class LinkedHashMap<K,V>
...
@@ -246,11 +246,12 @@ public class LinkedHashMap<K,V>
* by superclass resize. It is overridden for performance, as it is
* by superclass resize. It is overridden for performance, as it is
* faster to iterate using our linked list.
* faster to iterate using our linked list.
*/
*/
@SuppressWarnings
(
"unchecked"
)
void
transfer
(
HashMap
.
Entry
[]
newTable
)
{
void
transfer
(
HashMap
.
Entry
[]
newTable
)
{
int
newCapacity
=
newTable
.
length
;
int
newCapacity
=
newTable
.
length
;
for
(
Entry
<
K
,
V
>
e
=
header
.
after
;
e
!=
header
;
e
=
e
.
after
)
{
for
(
Entry
<
K
,
V
>
e
=
header
.
after
;
e
!=
header
;
e
=
e
.
after
)
{
int
index
=
indexFor
(
e
.
hash
,
newCapacity
);
int
index
=
indexFor
(
e
.
hash
,
newCapacity
);
e
.
next
=
newTable
[
index
];
e
.
next
=
(
HashMap
.
Entry
<
K
,
V
>)
newTable
[
index
];
newTable
[
index
]
=
e
;
newTable
[
index
]
=
e
;
}
}
}
}
...
@@ -267,11 +268,11 @@ public class LinkedHashMap<K,V>
...
@@ -267,11 +268,11 @@ public class LinkedHashMap<K,V>
public
boolean
containsValue
(
Object
value
)
{
public
boolean
containsValue
(
Object
value
)
{
// Overridden to take advantage of faster iterator
// Overridden to take advantage of faster iterator
if
(
value
==
null
)
{
if
(
value
==
null
)
{
for
(
Entry
e
=
header
.
after
;
e
!=
header
;
e
=
e
.
after
)
for
(
Entry
<?,?>
e
=
header
.
after
;
e
!=
header
;
e
=
e
.
after
)
if
(
e
.
value
==
null
)
if
(
e
.
value
==
null
)
return
true
;
return
true
;
}
else
{
}
else
{
for
(
Entry
e
=
header
.
after
;
e
!=
header
;
e
=
e
.
after
)
for
(
Entry
<?,?>
e
=
header
.
after
;
e
!=
header
;
e
=
e
.
after
)
if
(
value
.
equals
(
e
.
value
))
if
(
value
.
equals
(
e
.
value
))
return
true
;
return
true
;
}
}
...
@@ -437,7 +438,8 @@ public class LinkedHashMap<K,V>
...
@@ -437,7 +438,8 @@ public class LinkedHashMap<K,V>
* table or remove the eldest entry.
* table or remove the eldest entry.
*/
*/
void
createEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
void
createEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
HashMap
.
Entry
<
K
,
V
>
old
=
table
[
bucketIndex
];
@SuppressWarnings
(
"unchecked"
)
HashMap
.
Entry
<
K
,
V
>
old
=
(
HashMap
.
Entry
<
K
,
V
>)
table
[
bucketIndex
];
Entry
<
K
,
V
>
e
=
new
Entry
<>(
hash
,
key
,
value
,
old
);
Entry
<
K
,
V
>
e
=
new
Entry
<>(
hash
,
key
,
value
,
old
);
table
[
bucketIndex
]
=
e
;
table
[
bucketIndex
]
=
e
;
e
.
addBefore
(
header
);
e
.
addBefore
(
header
);
...
...
src/share/classes/java/util/Observable.java
浏览文件 @
cb0fea8f
...
@@ -61,12 +61,12 @@ package java.util;
...
@@ -61,12 +61,12 @@ package java.util;
*/
*/
public
class
Observable
{
public
class
Observable
{
private
boolean
changed
=
false
;
private
boolean
changed
=
false
;
private
Vector
obs
;
private
Vector
<
Observer
>
obs
;
/** Construct an Observable with zero Observers. */
/** Construct an Observable with zero Observers. */
public
Observable
()
{
public
Observable
()
{
obs
=
new
Vector
();
obs
=
new
Vector
<>
();
}
}
/**
/**
...
...
src/share/classes/java/util/PriorityQueue.java
浏览文件 @
cb0fea8f
...
@@ -449,6 +449,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -449,6 +449,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
* this queue
* this queue
* @throws NullPointerException if the specified array is null
* @throws NullPointerException if the specified array is null
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
if
(
a
.
length
<
size
)
if
(
a
.
length
<
size
)
// Make a new array of a's runtime type, but my contents:
// Make a new array of a's runtime type, but my contents:
...
@@ -514,6 +515,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -514,6 +515,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
(
forgetMeNot
!=
null
&&
!
forgetMeNot
.
isEmpty
());
(
forgetMeNot
!=
null
&&
!
forgetMeNot
.
isEmpty
());
}
}
@SuppressWarnings
(
"unchecked"
)
public
E
next
()
{
public
E
next
()
{
if
(
expectedModCount
!=
modCount
)
if
(
expectedModCount
!=
modCount
)
throw
new
ConcurrentModificationException
();
throw
new
ConcurrentModificationException
();
...
@@ -571,7 +573,9 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -571,7 +573,9 @@ public class PriorityQueue<E> extends AbstractQueue<E>
return
null
;
return
null
;
int
s
=
--
size
;
int
s
=
--
size
;
modCount
++;
modCount
++;
@SuppressWarnings
(
"unchecked"
)
E
result
=
(
E
)
queue
[
0
];
E
result
=
(
E
)
queue
[
0
];
@SuppressWarnings
(
"unchecked"
)
E
x
=
(
E
)
queue
[
s
];
E
x
=
(
E
)
queue
[
s
];
queue
[
s
]
=
null
;
queue
[
s
]
=
null
;
if
(
s
!=
0
)
if
(
s
!=
0
)
...
@@ -598,6 +602,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -598,6 +602,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
if
(
s
==
i
)
// removed last element
if
(
s
==
i
)
// removed last element
queue
[
i
]
=
null
;
queue
[
i
]
=
null
;
else
{
else
{
@SuppressWarnings
(
"unchecked"
)
E
moved
=
(
E
)
queue
[
s
];
E
moved
=
(
E
)
queue
[
s
];
queue
[
s
]
=
null
;
queue
[
s
]
=
null
;
siftDown
(
i
,
moved
);
siftDown
(
i
,
moved
);
...
@@ -629,6 +634,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -629,6 +634,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
siftUpComparable
(
k
,
x
);
siftUpComparable
(
k
,
x
);
}
}
@SuppressWarnings
(
"unchecked"
)
private
void
siftUpComparable
(
int
k
,
E
x
)
{
private
void
siftUpComparable
(
int
k
,
E
x
)
{
Comparable
<?
super
E
>
key
=
(
Comparable
<?
super
E
>)
x
;
Comparable
<?
super
E
>
key
=
(
Comparable
<?
super
E
>)
x
;
while
(
k
>
0
)
{
while
(
k
>
0
)
{
...
@@ -645,8 +651,9 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -645,8 +651,9 @@ public class PriorityQueue<E> extends AbstractQueue<E>
private
void
siftUpUsingComparator
(
int
k
,
E
x
)
{
private
void
siftUpUsingComparator
(
int
k
,
E
x
)
{
while
(
k
>
0
)
{
while
(
k
>
0
)
{
int
parent
=
(
k
-
1
)
>>>
1
;
int
parent
=
(
k
-
1
)
>>>
1
;
Object
e
=
queue
[
parent
];
@SuppressWarnings
(
"unchecked"
)
if
(
comparator
.
compare
(
x
,
(
E
)
e
)
>=
0
)
E
e
=
(
E
)
queue
[
parent
];
if
(
comparator
.
compare
(
x
,
e
)
>=
0
)
break
;
break
;
queue
[
k
]
=
e
;
queue
[
k
]
=
e
;
k
=
parent
;
k
=
parent
;
...
@@ -669,6 +676,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -669,6 +676,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
siftDownComparable
(
k
,
x
);
siftDownComparable
(
k
,
x
);
}
}
@SuppressWarnings
(
"unchecked"
)
private
void
siftDownComparable
(
int
k
,
E
x
)
{
private
void
siftDownComparable
(
int
k
,
E
x
)
{
Comparable
<?
super
E
>
key
=
(
Comparable
<?
super
E
>)
x
;
Comparable
<?
super
E
>
key
=
(
Comparable
<?
super
E
>)
x
;
int
half
=
size
>>>
1
;
// loop while a non-leaf
int
half
=
size
>>>
1
;
// loop while a non-leaf
...
@@ -687,6 +695,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -687,6 +695,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
queue
[
k
]
=
key
;
queue
[
k
]
=
key
;
}
}
@SuppressWarnings
(
"unchecked"
)
private
void
siftDownUsingComparator
(
int
k
,
E
x
)
{
private
void
siftDownUsingComparator
(
int
k
,
E
x
)
{
int
half
=
size
>>>
1
;
int
half
=
size
>>>
1
;
while
(
k
<
half
)
{
while
(
k
<
half
)
{
...
@@ -708,6 +717,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
...
@@ -708,6 +717,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
* Establishes the heap invariant (described above) in the entire tree,
* Establishes the heap invariant (described above) in the entire tree,
* assuming nothing about the order of the elements prior to the call.
* assuming nothing about the order of the elements prior to the call.
*/
*/
@SuppressWarnings
(
"unchecked"
)
private
void
heapify
()
{
private
void
heapify
()
{
for
(
int
i
=
(
size
>>>
1
)
-
1
;
i
>=
0
;
i
--)
for
(
int
i
=
(
size
>>>
1
)
-
1
;
i
>=
0
;
i
--)
siftDown
(
i
,
(
E
)
queue
[
i
]);
siftDown
(
i
,
(
E
)
queue
[
i
]);
...
...
src/share/classes/java/util/Properties.java
浏览文件 @
cb0fea8f
...
@@ -824,7 +824,7 @@ class Properties extends Hashtable<Object,Object> {
...
@@ -824,7 +824,7 @@ class Properties extends Hashtable<Object,Object> {
bw
.
write
(
"#"
+
new
Date
().
toString
());
bw
.
write
(
"#"
+
new
Date
().
toString
());
bw
.
newLine
();
bw
.
newLine
();
synchronized
(
this
)
{
synchronized
(
this
)
{
for
(
Enumeration
e
=
keys
();
e
.
hasMoreElements
();)
{
for
(
Enumeration
<?>
e
=
keys
();
e
.
hasMoreElements
();)
{
String
key
=
(
String
)
e
.
nextElement
();
String
key
=
(
String
)
e
.
nextElement
();
String
val
=
(
String
)
get
(
key
);
String
val
=
(
String
)
get
(
key
);
key
=
saveConvert
(
key
,
true
,
escUnicode
);
key
=
saveConvert
(
key
,
true
,
escUnicode
);
...
@@ -987,7 +987,7 @@ class Properties extends Hashtable<Object,Object> {
...
@@ -987,7 +987,7 @@ class Properties extends Hashtable<Object,Object> {
* @see #stringPropertyNames
* @see #stringPropertyNames
*/
*/
public
Enumeration
<?>
propertyNames
()
{
public
Enumeration
<?>
propertyNames
()
{
Hashtable
h
=
new
Hashtable
();
Hashtable
<
String
,
Object
>
h
=
new
Hashtable
<>
();
enumerate
(
h
);
enumerate
(
h
);
return
h
.
keys
();
return
h
.
keys
();
}
}
...
@@ -1026,10 +1026,10 @@ class Properties extends Hashtable<Object,Object> {
...
@@ -1026,10 +1026,10 @@ class Properties extends Hashtable<Object,Object> {
*/
*/
public
void
list
(
PrintStream
out
)
{
public
void
list
(
PrintStream
out
)
{
out
.
println
(
"-- listing properties --"
);
out
.
println
(
"-- listing properties --"
);
Hashtable
h
=
new
Hashtable
();
Hashtable
<
String
,
Object
>
h
=
new
Hashtable
<>
();
enumerate
(
h
);
enumerate
(
h
);
for
(
Enumeration
e
=
h
.
keys
()
;
e
.
hasMoreElements
()
;)
{
for
(
Enumeration
<
String
>
e
=
h
.
keys
()
;
e
.
hasMoreElements
()
;)
{
String
key
=
(
String
)
e
.
nextElement
();
String
key
=
e
.
nextElement
();
String
val
=
(
String
)
h
.
get
(
key
);
String
val
=
(
String
)
h
.
get
(
key
);
if
(
val
.
length
()
>
40
)
{
if
(
val
.
length
()
>
40
)
{
val
=
val
.
substring
(
0
,
37
)
+
"..."
;
val
=
val
.
substring
(
0
,
37
)
+
"..."
;
...
@@ -1054,10 +1054,10 @@ class Properties extends Hashtable<Object,Object> {
...
@@ -1054,10 +1054,10 @@ class Properties extends Hashtable<Object,Object> {
*/
*/
public
void
list
(
PrintWriter
out
)
{
public
void
list
(
PrintWriter
out
)
{
out
.
println
(
"-- listing properties --"
);
out
.
println
(
"-- listing properties --"
);
Hashtable
h
=
new
Hashtable
();
Hashtable
<
String
,
Object
>
h
=
new
Hashtable
<>
();
enumerate
(
h
);
enumerate
(
h
);
for
(
Enumeration
e
=
h
.
keys
()
;
e
.
hasMoreElements
()
;)
{
for
(
Enumeration
<
String
>
e
=
h
.
keys
()
;
e
.
hasMoreElements
()
;)
{
String
key
=
(
String
)
e
.
nextElement
();
String
key
=
e
.
nextElement
();
String
val
=
(
String
)
h
.
get
(
key
);
String
val
=
(
String
)
h
.
get
(
key
);
if
(
val
.
length
()
>
40
)
{
if
(
val
.
length
()
>
40
)
{
val
=
val
.
substring
(
0
,
37
)
+
"..."
;
val
=
val
.
substring
(
0
,
37
)
+
"..."
;
...
@@ -1072,11 +1072,11 @@ class Properties extends Hashtable<Object,Object> {
...
@@ -1072,11 +1072,11 @@ class Properties extends Hashtable<Object,Object> {
* @throws ClassCastException if any of the property keys
* @throws ClassCastException if any of the property keys
* is not of String type.
* is not of String type.
*/
*/
private
synchronized
void
enumerate
(
Hashtable
h
)
{
private
synchronized
void
enumerate
(
Hashtable
<
String
,
Object
>
h
)
{
if
(
defaults
!=
null
)
{
if
(
defaults
!=
null
)
{
defaults
.
enumerate
(
h
);
defaults
.
enumerate
(
h
);
}
}
for
(
Enumeration
e
=
keys
()
;
e
.
hasMoreElements
()
;)
{
for
(
Enumeration
<?>
e
=
keys
()
;
e
.
hasMoreElements
()
;)
{
String
key
=
(
String
)
e
.
nextElement
();
String
key
=
(
String
)
e
.
nextElement
();
h
.
put
(
key
,
get
(
key
));
h
.
put
(
key
,
get
(
key
));
}
}
...
@@ -1091,7 +1091,7 @@ class Properties extends Hashtable<Object,Object> {
...
@@ -1091,7 +1091,7 @@ class Properties extends Hashtable<Object,Object> {
if
(
defaults
!=
null
)
{
if
(
defaults
!=
null
)
{
defaults
.
enumerateStringProperties
(
h
);
defaults
.
enumerateStringProperties
(
h
);
}
}
for
(
Enumeration
e
=
keys
()
;
e
.
hasMoreElements
()
;)
{
for
(
Enumeration
<?>
e
=
keys
()
;
e
.
hasMoreElements
()
;)
{
Object
k
=
e
.
nextElement
();
Object
k
=
e
.
nextElement
();
Object
v
=
get
(
k
);
Object
v
=
get
(
k
);
if
(
k
instanceof
String
&&
v
instanceof
String
)
{
if
(
k
instanceof
String
&&
v
instanceof
String
)
{
...
...
src/share/classes/java/util/PropertyPermission.java
浏览文件 @
cb0fea8f
...
@@ -442,7 +442,7 @@ implements Serializable
...
@@ -442,7 +442,7 @@ implements Serializable
* Key is property name; value is PropertyPermission.
* Key is property name; value is PropertyPermission.
* Not serialized; see serialization section at end of class.
* Not serialized; see serialization section at end of class.
*/
*/
private
transient
Map
<
String
,
Permission
>
perms
;
private
transient
Map
<
String
,
P
ropertyP
ermission
>
perms
;
/**
/**
* Boolean saying if "*" is in the collection.
* Boolean saying if "*" is in the collection.
...
@@ -488,7 +488,7 @@ implements Serializable
...
@@ -488,7 +488,7 @@ implements Serializable
String
propName
=
pp
.
getName
();
String
propName
=
pp
.
getName
();
synchronized
(
this
)
{
synchronized
(
this
)
{
PropertyPermission
existing
=
(
PropertyPermission
)
perms
.
get
(
propName
);
PropertyPermission
existing
=
perms
.
get
(
propName
);
if
(
existing
!=
null
)
{
if
(
existing
!=
null
)
{
int
oldMask
=
existing
.
getMask
();
int
oldMask
=
existing
.
getMask
();
...
@@ -499,7 +499,7 @@ implements Serializable
...
@@ -499,7 +499,7 @@ implements Serializable
perms
.
put
(
propName
,
new
PropertyPermission
(
propName
,
actions
));
perms
.
put
(
propName
,
new
PropertyPermission
(
propName
,
actions
));
}
}
}
else
{
}
else
{
perms
.
put
(
propName
,
p
ermission
);
perms
.
put
(
propName
,
p
p
);
}
}
}
}
...
@@ -533,7 +533,7 @@ implements Serializable
...
@@ -533,7 +533,7 @@ implements Serializable
// short circuit if the "*" Permission was added
// short circuit if the "*" Permission was added
if
(
all_allowed
)
{
if
(
all_allowed
)
{
synchronized
(
this
)
{
synchronized
(
this
)
{
x
=
(
PropertyPermission
)
perms
.
get
(
"*"
);
x
=
perms
.
get
(
"*"
);
}
}
if
(
x
!=
null
)
{
if
(
x
!=
null
)
{
effective
|=
x
.
getMask
();
effective
|=
x
.
getMask
();
...
@@ -550,7 +550,7 @@ implements Serializable
...
@@ -550,7 +550,7 @@ implements Serializable
//System.out.println("check "+name);
//System.out.println("check "+name);
synchronized
(
this
)
{
synchronized
(
this
)
{
x
=
(
PropertyPermission
)
perms
.
get
(
name
);
x
=
perms
.
get
(
name
);
}
}
if
(
x
!=
null
)
{
if
(
x
!=
null
)
{
...
@@ -570,7 +570,7 @@ implements Serializable
...
@@ -570,7 +570,7 @@ implements Serializable
name
=
name
.
substring
(
0
,
last
+
1
)
+
"*"
;
name
=
name
.
substring
(
0
,
last
+
1
)
+
"*"
;
//System.out.println("check "+name);
//System.out.println("check "+name);
synchronized
(
this
)
{
synchronized
(
this
)
{
x
=
(
PropertyPermission
)
perms
.
get
(
name
);
x
=
perms
.
get
(
name
);
}
}
if
(
x
!=
null
)
{
if
(
x
!=
null
)
{
...
@@ -592,11 +592,15 @@ implements Serializable
...
@@ -592,11 +592,15 @@ implements Serializable
*
*
* @return an enumeration of all the PropertyPermission objects.
* @return an enumeration of all the PropertyPermission objects.
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
Enumeration
<
Permission
>
elements
()
{
public
Enumeration
<
Permission
>
elements
()
{
// Convert Iterator of Map values into an Enumeration
// Convert Iterator of Map values into an Enumeration
synchronized
(
this
)
{
synchronized
(
this
)
{
return
Collections
.
enumeration
(
perms
.
values
());
/**
* Casting to rawtype since Enumeration<PropertyPermission>
* cannot be directly cast to Enumeration<Permission>
*/
return
(
Enumeration
)
Collections
.
enumeration
(
perms
.
values
());
}
}
}
}
...
@@ -633,7 +637,8 @@ implements Serializable
...
@@ -633,7 +637,8 @@ implements Serializable
// Don't call out.defaultWriteObject()
// Don't call out.defaultWriteObject()
// Copy perms into a Hashtable
// Copy perms into a Hashtable
Hashtable
<
String
,
Permission
>
permissions
=
new
Hashtable
<>(
perms
.
size
()*
2
);
Hashtable
<
String
,
Permission
>
permissions
=
new
Hashtable
<>(
perms
.
size
()*
2
);
synchronized
(
this
)
{
synchronized
(
this
)
{
permissions
.
putAll
(
perms
);
permissions
.
putAll
(
perms
);
}
}
...
@@ -661,8 +666,8 @@ implements Serializable
...
@@ -661,8 +666,8 @@ implements Serializable
// Get permissions
// Get permissions
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Hashtable
<
String
,
Permission
>
permissions
=
Hashtable
<
String
,
P
ropertyP
ermission
>
permissions
=
(
Hashtable
<
String
,
Permission
>)
gfields
.
get
(
"permissions"
,
null
);
(
Hashtable
<
String
,
P
ropertyP
ermission
>)
gfields
.
get
(
"permissions"
,
null
);
perms
=
new
HashMap
<>(
permissions
.
size
()*
2
);
perms
=
new
HashMap
<>(
permissions
.
size
()*
2
);
perms
.
putAll
(
permissions
);
perms
.
putAll
(
permissions
);
}
}
...
...
src/share/classes/java/util/RegularEnumSet.java
浏览文件 @
cb0fea8f
...
@@ -41,7 +41,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -41,7 +41,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
*/
*/
private
long
elements
=
0L
;
private
long
elements
=
0L
;
RegularEnumSet
(
Class
<
E
>
elementType
,
Enum
[]
universe
)
{
RegularEnumSet
(
Class
<
E
>
elementType
,
Enum
<?>
[]
universe
)
{
super
(
elementType
,
universe
);
super
(
elementType
,
universe
);
}
}
...
@@ -96,6 +96,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -96,6 +96,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
return
unseen
!=
0
;
return
unseen
!=
0
;
}
}
@SuppressWarnings
(
"unchecked"
)
public
E
next
()
{
public
E
next
()
{
if
(
unseen
==
0
)
if
(
unseen
==
0
)
throw
new
NoSuchElementException
();
throw
new
NoSuchElementException
();
...
@@ -139,11 +140,11 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -139,11 +140,11 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
public
boolean
contains
(
Object
e
)
{
public
boolean
contains
(
Object
e
)
{
if
(
e
==
null
)
if
(
e
==
null
)
return
false
;
return
false
;
Class
eClass
=
e
.
getClass
();
Class
<?>
eClass
=
e
.
getClass
();
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
return
false
;
return
false
;
return
(
elements
&
(
1L
<<
((
Enum
)
e
).
ordinal
()))
!=
0
;
return
(
elements
&
(
1L
<<
((
Enum
<?>
)
e
).
ordinal
()))
!=
0
;
}
}
// Modification Operations
// Modification Operations
...
@@ -160,7 +161,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -160,7 +161,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
typeCheck
(
e
);
typeCheck
(
e
);
long
oldElements
=
elements
;
long
oldElements
=
elements
;
elements
|=
(
1L
<<
((
Enum
)
e
).
ordinal
());
elements
|=
(
1L
<<
((
Enum
<?>
)
e
).
ordinal
());
return
elements
!=
oldElements
;
return
elements
!=
oldElements
;
}
}
...
@@ -173,12 +174,12 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -173,12 +174,12 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
public
boolean
remove
(
Object
e
)
{
public
boolean
remove
(
Object
e
)
{
if
(
e
==
null
)
if
(
e
==
null
)
return
false
;
return
false
;
Class
eClass
=
e
.
getClass
();
Class
<?>
eClass
=
e
.
getClass
();
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
if
(
eClass
!=
elementType
&&
eClass
.
getSuperclass
()
!=
elementType
)
return
false
;
return
false
;
long
oldElements
=
elements
;
long
oldElements
=
elements
;
elements
&=
~(
1L
<<
((
Enum
)
e
).
ordinal
());
elements
&=
~(
1L
<<
((
Enum
<?>
)
e
).
ordinal
());
return
elements
!=
oldElements
;
return
elements
!=
oldElements
;
}
}
...
@@ -197,7 +198,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -197,7 +198,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
if
(!(
c
instanceof
RegularEnumSet
))
if
(!(
c
instanceof
RegularEnumSet
))
return
super
.
containsAll
(
c
);
return
super
.
containsAll
(
c
);
RegularEnumSet
es
=
(
RegularEnumSet
)
c
;
RegularEnumSet
<?>
es
=
(
RegularEnumSet
<?>
)
c
;
if
(
es
.
elementType
!=
elementType
)
if
(
es
.
elementType
!=
elementType
)
return
es
.
isEmpty
();
return
es
.
isEmpty
();
...
@@ -216,7 +217,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -216,7 +217,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
if
(!(
c
instanceof
RegularEnumSet
))
if
(!(
c
instanceof
RegularEnumSet
))
return
super
.
addAll
(
c
);
return
super
.
addAll
(
c
);
RegularEnumSet
es
=
(
RegularEnumSet
)
c
;
RegularEnumSet
<?>
es
=
(
RegularEnumSet
<?>
)
c
;
if
(
es
.
elementType
!=
elementType
)
{
if
(
es
.
elementType
!=
elementType
)
{
if
(
es
.
isEmpty
())
if
(
es
.
isEmpty
())
return
false
;
return
false
;
...
@@ -242,7 +243,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -242,7 +243,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
if
(!(
c
instanceof
RegularEnumSet
))
if
(!(
c
instanceof
RegularEnumSet
))
return
super
.
removeAll
(
c
);
return
super
.
removeAll
(
c
);
RegularEnumSet
es
=
(
RegularEnumSet
)
c
;
RegularEnumSet
<?>
es
=
(
RegularEnumSet
<?>
)
c
;
if
(
es
.
elementType
!=
elementType
)
if
(
es
.
elementType
!=
elementType
)
return
false
;
return
false
;
...
@@ -295,7 +296,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
...
@@ -295,7 +296,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
if
(!(
o
instanceof
RegularEnumSet
))
if
(!(
o
instanceof
RegularEnumSet
))
return
super
.
equals
(
o
);
return
super
.
equals
(
o
);
RegularEnumSet
es
=
(
RegularEnumSet
)
o
;
RegularEnumSet
<?>
es
=
(
RegularEnumSet
<?>
)
o
;
if
(
es
.
elementType
!=
elementType
)
if
(
es
.
elementType
!=
elementType
)
return
elements
==
0
&&
es
.
elements
==
0
;
return
elements
==
0
&&
es
.
elements
==
0
;
return
es
.
elements
==
elements
;
return
es
.
elements
==
elements
;
...
...
src/share/classes/java/util/ResourceBundle.java
浏览文件 @
cb0fea8f
...
@@ -294,7 +294,8 @@ public abstract class ResourceBundle {
...
@@ -294,7 +294,8 @@ public abstract class ResourceBundle {
/**
/**
* Queue for reference objects referring to class loaders or bundles.
* Queue for reference objects referring to class loaders or bundles.
*/
*/
private
static
final
ReferenceQueue
<
Object
>
referenceQueue
=
new
ReferenceQueue
<>();
private
static
final
ReferenceQueue
<
Object
>
referenceQueue
=
new
ReferenceQueue
<>();
/**
/**
* The parent bundle of this bundle.
* The parent bundle of this bundle.
...
@@ -417,7 +418,7 @@ public abstract class ResourceBundle {
...
@@ -417,7 +418,7 @@ public abstract class ResourceBundle {
* caller's caller.
* caller's caller.
*/
*/
private
static
ClassLoader
getLoader
()
{
private
static
ClassLoader
getLoader
()
{
Class
[]
stack
=
getClassContext
();
Class
<?>
[]
stack
=
getClassContext
();
/* Magic number 2 identifies our caller's caller */
/* Magic number 2 identifies our caller's caller */
Class
<?>
c
=
stack
[
2
];
Class
<?>
c
=
stack
[
2
];
ClassLoader
cl
=
(
c
==
null
)
?
null
:
c
.
getClassLoader
();
ClassLoader
cl
=
(
c
==
null
)
?
null
:
c
.
getClassLoader
();
...
@@ -434,7 +435,7 @@ public abstract class ResourceBundle {
...
@@ -434,7 +435,7 @@ public abstract class ResourceBundle {
return
cl
;
return
cl
;
}
}
private
static
native
Class
[]
getClassContext
();
private
static
native
Class
<?>
[]
getClassContext
();
/**
/**
* A wrapper of ClassLoader.getSystemClassLoader().
* A wrapper of ClassLoader.getSystemClassLoader().
...
...
src/share/classes/java/util/ServiceLoader.java
浏览文件 @
cb0fea8f
...
@@ -218,20 +218,20 @@ public final class ServiceLoader<S>
...
@@ -218,20 +218,20 @@ public final class ServiceLoader<S>
reload
();
reload
();
}
}
private
static
void
fail
(
Class
service
,
String
msg
,
Throwable
cause
)
private
static
void
fail
(
Class
<?>
service
,
String
msg
,
Throwable
cause
)
throws
ServiceConfigurationError
throws
ServiceConfigurationError
{
{
throw
new
ServiceConfigurationError
(
service
.
getName
()
+
": "
+
msg
,
throw
new
ServiceConfigurationError
(
service
.
getName
()
+
": "
+
msg
,
cause
);
cause
);
}
}
private
static
void
fail
(
Class
service
,
String
msg
)
private
static
void
fail
(
Class
<?>
service
,
String
msg
)
throws
ServiceConfigurationError
throws
ServiceConfigurationError
{
{
throw
new
ServiceConfigurationError
(
service
.
getName
()
+
": "
+
msg
);
throw
new
ServiceConfigurationError
(
service
.
getName
()
+
": "
+
msg
);
}
}
private
static
void
fail
(
Class
service
,
URL
u
,
int
line
,
String
msg
)
private
static
void
fail
(
Class
<?>
service
,
URL
u
,
int
line
,
String
msg
)
throws
ServiceConfigurationError
throws
ServiceConfigurationError
{
{
fail
(
service
,
u
+
":"
+
line
+
": "
+
msg
);
fail
(
service
,
u
+
":"
+
line
+
": "
+
msg
);
...
@@ -240,7 +240,7 @@ public final class ServiceLoader<S>
...
@@ -240,7 +240,7 @@ public final class ServiceLoader<S>
// Parse a single line from the given configuration file, adding the name
// Parse a single line from the given configuration file, adding the name
// on the line to the names list.
// on the line to the names list.
//
//
private
int
parseLine
(
Class
service
,
URL
u
,
BufferedReader
r
,
int
lc
,
private
int
parseLine
(
Class
<?>
service
,
URL
u
,
BufferedReader
r
,
int
lc
,
List
<
String
>
names
)
List
<
String
>
names
)
throws
IOException
,
ServiceConfigurationError
throws
IOException
,
ServiceConfigurationError
{
{
...
@@ -286,7 +286,7 @@ public final class ServiceLoader<S>
...
@@ -286,7 +286,7 @@ public final class ServiceLoader<S>
// If an I/O error occurs while reading from the given URL, or
// If an I/O error occurs while reading from the given URL, or
// if a configuration-file format error is detected
// if a configuration-file format error is detected
//
//
private
Iterator
<
String
>
parse
(
Class
service
,
URL
u
)
private
Iterator
<
String
>
parse
(
Class
<?>
service
,
URL
u
)
throws
ServiceConfigurationError
throws
ServiceConfigurationError
{
{
InputStream
in
=
null
;
InputStream
in
=
null
;
...
...
src/share/classes/java/util/TimeZone.java
浏览文件 @
cb0fea8f
...
@@ -428,7 +428,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
...
@@ -428,7 +428,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
// The structure is:
// The structure is:
// Map(key=id, value=SoftReference(Map(key=locale, value=displaynames)))
// Map(key=id, value=SoftReference(Map(key=locale, value=displaynames)))
private
static
final
Map
<
String
,
SoftReference
<
Map
<
Locale
,
String
[]>>>
CACHE
=
private
static
final
Map
<
String
,
SoftReference
<
Map
<
Locale
,
String
[]>>>
CACHE
=
new
ConcurrentHashMap
<
String
,
SoftReference
<
Map
<
Locale
,
String
[]>>
>();
new
ConcurrentHashMap
<>();
}
}
private
static
final
String
[]
getDisplayNames
(
String
id
,
Locale
locale
)
{
private
static
final
String
[]
getDisplayNames
(
String
id
,
Locale
locale
)
{
...
@@ -452,9 +452,9 @@ abstract public class TimeZone implements Serializable, Cloneable {
...
@@ -452,9 +452,9 @@ abstract public class TimeZone implements Serializable, Cloneable {
String
[]
names
=
TimeZoneNameUtility
.
retrieveDisplayNames
(
id
,
locale
);
String
[]
names
=
TimeZoneNameUtility
.
retrieveDisplayNames
(
id
,
locale
);
if
(
names
!=
null
)
{
if
(
names
!=
null
)
{
Map
<
Locale
,
String
[]>
perLocale
=
new
ConcurrentHashMap
<
Locale
,
String
[]
>();
Map
<
Locale
,
String
[]>
perLocale
=
new
ConcurrentHashMap
<>();
perLocale
.
put
(
locale
,
names
);
perLocale
.
put
(
locale
,
names
);
ref
=
new
SoftReference
<
Map
<
Locale
,
String
[]>
>(
perLocale
);
ref
=
new
SoftReference
<>(
perLocale
);
displayNames
.
put
(
id
,
ref
);
displayNames
.
put
(
id
,
ref
);
}
}
return
names
;
return
names
;
...
...
src/share/classes/java/util/TreeMap.java
浏览文件 @
cb0fea8f
...
@@ -307,7 +307,7 @@ public class TreeMap<K,V>
...
@@ -307,7 +307,7 @@ public class TreeMap<K,V>
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
map
)
{
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
map
)
{
int
mapSize
=
map
.
size
();
int
mapSize
=
map
.
size
();
if
(
size
==
0
&&
mapSize
!=
0
&&
map
instanceof
SortedMap
)
{
if
(
size
==
0
&&
mapSize
!=
0
&&
map
instanceof
SortedMap
)
{
Comparator
c
=
((
SortedMap
)
map
).
comparator
();
Comparator
<?>
c
=
((
SortedMap
<?,?>
)
map
).
comparator
();
if
(
c
==
comparator
||
(
c
!=
null
&&
c
.
equals
(
comparator
)))
{
if
(
c
==
comparator
||
(
c
!=
null
&&
c
.
equals
(
comparator
)))
{
++
modCount
;
++
modCount
;
try
{
try
{
...
@@ -340,6 +340,7 @@ public class TreeMap<K,V>
...
@@ -340,6 +340,7 @@ public class TreeMap<K,V>
return
getEntryUsingComparator
(
key
);
return
getEntryUsingComparator
(
key
);
if
(
key
==
null
)
if
(
key
==
null
)
throw
new
NullPointerException
();
throw
new
NullPointerException
();
@SuppressWarnings
(
"unchecked"
)
Comparable
<?
super
K
>
k
=
(
Comparable
<?
super
K
>)
key
;
Comparable
<?
super
K
>
k
=
(
Comparable
<?
super
K
>)
key
;
Entry
<
K
,
V
>
p
=
root
;
Entry
<
K
,
V
>
p
=
root
;
while
(
p
!=
null
)
{
while
(
p
!=
null
)
{
...
@@ -361,6 +362,7 @@ public class TreeMap<K,V>
...
@@ -361,6 +362,7 @@ public class TreeMap<K,V>
* worthwhile here.)
* worthwhile here.)
*/
*/
final
Entry
<
K
,
V
>
getEntryUsingComparator
(
Object
key
)
{
final
Entry
<
K
,
V
>
getEntryUsingComparator
(
Object
key
)
{
@SuppressWarnings
(
"unchecked"
)
K
k
=
(
K
)
key
;
K
k
=
(
K
)
key
;
Comparator
<?
super
K
>
cpr
=
comparator
;
Comparator
<?
super
K
>
cpr
=
comparator
;
if
(
cpr
!=
null
)
{
if
(
cpr
!=
null
)
{
...
@@ -554,6 +556,7 @@ public class TreeMap<K,V>
...
@@ -554,6 +556,7 @@ public class TreeMap<K,V>
else
{
else
{
if
(
key
==
null
)
if
(
key
==
null
)
throw
new
NullPointerException
();
throw
new
NullPointerException
();
@SuppressWarnings
(
"unchecked"
)
Comparable
<?
super
K
>
k
=
(
Comparable
<?
super
K
>)
key
;
Comparable
<?
super
K
>
k
=
(
Comparable
<?
super
K
>)
key
;
do
{
do
{
parent
=
t
;
parent
=
t
;
...
@@ -618,9 +621,9 @@ public class TreeMap<K,V>
...
@@ -618,9 +621,9 @@ public class TreeMap<K,V>
* @return a shallow copy of this map
* @return a shallow copy of this map
*/
*/
public
Object
clone
()
{
public
Object
clone
()
{
TreeMap
<
K
,
V
>
clone
=
null
;
TreeMap
<
?,?>
clone
;
try
{
try
{
clone
=
(
TreeMap
<
K
,
V
>)
super
.
clone
();
clone
=
(
TreeMap
<
?,?
>)
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
}
catch
(
CloneNotSupportedException
e
)
{
throw
new
InternalError
(
e
);
throw
new
InternalError
(
e
);
}
}
...
@@ -803,7 +806,7 @@ public class TreeMap<K,V>
...
@@ -803,7 +806,7 @@ public class TreeMap<K,V>
*/
*/
public
NavigableSet
<
K
>
navigableKeySet
()
{
public
NavigableSet
<
K
>
navigableKeySet
()
{
KeySet
<
K
>
nks
=
navigableKeySet
;
KeySet
<
K
>
nks
=
navigableKeySet
;
return
(
nks
!=
null
)
?
nks
:
(
navigableKeySet
=
new
KeySet
(
this
));
return
(
nks
!=
null
)
?
nks
:
(
navigableKeySet
=
new
KeySet
<>
(
this
));
}
}
/**
/**
...
@@ -859,7 +862,7 @@ public class TreeMap<K,V>
...
@@ -859,7 +862,7 @@ public class TreeMap<K,V>
public
NavigableMap
<
K
,
V
>
descendingMap
()
{
public
NavigableMap
<
K
,
V
>
descendingMap
()
{
NavigableMap
<
K
,
V
>
km
=
descendingMap
;
NavigableMap
<
K
,
V
>
km
=
descendingMap
;
return
(
km
!=
null
)
?
km
:
return
(
km
!=
null
)
?
km
:
(
descendingMap
=
new
DescendingSubMap
(
this
,
(
descendingMap
=
new
DescendingSubMap
<>
(
this
,
true
,
null
,
true
,
true
,
null
,
true
,
true
,
null
,
true
));
true
,
null
,
true
));
}
}
...
@@ -874,7 +877,7 @@ public class TreeMap<K,V>
...
@@ -874,7 +877,7 @@ public class TreeMap<K,V>
*/
*/
public
NavigableMap
<
K
,
V
>
subMap
(
K
fromKey
,
boolean
fromInclusive
,
public
NavigableMap
<
K
,
V
>
subMap
(
K
fromKey
,
boolean
fromInclusive
,
K
toKey
,
boolean
toInclusive
)
{
K
toKey
,
boolean
toInclusive
)
{
return
new
AscendingSubMap
(
this
,
return
new
AscendingSubMap
<>
(
this
,
false
,
fromKey
,
fromInclusive
,
false
,
fromKey
,
fromInclusive
,
false
,
toKey
,
toInclusive
);
false
,
toKey
,
toInclusive
);
}
}
...
@@ -888,7 +891,7 @@ public class TreeMap<K,V>
...
@@ -888,7 +891,7 @@ public class TreeMap<K,V>
* @since 1.6
* @since 1.6
*/
*/
public
NavigableMap
<
K
,
V
>
headMap
(
K
toKey
,
boolean
inclusive
)
{
public
NavigableMap
<
K
,
V
>
headMap
(
K
toKey
,
boolean
inclusive
)
{
return
new
AscendingSubMap
(
this
,
return
new
AscendingSubMap
<>
(
this
,
true
,
null
,
true
,
true
,
null
,
true
,
false
,
toKey
,
inclusive
);
false
,
toKey
,
inclusive
);
}
}
...
@@ -902,7 +905,7 @@ public class TreeMap<K,V>
...
@@ -902,7 +905,7 @@ public class TreeMap<K,V>
* @since 1.6
* @since 1.6
*/
*/
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
)
{
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
)
{
return
new
AscendingSubMap
(
this
,
return
new
AscendingSubMap
<>
(
this
,
false
,
fromKey
,
inclusive
,
false
,
fromKey
,
inclusive
,
true
,
null
,
true
);
true
,
null
,
true
);
}
}
...
@@ -978,8 +981,8 @@ public class TreeMap<K,V>
...
@@ -978,8 +981,8 @@ public class TreeMap<K,V>
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
<
K
,
V
>
entry
=
(
Map
.
Entry
<
K
,
V
>)
o
;
Map
.
Entry
<
?,?>
entry
=
(
Map
.
Entry
<?,?
>)
o
;
V
value
=
entry
.
getValue
();
Object
value
=
entry
.
getValue
();
Entry
<
K
,
V
>
p
=
getEntry
(
entry
.
getKey
());
Entry
<
K
,
V
>
p
=
getEntry
(
entry
.
getKey
());
return
p
!=
null
&&
valEquals
(
p
.
getValue
(),
value
);
return
p
!=
null
&&
valEquals
(
p
.
getValue
(),
value
);
}
}
...
@@ -987,8 +990,8 @@ public class TreeMap<K,V>
...
@@ -987,8 +990,8 @@ public class TreeMap<K,V>
public
boolean
remove
(
Object
o
)
{
public
boolean
remove
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
<
K
,
V
>
entry
=
(
Map
.
Entry
<
K
,
V
>)
o
;
Map
.
Entry
<
?,?>
entry
=
(
Map
.
Entry
<?,?
>)
o
;
V
value
=
entry
.
getValue
();
Object
value
=
entry
.
getValue
();
Entry
<
K
,
V
>
p
=
getEntry
(
entry
.
getKey
());
Entry
<
K
,
V
>
p
=
getEntry
(
entry
.
getKey
());
if
(
p
!=
null
&&
valEquals
(
p
.
getValue
(),
value
))
{
if
(
p
!=
null
&&
valEquals
(
p
.
getValue
(),
value
))
{
deleteEntry
(
p
);
deleteEntry
(
p
);
...
@@ -1023,21 +1026,21 @@ public class TreeMap<K,V>
...
@@ -1023,21 +1026,21 @@ public class TreeMap<K,V>
}
}
static
final
class
KeySet
<
E
>
extends
AbstractSet
<
E
>
implements
NavigableSet
<
E
>
{
static
final
class
KeySet
<
E
>
extends
AbstractSet
<
E
>
implements
NavigableSet
<
E
>
{
private
final
NavigableMap
<
E
,
Object
>
m
;
private
final
NavigableMap
<
E
,
?
>
m
;
KeySet
(
NavigableMap
<
E
,
Object
>
map
)
{
m
=
map
;
}
KeySet
(
NavigableMap
<
E
,
?
>
map
)
{
m
=
map
;
}
public
Iterator
<
E
>
iterator
()
{
public
Iterator
<
E
>
iterator
()
{
if
(
m
instanceof
TreeMap
)
if
(
m
instanceof
TreeMap
)
return
((
TreeMap
<
E
,
Object
>)
m
).
keyIterator
();
return
((
TreeMap
<
E
,
?
>)
m
).
keyIterator
();
else
else
return
(
Iterator
<
E
>)(((
TreeMap
.
NavigableSubMap
)
m
).
keyIterator
()
);
return
(
(
TreeMap
.
NavigableSubMap
<
E
,?>)
m
).
keyIterator
(
);
}
}
public
Iterator
<
E
>
descendingIterator
()
{
public
Iterator
<
E
>
descendingIterator
()
{
if
(
m
instanceof
TreeMap
)
if
(
m
instanceof
TreeMap
)
return
((
TreeMap
<
E
,
Object
>)
m
).
descendingKeyIterator
();
return
((
TreeMap
<
E
,
?
>)
m
).
descendingKeyIterator
();
else
else
return
(
Iterator
<
E
>)(((
TreeMap
.
NavigableSubMap
)
m
).
descendingKeyIterator
()
);
return
(
(
TreeMap
.
NavigableSubMap
<
E
,?>)
m
).
descendingKeyIterator
(
);
}
}
public
int
size
()
{
return
m
.
size
();
}
public
int
size
()
{
return
m
.
size
();
}
...
@@ -1052,11 +1055,11 @@ public class TreeMap<K,V>
...
@@ -1052,11 +1055,11 @@ public class TreeMap<K,V>
public
E
last
()
{
return
m
.
lastKey
();
}
public
E
last
()
{
return
m
.
lastKey
();
}
public
Comparator
<?
super
E
>
comparator
()
{
return
m
.
comparator
();
}
public
Comparator
<?
super
E
>
comparator
()
{
return
m
.
comparator
();
}
public
E
pollFirst
()
{
public
E
pollFirst
()
{
Map
.
Entry
<
E
,
Object
>
e
=
m
.
pollFirstEntry
();
Map
.
Entry
<
E
,
?
>
e
=
m
.
pollFirstEntry
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
}
}
public
E
pollLast
()
{
public
E
pollLast
()
{
Map
.
Entry
<
E
,
Object
>
e
=
m
.
pollLastEntry
();
Map
.
Entry
<
E
,
?
>
e
=
m
.
pollLastEntry
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
}
}
public
boolean
remove
(
Object
o
)
{
public
boolean
remove
(
Object
o
)
{
...
@@ -1085,7 +1088,7 @@ public class TreeMap<K,V>
...
@@ -1085,7 +1088,7 @@ public class TreeMap<K,V>
return
tailSet
(
fromElement
,
true
);
return
tailSet
(
fromElement
,
true
);
}
}
public
NavigableSet
<
E
>
descendingSet
()
{
public
NavigableSet
<
E
>
descendingSet
()
{
return
new
KeySet
(
m
.
descendingMap
());
return
new
KeySet
<>
(
m
.
descendingMap
());
}
}
}
}
...
@@ -1184,6 +1187,7 @@ public class TreeMap<K,V>
...
@@ -1184,6 +1187,7 @@ public class TreeMap<K,V>
/**
/**
* Compares two keys using the correct comparison method for this TreeMap.
* Compares two keys using the correct comparison method for this TreeMap.
*/
*/
@SuppressWarnings
(
"unchecked"
)
final
int
compare
(
Object
k1
,
Object
k2
)
{
final
int
compare
(
Object
k1
,
Object
k2
)
{
return
comparator
==
null
?
((
Comparable
<?
super
K
>)
k1
).
compareTo
((
K
)
k2
)
return
comparator
==
null
?
((
Comparable
<?
super
K
>)
k1
).
compareTo
((
K
)
k2
)
:
comparator
.
compare
((
K
)
k1
,
(
K
)
k2
);
:
comparator
.
compare
((
K
)
k1
,
(
K
)
k2
);
...
@@ -1488,7 +1492,7 @@ public class TreeMap<K,V>
...
@@ -1488,7 +1492,7 @@ public class TreeMap<K,V>
public
final
NavigableSet
<
K
>
navigableKeySet
()
{
public
final
NavigableSet
<
K
>
navigableKeySet
()
{
KeySet
<
K
>
nksv
=
navigableKeySetView
;
KeySet
<
K
>
nksv
=
navigableKeySetView
;
return
(
nksv
!=
null
)
?
nksv
:
return
(
nksv
!=
null
)
?
nksv
:
(
navigableKeySetView
=
new
TreeMap
.
KeySet
(
this
));
(
navigableKeySetView
=
new
TreeMap
.
KeySet
<>
(
this
));
}
}
public
final
Set
<
K
>
keySet
()
{
public
final
Set
<
K
>
keySet
()
{
...
@@ -1522,7 +1526,7 @@ public class TreeMap<K,V>
...
@@ -1522,7 +1526,7 @@ public class TreeMap<K,V>
if
(
size
==
-
1
||
sizeModCount
!=
m
.
modCount
)
{
if
(
size
==
-
1
||
sizeModCount
!=
m
.
modCount
)
{
sizeModCount
=
m
.
modCount
;
sizeModCount
=
m
.
modCount
;
size
=
0
;
size
=
0
;
Iterator
i
=
iterator
();
Iterator
<?>
i
=
iterator
();
while
(
i
.
hasNext
())
{
while
(
i
.
hasNext
())
{
size
++;
size
++;
i
.
next
();
i
.
next
();
...
@@ -1539,11 +1543,11 @@ public class TreeMap<K,V>
...
@@ -1539,11 +1543,11 @@ public class TreeMap<K,V>
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
<
K
,
V
>
entry
=
(
Map
.
Entry
<
K
,
V
>)
o
;
Map
.
Entry
<
?,?>
entry
=
(
Map
.
Entry
<?,?
>)
o
;
K
key
=
entry
.
getKey
();
Object
key
=
entry
.
getKey
();
if
(!
inRange
(
key
))
if
(!
inRange
(
key
))
return
false
;
return
false
;
TreeMap
.
Entry
node
=
m
.
getEntry
(
key
);
TreeMap
.
Entry
<?,?>
node
=
m
.
getEntry
(
key
);
return
node
!=
null
&&
return
node
!=
null
&&
valEquals
(
node
.
getValue
(),
entry
.
getValue
());
valEquals
(
node
.
getValue
(),
entry
.
getValue
());
}
}
...
@@ -1551,8 +1555,8 @@ public class TreeMap<K,V>
...
@@ -1551,8 +1555,8 @@ public class TreeMap<K,V>
public
boolean
remove
(
Object
o
)
{
public
boolean
remove
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
return
false
;
Map
.
Entry
<
K
,
V
>
entry
=
(
Map
.
Entry
<
K
,
V
>)
o
;
Map
.
Entry
<
?,?>
entry
=
(
Map
.
Entry
<?,?
>)
o
;
K
key
=
entry
.
getKey
();
Object
key
=
entry
.
getKey
();
if
(!
inRange
(
key
))
if
(!
inRange
(
key
))
return
false
;
return
false
;
TreeMap
.
Entry
<
K
,
V
>
node
=
m
.
getEntry
(
key
);
TreeMap
.
Entry
<
K
,
V
>
node
=
m
.
getEntry
(
key
);
...
@@ -1709,7 +1713,7 @@ public class TreeMap<K,V>
...
@@ -1709,7 +1713,7 @@ public class TreeMap<K,V>
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
if
(!
inRange
(
toKey
,
toInclusive
))
if
(!
inRange
(
toKey
,
toInclusive
))
throw
new
IllegalArgumentException
(
"toKey out of range"
);
throw
new
IllegalArgumentException
(
"toKey out of range"
);
return
new
AscendingSubMap
(
m
,
return
new
AscendingSubMap
<>
(
m
,
false
,
fromKey
,
fromInclusive
,
false
,
fromKey
,
fromInclusive
,
false
,
toKey
,
toInclusive
);
false
,
toKey
,
toInclusive
);
}
}
...
@@ -1717,7 +1721,7 @@ public class TreeMap<K,V>
...
@@ -1717,7 +1721,7 @@ public class TreeMap<K,V>
public
NavigableMap
<
K
,
V
>
headMap
(
K
toKey
,
boolean
inclusive
)
{
public
NavigableMap
<
K
,
V
>
headMap
(
K
toKey
,
boolean
inclusive
)
{
if
(!
inRange
(
toKey
,
inclusive
))
if
(!
inRange
(
toKey
,
inclusive
))
throw
new
IllegalArgumentException
(
"toKey out of range"
);
throw
new
IllegalArgumentException
(
"toKey out of range"
);
return
new
AscendingSubMap
(
m
,
return
new
AscendingSubMap
<>
(
m
,
fromStart
,
lo
,
loInclusive
,
fromStart
,
lo
,
loInclusive
,
false
,
toKey
,
inclusive
);
false
,
toKey
,
inclusive
);
}
}
...
@@ -1725,7 +1729,7 @@ public class TreeMap<K,V>
...
@@ -1725,7 +1729,7 @@ public class TreeMap<K,V>
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
)
{
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
)
{
if
(!
inRange
(
fromKey
,
inclusive
))
if
(!
inRange
(
fromKey
,
inclusive
))
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
return
new
AscendingSubMap
(
m
,
return
new
AscendingSubMap
<>
(
m
,
false
,
fromKey
,
inclusive
,
false
,
fromKey
,
inclusive
,
toEnd
,
hi
,
hiInclusive
);
toEnd
,
hi
,
hiInclusive
);
}
}
...
@@ -1734,7 +1738,7 @@ public class TreeMap<K,V>
...
@@ -1734,7 +1738,7 @@ public class TreeMap<K,V>
NavigableMap
<
K
,
V
>
mv
=
descendingMapView
;
NavigableMap
<
K
,
V
>
mv
=
descendingMapView
;
return
(
mv
!=
null
)
?
mv
:
return
(
mv
!=
null
)
?
mv
:
(
descendingMapView
=
(
descendingMapView
=
new
DescendingSubMap
(
m
,
new
DescendingSubMap
<>
(
m
,
fromStart
,
lo
,
loInclusive
,
fromStart
,
lo
,
loInclusive
,
toEnd
,
hi
,
hiInclusive
));
toEnd
,
hi
,
hiInclusive
));
}
}
...
@@ -1790,7 +1794,7 @@ public class TreeMap<K,V>
...
@@ -1790,7 +1794,7 @@ public class TreeMap<K,V>
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
if
(!
inRange
(
toKey
,
toInclusive
))
if
(!
inRange
(
toKey
,
toInclusive
))
throw
new
IllegalArgumentException
(
"toKey out of range"
);
throw
new
IllegalArgumentException
(
"toKey out of range"
);
return
new
DescendingSubMap
(
m
,
return
new
DescendingSubMap
<>
(
m
,
false
,
toKey
,
toInclusive
,
false
,
toKey
,
toInclusive
,
false
,
fromKey
,
fromInclusive
);
false
,
fromKey
,
fromInclusive
);
}
}
...
@@ -1798,7 +1802,7 @@ public class TreeMap<K,V>
...
@@ -1798,7 +1802,7 @@ public class TreeMap<K,V>
public
NavigableMap
<
K
,
V
>
headMap
(
K
toKey
,
boolean
inclusive
)
{
public
NavigableMap
<
K
,
V
>
headMap
(
K
toKey
,
boolean
inclusive
)
{
if
(!
inRange
(
toKey
,
inclusive
))
if
(!
inRange
(
toKey
,
inclusive
))
throw
new
IllegalArgumentException
(
"toKey out of range"
);
throw
new
IllegalArgumentException
(
"toKey out of range"
);
return
new
DescendingSubMap
(
m
,
return
new
DescendingSubMap
<>
(
m
,
false
,
toKey
,
inclusive
,
false
,
toKey
,
inclusive
,
toEnd
,
hi
,
hiInclusive
);
toEnd
,
hi
,
hiInclusive
);
}
}
...
@@ -1806,7 +1810,7 @@ public class TreeMap<K,V>
...
@@ -1806,7 +1810,7 @@ public class TreeMap<K,V>
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
)
{
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
)
{
if
(!
inRange
(
fromKey
,
inclusive
))
if
(!
inRange
(
fromKey
,
inclusive
))
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
return
new
DescendingSubMap
(
m
,
return
new
DescendingSubMap
<>
(
m
,
fromStart
,
lo
,
loInclusive
,
fromStart
,
lo
,
loInclusive
,
false
,
fromKey
,
inclusive
);
false
,
fromKey
,
inclusive
);
}
}
...
@@ -1815,7 +1819,7 @@ public class TreeMap<K,V>
...
@@ -1815,7 +1819,7 @@ public class TreeMap<K,V>
NavigableMap
<
K
,
V
>
mv
=
descendingMapView
;
NavigableMap
<
K
,
V
>
mv
=
descendingMapView
;
return
(
mv
!=
null
)
?
mv
:
return
(
mv
!=
null
)
?
mv
:
(
descendingMapView
=
(
descendingMapView
=
new
AscendingSubMap
(
m
,
new
AscendingSubMap
<>
(
m
,
fromStart
,
lo
,
loInclusive
,
fromStart
,
lo
,
loInclusive
,
toEnd
,
hi
,
hiInclusive
));
toEnd
,
hi
,
hiInclusive
));
}
}
...
@@ -1862,7 +1866,7 @@ public class TreeMap<K,V>
...
@@ -1862,7 +1866,7 @@ public class TreeMap<K,V>
private
boolean
fromStart
=
false
,
toEnd
=
false
;
private
boolean
fromStart
=
false
,
toEnd
=
false
;
private
K
fromKey
,
toKey
;
private
K
fromKey
,
toKey
;
private
Object
readResolve
()
{
private
Object
readResolve
()
{
return
new
AscendingSubMap
(
TreeMap
.
this
,
return
new
AscendingSubMap
<>
(
TreeMap
.
this
,
fromStart
,
fromKey
,
true
,
fromStart
,
fromKey
,
true
,
toEnd
,
toKey
,
false
);
toEnd
,
toKey
,
false
);
}
}
...
@@ -2331,12 +2335,12 @@ public class TreeMap<K,V>
...
@@ -2331,12 +2335,12 @@ public class TreeMap<K,V>
* @param defaultVal if non-null, this default value is used for
* @param defaultVal if non-null, this default value is used for
* each value in the map. If null, each value is read from
* each value in the map. If null, each value is read from
* iterator or stream, as described above.
* iterator or stream, as described above.
* @throws IOException propagated from stream reads. This cannot
* @throws
java.io.
IOException propagated from stream reads. This cannot
* occur if str is null.
* occur if str is null.
* @throws ClassNotFoundException propagated from readObject.
* @throws ClassNotFoundException propagated from readObject.
* This cannot occur if str is null.
* This cannot occur if str is null.
*/
*/
private
void
buildFromSorted
(
int
size
,
Iterator
it
,
private
void
buildFromSorted
(
int
size
,
Iterator
<?>
it
,
java
.
io
.
ObjectInputStream
str
,
java
.
io
.
ObjectInputStream
str
,
V
defaultVal
)
V
defaultVal
)
throws
java
.
io
.
IOException
,
ClassNotFoundException
{
throws
java
.
io
.
IOException
,
ClassNotFoundException
{
...
@@ -2359,9 +2363,10 @@ public class TreeMap<K,V>
...
@@ -2359,9 +2363,10 @@ public class TreeMap<K,V>
* @param redLevel the level at which nodes should be red.
* @param redLevel the level at which nodes should be red.
* Must be equal to computeRedLevel for tree of this size.
* Must be equal to computeRedLevel for tree of this size.
*/
*/
@SuppressWarnings
(
"unchecked"
)
private
final
Entry
<
K
,
V
>
buildFromSorted
(
int
level
,
int
lo
,
int
hi
,
private
final
Entry
<
K
,
V
>
buildFromSorted
(
int
level
,
int
lo
,
int
hi
,
int
redLevel
,
int
redLevel
,
Iterator
it
,
Iterator
<?>
it
,
java
.
io
.
ObjectInputStream
str
,
java
.
io
.
ObjectInputStream
str
,
V
defaultVal
)
V
defaultVal
)
throws
java
.
io
.
IOException
,
ClassNotFoundException
{
throws
java
.
io
.
IOException
,
ClassNotFoundException
{
...
@@ -2391,9 +2396,9 @@ public class TreeMap<K,V>
...
@@ -2391,9 +2396,9 @@ public class TreeMap<K,V>
V
value
;
V
value
;
if
(
it
!=
null
)
{
if
(
it
!=
null
)
{
if
(
defaultVal
==
null
)
{
if
(
defaultVal
==
null
)
{
Map
.
Entry
<
K
,
V
>
entry
=
(
Map
.
Entry
<
K
,
V
>)
it
.
next
();
Map
.
Entry
<
?,?>
entry
=
(
Map
.
Entry
<?,?
>)
it
.
next
();
key
=
entry
.
getKey
();
key
=
(
K
)
entry
.
getKey
();
value
=
entry
.
getValue
();
value
=
(
V
)
entry
.
getValue
();
}
else
{
}
else
{
key
=
(
K
)
it
.
next
();
key
=
(
K
)
it
.
next
();
value
=
defaultVal
;
value
=
defaultVal
;
...
...
src/share/classes/java/util/TreeSet.java
浏览文件 @
cb0fea8f
...
@@ -302,7 +302,7 @@ public class TreeSet<E> extends AbstractSet<E>
...
@@ -302,7 +302,7 @@ public class TreeSet<E> extends AbstractSet<E>
m
instanceof
TreeMap
)
{
m
instanceof
TreeMap
)
{
SortedSet
<?
extends
E
>
set
=
(
SortedSet
<?
extends
E
>)
c
;
SortedSet
<?
extends
E
>
set
=
(
SortedSet
<?
extends
E
>)
c
;
TreeMap
<
E
,
Object
>
map
=
(
TreeMap
<
E
,
Object
>)
m
;
TreeMap
<
E
,
Object
>
map
=
(
TreeMap
<
E
,
Object
>)
m
;
Comparator
<?
super
E
>
cc
=
(
Comparator
<?
super
E
>)
set
.
comparator
();
Comparator
<?
>
cc
=
set
.
comparator
();
Comparator
<?
super
E
>
mc
=
map
.
comparator
();
Comparator
<?
super
E
>
mc
=
map
.
comparator
();
if
(
cc
==
mc
||
(
cc
!=
null
&&
cc
.
equals
(
mc
)))
{
if
(
cc
==
mc
||
(
cc
!=
null
&&
cc
.
equals
(
mc
)))
{
map
.
addAllForTreeSet
(
set
,
PRESENT
);
map
.
addAllForTreeSet
(
set
,
PRESENT
);
...
@@ -469,8 +469,9 @@ public class TreeSet<E> extends AbstractSet<E>
...
@@ -469,8 +469,9 @@ public class TreeSet<E> extends AbstractSet<E>
*
*
* @return a shallow copy of this set
* @return a shallow copy of this set
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
Object
clone
()
{
public
Object
clone
()
{
TreeSet
<
E
>
clone
=
null
;
TreeSet
<
E
>
clone
;
try
{
try
{
clone
=
(
TreeSet
<
E
>)
super
.
clone
();
clone
=
(
TreeSet
<
E
>)
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
}
catch
(
CloneNotSupportedException
e
)
{
...
@@ -519,14 +520,11 @@ public class TreeSet<E> extends AbstractSet<E>
...
@@ -519,14 +520,11 @@ public class TreeSet<E> extends AbstractSet<E>
s
.
defaultReadObject
();
s
.
defaultReadObject
();
// Read in Comparator
// Read in Comparator
@SuppressWarnings
(
"unchecked"
)
Comparator
<?
super
E
>
c
=
(
Comparator
<?
super
E
>)
s
.
readObject
();
Comparator
<?
super
E
>
c
=
(
Comparator
<?
super
E
>)
s
.
readObject
();
// Create backing TreeMap
// Create backing TreeMap
TreeMap
<
E
,
Object
>
tm
;
TreeMap
<
E
,
Object
>
tm
=
new
TreeMap
<>(
c
);
if
(
c
==
null
)
tm
=
new
TreeMap
<>();
else
tm
=
new
TreeMap
<>(
c
);
m
=
tm
;
m
=
tm
;
// Read in size
// Read in size
...
...
src/share/classes/java/util/WeakHashMap.java
浏览文件 @
cb0fea8f
...
@@ -186,7 +186,7 @@ public class WeakHashMap<K,V>
...
@@ -186,7 +186,7 @@ public class WeakHashMap<K,V>
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
private
Entry
<
K
,
V
>[]
newTable
(
int
n
)
{
private
Entry
<
K
,
V
>[]
newTable
(
int
n
)
{
return
(
Entry
<
K
,
V
>[])
new
Entry
[
n
];
return
(
Entry
<
K
,
V
>[])
new
Entry
<?,?>
[
n
];
}
}
/**
/**
...
...
src/share/classes/java/util/regex/Matcher.java
浏览文件 @
cb0fea8f
...
@@ -759,16 +759,19 @@ public final class Matcher implements MatchResult {
...
@@ -759,16 +759,19 @@ public final class Matcher implements MatchResult {
char
nextChar
=
replacement
.
charAt
(
cursor
);
char
nextChar
=
replacement
.
charAt
(
cursor
);
if
(
nextChar
==
'\\'
)
{
if
(
nextChar
==
'\\'
)
{
cursor
++;
cursor
++;
if
(
cursor
==
replacement
.
length
())
throw
new
IllegalArgumentException
(
"character to be escaped is missing"
);
nextChar
=
replacement
.
charAt
(
cursor
);
nextChar
=
replacement
.
charAt
(
cursor
);
result
.
append
(
nextChar
);
result
.
append
(
nextChar
);
cursor
++;
cursor
++;
}
else
if
(
nextChar
==
'$'
)
{
}
else
if
(
nextChar
==
'$'
)
{
// Skip past $
// Skip past $
cursor
++;
cursor
++;
//
A StringIndexOutOfBoundsException is thrown if
//
Throw IAE if this "$" is the last character in replacement
// this "$" is the last character in replacement
if
(
cursor
==
replacement
.
length
())
// string in current implementation, a IAE might be
throw
new
IllegalArgumentException
(
// more appropriate.
"Illegal group reference: group index is missing"
);
nextChar
=
replacement
.
charAt
(
cursor
);
nextChar
=
replacement
.
charAt
(
cursor
);
int
refNum
=
-
1
;
int
refNum
=
-
1
;
if
(
nextChar
==
'{'
)
{
if
(
nextChar
==
'{'
)
{
...
...
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2001, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -970,6 +970,7 @@ class DatagramChannelImpl
...
@@ -970,6 +970,7 @@ class DatagramChannelImpl
protected
void
implCloseSelectableChannel
()
throws
IOException
{
protected
void
implCloseSelectableChannel
()
throws
IOException
{
synchronized
(
stateLock
)
{
synchronized
(
stateLock
)
{
if
(
state
!=
ST_KILLED
)
nd
.
preClose
(
fd
);
nd
.
preClose
(
fd
);
ResourceManager
.
afterUdpClose
();
ResourceManager
.
afterUdpClose
();
...
...
src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2000, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -261,6 +261,7 @@ class ServerSocketChannelImpl
...
@@ -261,6 +261,7 @@ class ServerSocketChannelImpl
protected
void
implCloseSelectableChannel
()
throws
IOException
{
protected
void
implCloseSelectableChannel
()
throws
IOException
{
synchronized
(
stateLock
)
{
synchronized
(
stateLock
)
{
if
(
state
!=
ST_KILLED
)
nd
.
preClose
(
fd
);
nd
.
preClose
(
fd
);
long
th
=
thread
;
long
th
=
thread
;
if
(
th
!=
0
)
if
(
th
!=
0
)
...
...
src/share/classes/sun/nio/ch/SocketChannelImpl.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2000, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -816,6 +816,7 @@ class SocketChannelImpl
...
@@ -816,6 +816,7 @@ class SocketChannelImpl
// channel from using the old fd, which might be recycled in the
// channel from using the old fd, which might be recycled in the
// meantime and allocated to an entirely different channel.
// meantime and allocated to an entirely different channel.
//
//
if
(
state
!=
ST_KILLED
)
nd
.
preClose
(
fd
);
nd
.
preClose
(
fd
);
// Signal native threads, if needed. If a target thread is not
// Signal native threads, if needed. If a target thread is not
...
...
src/share/classes/sun/nio/cs/ext/SJIS_0213.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008,
2012,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -31,6 +31,8 @@ import java.nio.charset.Charset;
...
@@ -31,6 +31,8 @@ import java.nio.charset.Charset;
import
java.nio.charset.CharsetEncoder
;
import
java.nio.charset.CharsetEncoder
;
import
java.nio.charset.CharsetDecoder
;
import
java.nio.charset.CharsetDecoder
;
import
java.nio.charset.CoderResult
;
import
java.nio.charset.CoderResult
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
sun.nio.cs.CharsetMapping
;
import
sun.nio.cs.CharsetMapping
;
...
@@ -73,8 +75,12 @@ public class SJIS_0213 extends Charset {
...
@@ -73,8 +75,12 @@ public class SJIS_0213 extends Charset {
return
new
Encoder
(
this
);
return
new
Encoder
(
this
);
}
}
static
CharsetMapping
mapping
=
static
CharsetMapping
mapping
=
AccessController
.
doPrivileged
(
CharsetMapping
.
get
(
SJIS_0213
.
class
.
getResourceAsStream
(
"sjis0213.dat"
));
new
PrivilegedAction
<
CharsetMapping
>()
{
public
CharsetMapping
run
()
{
return
CharsetMapping
.
get
(
SJIS_0213
.
class
.
getResourceAsStream
(
"sjis0213.dat"
));
}
});
protected
static
class
Decoder
extends
CharsetDecoder
{
protected
static
class
Decoder
extends
CharsetDecoder
{
protected
static
final
char
UNMAPPABLE
=
CharsetMapping
.
UNMAPPABLE_DECODING
;
protected
static
final
char
UNMAPPABLE
=
CharsetMapping
.
UNMAPPABLE_DECODING
;
...
...
src/share/classes/sun/security/ec/ECParameters.java
浏览文件 @
cb0fea8f
...
@@ -87,8 +87,8 @@ public final class ECParameters extends AlgorithmParametersSpi {
...
@@ -87,8 +87,8 @@ public final class ECParameters extends AlgorithmParametersSpi {
if
((
data
.
length
==
0
)
||
(
data
[
0
]
!=
4
))
{
if
((
data
.
length
==
0
)
||
(
data
[
0
]
!=
4
))
{
throw
new
IOException
(
"Only uncompressed point format supported"
);
throw
new
IOException
(
"Only uncompressed point format supported"
);
}
}
int
n
=
(
curve
.
getField
().
getFieldSize
()
+
7
)
>>
3
;
int
n
=
data
.
length
/
2
;
if
(
data
.
length
!=
(
n
*
2
)
+
1
)
{
if
(
n
>
((
curve
.
getField
().
getFieldSize
()
+
7
)
>>
3
)
)
{
throw
new
IOException
(
"Point does not match field size"
);
throw
new
IOException
(
"Point does not match field size"
);
}
}
byte
[]
xb
=
new
byte
[
n
];
byte
[]
xb
=
new
byte
[
n
];
...
...
src/share/classes/sun/security/krb5/Credentials.java
浏览文件 @
cb0fea8f
...
@@ -330,12 +330,17 @@ public class Credentials {
...
@@ -330,12 +330,17 @@ public class Credentials {
CredentialsCache
ccache
=
CredentialsCache
ccache
=
CredentialsCache
.
getInstance
(
princ
,
ticketCache
);
CredentialsCache
.
getInstance
(
princ
,
ticketCache
);
if
(
ccache
==
null
)
if
(
ccache
==
null
)
{
return
null
;
return
null
;
}
sun
.
security
.
krb5
.
internal
.
ccache
.
Credentials
tgtCred
=
sun
.
security
.
krb5
.
internal
.
ccache
.
Credentials
tgtCred
=
ccache
.
getDefaultCreds
();
ccache
.
getDefaultCreds
();
if
(
tgtCred
==
null
)
{
return
null
;
}
if
(
EType
.
isSupported
(
tgtCred
.
getEType
()))
{
if
(
EType
.
isSupported
(
tgtCred
.
getEType
()))
{
return
tgtCred
.
setKrbCreds
();
return
tgtCred
.
setKrbCreds
();
}
else
{
}
else
{
...
@@ -375,12 +380,13 @@ public class Credentials {
...
@@ -375,12 +380,13 @@ public class Credentials {
cache
=
CredentialsCache
.
getInstance
();
cache
=
CredentialsCache
.
getInstance
();
}
}
if
(
cache
!=
null
)
{
if
(
cache
!=
null
)
{
if
(
DEBUG
)
{
System
.
out
.
println
(
">>> KrbCreds found the default ticket "
+
"granting ticket in credential cache."
);
}
sun
.
security
.
krb5
.
internal
.
ccache
.
Credentials
temp
=
sun
.
security
.
krb5
.
internal
.
ccache
.
Credentials
temp
=
cache
.
getDefaultCreds
();
cache
.
getDefaultCreds
();
if
(
temp
!=
null
)
{
if
(
DEBUG
)
{
System
.
out
.
println
(
">>> KrbCreds found the default ticket"
+
" granting ticket in credential cache."
);
}
if
(
EType
.
isSupported
(
temp
.
getEType
()))
{
if
(
EType
.
isSupported
(
temp
.
getEType
()))
{
result
=
temp
.
setKrbCreds
();
result
=
temp
.
setKrbCreds
();
}
else
{
}
else
{
...
@@ -391,6 +397,7 @@ public class Credentials {
...
@@ -391,6 +397,7 @@ public class Credentials {
}
}
}
}
}
}
}
if
(
result
==
null
)
{
if
(
result
==
null
)
{
// Doesn't seem to be a default cache on this system or
// Doesn't seem to be a default cache on this system or
// TGT has unsupported encryption type
// TGT has unsupported encryption type
...
...
src/share/classes/sun/security/ssl/AppOutputStream.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 1996, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -91,9 +91,20 @@ class AppOutputStream extends OutputStream {
...
@@ -91,9 +91,20 @@ class AppOutputStream extends OutputStream {
// however they like; if we buffered here, they couldn't.
// however they like; if we buffered here, they couldn't.
try
{
try
{
do
{
do
{
boolean
holdRecord
=
false
;
int
howmuch
;
int
howmuch
;
if
(
isFirstRecordOfThePayload
&&
c
.
needToSplitPayload
())
{
if
(
isFirstRecordOfThePayload
&&
c
.
needToSplitPayload
())
{
howmuch
=
Math
.
min
(
0x01
,
r
.
availableDataBytes
());
howmuch
=
Math
.
min
(
0x01
,
r
.
availableDataBytes
());
/*
* Nagle's algorithm (TCP_NODELAY) was coming into
* play here when writing short (split) packets.
* Signal to the OutputRecord code to internally
* buffer this small packet until the next outbound
* packet (of any type) is written.
*/
if
((
len
!=
1
)
&&
(
howmuch
==
1
))
{
holdRecord
=
true
;
}
}
else
{
}
else
{
howmuch
=
Math
.
min
(
len
,
r
.
availableDataBytes
());
howmuch
=
Math
.
min
(
len
,
r
.
availableDataBytes
());
}
}
...
@@ -108,7 +119,7 @@ class AppOutputStream extends OutputStream {
...
@@ -108,7 +119,7 @@ class AppOutputStream extends OutputStream {
off
+=
howmuch
;
off
+=
howmuch
;
len
-=
howmuch
;
len
-=
howmuch
;
}
}
c
.
writeRecord
(
r
);
c
.
writeRecord
(
r
,
holdRecord
);
c
.
checkWrite
();
c
.
checkWrite
();
}
while
(
len
>
0
);
}
while
(
len
>
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/share/classes/sun/security/ssl/EngineOutputRecord.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2003, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -155,8 +155,9 @@ final class EngineOutputRecord extends OutputRecord {
...
@@ -155,8 +155,9 @@ final class EngineOutputRecord extends OutputRecord {
* data to be generated/output before the exception is ever
* data to be generated/output before the exception is ever
* generated.
* generated.
*/
*/
void
writeBuffer
(
OutputStream
s
,
byte
[]
buf
,
int
off
,
int
len
)
@Override
throws
IOException
{
void
writeBuffer
(
OutputStream
s
,
byte
[]
buf
,
int
off
,
int
len
,
int
debugOffset
)
throws
IOException
{
/*
/*
* Copy data out of buffer, it's ready to go.
* Copy data out of buffer, it's ready to go.
*/
*/
...
@@ -196,7 +197,8 @@ final class EngineOutputRecord extends OutputRecord {
...
@@ -196,7 +197,8 @@ final class EngineOutputRecord extends OutputRecord {
// compress(); // eventually
// compress(); // eventually
addMAC
(
writeMAC
);
addMAC
(
writeMAC
);
encrypt
(
writeCipher
);
encrypt
(
writeCipher
);
write
((
OutputStream
)
null
);
// send down for processing
write
((
OutputStream
)
null
,
false
,
// send down for processing
(
ByteArrayOutputStream
)
null
);
}
}
return
;
return
;
}
}
...
...
src/share/classes/sun/security/ssl/OutputRecord.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 1996, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -28,6 +28,7 @@ package sun.security.ssl;
...
@@ -28,6 +28,7 @@ package sun.security.ssl;
import
java.io.*
;
import
java.io.*
;
import
java.nio.*
;
import
java.nio.*
;
import
java.util.Arrays
;
import
javax.net.ssl.SSLException
;
import
javax.net.ssl.SSLException
;
import
sun.misc.HexDumpEncoder
;
import
sun.misc.HexDumpEncoder
;
...
@@ -226,6 +227,24 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
...
@@ -226,6 +227,24 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
return
maxDataSize
-
dataSize
;
return
maxDataSize
-
dataSize
;
}
}
/*
* Increases the capacity if necessary to ensure that it can hold
* at least the number of elements specified by the minimum
* capacity argument.
*
* Note that the increased capacity is only can be used for held
* record buffer. Please DO NOT update the availableDataBytes()
* according to the expended buffer capacity.
*
* @see availableDataBytes()
*/
private
void
ensureCapacity
(
int
minCapacity
)
{
// overflow-conscious code
if
(
minCapacity
>
buf
.
length
)
{
buf
=
Arrays
.
copyOf
(
buf
,
minCapacity
);
}
}
/*
/*
* Return the type of SSL record that's buffered here.
* Return the type of SSL record that's buffered here.
*/
*/
...
@@ -243,7 +262,9 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
...
@@ -243,7 +262,9 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
* that synchronization be done elsewhere. Also, this does its work
* that synchronization be done elsewhere. Also, this does its work
* in a single low level write, for efficiency.
* in a single low level write, for efficiency.
*/
*/
void
write
(
OutputStream
s
)
throws
IOException
{
void
write
(
OutputStream
s
,
boolean
holdRecord
,
ByteArrayOutputStream
heldRecordBuffer
)
throws
IOException
{
/*
/*
* Don't emit content-free records. (Even change cipher spec
* Don't emit content-free records. (Even change cipher spec
* messages have a byte of data!)
* messages have a byte of data!)
...
@@ -300,7 +321,49 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
...
@@ -300,7 +321,49 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
}
}
firstMessage
=
false
;
firstMessage
=
false
;
writeBuffer
(
s
,
buf
,
0
,
count
);
/*
* The upper levels may want us to delay sending this packet so
* multiple TLS Records can be sent in one (or more) TCP packets.
* If so, add this packet to the heldRecordBuffer.
*
* NOTE: all writes have been synchronized by upper levels.
*/
int
debugOffset
=
0
;
if
(
holdRecord
)
{
/*
* If holdRecord is true, we must have a heldRecordBuffer.
*
* Don't worry about the override of writeBuffer(), because
* when holdRecord is true, the implementation in this class
* will be used.
*/
writeBuffer
(
heldRecordBuffer
,
buf
,
0
,
count
,
debugOffset
);
}
else
{
// It's time to send, do we have buffered data?
// May or may not have a heldRecordBuffer.
if
(
heldRecordBuffer
!=
null
&&
heldRecordBuffer
.
size
()
>
0
)
{
int
heldLen
=
heldRecordBuffer
.
size
();
// Ensure the capacity of this buffer.
ensureCapacity
(
count
+
heldLen
);
// Slide everything in the buffer to the right.
System
.
arraycopy
(
buf
,
0
,
buf
,
heldLen
,
count
);
// Prepend the held record to the buffer.
System
.
arraycopy
(
heldRecordBuffer
.
toByteArray
(),
0
,
buf
,
0
,
heldLen
);
count
+=
heldLen
;
// Clear the held buffer.
heldRecordBuffer
.
reset
();
// The held buffer has been dumped, set the debug dump offset.
debugOffset
=
heldLen
;
}
writeBuffer
(
s
,
buf
,
0
,
count
,
debugOffset
);
}
reset
();
reset
();
}
}
...
@@ -309,15 +372,17 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
...
@@ -309,15 +372,17 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
* we'll override this method and let it take the appropriate
* we'll override this method and let it take the appropriate
* action.
* action.
*/
*/
void
writeBuffer
(
OutputStream
s
,
byte
[]
buf
,
int
off
,
int
len
)
void
writeBuffer
(
OutputStream
s
,
byte
[]
buf
,
int
off
,
int
len
,
throws
IOException
{
int
debugOffset
)
throws
IOException
{
s
.
write
(
buf
,
off
,
len
);
s
.
write
(
buf
,
off
,
len
);
s
.
flush
();
s
.
flush
();
// Output only the record from the specified debug offset.
if
(
debug
!=
null
&&
Debug
.
isOn
(
"packet"
))
{
if
(
debug
!=
null
&&
Debug
.
isOn
(
"packet"
))
{
try
{
try
{
HexDumpEncoder
hd
=
new
HexDumpEncoder
();
HexDumpEncoder
hd
=
new
HexDumpEncoder
();
ByteBuffer
bb
=
ByteBuffer
.
wrap
(
buf
,
off
,
len
);
ByteBuffer
bb
=
ByteBuffer
.
wrap
(
buf
,
off
+
debugOffset
,
len
-
debugOffset
);
System
.
out
.
println
(
"[Raw write]: length = "
+
System
.
out
.
println
(
"[Raw write]: length = "
+
bb
.
remaining
());
bb
.
remaining
());
...
...
src/share/classes/sun/security/ssl/SSLSocketImpl.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 1996, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -374,6 +374,12 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
...
@@ -374,6 +374,12 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
*/
*/
private
boolean
isFirstAppOutputRecord
=
true
;
private
boolean
isFirstAppOutputRecord
=
true
;
/*
* If AppOutputStream needs to delay writes of small packets, we
* will use this to store the data until we actually do the write.
*/
private
ByteArrayOutputStream
heldRecordBuffer
=
null
;
//
//
// CONSTRUCTORS AND INITIALIZATION CODE
// CONSTRUCTORS AND INITIALIZATION CODE
//
//
...
@@ -653,6 +659,17 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
...
@@ -653,6 +659,17 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
// READING AND WRITING RECORDS
// READING AND WRITING RECORDS
//
//
/*
* AppOutputStream calls may need to buffer multiple outbound
* application packets.
*
* All other writeRecord() calls will not buffer, so do not hold
* these records.
*/
void
writeRecord
(
OutputRecord
r
)
throws
IOException
{
writeRecord
(
r
,
false
);
}
/*
/*
* Record Output. Application data can't be sent until the first
* Record Output. Application data can't be sent until the first
* handshake establishes a session.
* handshake establishes a session.
...
@@ -660,7 +677,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
...
@@ -660,7 +677,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* NOTE: we let empty records be written as a hook to force some
* NOTE: we let empty records be written as a hook to force some
* TCP-level activity, notably handshaking, to occur.
* TCP-level activity, notably handshaking, to occur.
*/
*/
void
writeRecord
(
OutputRecord
r
)
throws
IOException
{
void
writeRecord
(
OutputRecord
r
,
boolean
holdRecord
)
throws
IOException
{
/*
/*
* The loop is in case of HANDSHAKE --> ERROR transitions, etc
* The loop is in case of HANDSHAKE --> ERROR transitions, etc
*/
*/
...
@@ -731,7 +748,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
...
@@ -731,7 +748,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
try
{
try
{
if
(
writeLock
.
tryLock
(
getSoLinger
(),
TimeUnit
.
SECONDS
))
{
if
(
writeLock
.
tryLock
(
getSoLinger
(),
TimeUnit
.
SECONDS
))
{
try
{
try
{
writeRecordInternal
(
r
);
writeRecordInternal
(
r
,
holdRecord
);
}
finally
{
}
finally
{
writeLock
.
unlock
();
writeLock
.
unlock
();
}
}
...
@@ -779,7 +796,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
...
@@ -779,7 +796,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
}
else
{
}
else
{
writeLock
.
lock
();
writeLock
.
lock
();
try
{
try
{
writeRecordInternal
(
r
);
writeRecordInternal
(
r
,
holdRecord
);
}
finally
{
}
finally
{
writeLock
.
unlock
();
writeLock
.
unlock
();
}
}
...
@@ -787,11 +804,29 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
...
@@ -787,11 +804,29 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
}
}
}
}
private
void
writeRecordInternal
(
OutputRecord
r
)
throws
IOException
{
private
void
writeRecordInternal
(
OutputRecord
r
,
boolean
holdRecord
)
throws
IOException
{
// r.compress(c);
// r.compress(c);
r
.
addMAC
(
writeMAC
);
r
.
addMAC
(
writeMAC
);
r
.
encrypt
(
writeCipher
);
r
.
encrypt
(
writeCipher
);
r
.
write
(
sockOutput
);
if
(
holdRecord
)
{
// If we were requested to delay the record due to possibility
// of Nagle's being active when finally got to writing, and
// it's actually not, we don't really need to delay it.
if
(
getTcpNoDelay
())
{
holdRecord
=
false
;
}
else
{
// We need to hold the record, so let's provide
// a per-socket place to do it.
if
(
heldRecordBuffer
==
null
)
{
// Likely only need 37 bytes.
heldRecordBuffer
=
new
ByteArrayOutputStream
(
40
);
}
}
}
r
.
write
(
sockOutput
,
holdRecord
,
heldRecordBuffer
);
/*
/*
* Check the sequence number state
* Check the sequence number state
...
...
src/share/classes/sun/tools/java/ClassPath.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 1994, 20
07
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 20
12
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -141,7 +141,7 @@ class ClassPath {
...
@@ -141,7 +141,7 @@ class ClassPath {
}
else
{
}
else
{
StringBuilder
sb
=
new
StringBuilder
(
patharray
[
0
]);
StringBuilder
sb
=
new
StringBuilder
(
patharray
[
0
]);
for
(
int
i
=
1
;
i
<
patharray
.
length
;
i
++)
{
for
(
int
i
=
1
;
i
<
patharray
.
length
;
i
++)
{
sb
.
append
(
File
.
separato
r
);
sb
.
append
(
File
.
pathSeparatorCha
r
);
sb
.
append
(
patharray
[
i
]);
sb
.
append
(
patharray
[
i
]);
}
}
this
.
pathstr
=
sb
.
toString
();
this
.
pathstr
=
sb
.
toString
();
...
...
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java
浏览文件 @
cb0fea8f
...
@@ -78,7 +78,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
...
@@ -78,7 +78,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
}
}
try
{
try
{
// only support legacy JAR URL syntax jar:{uri}!/{entry} for now
// only support legacy JAR URL syntax jar:{uri}!/{entry} for now
String
spec
=
uri
.
getSchemeSpecificPart
();
String
spec
=
uri
.
get
Raw
SchemeSpecificPart
();
int
sep
=
spec
.
indexOf
(
"!/"
);
int
sep
=
spec
.
indexOf
(
"!/"
);
if
(
sep
!=
-
1
)
if
(
sep
!=
-
1
)
spec
=
spec
.
substring
(
0
,
sep
);
spec
=
spec
.
substring
(
0
,
sep
);
...
...
src/share/lib/security/java.security
浏览文件 @
cb0fea8f
...
@@ -123,7 +123,7 @@ keystore.type=jks
...
@@ -123,7 +123,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
# been granted.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
#
# List of comma-separated packages that start with or equal this string
# List of comma-separated packages that start with or equal this string
...
...
src/share/lib/security/java.security-macosx
浏览文件 @
cb0fea8f
...
@@ -124,7 +124,7 @@ keystore.type=jks
...
@@ -124,7 +124,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
# been granted.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.
,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
#
# List of comma-separated packages that start with or equal this string
# List of comma-separated packages that start with or equal this string
...
...
src/share/lib/security/java.security-solaris
浏览文件 @
cb0fea8f
...
@@ -125,7 +125,7 @@ keystore.type=jks
...
@@ -125,7 +125,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
# been granted.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
#
# List of comma-separated packages that start with or equal this string
# List of comma-separated packages that start with or equal this string
...
...
src/share/lib/security/java.security-windows
浏览文件 @
cb0fea8f
...
@@ -124,7 +124,7 @@ keystore.type=jks
...
@@ -124,7 +124,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
# been granted.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
#
# List of comma-separated packages that start with or equal this string
# List of comma-separated packages that start with or equal this string
...
...
src/solaris/classes/sun/nio/ch/SinkChannelImpl.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2000, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 20
12
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -84,6 +84,7 @@ class SinkChannelImpl
...
@@ -84,6 +84,7 @@ class SinkChannelImpl
protected
void
implCloseSelectableChannel
()
throws
IOException
{
protected
void
implCloseSelectableChannel
()
throws
IOException
{
synchronized
(
stateLock
)
{
synchronized
(
stateLock
)
{
if
(
state
!=
ST_KILLED
)
nd
.
preClose
(
fd
);
nd
.
preClose
(
fd
);
long
th
=
thread
;
long
th
=
thread
;
if
(
th
!=
0
)
if
(
th
!=
0
)
...
...
src/solaris/classes/sun/nio/ch/SourceChannelImpl.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2000, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 20
12
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -84,6 +84,7 @@ class SourceChannelImpl
...
@@ -84,6 +84,7 @@ class SourceChannelImpl
protected
void
implCloseSelectableChannel
()
throws
IOException
{
protected
void
implCloseSelectableChannel
()
throws
IOException
{
synchronized
(
stateLock
)
{
synchronized
(
stateLock
)
{
if
(
state
!=
ST_KILLED
)
nd
.
preClose
(
fd
);
nd
.
preClose
(
fd
);
long
th
=
thread
;
long
th
=
thread
;
if
(
th
!=
0
)
if
(
th
!=
0
)
...
...
src/solaris/native/com/sun/management/MacosxOperatingSystem.c
浏览文件 @
cb0fea8f
...
@@ -25,16 +25,136 @@
...
@@ -25,16 +25,136 @@
#include "com_sun_management_UnixOperatingSystem.h"
#include "com_sun_management_UnixOperatingSystem.h"
#include <sys/time.h>
#include <mach/mach.h>
#include <mach/task_info.h>
JNIEXPORT
jdouble
JNICALL
JNIEXPORT
jdouble
JNICALL
Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
(
JNIEnv
*
env
,
jobject
dummy
)
(
JNIEnv
*
env
,
jobject
dummy
)
{
{
return
-
1
.
0
;
// not available
// This code is influenced by the darwin top source
kern_return_t
kr
;
mach_msg_type_number_t
count
;
host_cpu_load_info_data_t
load
;
static
jlong
last_used
=
0
;
static
jlong
last_total
=
0
;
count
=
HOST_CPU_LOAD_INFO_COUNT
;
kr
=
host_statistics
(
mach_host_self
(),
HOST_CPU_LOAD_INFO
,
(
host_info_t
)
&
load
,
&
count
);
if
(
kr
!=
KERN_SUCCESS
)
{
return
-
1
;
}
jlong
used
=
load
.
cpu_ticks
[
CPU_STATE_USER
]
+
load
.
cpu_ticks
[
CPU_STATE_NICE
]
+
load
.
cpu_ticks
[
CPU_STATE_SYSTEM
];
jlong
total
=
used
+
load
.
cpu_ticks
[
CPU_STATE_IDLE
];
if
(
last_used
==
0
||
last_total
==
0
)
{
// First call, just set the last values
last_used
=
used
;
last_total
=
total
;
// return 0 since we have no data, not -1 which indicates error
return
0
;
}
jlong
used_delta
=
used
-
last_used
;
jlong
total_delta
=
total
-
last_total
;
jdouble
cpu
=
(
jdouble
)
used_delta
/
total_delta
;
last_used
=
used
;
last_total
=
total
;
return
cpu
;
}
}
#define TIME_VALUE_TO_TIMEVAL(a, r) do { \
(r)->tv_sec = (a)->seconds; \
(r)->tv_usec = (a)->microseconds; \
} while (0)
#define TIME_VALUE_TO_MICROSECONDS(TV) \
((TV).tv_sec * 1000 * 1000 + (TV).tv_usec)
JNIEXPORT
jdouble
JNICALL
JNIEXPORT
jdouble
JNICALL
Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
(
JNIEnv
*
env
,
jobject
dummy
)
(
JNIEnv
*
env
,
jobject
dummy
)
{
{
return
-
1
.
0
;
// not available
// This code is influenced by the darwin top source
}
struct
task_basic_info_64
task_info_data
;
struct
task_thread_times_info
thread_info_data
;
struct
timeval
user_timeval
,
system_timeval
,
task_timeval
;
struct
timeval
now
;
mach_port_t
task
=
mach_task_self
();
kern_return_t
kr
;
static
jlong
last_task_time
=
0
;
static
jlong
last_time
=
0
;
mach_msg_type_number_t
thread_info_count
=
TASK_THREAD_TIMES_INFO_COUNT
;
kr
=
task_info
(
task
,
TASK_THREAD_TIMES_INFO
,
(
task_info_t
)
&
thread_info_data
,
&
thread_info_count
);
if
(
kr
!=
KERN_SUCCESS
)
{
// Most likely cause: |task| is a zombie.
return
-
1
;
}
mach_msg_type_number_t
count
=
TASK_BASIC_INFO_64_COUNT
;
kr
=
task_info
(
task
,
TASK_BASIC_INFO_64
,
(
task_info_t
)
&
task_info_data
,
&
count
);
if
(
kr
!=
KERN_SUCCESS
)
{
// Most likely cause: |task| is a zombie.
return
-
1
;
}
/* Set total_time. */
// thread info contains live time...
TIME_VALUE_TO_TIMEVAL
(
&
thread_info_data
.
user_time
,
&
user_timeval
);
TIME_VALUE_TO_TIMEVAL
(
&
thread_info_data
.
system_time
,
&
system_timeval
);
timeradd
(
&
user_timeval
,
&
system_timeval
,
&
task_timeval
);
// ... task info contains terminated time.
TIME_VALUE_TO_TIMEVAL
(
&
task_info_data
.
user_time
,
&
user_timeval
);
TIME_VALUE_TO_TIMEVAL
(
&
task_info_data
.
system_time
,
&
system_timeval
);
timeradd
(
&
user_timeval
,
&
task_timeval
,
&
task_timeval
);
timeradd
(
&
system_timeval
,
&
task_timeval
,
&
task_timeval
);
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
return
-
1
;
}
jint
ncpus
=
JVM_ActiveProcessorCount
();
jlong
time
=
TIME_VALUE_TO_MICROSECONDS
(
now
)
*
ncpus
;
jlong
task_time
=
TIME_VALUE_TO_MICROSECONDS
(
task_timeval
);
if
((
last_task_time
==
0
)
||
(
last_time
==
0
))
{
// First call, just set the last values.
last_task_time
=
task_time
;
last_time
=
time
;
// return 0 since we have no data, not -1 which indicates error
return
0
;
}
jlong
task_time_delta
=
task_time
-
last_task_time
;
jlong
time_delta
=
time
-
last_time
;
if
(
time_delta
==
0
)
{
return
-
1
;
}
jdouble
cpu
=
(
jdouble
)
task_time_delta
/
time_delta
;
last_task_time
=
task_time
;
last_time
=
time
;
return
cpu
;
}
src/solaris/native/com/sun/management/UnixOperatingSystem_md.c
浏览文件 @
cb0fea8f
...
@@ -34,6 +34,13 @@
...
@@ -34,6 +34,13 @@
#include <sys/stat.h>
#include <sys/stat.h>
#if defined(_ALLBSD_SOURCE)
#if defined(_ALLBSD_SOURCE)
#include <sys/sysctl.h>
#include <sys/sysctl.h>
#ifdef __APPLE__
#include <sys/param.h>
#include <sys/mount.h>
#include <mach/mach.h>
#include <sys/proc_info.h>
#include <libproc.h>
#endif
#else
#else
#include <sys/swap.h>
#include <sys/swap.h>
#endif
#endif
...
@@ -150,6 +157,13 @@ static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean availa
...
@@ -150,6 +157,13 @@ static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean availa
avail
=
(
jlong
)
si
.
freeswap
*
si
.
mem_unit
;
avail
=
(
jlong
)
si
.
freeswap
*
si
.
mem_unit
;
return
available
?
avail
:
total
;
return
available
?
avail
:
total
;
#elif defined(__APPLE__)
struct
xsw_usage
vmusage
;
size_t
size
=
sizeof
(
vmusage
);
if
(
sysctlbyname
(
"vm.swapusage"
,
&
vmusage
,
&
size
,
NULL
,
0
)
!=
0
)
{
throw_internal_error
(
env
,
"sysctlbyname failed"
);
}
return
available
?
(
jlong
)
vmusage
.
xsu_avail
:
(
jlong
)
vmusage
.
xsu_total
;
#else
/* _ALLBSD_SOURCE */
#else
/* _ALLBSD_SOURCE */
/*
/*
* XXXBSD: there's no way available to get swap info in
* XXXBSD: there's no way available to get swap info in
...
@@ -216,6 +230,15 @@ Java_com_sun_management_UnixOperatingSystem_getCommittedVirtualMemorySize
...
@@ -216,6 +230,15 @@ Java_com_sun_management_UnixOperatingSystem_getCommittedVirtualMemorySize
fclose
(
fp
);
fclose
(
fp
);
return
(
jlong
)
vsize
;
return
(
jlong
)
vsize
;
#elif defined(__APPLE__)
struct
task_basic_info
t_info
;
mach_msg_type_number_t
t_info_count
=
TASK_BASIC_INFO_COUNT
;
kern_return_t
res
=
task_info
(
mach_task_self
(),
TASK_BASIC_INFO
,
(
task_info_t
)
&
t_info
,
&
t_info_count
);
if
(
res
!=
KERN_SUCCESS
)
{
throw_internal_error
(
env
,
"task_info failed"
);
}
return
t_info
.
virtual_size
;
#else
/* _ALLBSD_SOURCE */
#else
/* _ALLBSD_SOURCE */
/*
/*
* XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
* XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
...
@@ -243,6 +266,17 @@ JNIEXPORT jlong JNICALL
...
@@ -243,6 +266,17 @@ JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
(
JNIEnv
*
env
,
jobject
mbean
)
(
JNIEnv
*
env
,
jobject
mbean
)
{
{
#ifdef __APPLE__
struct
rusage
usage
;
if
(
getrusage
(
RUSAGE_SELF
,
&
usage
)
!=
0
)
{
throw_internal_error
(
env
,
"getrusage failed"
);
return
-
1
;
}
jlong
microsecs
=
usage
.
ru_utime
.
tv_sec
*
1000
*
1000
+
usage
.
ru_utime
.
tv_usec
+
usage
.
ru_stime
.
tv_sec
*
1000
*
1000
+
usage
.
ru_stime
.
tv_usec
;
return
microsecs
*
1000
;
#else
jlong
clk_tck
,
ns_per_clock_tick
;
jlong
clk_tck
,
ns_per_clock_tick
;
jlong
cpu_time_ns
;
jlong
cpu_time_ns
;
struct
tms
time
;
struct
tms
time
;
...
@@ -267,19 +301,32 @@ Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
...
@@ -267,19 +301,32 @@ Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
cpu_time_ns
=
((
jlong
)
time
.
tms_utime
+
(
jlong
)
time
.
tms_stime
)
*
cpu_time_ns
=
((
jlong
)
time
.
tms_utime
+
(
jlong
)
time
.
tms_stime
)
*
ns_per_clock_tick
;
ns_per_clock_tick
;
return
cpu_time_ns
;
return
cpu_time_ns
;
#endif
}
}
JNIEXPORT
jlong
JNICALL
JNIEXPORT
jlong
JNICALL
Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize
Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize
(
JNIEnv
*
env
,
jobject
mbean
)
(
JNIEnv
*
env
,
jobject
mbean
)
{
{
#ifdef _ALLBSD_SOURCE
#ifdef __APPLE__
mach_msg_type_number_t
count
;
vm_statistics_data_t
vm_stats
;
kern_return_t
res
;
count
=
HOST_VM_INFO_COUNT
;
res
=
host_statistics
(
mach_host_self
(),
HOST_VM_INFO
,
(
host_info_t
)
&
vm_stats
,
&
count
);
if
(
res
!=
KERN_SUCCESS
)
{
throw_internal_error
(
env
,
"host_statistics failed"
);
return
-
1
;
}
return
(
jlong
)
vm_stats
.
free_count
*
page_size
;
#elif defined(_ALLBSD_SOURCE)
/*
/*
* XXBSDL no way to do it in FreeBSD
* XXBSDL no way to do it in FreeBSD
*/
*/
// throw_internal_error(env, "unimplemented in FreeBSD")
// throw_internal_error(env, "unimplemented in FreeBSD")
return
(
128
*
MB
);
return
(
128
*
MB
);
#else
#else
// solaris / linux
jlong
num_avail_physical_pages
=
sysconf
(
_SC_AVPHYS_PAGES
);
jlong
num_avail_physical_pages
=
sysconf
(
_SC_AVPHYS_PAGES
);
return
(
num_avail_physical_pages
*
page_size
);
return
(
num_avail_physical_pages
*
page_size
);
#endif
#endif
...
@@ -290,28 +337,75 @@ Java_com_sun_management_UnixOperatingSystem_getTotalPhysicalMemorySize
...
@@ -290,28 +337,75 @@ Java_com_sun_management_UnixOperatingSystem_getTotalPhysicalMemorySize
(
JNIEnv
*
env
,
jobject
mbean
)
(
JNIEnv
*
env
,
jobject
mbean
)
{
{
#ifdef _ALLBSD_SOURCE
#ifdef _ALLBSD_SOURCE
jlong
result
;
jlong
result
=
0
;
int
mib
[
2
];
int
mib
[
2
];
size_t
rlen
;
size_t
rlen
;
mib
[
0
]
=
CTL_HW
;
mib
[
0
]
=
CTL_HW
;
mib
[
1
]
=
HW_
PHYSMEM
;
mib
[
1
]
=
HW_
MEMSIZE
;
rlen
=
sizeof
(
result
);
rlen
=
sizeof
(
result
);
if
(
sysctl
(
mib
,
2
,
&
result
,
&
rlen
,
NULL
,
0
)
==
-
1
)
if
(
sysctl
(
mib
,
2
,
&
result
,
&
rlen
,
NULL
,
0
)
!=
0
)
{
result
=
256
*
MB
;
throw_internal_error
(
env
,
"sysctl failed"
);
return
-
1
;
return
(
result
);
}
#else
return
result
;
#else // solaris / linux
jlong
num_physical_pages
=
sysconf
(
_SC_PHYS_PAGES
);
jlong
num_physical_pages
=
sysconf
(
_SC_PHYS_PAGES
);
return
(
num_physical_pages
*
page_size
);
return
(
num_physical_pages
*
page_size
);
#endif
#endif
}
}
JNIEXPORT
jlong
JNICALL
JNIEXPORT
jlong
JNICALL
Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
(
JNIEnv
*
env
,
jobject
mbean
)
(
JNIEnv
*
env
,
jobject
mbean
)
{
{
#ifdef _ALLBSD_SOURCE
#ifdef __APPLE__
// This code is influenced by the darwin lsof source
pid_t
my_pid
;
struct
proc_bsdinfo
bsdinfo
;
struct
proc_fdinfo
*
fds
;
int
nfiles
;
kern_return_t
kres
;
int
res
;
size_t
fds_size
;
kres
=
pid_for_task
(
mach_task_self
(),
&
my_pid
);
if
(
res
!=
KERN_SUCCESS
)
{
throw_internal_error
(
env
,
"pid_for_task failed"
);
return
-
1
;
}
// get the maximum number of file descriptors
res
=
proc_pidinfo
(
my_pid
,
PROC_PIDTBSDINFO
,
0
,
&
bsdinfo
,
PROC_PIDTBSDINFO_SIZE
);
if
(
res
<=
0
)
{
throw_internal_error
(
env
,
"proc_pidinfo with PROC_PIDTBSDINFO failed"
);
return
-
1
;
}
// allocate memory to hold the fd information (we don't acutally use this information
// but need it to get the number of open files)
fds_size
=
bsdinfo
.
pbi_nfiles
*
sizeof
(
struct
proc_fdinfo
);
fds
=
malloc
(
fds_size
);
if
(
fds
==
NULL
)
{
JNU_ThrowOutOfMemoryError
(
env
,
"could not allocate space for file descriptors"
);
return
-
1
;
}
// get the list of open files - the return value is the number of bytes
// proc_pidinfo filled in
res
=
proc_pidinfo
(
my_pid
,
PROC_PIDLISTFDS
,
0
,
fds
,
fds_size
);
if
(
res
<=
0
)
{
free
(
fds
);
throw_internal_error
(
env
,
"proc_pidinfo failed for PROC_PIDLISTFDS"
);
return
-
1
;
}
nfiles
=
res
/
sizeof
(
struct
proc_fdinfo
);
free
(
fds
);
return
nfiles
;
#elif defined(_ALLBSD_SOURCE)
/*
/*
* XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
* XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
*/
*/
...
...
test/ProblemList.txt
浏览文件 @
cb0fea8f
...
@@ -161,6 +161,26 @@ demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all
...
@@ -161,6 +161,26 @@ demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all
# Need to be marked othervm, or changed to be samevm safe
# Need to be marked othervm, or changed to be samevm safe
com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java generic-all
com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java generic-all
# 7162111
demo/jvmti/mtrace/TraceJFrame.java macosx-all
javax/script/CauseExceptionTest.java macosx-all
javax/script/GetInterfaceTest.java macosx-all
javax/script/JavaScriptScopeTest.java macosx-all
javax/script/NullUndefinedVarTest.java macosx-all
javax/script/PluggableContextTest.java macosx-all
javax/script/ProviderTest.sh macosx-all
javax/script/RhinoExceptionTest.java macosx-all
javax/script/StringWriterPrintTest.java macosx-all
javax/script/Test1.java macosx-all
javax/script/Test2.java macosx-all
javax/script/Test3.java macosx-all
javax/script/Test4.java macosx-all
javax/script/Test5.java macosx-all
javax/script/Test6.java macosx-all
javax/script/Test7.java macosx-all
javax/script/Test8.java macosx-all
javax/script/UnescapedBracketRegExTest.java macosx-all
javax/script/VersionTest.java macosx-all
############################################################################
############################################################################
# jdk_net
# jdk_net
...
@@ -202,6 +222,8 @@ java/net/DatagramSocket/SendDatagramToBadAddress.java macosx-all
...
@@ -202,6 +222,8 @@ java/net/DatagramSocket/SendDatagramToBadAddress.java macosx-all
sun/net/www/protocol/http/B6299712.java macosx-all
sun/net/www/protocol/http/B6299712.java macosx-all
java/net/CookieHandler/CookieManagerTest.java macosx-all
java/net/CookieHandler/CookieManagerTest.java macosx-all
# JPRT needs to set 127.0.0.1 in proxy bypass list
java/net/URLClassLoader/closetest/CloseTest.java macosx-all
############################################################################
############################################################################
# jdk_io
# jdk_io
...
@@ -252,6 +274,9 @@ java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all
...
@@ -252,6 +274,9 @@ java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all
# 7132247
# 7132247
java/rmi/registry/readTest/readTest.sh windows-all
java/rmi/registry/readTest/readTest.sh windows-all
# 7142596
java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java generic-all
############################################################################
############################################################################
# jdk_security
# jdk_security
...
...
test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh
浏览文件 @
cb0fea8f
...
@@ -83,6 +83,13 @@ case `uname -s` in
...
@@ -83,6 +83,13 @@ case `uname -s` in
total_swap
=
`
free
-b
|
grep
-i
swap |
awk
'{print $2}'
`
total_swap
=
`
free
-b
|
grep
-i
swap |
awk
'{print $2}'
`
runOne GetTotalSwapSpaceSize
$total_swap
runOne GetTotalSwapSpaceSize
$total_swap
;;
;;
Darwin
)
# $ sysctl -n vm.swapusage
# total = 8192.00M used = 7471.11M free = 720.89M (encrypted)
swap
=
`
/usr/sbin/sysctl
-n
vm.swapusage |
awk
'{ print $3 }'
|
awk
-F
.
'{ print $1 }'
`
||
exit
2
total_swap
=
`
expr
$swap
\*
1024
\*
1024
`
||
exit
2
runOne GetTotalSwapSpaceSize
$total_swap
;;
*
)
*
)
runOne GetTotalSwapSpaceSize
"sanity-only"
runOne GetTotalSwapSpaceSize
"sanity-only"
;;
;;
...
...
test/demo/zipfs/ZFSTests.java
0 → 100644
浏览文件 @
cb0fea8f
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 7156873
@summary ZipFileSystem regression tests
*/
import
java.net.URI
;
import
java.nio.file.*
;
import
java.util.Map
;
import
java.util.HashMap
;
public
class
ZFSTests
{
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
test7156873
();
}
static
void
test7156873
()
throws
Throwable
{
String
DIRWITHSPACE
=
"testdir with spaces"
;
Path
dir
=
Paths
.
get
(
DIRWITHSPACE
);
Path
path
=
Paths
.
get
(
DIRWITHSPACE
,
"file.zip"
);
try
{
Files
.
createDirectory
(
dir
);
URI
uri
=
URI
.
create
(
"jar:"
+
path
.
toUri
());
Map
<
String
,
Object
>
env
=
new
HashMap
<
String
,
Object
>();
env
.
put
(
"create"
,
"true"
);
try
(
FileSystem
fs
=
FileSystems
.
newFileSystem
(
uri
,
env
))
{}
}
finally
{
Files
.
deleteIfExists
(
path
);
Files
.
deleteIfExists
(
dir
);
}
}
}
test/java/lang/SecurityManager/CheckPackageAccess.java
0 → 100644
浏览文件 @
cb0fea8f
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7146431
* @summary Test that internal JAXP packages cannot be accessed
*/
public
class
CheckPackageAccess
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
[]
pkgs
=
new
String
[]
{
"com.sun.org.apache.xerces.internal.utils."
,
"com.sun.org.apache.xalan.internal.utils."
};
SecurityManager
sm
=
new
SecurityManager
();
System
.
setSecurityManager
(
sm
);
for
(
String
pkg
:
pkgs
)
{
System
.
out
.
println
(
"Checking package access for "
+
pkg
);
try
{
sm
.
checkPackageAccess
(
pkg
);
throw
new
Exception
(
"Expected SecurityException not thrown"
);
}
catch
(
SecurityException
se
)
{
}
}
}
}
test/java/nio/channels/Selector/OpRead.java
浏览文件 @
cb0fea8f
...
@@ -58,7 +58,10 @@ public class OpRead {
...
@@ -58,7 +58,10 @@ public class OpRead {
boolean
done
=
false
;
boolean
done
=
false
;
int
failCount
=
0
;
int
failCount
=
0
;
while
(!
done
)
{
while
(!
done
)
{
if
(
selector
.
select
()
>
0
)
{
int
nSelected
=
selector
.
select
();
if
(
nSelected
>
0
)
{
if
(
nSelected
>
1
)
throw
new
RuntimeException
(
"More than one channel selected"
);
Set
<
SelectionKey
>
keys
=
selector
.
selectedKeys
();
Set
<
SelectionKey
>
keys
=
selector
.
selectedKeys
();
Iterator
<
SelectionKey
>
iterator
=
keys
.
iterator
();
Iterator
<
SelectionKey
>
iterator
=
keys
.
iterator
();
while
(
iterator
.
hasNext
())
{
while
(
iterator
.
hasNext
())
{
...
...
test/java/nio/charset/coders/StreamTimeout.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2012,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -27,31 +27,32 @@
...
@@ -27,31 +27,32 @@
* when the underlying byte stream times out
* when the underlying byte stream times out
*/
*/
import
java.net.*
;
import
java.io.Closeable
;
import
java.io.*
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.InterruptedIOException
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintStream
;
import
java.io.Reader
;
import
java.io.Writer
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
public
class
StreamTimeout
{
public
class
StreamTimeout
{
static
final
PrintStream
log
=
System
.
err
;
static
String
charset
=
"US-ASCII"
;
private
static
PrintStream
log
=
System
.
err
;
private
static
class
Client
extends
Thread
implements
Closeable
{
private
final
Socket
so
;
private
static
String
charset
=
"US-ASCII"
;
private
static
Object
lock
=
new
Object
();
Client
(
int
port
)
throws
IOException
{
private
static
synchronized
void
waitABit
(
int
millisec
)
{
so
=
new
Socket
(
"127.0.0.1"
,
port
);
synchronized
(
lock
)
{
try
{
lock
.
wait
(
millisec
);
}
catch
(
InterruptedException
e
)
{
//ignore
}
}
}
}
private
static
class
Client
extends
Thread
{
@Override
public
void
run
()
{
public
void
run
()
{
try
{
try
{
Socket
so
=
new
Socket
(
"127.0.0.1"
,
22222
);
Writer
wr
=
new
OutputStreamWriter
(
so
.
getOutputStream
(),
Writer
wr
=
new
OutputStreamWriter
(
so
.
getOutputStream
(),
charset
);
charset
);
wr
.
write
(
"ab"
);
wr
.
write
(
"ab"
);
...
@@ -59,9 +60,13 @@ public class StreamTimeout {
...
@@ -59,9 +60,13 @@ public class StreamTimeout {
}
catch
(
IOException
x
)
{
}
catch
(
IOException
x
)
{
log
.
print
(
"Unexpected exception in writer: "
);
log
.
print
(
"Unexpected exception in writer: "
);
x
.
printStackTrace
();
x
.
printStackTrace
();
System
.
exit
(
1
);
}
}
}
}
@Override
public
void
close
()
throws
IOException
{
so
.
close
();
}
}
}
private
static
void
gobble
(
InputStream
is
,
Reader
rd
,
private
static
void
gobble
(
InputStream
is
,
Reader
rd
,
...
@@ -95,13 +100,16 @@ public class StreamTimeout {
...
@@ -95,13 +100,16 @@ public class StreamTimeout {
if
(
args
.
length
>
0
)
if
(
args
.
length
>
0
)
charset
=
args
[
0
];
charset
=
args
[
0
];
ServerSocket
ss
=
new
ServerSocket
(
22222
);
try
(
ServerSocket
ss
=
new
ServerSocket
(
0
);
Thread
cl
=
new
Client
();
Client
cl
=
new
Client
(
ss
.
getLocalPort
()))
{
cl
.
start
();
cl
.
start
();
Socket
s
=
ss
.
accept
();
try
(
Socket
s
=
ss
.
accept
())
{
s
.
setSoTimeout
(
150
);
s
.
setSoTimeout
(
150
);
InputStream
is
=
s
.
getInputStream
();
Reader
rd
=
new
InputStreamReader
(
is
,
charset
);
try
(
InputStream
is
=
s
.
getInputStream
();
Reader
rd
=
new
InputStreamReader
(
is
,
charset
))
{
while
(
is
.
available
()
<=
0
)
while
(
is
.
available
()
<=
0
)
Thread
.
yield
();
Thread
.
yield
();
...
@@ -131,7 +139,10 @@ public class StreamTimeout {
...
@@ -131,7 +139,10 @@ public class StreamTimeout {
}
}
if
(!
caught
)
if
(!
caught
)
throw
new
Exception
(
"Second read completed"
);
throw
new
Exception
(
"Second read completed"
);
}
}
}
cl
.
join
();
}
}
}
}
test/java/security/CodeSource/Implies.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003,
2012,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -23,25 +23,42 @@
...
@@ -23,25 +23,42 @@
/*
/*
* @test
* @test
* @bug 4866847
* @bug 4866847
7152564 7155693
* @summary
NullPointerException from CodeSource.matchLocation
* @summary
various CodeSource.implies tests
*/
*/
import
java.security.CodeSource
;
import
java.security.CodeSource
;
import
java.net.
*
;
import
java.net.
URL
;
public
class
Implies
{
public
class
Implies
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
URL
thisURL
=
new
URL
(
"http"
,
"localhost"
,
"file"
);
URL
thisURL
=
new
URL
(
"http"
,
"localhost"
,
"file"
);
URL
thatURL
=
new
URL
(
"http"
,
null
,
"file"
);
URL
thatURL
=
new
URL
(
"http"
,
null
,
"file"
);
// should not throw NullPointerException
testImplies
(
thisURL
,
thatURL
,
false
);
thisURL
=
new
URL
(
"http"
,
"localhost"
,
"dir/-"
);
thatURL
=
new
URL
(
"HTTP"
,
"localhost"
,
"dir/file"
);
// protocol check should ignore case
testImplies
(
thisURL
,
thatURL
,
true
);
thisURL
=
new
URL
(
"http"
,
"localhost"
,
80
,
"dir/-"
);
thatURL
=
new
URL
(
"HTTP"
,
"localhost"
,
"dir/file"
);
// port check should match default port of thatURL
testImplies
(
thisURL
,
thatURL
,
true
);
System
.
out
.
println
(
"test passed"
);
}
private
static
void
testImplies
(
URL
thisURL
,
URL
thatURL
,
boolean
result
)
throws
SecurityException
{
CodeSource
thisCs
=
CodeSource
thisCs
=
new
CodeSource
(
thisURL
,
(
java
.
security
.
cert
.
Certificate
[])
null
);
new
CodeSource
(
thisURL
,
(
java
.
security
.
cert
.
Certificate
[])
null
);
CodeSource
thatCs
=
CodeSource
thatCs
=
new
CodeSource
(
thatURL
,
(
java
.
security
.
cert
.
Certificate
[])
null
);
new
CodeSource
(
thatURL
,
(
java
.
security
.
cert
.
Certificate
[])
null
);
if
(
thisCs
.
implies
(
thatCs
)
!=
result
)
{
if
(
thisCs
.
implies
(
thatCs
))
{
throw
new
SecurityException
(
"test failed"
);
throw
new
SecurityException
(
"test failed"
);
}
}
System
.
out
.
println
(
"test passed"
);
}
}
}
}
test/java/util/AbstractCollection/ToArrayTest.java
0 → 100644
浏览文件 @
cb0fea8f
/*
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7121314
* @summary AbstractCollection.toArray(T[]) doesn't return the given array
* in concurrent modification.
* @author Ulf Zibis, David Holmes
*/
import
java.util.AbstractCollection
;
import
java.util.Arrays
;
import
java.util.Iterator
;
public
class
ToArrayTest
{
static
class
TestCollection
<
E
>
extends
AbstractCollection
<
E
>
{
private
final
E
[]
elements
;
private
int
[]
sizes
;
private
int
nextSize
;
public
TestCollection
(
E
[]
elements
)
{
this
.
elements
=
elements
;
setSizeSequence
(
new
int
[]
{
elements
.
length
});
}
/*
* Sets the values that size() will return on each use. The next
* call to size will return sizes[0], then sizes[1] etc. This allows us
* to emulate a concurrent change to the contents of the collection
* without having to perform concurrent changes. If sizes[n+1] contains
* a larger value, the collection will appear to have shrunk when
* iterated; if a smaller value then the collection will appear to have
* grown when iterated.
*/
void
setSizeSequence
(
int
...
sizes
)
{
this
.
sizes
=
sizes
;
nextSize
=
0
;
}
/* can change collection's size after each invocation */
@Override
public
int
size
()
{
return
sizes
[
nextSize
==
sizes
.
length
-
1
?
nextSize
:
nextSize
++];
}
@Override
public
Iterator
<
E
>
iterator
()
{
return
new
Iterator
<
E
>()
{
int
pos
=
0
;
public
boolean
hasNext
()
{
return
pos
<
sizes
[
nextSize
];
}
public
E
next
()
{
return
elements
[
pos
++];
}
public
void
remove
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
}
};
}
}
static
final
Object
[]
OBJECTS
=
{
new
Object
(),
new
Object
(),
new
Object
()
};
static
final
TestCollection
<?>
CANDIDATE
=
new
TestCollection
<
Object
>(
OBJECTS
);
static
final
int
CAP
=
OBJECTS
.
length
;
// capacity of the CANDIDATE
static
final
int
LAST
=
CAP
-
1
;
// last possible array index
Object
[]
a
;
Object
[]
res
;
int
last
()
{
return
a
.
length
-
1
;
}
protected
void
test
()
throws
Throwable
{
// Check array type conversion
res
=
new
TestCollection
<>(
new
Object
[]
{
"1"
,
"2"
}).
toArray
(
new
String
[
0
]);
check
(
res
instanceof
String
[]);
check
(
res
.
length
==
2
);
check
(
res
[
1
]
==
"2"
);
// Check incompatible type of target array
try
{
res
=
CANDIDATE
.
toArray
(
new
String
[
CAP
]);
check
(
false
);
}
catch
(
Throwable
t
)
{
check
(
t
instanceof
ArrayStoreException
);
}
// Check more elements than a.length
a
=
new
Object
[
CAP
-
1
];
// appears too small
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
!=
a
);
check
(
res
[
LAST
]
!=
null
);
// Check equal elements as a.length
a
=
new
Object
[
CAP
];
// appears to match
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
==
a
);
check
(
res
[
last
()]
!=
null
);
// Check equal elements as a.length
a
=
new
Object
[
CAP
+
1
];
// appears too big
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
==
a
);
check
(
res
[
last
()]
==
null
);
// Check less elements than expected, but more than a.length
a
=
new
Object
[
CAP
-
2
];
// appears too small
CANDIDATE
.
setSizeSequence
(
CAP
,
CAP
-
1
);
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
!=
a
);
check
(
res
.
length
==
CAP
-
1
);
check
(
res
[
LAST
-
1
]
!=
null
);
// Check less elements than expected, but equal as a.length
a
=
Arrays
.
copyOf
(
OBJECTS
,
CAP
);
// appears to match
CANDIDATE
.
setSizeSequence
(
CAP
,
CAP
-
1
);
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
==
a
);
check
(
res
[
last
()]
==
null
);
// Check more elements than expected and more than a.length
a
=
new
Object
[
CAP
-
1
];
// appears to match
CANDIDATE
.
setSizeSequence
(
CAP
-
1
,
CAP
);
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
!=
a
);
check
(
res
[
LAST
]
!=
null
);
// Check more elements than expected, but equal as a.length
a
=
new
Object
[
CAP
-
1
];
// appears to match
CANDIDATE
.
setSizeSequence
(
CAP
-
2
,
CAP
-
1
);
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
==
a
);
check
(
res
[
last
()]
!=
null
);
// Check more elements than expected, but less than a.length
a
=
Arrays
.
copyOf
(
OBJECTS
,
CAP
);
// appears to match
CANDIDATE
.
setSizeSequence
(
CAP
-
2
,
CAP
-
1
);
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
==
a
);
check
(
res
[
last
()]
==
null
);
test_7121314
();
}
/*
* Major target of this testcase, bug 7121314.
*/
protected
void
test_7121314
()
throws
Throwable
{
// Check equal elements as a.length, but less than expected
a
=
new
Object
[
CAP
-
1
];
// appears too small
CANDIDATE
.
setSizeSequence
(
CAP
,
CAP
-
1
);
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
==
a
);
check
(
res
[
last
()]
!=
null
);
// Check less elements than a.length and less than expected
a
=
Arrays
.
copyOf
(
OBJECTS
,
CAP
-
1
);
// appears too small
CANDIDATE
.
setSizeSequence
(
CAP
,
CAP
-
2
);
res
=
CANDIDATE
.
toArray
(
a
);
check
(
res
==
a
);
check
(
res
[
last
()]
==
null
);
}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
ToArrayTest
testcase
=
new
ToArrayTest
();
try
{
testcase
.
test
();
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
Exception
(
"Some tests failed"
);
}
//--------------------- Infrastructure ---------------------------
static
volatile
int
passed
=
0
,
failed
=
0
;
static
void
pass
()
{
passed
++;
}
static
void
fail
()
{
failed
++;
Thread
.
dumpStack
();
}
static
void
fail
(
String
msg
)
{
System
.
out
.
println
(
msg
);
fail
();
}
static
void
unexpected
(
Throwable
t
)
{
failed
++;
t
.
printStackTrace
();
}
static
void
check
(
boolean
cond
)
{
if
(
cond
)
pass
();
else
fail
();
}
static
void
equal
(
Object
x
,
Object
y
)
{
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
pass
();
else
{
System
.
out
.
println
(
x
+
" not equal to "
+
y
);
fail
();
}
}
}
test/java/util/regex/RegExTest.java
浏览文件 @
cb0fea8f
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
* 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
* 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
* 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
* 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
* 7067045
*/
*/
import
java.util.regex.*
;
import
java.util.regex.*
;
...
@@ -852,6 +853,17 @@ public class RegExTest {
...
@@ -852,6 +853,17 @@ public class RegExTest {
if
(!
result
.
equals
(
toSupplementaries
(
"zzz\\t$\\$zzz"
)))
if
(!
result
.
equals
(
toSupplementaries
(
"zzz\\t$\\$zzz"
)))
failCount
++;
failCount
++;
// IAE should be thrown if backslash or '$' is the last character
// in replacement string
try
{
"\uac00"
.
replaceAll
(
"\uac00"
,
"$"
);
"\uac00"
.
replaceAll
(
"\uac00"
,
"\\"
);
failCount
++;
}
catch
(
IllegalArgumentException
iie
)
{
}
catch
(
Exception
e
)
{
failCount
++;
}
report
(
"Literal replacement"
);
report
(
"Literal replacement"
);
}
}
...
...
test/sun/net/www/protocol/jar/B4957695.java
浏览文件 @
cb0fea8f
/*
/*
* Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
12
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -24,8 +24,6 @@
...
@@ -24,8 +24,6 @@
/**
/**
* @test
* @test
* @bug 4957695
* @bug 4957695
* @library ../../httptest/
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction AbstractCallback
* @summary URLJarFile.retrieve does not delete tmpFile on IOException
* @summary URLJarFile.retrieve does not delete tmpFile on IOException
*/
*/
...
@@ -34,43 +32,72 @@ import java.net.*;
...
@@ -34,43 +32,72 @@ import java.net.*;
public
class
B4957695
{
public
class
B4957695
{
static
int
count
=
0
;
static
Server
server
;
static
boolean
error
=
false
;
static
void
read
(
InputStream
is
)
throws
IOException
{
static
class
Server
extends
Thread
{
int
c
,
len
=
0
;
final
ServerSocket
srv
;
while
((
c
=
is
.
read
())
!=
-
1
)
{
static
final
byte
[]
requestEnd
=
new
byte
[]
{
'\r'
,
'\n'
,
'\r'
,
'\n'
};
len
+=
c
;
Server
(
ServerSocket
s
)
{
srv
=
s
;
}
void
readOneRequest
(
InputStream
is
)
throws
IOException
{
int
requestEndCount
=
0
,
r
;
while
((
r
=
is
.
read
())
!=
-
1
)
{
if
(
r
==
requestEnd
[
requestEndCount
])
{
requestEndCount
++;
if
(
requestEndCount
==
4
)
{
break
;
}
}
else
{
requestEndCount
=
0
;
}
}
}
System
.
out
.
println
(
"read "
+
len
+
" bytes"
);
}
}
static
class
CallBack
extends
AbstractCallback
{
public
void
run
()
{
try
(
Socket
s
=
srv
.
accept
())
{
// read HTTP request from client
readOneRequest
(
s
.
getInputStream
());
try
(
OutputStreamWriter
ow
=
new
OutputStreamWriter
((
s
.
getOutputStream
())))
{
FileInputStream
fin
=
new
FileInputStream
(
"foo1.jar"
);
int
length
=
fin
.
available
();
byte
[]
b
=
new
byte
[
length
-
10
];
fin
.
read
(
b
,
0
,
length
-
10
);
ow
.
write
(
"HTTP/1.0 200 OK\r\n"
);
public
void
request
(
HttpTransaction
req
,
int
count
)
{
// Note: The client expects length bytes.
try
{
ow
.
write
(
"Content-Length: "
+
length
+
"\r\n"
);
System
.
out
.
println
(
"Request received
"
);
ow
.
write
(
"Content-Type: text/html\r\n
"
);
req
.
setResponseEntityBody
(
new
FileInputStream
(
"foo1.jar"
)
);
ow
.
write
(
"\r\n"
);
System
.
out
.
println
(
"content length "
+
req
.
getResponseHeader
(
"Content-length"
// Note: The (buggy) server only sends length-10 bytes.
));
ow
.
write
(
new
String
(
b
));
req
.
sendPartialResponse
(
200
,
"Ok"
);
ow
.
flush
(
);
req
.
abortiveClose
();
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
}
};
static
void
read
(
InputStream
is
)
throws
IOException
{
int
c
,
len
=
0
;
static
HttpServer
server
;
while
((
c
=
is
.
read
())
!=
-
1
)
{
len
+=
c
;
}
System
.
out
.
println
(
"read "
+
len
+
" bytes"
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
tmpdir
=
System
.
getProperty
(
"java.io.tmpdir"
);
String
tmpdir
=
System
.
getProperty
(
"java.io.tmpdir"
);
String
[]
list1
=
listTmpFiles
(
tmpdir
);
String
[]
list1
=
listTmpFiles
(
tmpdir
);
//server = new HttpServer (new CallBack(), 10, 1, 0);
ServerSocket
serverSocket
=
new
ServerSocket
(
0
);
server
=
new
HttpServer
(
new
CallBack
(),
1
,
5
,
0
);
server
=
new
Server
(
serverSocket
);
int
port
=
server
.
getLocalPort
();
server
.
start
();
int
port
=
serverSocket
.
getLocalPort
();
System
.
out
.
println
(
"Server: listening on port: "
+
port
);
System
.
out
.
println
(
"Server: listening on port: "
+
port
);
URL
url
=
new
URL
(
"jar:http://localhost:"
+
port
+
"!/COPYRIGHT"
);
URL
url
=
new
URL
(
"jar:http://localhost:"
+
port
+
"!/COPYRIGHT"
);
try
{
try
{
...
@@ -81,14 +108,12 @@ public class B4957695 {
...
@@ -81,14 +108,12 @@ public class B4957695 {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Received IOException as expected"
);
System
.
out
.
println
(
"Received IOException as expected"
);
}
}
server
.
terminate
();
String
[]
list2
=
listTmpFiles
(
tmpdir
);
String
[]
list2
=
listTmpFiles
(
tmpdir
);
if
(!
sameList
(
list1
,
list2
))
{
if
(!
sameList
(
list1
,
list2
))
{
throw
new
RuntimeException
(
"some jar_cache files left behind"
);
throw
new
RuntimeException
(
"some jar_cache files left behind"
);
}
}
}
}
static
String
[]
listTmpFiles
(
String
d
)
{
static
String
[]
listTmpFiles
(
String
d
)
{
File
dir
=
new
File
(
d
);
File
dir
=
new
File
(
d
);
return
dir
.
list
(
new
FilenameFilter
()
{
return
dir
.
list
(
new
FilenameFilter
()
{
...
...
test/sun/nio/ch/SelProvider.java
浏览文件 @
cb0fea8f
...
@@ -38,20 +38,9 @@ public class SelProvider {
...
@@ -38,20 +38,9 @@ public class SelProvider {
if
(
"SunOS"
.
equals
(
osname
))
{
if
(
"SunOS"
.
equals
(
osname
))
{
expected
=
"sun.nio.ch.DevPollSelectorProvider"
;
expected
=
"sun.nio.ch.DevPollSelectorProvider"
;
}
else
if
(
"Linux"
.
equals
(
osname
))
{
}
else
if
(
"Linux"
.
equals
(
osname
))
{
String
[]
vers
=
osver
.
split
(
"\\."
,
0
);
if
(
vers
.
length
>=
2
)
{
int
major
=
Integer
.
parseInt
(
vers
[
0
]);
int
minor
=
Integer
.
parseInt
(
vers
[
1
]);
if
(
major
>
2
||
(
major
==
2
&&
minor
>=
6
))
{
expected
=
"sun.nio.ch.EPollSelectorProvider"
;
expected
=
"sun.nio.ch.EPollSelectorProvider"
;
}
else
{
expected
=
"sun.nio.ch.PollSelectorProvider"
;
}
}
else
{
throw
new
RuntimeException
(
"Test does not recognize this operating system"
);
}
}
else
if
(
osname
.
startsWith
(
"Mac OS"
))
{
}
else
if
(
osname
.
startsWith
(
"Mac OS"
))
{
expected
=
"sun.nio.ch.
Poll
SelectorProvider"
;
expected
=
"sun.nio.ch.
KQueue
SelectorProvider"
;
}
else
}
else
return
;
return
;
if
(!
spName
.
equals
(
expected
))
if
(!
spName
.
equals
(
expected
))
...
...
test/sun/nio/cs/TestSJIS0213_SM.java
0 → 100644
浏览文件 @
cb0fea8f
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 7152690
@summary Initialize SJIS_0213 charset with SecurityManager enabled
*/
public
class
TestSJIS0213_SM
{
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
==
null
)
{
System
.
setSecurityManager
(
new
SecurityManager
());
}
java
.
nio
.
charset
.
Charset
.
forName
(
"SJIS_0213"
);
}
}
test/sun/rmi/rmic/classpath/RMICClassPathTest.java
0 → 100644
浏览文件 @
cb0fea8f
/*
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/*
* Portions Copyright (c) 2012 IBM Corporation
*/
/* @test
* @bug 6610897
* @summary New constructor in sun.tools.java.ClassPath builds a path using
* File.separator instead of File.pathSeparator
* @run main RMICClassPathTest
*/
import
java.io.File
;
import
sun.rmi.rmic.BatchEnvironment
;
public
class
RMICClassPathTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
sysPath
=
"/home/~user/jdk/jre/lib/rt.jar"
;
String
extDir
=
""
;
String
clPath
=
"/home/~user/user.jar"
+
File
.
pathSeparator
+
"/home/~user/user2.jar"
+
File
.
pathSeparator
+
"/home/~user/user3.jar"
;
String
cpStr
=
BatchEnvironment
.
createClassPath
(
clPath
,
sysPath
,
extDir
).
toString
();
String
[]
paths
=
cpStr
.
split
(
File
.
pathSeparator
);
if
(
paths
.
length
!=
4
)
{
throw
new
Exception
(
"ClassPath length is not correct: the expected length is 4 and the actual length is "
+
paths
.
length
);
}
}
}
test/sun/security/krb5/ccache/EmptyCC.java
0 → 100644
浏览文件 @
cb0fea8f
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7158329
* @summary NPE in sun.security.krb5.Credentials.acquireDefaultCreds()
* @compile -XDignore.symbol.file EmptyCC.java
* @run main EmptyCC
*/
import
java.io.File
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
sun.security.krb5.Credentials
;
import
sun.security.krb5.PrincipalName
;
import
sun.security.krb5.internal.ccache.CredentialsCache
;
public
class
EmptyCC
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
final
PrincipalName
pn
=
new
PrincipalName
(
"dummy@FOO.COM"
);
final
String
ccache
=
"tmpcc"
;
if
(
args
.
length
==
0
)
{
// Main process, write the ccache and launch sub process
CredentialsCache
cache
=
CredentialsCache
.
create
(
pn
,
ccache
);
cache
.
save
();
// java -cp $test.classes EmptyCC readcc
ProcessBuilder
pb
=
new
ProcessBuilder
(
new
File
(
new
File
(
System
.
getProperty
(
"java.home"
),
"bin"
),
"java"
).
getPath
(),
"-cp"
,
System
.
getProperty
(
"test.classes"
),
"EmptyCC"
,
"readcc"
);
pb
.
environment
().
put
(
"KRB5CCNAME"
,
ccache
);
pb
.
redirectErrorStream
(
true
);
Process
p
=
pb
.
start
();
try
(
InputStream
ins
=
p
.
getInputStream
())
{
byte
[]
buf
=
new
byte
[
8192
];
int
n
;
while
((
n
=
ins
.
read
(
buf
))
>
0
)
{
System
.
out
.
write
(
buf
,
0
,
n
);
}
}
if
(
p
.
waitFor
()
!=
0
)
{
throw
new
Exception
(
"Test failed"
);
}
}
else
{
// Sub process, read the ccache
String
cc
=
System
.
getenv
(
"KRB5CCNAME"
);
if
(!
cc
.
equals
(
ccache
))
{
throw
new
Exception
(
"env not set correctly"
);
}
Credentials
.
acquireTGTFromCache
(
pn
,
null
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录