Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
67166499
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看板
提交
67166499
编写于
10月 04, 2010
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
f7a6ec10
90152284
变更
113
显示空白变更内容
内联
并排
Showing
113 changed file
with
3396 addition
and
1052 deletion
+3396
-1052
make/Makefile
make/Makefile
+57
-19
make/common/Cscope.gmk
make/common/Cscope.gmk
+1
-1
make/common/Defs.gmk
make/common/Defs.gmk
+1
-33
make/common/Rules-SCCS.gmk
make/common/Rules-SCCS.gmk
+0
-70
make/common/shared/Defs-utils.gmk
make/common/shared/Defs-utils.gmk
+2
-3
make/common/shared/Defs.gmk
make/common/shared/Defs.gmk
+1
-1
make/java/java/FILES_java.gmk
make/java/java/FILES_java.gmk
+1
-0
make/jprt.properties
make/jprt.properties
+252
-30
src/share/classes/com/sun/rowset/CachedRowSetImpl.java
src/share/classes/com/sun/rowset/CachedRowSetImpl.java
+39
-34
src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
+7
-7
src/share/classes/com/sun/rowset/JdbcRowSetImpl.java
src/share/classes/com/sun/rowset/JdbcRowSetImpl.java
+10
-10
src/share/classes/com/sun/rowset/JoinRowSetImpl.java
src/share/classes/com/sun/rowset/JoinRowSetImpl.java
+26
-5
src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java
...e/classes/com/sun/rowset/internal/CachedRowSetWriter.java
+12
-12
src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java
...e/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java
+4
-4
src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java
...sses/com/sun/rowset/internal/XmlReaderContentHandler.java
+11
-11
src/share/classes/com/sun/rowset/providers/RIOptimisticProvider.java
...lasses/com/sun/rowset/providers/RIOptimisticProvider.java
+4
-4
src/share/classes/com/sun/rowset/providers/RIXMLProvider.java
...share/classes/com/sun/rowset/providers/RIXMLProvider.java
+2
-2
src/share/classes/com/sun/servicetag/Installer.java
src/share/classes/com/sun/servicetag/Installer.java
+6
-4
src/share/classes/com/sun/servicetag/RegistrationData.java
src/share/classes/com/sun/servicetag/RegistrationData.java
+2
-2
src/share/classes/com/sun/servicetag/Registry.java
src/share/classes/com/sun/servicetag/Registry.java
+1
-1
src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java
.../classes/com/sun/servicetag/SolarisSystemEnvironment.java
+4
-3
src/share/classes/java/lang/System.java
src/share/classes/java/lang/System.java
+7
-10
src/share/classes/java/net/InetAddress.java
src/share/classes/java/net/InetAddress.java
+73
-82
src/share/classes/java/nio/file/FileSystemLoopException.java
src/share/classes/java/nio/file/FileSystemLoopException.java
+50
-0
src/share/classes/java/nio/file/FileTreeWalker.java
src/share/classes/java/nio/file/FileTreeWalker.java
+24
-42
src/share/classes/java/nio/file/FileVisitOption.java
src/share/classes/java/nio/file/FileVisitOption.java
+1
-5
src/share/classes/java/nio/file/FileVisitor.java
src/share/classes/java/nio/file/FileVisitor.java
+45
-47
src/share/classes/java/nio/file/Files.java
src/share/classes/java/nio/file/Files.java
+23
-19
src/share/classes/java/nio/file/SimpleFileVisitor.java
src/share/classes/java/nio/file/SimpleFileVisitor.java
+26
-51
src/share/classes/java/sql/DatabaseMetaData.java
src/share/classes/java/sql/DatabaseMetaData.java
+1
-1
src/share/classes/java/sql/Statement.java
src/share/classes/java/sql/Statement.java
+2
-2
src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java
...e/classes/java/util/concurrent/ConcurrentLinkedDeque.java
+1445
-0
src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
...e/classes/java/util/concurrent/ConcurrentLinkedQueue.java
+223
-139
src/share/classes/java/util/concurrent/ForkJoinPool.java
src/share/classes/java/util/concurrent/ForkJoinPool.java
+31
-15
src/share/classes/java/util/concurrent/ForkJoinTask.java
src/share/classes/java/util/concurrent/ForkJoinTask.java
+49
-12
src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
...re/classes/java/util/concurrent/ForkJoinWorkerThread.java
+10
-1
src/share/classes/java/util/concurrent/RecursiveAction.java
src/share/classes/java/util/concurrent/RecursiveAction.java
+1
-1
src/share/classes/java/util/logging/LogManager.java
src/share/classes/java/util/logging/LogManager.java
+13
-0
src/share/classes/java/util/logging/Logger.java
src/share/classes/java/util/logging/Logger.java
+25
-2
src/share/classes/javax/sql/rowset/BaseRowSet.java
src/share/classes/javax/sql/rowset/BaseRowSet.java
+49
-49
src/share/classes/javax/sql/rowset/CachedRowSet.java
src/share/classes/javax/sql/rowset/CachedRowSet.java
+1
-2
src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java
src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java
+28
-31
src/share/classes/javax/sql/rowset/RowSetProvider.java
src/share/classes/javax/sql/rowset/RowSetProvider.java
+5
-6
src/share/classes/javax/sql/rowset/WebRowSet.java
src/share/classes/javax/sql/rowset/WebRowSet.java
+3
-3
src/share/classes/javax/sql/rowset/rowset.properties
src/share/classes/javax/sql/rowset/rowset.properties
+2
-2
src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java
src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java
+6
-6
src/share/classes/javax/sql/rowset/serial/SerialRef.java
src/share/classes/javax/sql/rowset/serial/SerialRef.java
+3
-3
src/share/classes/javax/sql/rowset/serial/SerialStruct.java
src/share/classes/javax/sql/rowset/serial/SerialStruct.java
+4
-4
src/share/classes/javax/sql/rowset/spi/SyncFactory.java
src/share/classes/javax/sql/rowset/spi/SyncFactory.java
+3
-3
src/share/classes/javax/sql/rowset/spi/SyncProvider.java
src/share/classes/javax/sql/rowset/spi/SyncProvider.java
+2
-2
src/share/classes/javax/sql/rowset/spi/package.html
src/share/classes/javax/sql/rowset/spi/package.html
+2
-2
src/share/classes/sun/net/www/http/HttpClient.java
src/share/classes/sun/net/www/http/HttpClient.java
+18
-4
src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
.../classes/sun/net/www/protocol/http/HttpURLConnection.java
+33
-1
src/share/classes/sun/security/tools/KeyTool.java
src/share/classes/sun/security/tools/KeyTool.java
+1
-1
src/share/classes/sun/security/util/Resources.java
src/share/classes/sun/security/util/Resources.java
+4
-13
src/share/native/java/lang/System.c
src/share/native/java/lang/System.c
+12
-5
src/share/sample/nio/file/Chmod.java
src/share/sample/nio/file/Chmod.java
+1
-7
src/share/sample/nio/file/Copy.java
src/share/sample/nio/file/Copy.java
+8
-14
src/share/sample/nio/file/WatchDir.java
src/share/sample/nio/file/WatchDir.java
+4
-6
src/solaris/classes/java/lang/UNIXProcess.java.linux
src/solaris/classes/java/lang/UNIXProcess.java.linux
+7
-5
src/solaris/classes/sun/nio/fs/LinuxFileStore.java
src/solaris/classes/sun/nio/fs/LinuxFileStore.java
+0
-5
src/solaris/classes/sun/nio/fs/SolarisFileStore.java
src/solaris/classes/sun/nio/fs/SolarisFileStore.java
+0
-5
src/solaris/classes/sun/nio/fs/UnixFileStore.java
src/solaris/classes/sun/nio/fs/UnixFileStore.java
+3
-18
src/solaris/native/java/io/io_util_md.c
src/solaris/native/java/io/io_util_md.c
+1
-3
src/solaris/native/java/net/Inet6AddressImpl.c
src/solaris/native/java/net/Inet6AddressImpl.c
+9
-10
src/solaris/native/java/net/net_util_md.c
src/solaris/native/java/net/net_util_md.c
+46
-6
src/solaris/native/java/net/net_util_md.h
src/solaris/native/java/net/net_util_md.h
+8
-2
src/windows/native/java/io/io_util_md.c
src/windows/native/java/io/io_util_md.c
+0
-1
src/windows/native/sun/net/spi/DefaultProxySelector.c
src/windows/native/sun/net/spi/DefaultProxySelector.c
+4
-0
test/ProblemList.txt
test/ProblemList.txt
+21
-0
test/com/sun/security/sasl/ntlm/NTLMTest.java
test/com/sun/security/sasl/ntlm/NTLMTest.java
+2
-10
test/com/sun/servicetag/JavaServiceTagTest.java
test/com/sun/servicetag/JavaServiceTagTest.java
+2
-1
test/com/sun/servicetag/JavaServiceTagTest1.java
test/com/sun/servicetag/JavaServiceTagTest1.java
+3
-1
test/com/sun/servicetag/Util.java
test/com/sun/servicetag/Util.java
+2
-0
test/com/sun/servicetag/environ.properties
test/com/sun/servicetag/environ.properties
+2
-2
test/com/sun/servicetag/missing-environ-field.xml
test/com/sun/servicetag/missing-environ-field.xml
+2
-2
test/com/sun/servicetag/newer-registry-version.xml
test/com/sun/servicetag/newer-registry-version.xml
+1
-1
test/com/sun/servicetag/registration.xml
test/com/sun/servicetag/registration.xml
+5
-5
test/com/sun/servicetag/servicetag1.properties
test/com/sun/servicetag/servicetag1.properties
+1
-1
test/com/sun/servicetag/servicetag2.properties
test/com/sun/servicetag/servicetag2.properties
+1
-1
test/com/sun/servicetag/servicetag3.properties
test/com/sun/servicetag/servicetag3.properties
+1
-1
test/com/sun/servicetag/servicetag4.properties
test/com/sun/servicetag/servicetag4.properties
+1
-1
test/com/sun/servicetag/servicetag5.properties
test/com/sun/servicetag/servicetag5.properties
+1
-1
test/java/lang/ProcessBuilder/Basic.java
test/java/lang/ProcessBuilder/Basic.java
+58
-0
test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java
...a/nio/channels/AsynchronousServerSocketChannel/Basic.java
+38
-0
test/java/nio/channels/AsynchronousSocketChannel/Basic.java
test/java/nio/channels/AsynchronousSocketChannel/Basic.java
+14
-2
test/java/nio/channels/DatagramChannel/SocketOptionTests.java
.../java/nio/channels/DatagramChannel/SocketOptionTests.java
+11
-2
test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java
...a/nio/channels/ServerSocketChannel/SocketOptionTests.java
+4
-0
test/java/nio/channels/SocketChannel/SocketOptionTests.java
test/java/nio/channels/SocketChannel/SocketOptionTests.java
+9
-0
test/java/nio/file/FileStore/Basic.java
test/java/nio/file/FileStore/Basic.java
+1
-1
test/java/nio/file/Files/MaxDepth.java
test/java/nio/file/Files/MaxDepth.java
+67
-0
test/java/nio/file/Files/Misc.java
test/java/nio/file/Files/Misc.java
+11
-10
test/java/nio/file/Files/PrintFileTree.java
test/java/nio/file/Files/PrintFileTree.java
+18
-13
test/java/nio/file/Files/SkipSiblings.java
test/java/nio/file/Files/SkipSiblings.java
+5
-9
test/java/nio/file/Files/TerminateWalk.java
test/java/nio/file/Files/TerminateWalk.java
+5
-8
test/java/nio/file/Files/WalkWithSecurity.java
test/java/nio/file/Files/WalkWithSecurity.java
+1
-1
test/java/nio/file/Files/walk_file_tree.sh
test/java/nio/file/Files/walk_file_tree.sh
+6
-2
test/java/nio/file/TestUtil.java
test/java/nio/file/TestUtil.java
+2
-7
test/java/util/Collection/BiggernYours.java
test/java/util/Collection/BiggernYours.java
+5
-0
test/java/util/Collection/IteratorAtEnd.java
test/java/util/Collection/IteratorAtEnd.java
+1
-0
test/java/util/Collection/MOAT.java
test/java/util/Collection/MOAT.java
+4
-2
test/java/util/Collections/RacingCollections.java
test/java/util/Collections/RacingCollections.java
+2
-0
test/java/util/Deque/ChorusLine.java
test/java/util/Deque/ChorusLine.java
+1
-0
test/java/util/concurrent/ConcurrentQueues/ConcurrentQueueLoops.java
...til/concurrent/ConcurrentQueues/ConcurrentQueueLoops.java
+2
-1
test/java/util/concurrent/ConcurrentQueues/GCRetention.java
test/java/util/concurrent/ConcurrentQueues/GCRetention.java
+2
-0
test/java/util/concurrent/ConcurrentQueues/IteratorWeakConsistency.java
.../concurrent/ConcurrentQueues/IteratorWeakConsistency.java
+1
-0
test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java
...va/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java
+1
-0
test/java/util/concurrent/ConcurrentQueues/RemovePollRace.java
...java/util/concurrent/ConcurrentQueues/RemovePollRace.java
+2
-0
test/sun/net/www/http/ChunkedInputStream/ChunkedCharEncoding.sh
...un/net/www/http/ChunkedInputStream/ChunkedCharEncoding.sh
+0
-62
test/sun/net/www/http/HttpClient/StreamingRetry.java
test/sun/net/www/http/HttpClient/StreamingRetry.java
+89
-0
test/sun/net/www/protocol/http/6550798/TestCache.java
test/sun/net/www/protocol/http/6550798/TestCache.java
+133
-0
test/sun/net/www/protocol/http/6550798/test.java
test/sun/net/www/protocol/http/6550798/test.java
+90
-0
test/sun/security/tools/jarsigner/crl.sh
test/sun/security/tools/jarsigner/crl.sh
+9
-1
未找到文件。
make/Makefile
浏览文件 @
67166499
...
@@ -75,7 +75,6 @@ import_product -- copy in the product components \n\
...
@@ -75,7 +75,6 @@ import_product -- copy in the product components \n\
import_fastdebug -- copy in the fastdebug components
\n\
import_fastdebug -- copy in the fastdebug components
\n\
import_debug -- copy in the debug components
\n\
import_debug -- copy in the debug components
\n\
modules -- build the jdk and jre module images (experimental)
\n\
modules -- build the jdk and jre module images (experimental)
\n\
sccs_get -- make sure all SCCS files are up-to-date (need SCCS)
\n\
create_links -- create softlinks in Solaris 32bit build to 64bit dirs
\n\
create_links -- create softlinks in Solaris 32bit build to 64bit dirs
\n\
"
"
...
@@ -278,21 +277,6 @@ include $(BUILDDIR)/common/Sanity.gmk
...
@@ -278,21 +277,6 @@ include $(BUILDDIR)/common/Sanity.gmk
$(OUTPUTDIR) $(TEMPDIR)
:
$(OUTPUTDIR) $(TEMPDIR)
:
$(MKDIR)
-p
$@
$(MKDIR)
-p
$@
# cleanup everything. If the workspace is not being built by the control
# workspace, and if it is a Teamware workspace, then see if there are
# any files which are not under SCCS control.
clean clobber
::
ifndef
EXTERNALSANITYCONTROL
@
if
[
-d
$(TOPDIR)
/Codemgr_wsdata
]
;
then
\
$(ECHO)
'\nPerforming workspace scan for remnant files.\n'
\
' Any files listed below are not under SCCS control in the workspace\n'
\
' and you should review them and possibly remove them manually:'
;
\
$(FIND)
$(TOPDIR)
/make
$(TOPDIR)
/src
-type
f |
\
$(SED)
's+SCCS/[ps]\.++'
|
$(SORT)
|
$(UNIQ)
-c
|
$(NAWK)
'$$1<2 {print $$2;}'
;
\
$(ECHO)
'End of workspace scan.'
;
\
fi
endif
# this should be the last rule in this file:
# this should be the last rule in this file:
all
::
all
::
@
if
[
-r
$(WARNING_FILE)
]
;
then
\
@
if
[
-r
$(WARNING_FILE)
]
;
then
\
...
@@ -341,16 +325,70 @@ endif
...
@@ -341,16 +325,70 @@ endif
include
$(BUILDDIR)/common/internal/BinaryPlugs.gmk
include
$(BUILDDIR)/common/internal/BinaryPlugs.gmk
#
#
#
Get top level sccs_ge
t rule
#
Tes
t rule
#
#
include
$(BUILDDIR)/common/Rules-SCCS.gmk
.NOTPARALLEL
:
test_run
test
:
$(MAKE)
test_run
test_run
:
test_clean test_start test_summary
test_start
:
@
$(ECHO)
"Tests started at
`
$(DATE)
`
"
test_clean
:
$(RM)
$(OUTPUTDIR)
/test_failures.txt
$(OUTPUTDIR)
/test_log.txt
test_summary
:
$(OUTPUTDIR)/test_failures.txt
@
$(ECHO)
"#################################################"
@
$(ECHO)
"Tests completed at
`
$(DATE)
`
"
@
(
$(EGREP)
'^TEST STATS:'
$(OUTPUTDIR)
/test_log.txt
\
||
$(ECHO)
"No TEST STATS seen in log"
)
@
$(ECHO)
"For complete details see:
$(OUTPUTDIR)
/test_log.txt"
@
$(ECHO)
"#################################################"
@
if
[
-s
$<
]
;
then
\
$(ECHO)
"ERROR: Test failure count:
`
$(CAT)
$<
|
$(WC)
-l
`
"
;
\
$(CAT)
$<
;
\
exit
1
;
\
else
\
$(ECHO)
"Success! No failures detected"
;
\
fi
# Get failure list from log
$(OUTPUTDIR)/test_failures.txt
:
$(OUTPUTDIR)/test_log.txt
@
$(RM)
$@
@
(
$(EGREP)
'^FAILED:'
$<
||
$(ECHO)
""
)
|
$(NAWK)
'length>0'
>
$@
# Get log file of all tests run
JDK_TO_TEST
:=
$(
shell
\
if
[
-d
"
$(ABS_OUTPUTDIR)
/j2sdk-image"
]
;
then
\
$(ECHO)
"
$(ABS_OUTPUTDIR)
/j2sdk-image"
;
\
elif
[
-d
"
$(ABS_OUTPUTDIR)
/bin"
]
;
then
\
$(ECHO)
"
$(ABS_OUTPUTDIR)
"
;
\
elif
[
"
$(PRODUCT_HOME)
"
!=
""
-a
-d
"
$(PRODUCT_HOME)
/bin"
]
;
then
\
$(ECHO)
"
$(PRODUCT_HOME)
"
;
\
fi
\
)
TEST_TARGETS
=
jdk_all
$(OUTPUTDIR)/test_log.txt
:
$(RM)
$@
(
$(CD)
../test
&&
\
$(MAKE)
NO_STOPPING
=
-
PRODUCT_HOME
=
$(JDK_TO_TEST)
$(TEST_TARGETS)
\
)
|
tee
$@
#
# JPRT rules
# JPRT rules
#
include
jprt.gmk
include
jprt.gmk
#
#
# Phonies to avoid accidents.
# Phonies to avoid accidents.
#
#
.PHONY
:
all build clean clobber optimized debug fastdebug create_links
\
.PHONY
:
all build clean clobber optimized debug fastdebug create_links
\
import import_product import_fastdebug import_debug
import import_product import_fastdebug import_debug
\
test test_run test_start test_clean test_summary
make/common/Cscope.gmk
浏览文件 @
67166499
...
@@ -76,7 +76,7 @@ cscope.out: cscope.files FRC
...
@@ -76,7 +76,7 @@ cscope.out: cscope.files FRC
# What files should we include? A simple rule might be just those files under
# What files should we include? A simple rule might be just those files under
# SCM control, however this would miss files we create like the opcodes and
# SCM control, however this would miss files we create like the opcodes and
# CClassHeaders. The following attempts to find everything that is *useful*.
# CClassHeaders. The following attempts to find everything that is *useful*.
# (
.del files are created by sccsrm,
demo directories contain many .java files
# (demo directories contain many .java files
# that probably aren't useful for development, and the pkgarchive may contain
# that probably aren't useful for development, and the pkgarchive may contain
# duplicates of files within the source hierarchy). The ordering of the .raw
# duplicates of files within the source hierarchy). The ordering of the .raw
# file is an attempt to make cscope display the most relevant files first.
# file is an attempt to make cscope display the most relevant files first.
...
...
make/common/Defs.gmk
浏览文件 @
67166499
...
@@ -334,7 +334,7 @@ DOCSDIR = $(OUTPUTDIR)/docs$(DOCSDIRSUFFIX)
...
@@ -334,7 +334,7 @@ DOCSDIR = $(OUTPUTDIR)/docs$(DOCSDIRSUFFIX)
DOCSDIRSUFFIX =
DOCSDIRSUFFIX =
# The MESSAGE, WARNING and ERROR files are used to store sanityck and
# The MESSAGE, WARNING and ERROR files are used to store sanityck and
#
SCCS check messages,
warnings and errors.
# warnings and errors.
ifndef ERROR_FILE
ifndef ERROR_FILE
ERROR_FILE = $(OUTPUTDIR)/sanityCheckErrors.txt
ERROR_FILE = $(OUTPUTDIR)/sanityCheckErrors.txt
endif
endif
...
@@ -634,38 +634,6 @@ LINTFLAGS = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
...
@@ -634,38 +634,6 @@ LINTFLAGS = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
# Note: As a rule, GNU Make rules should not appear in any of the
# Defs*.gmk files. These were added for Kestrel-Solaris and do address
# a TeamWare bug. They should be moved elsewhere for Merlin.
#
# Override gnumake built-in rules which do sccs get operations badly.
# (They put the checked out code in the current directory, not in the
# directory of the original file.)
# Since this is a symptom of a teamware failure, complain and die on the spot.
# This message immediately goes to stdout and the build terminates.
define SCCS-trouble
$(error \
"ERROR: File $@ referenced while building in $(CURRENT_DIRECTORY) \
is out of date with respect to its SCCS file $<. \
This can happen from an unresolved Teamware conflict, a file movement, or \
a failure in which SCCS files are updated but the 'sccs get' was not done. \
You should double check for other out of date files in your workspace. \
Or run: cd $(TOPDIR) && $(MAKE) sccs_get")
endef
%:: s.%
@$(SCCS-trouble)
%:: SCCS/s.%
@$(SCCS-trouble)
@$(ECHO) " is out of date with respect to its SCCS file." >> $(WARNING_FILE)
@$(ECHO) " This file may be from an unresolved Teamware conflict." >> $(WARNING_FILE)
@$(ECHO) " This is also a symptom of a Teamware bringover/putback failure" >> $(WARNING_FILE)
@$(ECHO) " in which SCCS files are updated but not checked out." >> $(WARNING_FILE)
@$(ECHO) " Check for other out of date files in your workspace." >> $(WARNING_FILE)
@$(ECHO) "" >> $(WARNING_FILE)
@#exit 666
ifdef INSANE
ifdef INSANE
export INSANE
export INSANE
endif
endif
...
...
make/common/Rules-SCCS.gmk
已删除
100644 → 0
浏览文件 @
f7a6ec10
#
# Copyright (c) 2005, 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. 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
# 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.
#
#
# Only get these rules if SCCS is available
#
ifdef SCCS
# SCCS command to extract out latest source
SCCS_GET=$(SCCS) get -s
#
# Make sure all files in workspace are fresh
#
TEMP_ALL_FILES=$(JDK_TOPDIR)/temp_filelist
$(TEMP_ALL_FILES): $(JDK_TOPDIR)/Codemgr_wsdata/nametable
$(prep-target)
@$(CUT) -d' ' -f1 $< \
| $(GREP) -v '^VERSION' \
| $(GREP) -v '^deleted_files' \
| $(GREP) -v '^Codemgr_wsdata' > $@
sccs_get: $(TEMP_ALL_FILES)
@$(PRINTF) "Workspace has %d files\n" `$(CAT) $< | $(WC) -l`
@count=0; \
for i in `$(CAT) $<` ; do \
f=$(JDK_TOPDIR)/$$i; \
count=`$(EXPR) $$count '+' 1`; \
if [ `$(EXPR) $$count '%' 100` = 0 ] ; then \
$(PRINTF) "\rChecked $$count files"; \
fi; \
if [ ! -f $$f ] ; then \
$(PRINTF) "\r$(SCCS_GET) $$f\n"; \
(cd `$(DIRNAME) $$f` && $(SCCS_GET) `$(BASENAME) $$f`); \
elif /usr/bin/test $$f -ot `$(DIRNAME) $$f`/SCCS/s.`$(BASENAME) $$f` ; then \
$(PRINTF) "\r$(SCCS_GET) $$f\n"; \
(cd `$(DIRNAME) $$f` && $(SCCS_GET) `$(BASENAME) $$f`); \
fi; \
done; \
$(PRINTF) "\rChecked $$count files\n"
#
# Phonies to avoid accidents.
#
.PHONY: sccs_get
endif
make/common/shared/Defs-utils.gmk
浏览文件 @
67166499
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
# UTILS_COMMAND_PATH
# UTILS_COMMAND_PATH
# /usr/bin/
# /usr/bin/
# UTILS_USR_BIN_PATH
# UTILS_USR_BIN_PATH
# /usr/ccs/bin/ (
sccs,
m4, lex, yacc, as, ar, strip, mcs)
# /usr/ccs/bin/ (m4, lex, yacc, as, ar, strip, mcs)
# UTILS_CCS_BIN_PATH
# UTILS_CCS_BIN_PATH
# Dev Tools: zip, unzip, etc that we may have special versions of
# Dev Tools: zip, unzip, etc that we may have special versions of
# UTILS_DEVTOOL_PATH
# UTILS_DEVTOOL_PATH
...
@@ -117,7 +117,6 @@ RC = $(UTILS_COMMAND_PATH)rc
...
@@ -117,7 +117,6 @@ RC = $(UTILS_COMMAND_PATH)rc
RMDIR = $(UTILS_COMMAND_PATH)rmdir
RMDIR = $(UTILS_COMMAND_PATH)rmdir
RPM = $(UTILS_COMMAND_PATH)rpm
RPM = $(UTILS_COMMAND_PATH)rpm
RPMBUILD = $(UTILS_COMMAND_PATH)rpmbuild
RPMBUILD = $(UTILS_COMMAND_PATH)rpmbuild
SCCS = $(UTILS_CCS_BIN_PATH)sccs
SED = $(UTILS_COMMAND_PATH)sed
SED = $(UTILS_COMMAND_PATH)sed
SH = $(UTILS_COMMAND_PATH)sh
SH = $(UTILS_COMMAND_PATH)sh
SHOWREV = $(UTILS_USR_BIN_PATH)showrev
SHOWREV = $(UTILS_USR_BIN_PATH)showrev
...
@@ -183,7 +182,7 @@ ifeq ($(PLATFORM),linux)
...
@@ -183,7 +182,7 @@ ifeq ($(PLATFORM),linux)
NAWK = $(USRBIN_PATH)gawk
NAWK = $(USRBIN_PATH)gawk
# Intrinsic unix command, with backslash-escaped character interpretation
# Intrinsic unix command, with backslash-escaped character interpretation
ECHO = /bin/echo -e
ECHO = /bin/echo -e
# These are really in UTILS_USR_BIN_PATH on Linux
(only sccs is not)
# These are really in UTILS_USR_BIN_PATH on Linux
AR = $(UTILS_USR_BIN_PATH)ar
AR = $(UTILS_USR_BIN_PATH)ar
AS = $(UTILS_USR_BIN_PATH)as
AS = $(UTILS_USR_BIN_PATH)as
LD = $(UTILS_USR_BIN_PATH)ld
LD = $(UTILS_USR_BIN_PATH)ld
...
...
make/common/shared/Defs.gmk
浏览文件 @
67166499
...
@@ -219,7 +219,7 @@ else
...
@@ -219,7 +219,7 @@ else
PRODUCT_NAME = Java(TM)
PRODUCT_NAME = Java(TM)
PRODUCT_SUFFIX = SE Runtime Environment
PRODUCT_SUFFIX = SE Runtime Environment
JDK_RC_PLATFORM_NAME = Platform SE
JDK_RC_PLATFORM_NAME = Platform SE
COMPANY_NAME = Oracle
COMPANY_NAME = Oracle
Corporation
endif
endif
RUNTIME_NAME = $(PRODUCT_NAME) $(PRODUCT_SUFFIX)
RUNTIME_NAME = $(PRODUCT_NAME) $(PRODUCT_SUFFIX)
...
...
make/java/java/FILES_java.gmk
浏览文件 @
67166499
...
@@ -284,6 +284,7 @@ JAVA_JAVA_java = \
...
@@ -284,6 +284,7 @@ JAVA_JAVA_java = \
java/util/concurrent/CancellationException.java \
java/util/concurrent/CancellationException.java \
java/util/concurrent/CompletionService.java \
java/util/concurrent/CompletionService.java \
java/util/concurrent/ConcurrentHashMap.java \
java/util/concurrent/ConcurrentHashMap.java \
java/util/concurrent/ConcurrentLinkedDeque.java \
java/util/concurrent/ConcurrentLinkedQueue.java \
java/util/concurrent/ConcurrentLinkedQueue.java \
java/util/concurrent/ConcurrentMap.java \
java/util/concurrent/ConcurrentMap.java \
java/util/concurrent/ConcurrentNavigableMap.java \
java/util/concurrent/ConcurrentNavigableMap.java \
...
...
make/jprt.properties
浏览文件 @
67166499
...
@@ -25,43 +25,265 @@
...
@@ -25,43 +25,265 @@
# Properties for jprt
# Properties for jprt
# Use whatever release that the submitted job requests
# At submit time, the release supplied will be in jprt.submit.release
# and will be one of the official release names defined in jprt.
# jprt supports property value expansion using ${property.name} syntax.
# This tells jprt what default release we want to build
jprt.tools.default.release
=
${jprt.submit.release}
jprt.tools.default.release
=
${jprt.submit.release}
# The different build flavors we want, we override here so we just get these 2
# The different build flavors we want, we override here so we just get these 2
jprt.build.flavors
=
product,fastdebug
jprt.build.flavors
=
product,fastdebug
# Standard test target for everybody
# Define the Windows we want (temporary)
jprt.test.targets
=
*-*-*-jvm98
jprt.my.windows.i586.jdk7b107
=
windows_i586_5.0
jprt.my.windows.i586.jdk7temp
=
windows_i586_5.0
jprt.my.windows.i586.jdk7
=
windows_i586_5.1
jprt.my.windows.i586
=
${jprt.my.windows.i586.${jprt.tools.default.release}}
# Standard list of jprt build targets for this source tree
jprt.build.targets
=
\
solaris_sparc_5.10-{product|fastdebug},
\
solaris_sparcv9_5.10-{product|fastdebug},
\
solaris_i586_5.10-{product|fastdebug},
\
solaris_x64_5.10-{product|fastdebug},
\
linux_i586_2.6-{product|fastdebug},
\
linux_x64_2.6-{product|fastdebug},
\
${jprt.my.windows.i586}-{product|fastdebug},
\
windows_x64_5.2-{product|fastdebug}
# Standard vm test target
jprt.test.targets
=
\
solaris_sparc_5.10-product-c1-jvm98,
\
solaris_sparcv9_5.10-product-c2-jvm98,
\
solaris_i586_5.10-product-c1-jvm98,
\
solaris_x64_5.10-product-c2-jvm98,
\
linux_i586_2.6-product-{c1|c2}-jvm98,
\
linux_x64_2.6-product-c2-jvm98,
\
${jprt.my.windows.i586}-product-c1-jvm98,
\
windows_x64_5.2-product-c2-jvm98
# User can select the test set with jprt submit "-testset name" option
jprt.my.test.set
=
${jprt.test.set}
# Default jdk test targets in test/Makefile (no fastdebug & limited c2)
jprt.make.rule.default.test.targets
=
\
\
solaris_sparc_5.10-product-c1-jdk_beans1,
\
solaris_sparcv9_5.10-product-c2-jdk_beans1,
\
solaris_i586_5.10-product-c1-jdk_beans1,
\
solaris_x64_5.10-product-c2-jdk_beans1,
\
linux_i586_2.6-product-{c1|c2}-jdk_beans1,
\
linux_x64_2.6-product-c2-jdk_beans1,
\
${jprt.my.windows.i586}-product-c1-jdk_beans1,
\
windows_x64_5.2-product-c2-jdk_beans1,
\
\
solaris_sparc_5.10-product-c1-jdk_io,
\
solaris_sparcv9_5.10-product-c2-jdk_io,
\
solaris_i586_5.10-product-c1-jdk_io,
\
solaris_x64_5.10-product-c2-jdk_io,
\
linux_i586_2.6-product-{c1|c2}-jdk_io,
\
linux_x64_2.6-product-c2-jdk_io,
\
${jprt.my.windows.i586}-product-c1-jdk_io,
\
windows_x64_5.2-product-c2-jdk_io,
\
\
solaris_sparc_5.10-product-c1-jdk_lang,
\
solaris_sparcv9_5.10-product-c2-jdk_lang,
\
solaris_i586_5.10-product-c1-jdk_lang,
\
solaris_x64_5.10-product-c2-jdk_lang,
\
linux_i586_2.6-product-{c1|c2}-jdk_lang,
\
linux_x64_2.6-product-c2-jdk_lang,
\
${jprt.my.windows.i586}-product-c1-jdk_lang,
\
windows_x64_5.2-product-c2-jdk_lang,
\
\
solaris_sparc_5.10-product-c1-jdk_math,
\
solaris_sparcv9_5.10-product-c2-jdk_math,
\
solaris_i586_5.10-product-c1-jdk_math,
\
solaris_x64_5.10-product-c2-jdk_math,
\
linux_i586_2.6-product-{c1|c2}-jdk_math,
\
linux_x64_2.6-product-c2-jdk_math,
\
${jprt.my.windows.i586}-product-c1-jdk_math,
\
windows_x64_5.2-product-c2-jdk_math,
\
\
solaris_sparc_5.10-product-c1-jdk_misc,
\
solaris_sparcv9_5.10-product-c2-jdk_misc,
\
solaris_i586_5.10-product-c1-jdk_misc,
\
solaris_x64_5.10-product-c2-jdk_misc,
\
linux_i586_2.6-product-{c1|c2}-jdk_misc,
\
linux_x64_2.6-product-c2-jdk_misc,
\
${jprt.my.windows.i586}-product-c1-jdk_misc,
\
windows_x64_5.2-product-c2-jdk_misc,
\
\
solaris_sparc_5.10-product-c1-jdk_net,
\
solaris_sparcv9_5.10-product-c2-jdk_net,
\
solaris_i586_5.10-product-c1-jdk_net,
\
solaris_x64_5.10-product-c2-jdk_net,
\
linux_i586_2.6-product-{c1|c2}-jdk_net,
\
linux_x64_2.6-product-c2-jdk_net,
\
${jprt.my.windows.i586}-product-c1-jdk_net,
\
windows_x64_5.2-product-c2-jdk_net,
\
\
solaris_sparc_5.10-product-c1-jdk_nio1,
\
solaris_sparcv9_5.10-product-c2-jdk_nio1,
\
solaris_i586_5.10-product-c1-jdk_nio1,
\
solaris_x64_5.10-product-c2-jdk_nio1,
\
linux_i586_2.6-product-{c1|c2}-jdk_nio1,
\
linux_x64_2.6-product-c2-jdk_nio1,
\
${jprt.my.windows.i586}-product-c1-jdk_nio1,
\
windows_x64_5.2-product-c2-jdk_nio1,
\
\
solaris_sparc_5.10-product-c1-jdk_nio2,
\
solaris_sparcv9_5.10-product-c2-jdk_nio2,
\
solaris_i586_5.10-product-c1-jdk_nio2,
\
solaris_x64_5.10-product-c2-jdk_nio2,
\
linux_i586_2.6-product-{c1|c2}-jdk_nio2,
\
linux_x64_2.6-product-c2-jdk_nio2,
\
${jprt.my.windows.i586}-product-c1-jdk_nio2,
\
windows_x64_5.2-product-c2-jdk_nio2,
\
\
solaris_sparc_5.10-product-c1-jdk_nio3,
\
solaris_sparcv9_5.10-product-c2-jdk_nio3,
\
solaris_i586_5.10-product-c1-jdk_nio3,
\
solaris_x64_5.10-product-c2-jdk_nio3,
\
linux_i586_2.6-product-{c1|c2}-jdk_nio3,
\
linux_x64_2.6-product-c2-jdk_nio3,
\
${jprt.my.windows.i586}-product-c1-jdk_nio3,
\
windows_x64_5.2-product-c2-jdk_nio3,
\
\
solaris_sparc_5.10-product-c1-jdk_security1,
\
solaris_sparcv9_5.10-product-c2-jdk_security1,
\
solaris_i586_5.10-product-c1-jdk_security1,
\
solaris_x64_5.10-product-c2-jdk_security1,
\
linux_i586_2.6-product-{c1|c2}-jdk_security1,
\
linux_x64_2.6-product-c2-jdk_security1,
\
${jprt.my.windows.i586}-product-c1-jdk_security1,
\
windows_x64_5.2-product-c2-jdk_security1,
\
\
solaris_sparc_5.10-product-c1-jdk_text,
\
solaris_sparcv9_5.10-product-c2-jdk_text,
\
solaris_i586_5.10-product-c1-jdk_text,
\
solaris_x64_5.10-product-c2-jdk_text,
\
linux_i586_2.6-product-{c1|c2}-jdk_text,
\
linux_x64_2.6-product-c2-jdk_text,
\
${jprt.my.windows.i586}-product-c1-jdk_text,
\
windows_x64_5.2-product-c2-jdk_text,
\
\
solaris_sparc_5.10-product-c1-jdk_tools1,
\
solaris_sparcv9_5.10-product-c2-jdk_tools1,
\
solaris_i586_5.10-product-c1-jdk_tools1,
\
solaris_x64_5.10-product-c2-jdk_tools1,
\
linux_i586_2.6-product-{c1|c2}-jdk_tools1,
\
linux_x64_2.6-product-c2-jdk_tools1,
\
${jprt.my.windows.i586}-product-c1-jdk_tools1,
\
windows_x64_5.2-product-c2-jdk_tools1,
\
\
solaris_sparc_5.10-product-c1-jdk_util,
\
solaris_sparcv9_5.10-product-c2-jdk_util,
\
solaris_i586_5.10-product-c1-jdk_util,
\
solaris_x64_5.10-product-c2-jdk_util,
\
linux_i586_2.6-product-{c1|c2}-jdk_util,
\
linux_x64_2.6-product-c2-jdk_util,
\
${jprt.my.windows.i586}-product-c1-jdk_util,
\
windows_x64_5.2-product-c2-jdk_util
# Test targets in test/Makefile (some longer running tests only test c2)
# All jdk test targets in test/Makefile (still no fastdebug & limited c2)
jprt.make.rule.test.targets
=
\
jprt.make.rule.all.test.targets
=
\
*-product-*-jdk_beans1,
\
\
*-product-*-jdk_beans2,
\
${jprt.make.rule.default.test.targets},
\
*-product-*-jdk_beans3,
\
\
*-product-*-jdk_io,
\
solaris_sparc_5.10-product-c1-jdk_awt,
\
*-product-*-jdk_lang,
\
solaris_sparcv9_5.10-product-c2-jdk_awt,
\
*-product-*-jdk_management1,
\
solaris_i586_5.10-product-c1-jdk_awt,
\
*-product-*-jdk_management2,
\
solaris_x64_5.10-product-c2-jdk_awt,
\
*-product-*-jdk_math,
\
linux_i586_2.6-product-{c1|c2}-jdk_awt,
\
*-product-*-jdk_misc,
\
linux_x64_2.6-product-c2-jdk_awt,
\
*-product-*-jdk_net,
\
${jprt.my.windows.i586}-product-c1-jdk_awt,
\
*-product-*-jdk_nio1,
\
windows_x64_5.2-product-c2-jdk_awt,
\
*-product-*-jdk_nio2,
\
\
*-product-*-jdk_nio3,
\
solaris_sparc_5.10-product-c1-jdk_beans2,
\
*-product-*-jdk_security1,
\
solaris_sparcv9_5.10-product-c2-jdk_beans2,
\
*-product-*-jdk_security2,
\
solaris_i586_5.10-product-c1-jdk_beans2,
\
*-product-*-jdk_security3,
\
solaris_x64_5.10-product-c2-jdk_beans2,
\
*-product-*-jdk_text,
\
linux_i586_2.6-product-{c1|c2}-jdk_beans2,
\
*-product-*-jdk_tools1,
\
linux_x64_2.6-product-c2-jdk_beans2,
\
*-product-*-jdk_tools2,
\
${jprt.my.windows.i586}-product-c1-jdk_beans2,
\
*-product-*-jdk_util
windows_x64_5.2-product-c2-jdk_beans2,
\
\
solaris_sparc_5.10-product-c1-jdk_beans3,
\
solaris_sparcv9_5.10-product-c2-jdk_beans3,
\
solaris_i586_5.10-product-c1-jdk_beans3,
\
solaris_x64_5.10-product-c2-jdk_beans3,
\
linux_i586_2.6-product-{c1|c2}-jdk_beans3,
\
linux_x64_2.6-product-c2-jdk_beans3,
\
${jprt.my.windows.i586}-product-c1-jdk_beans3,
\
windows_x64_5.2-product-c2-jdk_beans3,
\
\
solaris_sparc_5.10-product-c1-jdk_management1,
\
solaris_sparcv9_5.10-product-c2-jdk_management1,
\
solaris_i586_5.10-product-c1-jdk_management1,
\
solaris_x64_5.10-product-c2-jdk_management1,
\
linux_i586_2.6-product-{c1|c2}-jdk_management1,
\
linux_x64_2.6-product-c2-jdk_management1,
\
${jprt.my.windows.i586}-product-c1-jdk_management1,
\
windows_x64_5.2-product-c2-jdk_management1,
\
\
solaris_sparc_5.10-product-c1-jdk_management2,
\
solaris_sparcv9_5.10-product-c2-jdk_management2,
\
solaris_i586_5.10-product-c1-jdk_management2,
\
solaris_x64_5.10-product-c2-jdk_management2,
\
linux_i586_2.6-product-{c1|c2}-jdk_management2,
\
linux_x64_2.6-product-c2-jdk_management2,
\
${jprt.my.windows.i586}-product-c1-jdk_management2,
\
windows_x64_5.2-product-c2-jdk_management2,
\
\
solaris_sparc_5.10-product-c1-jdk_rmi,
\
solaris_sparcv9_5.10-product-c2-jdk_rmi,
\
solaris_i586_5.10-product-c1-jdk_rmi,
\
solaris_x64_5.10-product-c2-jdk_rmi,
\
linux_i586_2.6-product-{c1|c2}-jdk_rmi,
\
linux_x64_2.6-product-c2-jdk_rmi,
\
${jprt.my.windows.i586}-product-c1-jdk_rmi,
\
windows_x64_5.2-product-c2-jdk_rmi,
\
\
solaris_sparc_5.10-product-c1-jdk_security2,
\
solaris_sparcv9_5.10-product-c2-jdk_security2,
\
solaris_i586_5.10-product-c1-jdk_security2,
\
solaris_x64_5.10-product-c2-jdk_security2,
\
linux_i586_2.6-product-{c1|c2}-jdk_security2,
\
linux_x64_2.6-product-c2-jdk_security2,
\
${jprt.my.windows.i586}-product-c1-jdk_security2,
\
windows_x64_5.2-product-c2-jdk_security2,
\
\
solaris_sparc_5.10-product-c1-jdk_security3,
\
solaris_sparcv9_5.10-product-c2-jdk_security3,
\
solaris_i586_5.10-product-c1-jdk_security3,
\
solaris_x64_5.10-product-c2-jdk_security3,
\
linux_i586_2.6-product-{c1|c2}-jdk_security3,
\
linux_x64_2.6-product-c2-jdk_security3,
\
${jprt.my.windows.i586}-product-c1-jdk_security3,
\
windows_x64_5.2-product-c2-jdk_security3,
\
\
solaris_sparc_5.10-product-c1-jdk_swing,
\
solaris_sparcv9_5.10-product-c2-jdk_swing,
\
solaris_i586_5.10-product-c1-jdk_swing,
\
solaris_x64_5.10-product-c2-jdk_swing,
\
linux_i586_2.6-product-{c1|c2}-jdk_swing,
\
linux_x64_2.6-product-c2-jdk_swing,
\
${jprt.my.windows.i586}-product-c1-jdk_swing,
\
windows_x64_5.2-product-c2-jdk_swing,
\
\
solaris_sparc_5.10-product-c1-jdk_tools2,
\
solaris_sparcv9_5.10-product-c2-jdk_tools2,
\
solaris_i586_5.10-product-c1-jdk_tools2,
\
solaris_x64_5.10-product-c2-jdk_tools2,
\
linux_i586_2.6-product-{c1|c2}-jdk_tools2,
\
linux_x64_2.6-product-c2-jdk_tools2,
\
${jprt.my.windows.i586}-product-c1-jdk_tools2,
\
windows_x64_5.2-product-c2-jdk_tools2
# Some of these are crashing Xvfb or windows manager, need dedicated DISPLAY per test batch
# Select list to use (allow for testset to be empty too)
jprt2.make.rule.test.targets
=
\
jprt.make.rule..test.targets
=
${jprt.make.rule.default.test.targets}
*-product-*-jdk_awt,
\
jprt.make.rule.test.targets
=
${jprt.make.rule.${jprt.my.test.set}.test.targets}
*-product-*-jdk_rmi,
\
*-product-*-jdk_swing,
\
# Directories to be excluded from the source bundles
# Directories to be excluded from the source bundles
jprt.bundle.exclude.src.dirs
=
build dist webrev
jprt.bundle.exclude.src.dirs
=
build dist webrev
...
...
src/share/classes/com/sun/rowset/CachedRowSetImpl.java
浏览文件 @
67166499
...
@@ -525,7 +525,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -525,7 +525,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
iMatchColumns
=
new
Vector
(
10
);
iMatchColumns
=
new
Vector
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
iMatchColumns
.
add
(
i
,
new
Integer
(-
1
));
iMatchColumns
.
add
(
i
,
Integer
.
valueOf
(-
1
));
}
}
strMatchColumns
=
new
Vector
(
10
);
strMatchColumns
=
new
Vector
(
10
);
...
@@ -889,7 +889,12 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -889,7 +889,12 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
success
=
false
;
success
=
false
;
}
else
{
}
else
{
tWriter
=
(
TransactionalWriter
)
rowSetWriter
;
tWriter
=
(
TransactionalWriter
)
rowSetWriter
;
if
(
tWriter
instanceof
CachedRowSetWriter
)
{
((
CachedRowSetWriter
)
tWriter
).
commit
(
this
,
updateOnInsert
);
((
CachedRowSetWriter
)
tWriter
).
commit
(
this
,
updateOnInsert
);
}
else
{
tWriter
.
commit
();
}
success
=
true
;
success
=
true
;
}
}
}
}
...
@@ -1294,7 +1299,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -1294,7 +1299,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
tMap
=
new
TreeMap
();
tMap
=
new
TreeMap
();
for
(
int
i
=
0
;
i
<
numRows
;
i
++)
{
for
(
int
i
=
0
;
i
<
numRows
;
i
++)
{
tMap
.
put
(
new
Integer
(
i
),
rvh
.
get
(
i
));
tMap
.
put
(
Integer
.
valueOf
(
i
),
rvh
.
get
(
i
));
}
}
return
(
tMap
.
values
());
return
(
tMap
.
values
());
...
@@ -1806,7 +1811,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -1806,7 +1811,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
return
(
byte
)
0
;
return
(
byte
)
0
;
}
}
try
{
try
{
return
((
new
Byte
(
value
.
toString
())).
byteValue
());
return
((
Byte
.
valueOf
(
value
.
toString
())).
byteValue
());
}
catch
(
NumberFormatException
ex
)
{
}
catch
(
NumberFormatException
ex
)
{
throw
new
SQLException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.bytefail"
).
toString
(),
throw
new
SQLException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.bytefail"
).
toString
(),
new
Object
[]
{
value
.
toString
().
trim
(),
columnIndex
}));
new
Object
[]
{
value
.
toString
().
trim
(),
columnIndex
}));
...
@@ -1850,7 +1855,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -1850,7 +1855,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
}
}
try
{
try
{
return
((
new
Short
(
value
.
toString
().
trim
())).
shortValue
());
return
((
Short
.
valueOf
(
value
.
toString
().
trim
())).
shortValue
());
}
catch
(
NumberFormatException
ex
)
{
}
catch
(
NumberFormatException
ex
)
{
throw
new
SQLException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.shortfail"
).
toString
(),
throw
new
SQLException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.shortfail"
).
toString
(),
new
Object
[]
{
value
.
toString
().
trim
(),
columnIndex
}));
new
Object
[]
{
value
.
toString
().
trim
(),
columnIndex
}));
...
@@ -1893,7 +1898,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -1893,7 +1898,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
}
}
try
{
try
{
return
((
new
Integer
(
value
.
toString
().
trim
())).
intValue
());
return
((
Integer
.
valueOf
(
value
.
toString
().
trim
())).
intValue
());
}
catch
(
NumberFormatException
ex
)
{
}
catch
(
NumberFormatException
ex
)
{
throw
new
SQLException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.intfail"
).
toString
(),
throw
new
SQLException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.intfail"
).
toString
(),
new
Object
[]
{
value
.
toString
().
trim
(),
columnIndex
}));
new
Object
[]
{
value
.
toString
().
trim
(),
columnIndex
}));
...
@@ -1936,7 +1941,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -1936,7 +1941,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
return
(
long
)
0
;
return
(
long
)
0
;
}
}
try
{
try
{
return
((
new
Long
(
value
.
toString
().
trim
())).
longValue
());
return
((
Long
.
valueOf
(
value
.
toString
().
trim
())).
longValue
());
}
catch
(
NumberFormatException
ex
)
{
}
catch
(
NumberFormatException
ex
)
{
throw
new
SQLException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.longfail"
).
toString
(),
throw
new
SQLException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.longfail"
).
toString
(),
new
Object
[]
{
value
.
toString
().
trim
(),
columnIndex
}));
new
Object
[]
{
value
.
toString
().
trim
(),
columnIndex
}));
...
@@ -4014,18 +4019,18 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4014,18 +4019,18 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
try
{
try
{
switch
(
trgType
)
{
switch
(
trgType
)
{
case
java
.
sql
.
Types
.
BIT
:
case
java
.
sql
.
Types
.
BIT
:
Integer
i
=
new
Integer
(
srcObj
.
toString
().
trim
());
Integer
i
=
Integer
.
valueOf
(
srcObj
.
toString
().
trim
());
return
i
.
equals
(
new
Integer
((
int
)
0
))
?
return
i
.
equals
(
Integer
.
valueOf
((
int
)
0
))
?
new
Boolean
(
false
)
:
Boolean
.
valueOf
(
false
)
:
new
Boolean
(
true
);
Boolean
.
valueOf
(
true
);
case
java
.
sql
.
Types
.
TINYINT
:
case
java
.
sql
.
Types
.
TINYINT
:
return
new
Byte
(
srcObj
.
toString
().
trim
());
return
Byte
.
valueOf
(
srcObj
.
toString
().
trim
());
case
java
.
sql
.
Types
.
SMALLINT
:
case
java
.
sql
.
Types
.
SMALLINT
:
return
new
Short
(
srcObj
.
toString
().
trim
());
return
Short
.
valueOf
(
srcObj
.
toString
().
trim
());
case
java
.
sql
.
Types
.
INTEGER
:
case
java
.
sql
.
Types
.
INTEGER
:
return
new
Integer
(
srcObj
.
toString
().
trim
());
return
Integer
.
valueOf
(
srcObj
.
toString
().
trim
());
case
java
.
sql
.
Types
.
BIGINT
:
case
java
.
sql
.
Types
.
BIGINT
:
return
new
Long
(
srcObj
.
toString
().
trim
());
return
Long
.
valueOf
(
srcObj
.
toString
().
trim
());
case
java
.
sql
.
Types
.
NUMERIC
:
case
java
.
sql
.
Types
.
NUMERIC
:
case
java
.
sql
.
Types
.
DECIMAL
:
case
java
.
sql
.
Types
.
DECIMAL
:
return
new
BigDecimal
(
srcObj
.
toString
().
trim
());
return
new
BigDecimal
(
srcObj
.
toString
().
trim
());
...
@@ -4037,7 +4042,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4037,7 +4042,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
case
java
.
sql
.
Types
.
CHAR
:
case
java
.
sql
.
Types
.
CHAR
:
case
java
.
sql
.
Types
.
VARCHAR
:
case
java
.
sql
.
Types
.
VARCHAR
:
case
java
.
sql
.
Types
.
LONGVARCHAR
:
case
java
.
sql
.
Types
.
LONGVARCHAR
:
return
new
String
(
srcObj
.
toString
()
);
return
srcObj
.
toString
(
);
default
:
default
:
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.dtypemismt"
).
toString
()+
trgType
);
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.dtypemismt"
).
toString
()+
trgType
);
}
}
...
@@ -4134,7 +4139,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4134,7 +4139,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
case
java
.
sql
.
Types
.
CHAR
:
case
java
.
sql
.
Types
.
CHAR
:
case
java
.
sql
.
Types
.
VARCHAR
:
case
java
.
sql
.
Types
.
VARCHAR
:
case
java
.
sql
.
Types
.
LONGVARCHAR
:
case
java
.
sql
.
Types
.
LONGVARCHAR
:
return
new
String
(
srcObj
.
toString
()
);
return
srcObj
.
toString
(
);
default
:
default
:
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.dtypemismt"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.dtypemismt"
).
toString
());
}
}
...
@@ -4181,12 +4186,12 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4181,12 +4186,12 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
try
{
try
{
switch
(
trgType
)
{
switch
(
trgType
)
{
case
java
.
sql
.
Types
.
BIT
:
case
java
.
sql
.
Types
.
BIT
:
Integer
i
=
new
Integer
(
srcObj
.
toString
().
trim
());
Integer
i
=
Integer
.
valueOf
(
srcObj
.
toString
().
trim
());
return
i
.
equals
(
new
Integer
((
int
)
0
))
?
return
i
.
equals
(
Integer
.
valueOf
((
int
)
0
))
?
new
Boolean
(
false
)
:
Boolean
.
valueOf
(
false
)
:
new
Boolean
(
true
);
Boolean
.
valueOf
(
true
);
case
java
.
sql
.
Types
.
BOOLEAN
:
case
java
.
sql
.
Types
.
BOOLEAN
:
return
new
Boolean
(
srcObj
.
toString
().
trim
());
return
Boolean
.
valueOf
(
srcObj
.
toString
().
trim
());
default
:
default
:
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.dtypemismt"
).
toString
()+
trgType
);
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.dtypemismt"
).
toString
()+
trgType
);
}
}
...
@@ -4260,7 +4265,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4260,7 +4265,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
checkIndex
(
columnIndex
);
checkIndex
(
columnIndex
);
// make sure the cursor is on a valid row
// make sure the cursor is on a valid row
checkCursor
();
checkCursor
();
Object
obj
=
convertBoolean
(
new
Boolean
(
x
),
Object
obj
=
convertBoolean
(
Boolean
.
valueOf
(
x
),
java
.
sql
.
Types
.
BIT
,
java
.
sql
.
Types
.
BIT
,
RowSetMD
.
getColumnType
(
columnIndex
));
RowSetMD
.
getColumnType
(
columnIndex
));
...
@@ -4296,7 +4301,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4296,7 +4301,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
// make sure the cursor is on a valid row
// make sure the cursor is on a valid row
checkCursor
();
checkCursor
();
Object
obj
=
convertNumeric
(
new
Byte
(
x
),
Object
obj
=
convertNumeric
(
Byte
.
valueOf
(
x
),
java
.
sql
.
Types
.
TINYINT
,
java
.
sql
.
Types
.
TINYINT
,
RowSetMD
.
getColumnType
(
columnIndex
));
RowSetMD
.
getColumnType
(
columnIndex
));
...
@@ -4332,7 +4337,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4332,7 +4337,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
// make sure the cursor is on a valid row
// make sure the cursor is on a valid row
checkCursor
();
checkCursor
();
Object
obj
=
convertNumeric
(
new
Short
(
x
),
Object
obj
=
convertNumeric
(
Short
.
valueOf
(
x
),
java
.
sql
.
Types
.
SMALLINT
,
java
.
sql
.
Types
.
SMALLINT
,
RowSetMD
.
getColumnType
(
columnIndex
));
RowSetMD
.
getColumnType
(
columnIndex
));
...
@@ -4367,7 +4372,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4367,7 +4372,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
checkIndex
(
columnIndex
);
checkIndex
(
columnIndex
);
// make sure the cursor is on a valid row
// make sure the cursor is on a valid row
checkCursor
();
checkCursor
();
Object
obj
=
convertNumeric
(
new
Integer
(
x
),
Object
obj
=
convertNumeric
(
Integer
.
valueOf
(
x
),
java
.
sql
.
Types
.
INTEGER
,
java
.
sql
.
Types
.
INTEGER
,
RowSetMD
.
getColumnType
(
columnIndex
));
RowSetMD
.
getColumnType
(
columnIndex
));
...
@@ -4403,7 +4408,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -4403,7 +4408,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
// make sure the cursor is on a valid row
// make sure the cursor is on a valid row
checkCursor
();
checkCursor
();
Object
obj
=
convertNumeric
(
new
Long
(
x
),
Object
obj
=
convertNumeric
(
Long
.
valueOf
(
x
),
java
.
sql
.
Types
.
BIGINT
,
java
.
sql
.
Types
.
BIGINT
,
RowSetMD
.
getColumnType
(
columnIndex
));
RowSetMD
.
getColumnType
(
columnIndex
));
...
@@ -6429,7 +6434,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -6429,7 +6434,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
if
(
tabName
==
null
)
if
(
tabName
==
null
)
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.tablename"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.tablename"
).
toString
());
else
else
tableName
=
new
String
(
tabName
)
;
tableName
=
tabName
;
}
}
/**
/**
...
@@ -6940,7 +6945,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -6940,7 +6945,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
}
}
for
(
int
i
=
0
;
i
<
columnIdxes
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnIdxes
.
length
;
i
++)
{
iMatchColumns
.
set
(
i
,
new
Integer
(-
1
));
iMatchColumns
.
set
(
i
,
Integer
.
valueOf
(-
1
));
}
}
}
}
...
@@ -7049,7 +7054,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -7049,7 +7054,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
}
}
}
}
for
(
int
i
=
0
;
i
<
columnIdxes
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnIdxes
.
length
;
i
++)
{
iMatchColumns
.
add
(
i
,
new
Integer
(
columnIdxes
[
i
]));
iMatchColumns
.
add
(
i
,
Integer
.
valueOf
(
columnIdxes
[
i
]));
}
}
}
}
...
@@ -7104,7 +7109,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -7104,7 +7109,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.matchcols1"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.matchcols1"
).
toString
());
}
else
{
}
else
{
// set iMatchColumn
// set iMatchColumn
iMatchColumns
.
set
(
0
,
new
Integer
(
columnIdx
));
iMatchColumns
.
set
(
0
,
Integer
.
valueOf
(
columnIdx
));
//strMatchColumn = null;
//strMatchColumn = null;
}
}
}
}
...
@@ -7126,7 +7131,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -7126,7 +7131,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
*/
public
void
setMatchColumn
(
String
columnName
)
throws
SQLException
{
public
void
setMatchColumn
(
String
columnName
)
throws
SQLException
{
// validate, if col is ok to be set
// validate, if col is ok to be set
if
(
columnName
.
equals
(
null
)
||
((
columnName
=
columnName
.
trim
())
==
""
)
)
{
if
(
columnName
==
null
||
(
columnName
=
columnName
.
trim
()).
equals
(
""
)
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.matchcols2"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.matchcols2"
).
toString
());
}
else
{
}
else
{
// set strMatchColumn
// set strMatchColumn
...
@@ -7151,13 +7156,13 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
...
@@ -7151,13 +7156,13 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
*/
public
void
unsetMatchColumn
(
int
columnIdx
)
throws
SQLException
{
public
void
unsetMatchColumn
(
int
columnIdx
)
throws
SQLException
{
// check if we are unsetting the SAME column
// check if we are unsetting the SAME column
if
(!
iMatchColumns
.
get
(
0
).
equals
(
new
Integer
(
columnIdx
)
)
)
{
if
(!
iMatchColumns
.
get
(
0
).
equals
(
Integer
.
valueOf
(
columnIdx
)
)
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.unsetmatch"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.unsetmatch"
).
toString
());
}
else
if
(
strMatchColumns
.
get
(
0
)
!=
null
)
{
}
else
if
(
strMatchColumns
.
get
(
0
)
!=
null
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.unsetmatch1"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"cachedrowsetimpl.unsetmatch1"
).
toString
());
}
else
{
}
else
{
// that is, we are unsetting it.
// that is, we are unsetting it.
iMatchColumns
.
set
(
0
,
new
Integer
(-
1
));
iMatchColumns
.
set
(
0
,
Integer
.
valueOf
(-
1
));
}
}
}
}
...
...
src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
浏览文件 @
67166499
...
@@ -499,7 +499,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
...
@@ -499,7 +499,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
if
(
onInsertRow
)
{
if
(
onInsertRow
)
{
if
(
p
!=
null
)
{
if
(
p
!=
null
)
{
bool
=
p
.
evaluate
(
new
Integer
(
x
),
columnIndex
);
bool
=
p
.
evaluate
(
Integer
.
valueOf
(
x
),
columnIndex
);
if
(!
bool
)
{
if
(!
bool
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
...
@@ -566,7 +566,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
...
@@ -566,7 +566,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
if
(
onInsertRow
)
{
if
(
onInsertRow
)
{
if
(
p
!=
null
)
{
if
(
p
!=
null
)
{
bool
=
p
.
evaluate
(
new
Boolean
(
x
)
,
columnIndex
);
bool
=
p
.
evaluate
(
Boolean
.
valueOf
(
x
)
,
columnIndex
);
if
(!
bool
)
{
if
(!
bool
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
...
@@ -634,7 +634,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
...
@@ -634,7 +634,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
if
(
onInsertRow
)
{
if
(
onInsertRow
)
{
if
(
p
!=
null
)
{
if
(
p
!=
null
)
{
bool
=
p
.
evaluate
(
new
Byte
(
x
),
columnIndex
);
bool
=
p
.
evaluate
(
Byte
.
valueOf
(
x
),
columnIndex
);
if
(!
bool
)
{
if
(!
bool
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
...
@@ -703,7 +703,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
...
@@ -703,7 +703,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
if
(
onInsertRow
)
{
if
(
onInsertRow
)
{
if
(
p
!=
null
)
{
if
(
p
!=
null
)
{
bool
=
p
.
evaluate
(
new
Short
(
x
),
columnIndex
);
bool
=
p
.
evaluate
(
Short
.
valueOf
(
x
),
columnIndex
);
if
(!
bool
)
{
if
(!
bool
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
...
@@ -771,7 +771,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
...
@@ -771,7 +771,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
if
(
onInsertRow
)
{
if
(
onInsertRow
)
{
if
(
p
!=
null
)
{
if
(
p
!=
null
)
{
bool
=
p
.
evaluate
(
new
Long
(
x
),
columnIndex
);
bool
=
p
.
evaluate
(
Long
.
valueOf
(
x
),
columnIndex
);
if
(!
bool
)
{
if
(!
bool
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"filteredrowsetimpl.notallowed"
).
toString
());
...
@@ -1106,12 +1106,12 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
...
@@ -1106,12 +1106,12 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
public
void
updateBytes
(
int
columnIndex
,
byte
[]
x
)
throws
SQLException
{
public
void
updateBytes
(
int
columnIndex
,
byte
[]
x
)
throws
SQLException
{
boolean
bool
;
boolean
bool
;
String
val
=
new
String
()
;
String
val
=
""
;
Byte
[]
obj_arr
=
new
Byte
[
x
.
length
];
Byte
[]
obj_arr
=
new
Byte
[
x
.
length
];
for
(
int
i
=
0
;
i
<
x
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
x
.
length
;
i
++)
{
obj_arr
[
i
]
=
new
Byte
(
x
[
i
]);
obj_arr
[
i
]
=
Byte
.
valueOf
(
x
[
i
]);
val
=
val
.
concat
(
obj_arr
[
i
].
toString
());
val
=
val
.
concat
(
obj_arr
[
i
].
toString
());
}
}
...
...
src/share/classes/com/sun/rowset/JdbcRowSetImpl.java
浏览文件 @
67166499
...
@@ -215,7 +215,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -215,7 +215,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
iMatchColumns
=
new
Vector
(
10
);
iMatchColumns
=
new
Vector
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
iMatchColumns
.
add
(
i
,
new
Integer
(-
1
));
iMatchColumns
.
add
(
i
,
Integer
.
valueOf
(-
1
));
}
}
strMatchColumns
=
new
Vector
(
10
);
strMatchColumns
=
new
Vector
(
10
);
...
@@ -288,7 +288,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -288,7 +288,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
iMatchColumns
=
new
Vector
(
10
);
iMatchColumns
=
new
Vector
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
iMatchColumns
.
add
(
i
,
new
Integer
(-
1
));
iMatchColumns
.
add
(
i
,
Integer
.
valueOf
(-
1
));
}
}
strMatchColumns
=
new
Vector
(
10
);
strMatchColumns
=
new
Vector
(
10
);
...
@@ -375,7 +375,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -375,7 +375,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
iMatchColumns
=
new
Vector
(
10
);
iMatchColumns
=
new
Vector
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
iMatchColumns
.
add
(
i
,
new
Integer
(-
1
));
iMatchColumns
.
add
(
i
,
Integer
.
valueOf
(-
1
));
}
}
strMatchColumns
=
new
Vector
(
10
);
strMatchColumns
=
new
Vector
(
10
);
...
@@ -465,7 +465,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -465,7 +465,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
iMatchColumns
=
new
Vector
(
10
);
iMatchColumns
=
new
Vector
(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
iMatchColumns
.
add
(
i
,
new
Integer
(-
1
));
iMatchColumns
.
add
(
i
,
Integer
.
valueOf
(-
1
));
}
}
strMatchColumns
=
new
Vector
(
10
);
strMatchColumns
=
new
Vector
(
10
);
...
@@ -3754,7 +3754,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -3754,7 +3754,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
}
}
for
(
int
i
=
0
;
i
<
columnIdxes
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnIdxes
.
length
;
i
++)
{
iMatchColumns
.
set
(
i
,
new
Integer
(-
1
));
iMatchColumns
.
set
(
i
,
Integer
.
valueOf
(-
1
));
}
}
}
}
...
@@ -3863,7 +3863,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -3863,7 +3863,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
}
}
}
}
for
(
int
i
=
0
;
i
<
columnIdxes
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnIdxes
.
length
;
i
++)
{
iMatchColumns
.
add
(
i
,
new
Integer
(
columnIdxes
[
i
]));
iMatchColumns
.
add
(
i
,
Integer
.
valueOf
(
columnIdxes
[
i
]));
}
}
}
}
...
@@ -3918,7 +3918,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -3918,7 +3918,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"jdbcrowsetimpl.matchcols1"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"jdbcrowsetimpl.matchcols1"
).
toString
());
}
else
{
}
else
{
// set iMatchColumn
// set iMatchColumn
iMatchColumns
.
set
(
0
,
new
Integer
(
columnIdx
));
iMatchColumns
.
set
(
0
,
Integer
.
valueOf
(
columnIdx
));
//strMatchColumn = null;
//strMatchColumn = null;
}
}
}
}
...
@@ -3940,7 +3940,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -3940,7 +3940,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
*/
*/
public
void
setMatchColumn
(
String
columnName
)
throws
SQLException
{
public
void
setMatchColumn
(
String
columnName
)
throws
SQLException
{
// validate, if col is ok to be set
// validate, if col is ok to be set
if
(
columnName
.
equals
(
null
)
||
((
columnName
=
columnName
.
trim
())
==
""
))
{
if
(
columnName
==
null
||
(
columnName
=
columnName
.
trim
()).
equals
(
""
))
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"jdbcrowsetimpl.matchcols2"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"jdbcrowsetimpl.matchcols2"
).
toString
());
}
else
{
}
else
{
// set strMatchColumn
// set strMatchColumn
...
@@ -3965,13 +3965,13 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
...
@@ -3965,13 +3965,13 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
*/
*/
public
void
unsetMatchColumn
(
int
columnIdx
)
throws
SQLException
{
public
void
unsetMatchColumn
(
int
columnIdx
)
throws
SQLException
{
// check if we are unsetting the SAME column
// check if we are unsetting the SAME column
if
(!
iMatchColumns
.
get
(
0
).
equals
(
new
Integer
(
columnIdx
)
)
)
{
if
(!
iMatchColumns
.
get
(
0
).
equals
(
Integer
.
valueOf
(
columnIdx
)
)
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"jdbcrowsetimpl.unsetmatch"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"jdbcrowsetimpl.unsetmatch"
).
toString
());
}
else
if
(
strMatchColumns
.
get
(
0
)
!=
null
)
{
}
else
if
(
strMatchColumns
.
get
(
0
)
!=
null
)
{
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"jdbcrowsetimpl.usecolname"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"jdbcrowsetimpl.usecolname"
).
toString
());
}
else
{
}
else
{
// that is, we are unsetting it.
// that is, we are unsetting it.
iMatchColumns
.
set
(
0
,
new
Integer
(-
1
));
iMatchColumns
.
set
(
0
,
Integer
.
valueOf
(-
1
));
}
}
}
}
...
...
src/share/classes/com/sun/rowset/JoinRowSetImpl.java
浏览文件 @
67166499
...
@@ -33,6 +33,8 @@ import java.math.*;
...
@@ -33,6 +33,8 @@ import java.math.*;
import
java.util.*
;
import
java.util.*
;
import
javax.sql.rowset.*
;
import
javax.sql.rowset.*
;
import
javax.sql.rowset.spi.SyncProvider
;
import
javax.sql.rowset.spi.SyncProviderException
;
/**
/**
* The standard implementation of the <code>JoinRowSet</code>
* The standard implementation of the <code>JoinRowSet</code>
...
@@ -550,7 +552,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
...
@@ -550,7 +552,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
// This 'if' will be removed after all joins are implemented.
// This 'if' will be removed after all joins are implemented.
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"joinrowsetimpl.notsupported"
).
toString
());
throw
new
SQLException
(
resBundle
.
handleGetObject
(
"joinrowsetimpl.notsupported"
).
toString
());
}
else
{
}
else
{
Integer
Intgr
=
new
Integer
(
JoinRowSet
.
INNER_JOIN
);
Integer
Intgr
=
Integer
.
valueOf
(
JoinRowSet
.
INNER_JOIN
);
vecJoinType
.
add
(
Intgr
);
vecJoinType
.
add
(
Intgr
);
}
}
}
else
{
}
else
{
...
@@ -874,8 +876,8 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
...
@@ -874,8 +876,8 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
String
strWhereClause
=
"Select "
;
String
strWhereClause
=
"Select "
;
String
whereClause
;
String
whereClause
;
String
tabName
=
null
;
String
tabName
=
""
;
String
strTabName
=
null
;
String
strTabName
=
""
;
int
sz
,
cols
;
int
sz
,
cols
;
int
j
;
int
j
;
CachedRowSetImpl
crs
;
CachedRowSetImpl
crs
;
...
@@ -889,8 +891,6 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
...
@@ -889,8 +891,6 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
// tableNameX.(rowsetX.getMatchColumnName()) ==
// tableNameX.(rowsetX.getMatchColumnName()) ==
// tableNameZ.(rowsetZ.getMatchColumnName()));
// tableNameZ.(rowsetZ.getMatchColumnName()));
tabName
=
new
String
();
strTabName
=
new
String
();
sz
=
vecRowSetsInJOIN
.
size
();
sz
=
vecRowSetsInJOIN
.
size
();
for
(
int
i
=
0
;
i
<
sz
;
i
++)
{
for
(
int
i
=
0
;
i
<
sz
;
i
++)
{
crs
=
(
CachedRowSetImpl
)
vecRowSetsInJOIN
.
get
(
i
);
crs
=
(
CachedRowSetImpl
)
vecRowSetsInJOIN
.
get
(
i
);
...
@@ -4311,6 +4311,27 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
...
@@ -4311,6 +4311,27 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
return
crsInternal
.
createCopySchema
();
return
crsInternal
.
createCopySchema
();
}
}
/**
* {@inheritDoc}
*/
public
void
setSyncProvider
(
String
providerStr
)
throws
SQLException
{
crsInternal
.
setSyncProvider
(
providerStr
);
}
/**
* {@inheritDoc}
*/
public
void
acceptChanges
()
throws
SyncProviderException
{
crsInternal
.
acceptChanges
();
}
/**
* {@inheritDoc}
*/
public
SyncProvider
getSyncProvider
()
throws
SQLException
{
return
crsInternal
.
getSyncProvider
();
}
/**
/**
* This method re populates the resBundle
* This method re populates the resBundle
* during the deserialization process
* during the deserialization process
...
...
src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java
浏览文件 @
67166499
...
@@ -338,11 +338,11 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
...
@@ -338,11 +338,11 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
if
(
crs
.
rowDeleted
())
{
if
(
crs
.
rowDeleted
())
{
// The row has been deleted.
// The row has been deleted.
if
(
conflict
=
(
deleteOriginalRow
(
crs
,
this
.
crsResolve
))
==
true
)
{
if
(
conflict
=
(
deleteOriginalRow
(
crs
,
this
.
crsResolve
))
==
true
)
{
status
.
add
(
rows
,
new
Integer
(
SyncResolver
.
DELETE_ROW_CONFLICT
));
status
.
add
(
rows
,
Integer
.
valueOf
(
SyncResolver
.
DELETE_ROW_CONFLICT
));
}
else
{
}
else
{
// delete happened without any occurrence of conflicts
// delete happened without any occurrence of conflicts
// so update status accordingly
// so update status accordingly
status
.
add
(
rows
,
new
Integer
(
SyncResolver
.
NO_ROW_CONFLICT
));
status
.
add
(
rows
,
Integer
.
valueOf
(
SyncResolver
.
NO_ROW_CONFLICT
));
}
}
}
else
if
(
crs
.
rowInserted
())
{
}
else
if
(
crs
.
rowInserted
())
{
...
@@ -350,20 +350,20 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
...
@@ -350,20 +350,20 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
pstmtIns
=
con
.
prepareStatement
(
insertCmd
);
pstmtIns
=
con
.
prepareStatement
(
insertCmd
);
if
(
(
conflict
=
insertNewRow
(
crs
,
pstmtIns
,
this
.
crsResolve
))
==
true
)
{
if
(
(
conflict
=
insertNewRow
(
crs
,
pstmtIns
,
this
.
crsResolve
))
==
true
)
{
status
.
add
(
rows
,
new
Integer
(
SyncResolver
.
INSERT_ROW_CONFLICT
));
status
.
add
(
rows
,
Integer
.
valueOf
(
SyncResolver
.
INSERT_ROW_CONFLICT
));
}
else
{
}
else
{
// insert happened without any occurrence of conflicts
// insert happened without any occurrence of conflicts
// so update status accordingly
// so update status accordingly
status
.
add
(
rows
,
new
Integer
(
SyncResolver
.
NO_ROW_CONFLICT
));
status
.
add
(
rows
,
Integer
.
valueOf
(
SyncResolver
.
NO_ROW_CONFLICT
));
}
}
}
else
if
(
crs
.
rowUpdated
())
{
}
else
if
(
crs
.
rowUpdated
())
{
// The row has been updated.
// The row has been updated.
if
(
conflict
=
(
updateOriginalRow
(
crs
))
==
true
)
{
if
(
conflict
=
(
updateOriginalRow
(
crs
))
==
true
)
{
status
.
add
(
rows
,
new
Integer
(
SyncResolver
.
UPDATE_ROW_CONFLICT
));
status
.
add
(
rows
,
Integer
.
valueOf
(
SyncResolver
.
UPDATE_ROW_CONFLICT
));
}
else
{
}
else
{
// update happened without any occurrence of conflicts
// update happened without any occurrence of conflicts
// so update status accordingly
// so update status accordingly
status
.
add
(
rows
,
new
Integer
(
SyncResolver
.
NO_ROW_CONFLICT
));
status
.
add
(
rows
,
Integer
.
valueOf
(
SyncResolver
.
NO_ROW_CONFLICT
));
}
}
}
else
{
}
else
{
...
@@ -375,7 +375,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
...
@@ -375,7 +375,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
* that is fine.
* that is fine.
**/
**/
int
icolCount
=
crs
.
getMetaData
().
getColumnCount
();
int
icolCount
=
crs
.
getMetaData
().
getColumnCount
();
status
.
add
(
rows
,
new
Integer
(
SyncResolver
.
NO_ROW_CONFLICT
));
status
.
add
(
rows
,
Integer
.
valueOf
(
SyncResolver
.
NO_ROW_CONFLICT
));
this
.
crsResolve
.
moveToInsertRow
();
this
.
crsResolve
.
moveToInsertRow
();
for
(
int
cols
=
0
;
cols
<
iColCount
;
cols
++)
{
for
(
int
cols
=
0
;
cols
<
iColCount
;
cols
++)
{
...
@@ -398,7 +398,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
...
@@ -398,7 +398,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
boolean
boolConf
=
false
;
boolean
boolConf
=
false
;
for
(
int
j
=
1
;
j
<
status
.
size
();
j
++){
for
(
int
j
=
1
;
j
<
status
.
size
();
j
++){
// ignore status for index = 0 which is set to null
// ignore status for index = 0 which is set to null
if
(!
((
status
.
get
(
j
)).
equals
(
new
Integer
(
SyncResolver
.
NO_ROW_CONFLICT
))))
{
if
(!
((
status
.
get
(
j
)).
equals
(
Integer
.
valueOf
(
SyncResolver
.
NO_ROW_CONFLICT
))))
{
// there is at least one conflict which needs to be resolved
// there is at least one conflict which needs to be resolved
boolConf
=
true
;
boolConf
=
true
;
break
;
break
;
...
@@ -541,7 +541,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
...
@@ -541,7 +541,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
// how many fields need to be updated
// how many fields need to be updated
int
colsNotChanged
=
0
;
int
colsNotChanged
=
0
;
Vector
cols
=
new
Vector
();
Vector
cols
=
new
Vector
();
String
updateExec
=
new
String
(
updateCmd
)
;
String
updateExec
=
updateCmd
;
Object
orig
;
Object
orig
;
Object
curr
;
Object
curr
;
Object
rsval
;
Object
rsval
;
...
@@ -652,7 +652,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
...
@@ -652,7 +652,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
updateExec
+=
", "
;
updateExec
+=
", "
;
}
}
updateExec
+=
crs
.
getMetaData
().
getColumnName
(
i
);
updateExec
+=
crs
.
getMetaData
().
getColumnName
(
i
);
cols
.
add
(
new
Integer
(
i
));
cols
.
add
(
Integer
.
valueOf
(
i
));
updateExec
+=
" = ? "
;
updateExec
+=
" = ? "
;
first
=
false
;
first
=
false
;
...
@@ -698,7 +698,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
...
@@ -698,7 +698,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
updateExec
+=
", "
;
updateExec
+=
", "
;
}
}
updateExec
+=
crs
.
getMetaData
().
getColumnName
(
i
);
updateExec
+=
crs
.
getMetaData
().
getColumnName
(
i
);
cols
.
add
(
new
Integer
(
i
));
cols
.
add
(
Integer
.
valueOf
(
i
));
updateExec
+=
" = ? "
;
updateExec
+=
" = ? "
;
flag
=
false
;
flag
=
false
;
}
else
{
}
else
{
...
@@ -1184,7 +1184,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
...
@@ -1184,7 +1184,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
// trim all the leading and trailing whitespaces,
// trim all the leading and trailing whitespaces,
// white spaces can never be catalog, schema or a table name.
// white spaces can never be catalog, schema or a table name.
String
cmd
=
new
String
()
;
String
cmd
=
""
;
catalog
=
catalog
.
trim
();
catalog
=
catalog
.
trim
();
schema
=
schema
.
trim
();
schema
=
schema
.
trim
();
...
...
src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java
浏览文件 @
67166499
...
@@ -248,7 +248,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
...
@@ -248,7 +248,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
String
strProvider
=
strProviderInstance
.
substring
(
0
,
(
caller
.
getSyncProvider
()).
toString
().
indexOf
(
"@"
));
String
strProvider
=
strProviderInstance
.
substring
(
0
,
(
caller
.
getSyncProvider
()).
toString
().
indexOf
(
"@"
));
propString
(
"sync-provider-name"
,
strProvider
);
propString
(
"sync-provider-name"
,
strProvider
);
propString
(
"sync-provider-vendor"
,
"
Sun Microsystems Inc.
"
);
propString
(
"sync-provider-vendor"
,
"
Oracle Corporation
"
);
propString
(
"sync-provider-version"
,
"1.0"
);
propString
(
"sync-provider-version"
,
"1.0"
);
propInteger
(
"sync-provider-grade"
,
caller
.
getSyncProvider
().
getProviderGrade
());
propInteger
(
"sync-provider-grade"
,
caller
.
getSyncProvider
().
getProviderGrade
());
propInteger
(
"data-source-lock"
,
caller
.
getSyncProvider
().
getDataSourceLock
());
propInteger
(
"data-source-lock"
,
caller
.
getSyncProvider
().
getDataSourceLock
());
...
@@ -387,7 +387,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
...
@@ -387,7 +387,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
if
(
caller
.
wasNull
())
if
(
caller
.
wasNull
())
writeNull
();
writeNull
();
else
else
writeInteger
(
caller
.
getInt
(
idx
)
);
writeInteger
(
i
);
break
;
break
;
case
java
.
sql
.
Types
.
BIGINT
:
case
java
.
sql
.
Types
.
BIGINT
:
long
l
=
caller
.
getLong
(
idx
);
long
l
=
caller
.
getLong
(
idx
);
...
@@ -574,7 +574,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
...
@@ -574,7 +574,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
}
}
private
void
writeBoolean
(
boolean
b
)
throws
java
.
io
.
IOException
{
private
void
writeBoolean
(
boolean
b
)
throws
java
.
io
.
IOException
{
writer
.
write
(
new
Boolean
(
b
).
toString
());
writer
.
write
(
Boolean
.
valueOf
(
b
).
toString
());
}
}
private
void
writeFloat
(
float
f
)
throws
java
.
io
.
IOException
{
private
void
writeFloat
(
float
f
)
throws
java
.
io
.
IOException
{
...
@@ -641,7 +641,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
...
@@ -641,7 +641,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
return
null
;
return
null
;
}
}
char
[]
charStr
=
s
.
toCharArray
();
char
[]
charStr
=
s
.
toCharArray
();
String
specialStr
=
new
String
()
;
String
specialStr
=
""
;
for
(
int
i
=
0
;
i
<
charStr
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
charStr
.
length
;
i
++)
{
if
(
charStr
[
i
]
==
'&'
)
{
if
(
charStr
[
i
]
==
'&'
)
{
...
...
src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java
浏览文件 @
67166499
...
@@ -441,9 +441,9 @@ public class XmlReaderContentHandler extends DefaultHandler {
...
@@ -441,9 +441,9 @@ public class XmlReaderContentHandler extends DefaultHandler {
updates
=
new
Vector
();
updates
=
new
Vector
();
// start out with the empty string
// start out with the empty string
columnValue
=
new
String
(
""
)
;
columnValue
=
""
;
propertyValue
=
new
String
(
""
)
;
propertyValue
=
""
;
metaDataValue
=
new
String
(
""
)
;
metaDataValue
=
""
;
nullVal
=
false
;
nullVal
=
false
;
idx
=
0
;
idx
=
0
;
...
@@ -481,21 +481,21 @@ public class XmlReaderContentHandler extends DefaultHandler {
...
@@ -481,21 +481,21 @@ public class XmlReaderContentHandler extends DefaultHandler {
items
=
properties
.
length
;
items
=
properties
.
length
;
for
(
i
=
0
;
i
<
items
;
i
++)
{
for
(
i
=
0
;
i
<
items
;
i
++)
{
propMap
.
put
(
properties
[
i
],
new
Integer
(
i
));
propMap
.
put
(
properties
[
i
],
Integer
.
valueOf
(
i
));
}
}
colDefMap
=
new
HashMap
();
colDefMap
=
new
HashMap
();
items
=
colDef
.
length
;
items
=
colDef
.
length
;
for
(
i
=
0
;
i
<
items
;
i
++)
{
for
(
i
=
0
;
i
<
items
;
i
++)
{
colDefMap
.
put
(
colDef
[
i
],
new
Integer
(
i
));
colDefMap
.
put
(
colDef
[
i
],
Integer
.
valueOf
(
i
));
}
}
dataMap
=
new
HashMap
();
dataMap
=
new
HashMap
();
items
=
data
.
length
;
items
=
data
.
length
;
for
(
i
=
0
;
i
<
items
;
i
++)
{
for
(
i
=
0
;
i
<
items
;
i
++)
{
dataMap
.
put
(
data
[
i
],
new
Integer
(
i
));
dataMap
.
put
(
data
[
i
],
Integer
.
valueOf
(
i
));
}
}
//Initialize connection map here
//Initialize connection map here
...
@@ -686,7 +686,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
...
@@ -686,7 +686,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
}
}
// propertyValue need to be reset to an empty string
// propertyValue need to be reset to an empty string
propertyValue
=
new
String
(
""
)
;
propertyValue
=
""
;
setTag
(-
1
);
setTag
(-
1
);
break
;
break
;
case
METADATA:
case
METADATA:
...
@@ -710,7 +710,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
...
@@ -710,7 +710,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
}
}
// metaDataValue needs to be reset to an empty string
// metaDataValue needs to be reset to an empty string
metaDataValue
=
new
String
(
""
)
;
metaDataValue
=
""
;
}
}
setTag
(-
1
);
setTag
(-
1
);
break
;
break
;
...
@@ -736,7 +736,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
...
@@ -736,7 +736,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
insertValue
(
tempStr
);
insertValue
(
tempStr
);
}
}
// columnValue now need to be reset to the empty string
// columnValue now need to be reset to the empty string
columnValue
=
new
String
(
""
)
;
columnValue
=
""
;
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
throw
new
SAXException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"xmlrch.errinsert"
).
toString
(),
ex
.
getMessage
()));
throw
new
SAXException
(
MessageFormat
.
format
(
resBundle
.
handleGetObject
(
"xmlrch.errinsert"
).
toString
(),
ex
.
getMessage
()));
}
}
...
@@ -981,7 +981,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
...
@@ -981,7 +981,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
private
boolean
getBooleanValue
(
String
s
)
{
private
boolean
getBooleanValue
(
String
s
)
{
return
new
Boolean
(
s
).
booleanValue
();
return
Boolean
.
valueOf
(
s
).
booleanValue
();
}
}
private
java
.
math
.
BigDecimal
getBigDecimalValue
(
String
s
)
{
private
java
.
math
.
BigDecimal
getBigDecimalValue
(
String
s
)
{
...
@@ -1316,7 +1316,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
...
@@ -1316,7 +1316,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
**/
**/
tempUpdate
=
tempUpdate
.
concat
(
new
String
(
ch
,
start
,
len
));
tempUpdate
=
tempUpdate
.
concat
(
new
String
(
ch
,
start
,
len
));
upd
[
0
]
=
new
Integer
(
idx
);
upd
[
0
]
=
Integer
.
valueOf
(
idx
);
upd
[
1
]
=
tempUpdate
;
upd
[
1
]
=
tempUpdate
;
//updates.add(upd);
//updates.add(upd);
...
...
src/share/classes/com/sun/rowset/providers/RIOptimisticProvider.java
浏览文件 @
67166499
...
@@ -93,14 +93,14 @@ public final class RIOptimisticProvider extends SyncProvider implements Serializ
...
@@ -93,14 +93,14 @@ public final class RIOptimisticProvider extends SyncProvider implements Serializ
private
CachedRowSetWriter
writer
;
private
CachedRowSetWriter
writer
;
/**
/**
* The unique provider i
n
dentifier.
* The unique provider identifier.
*/
*/
private
String
providerID
=
"com.sun.rowset.providers.RIOptimisticProvider"
;
private
String
providerID
=
"com.sun.rowset.providers.RIOptimisticProvider"
;
/**
/**
* The vendor name of this SyncProvider implementation
* The vendor name of this SyncProvider implementation
*/
*/
private
String
vendorName
=
"
Sun Microsystems Inc.
"
;
private
String
vendorName
=
"
Oracle Corporation
"
;
/**
/**
* The version number of this SyncProvider implementation
* The version number of this SyncProvider implementation
...
@@ -236,8 +236,8 @@ public final class RIOptimisticProvider extends SyncProvider implements Serializ
...
@@ -236,8 +236,8 @@ public final class RIOptimisticProvider extends SyncProvider implements Serializ
}
}
/**
/**
* Returns the vendor name of the Reference Implemntation Optimistic
* Returns the vendor name of the Reference Implem
e
ntation Optimistic
* Sync
chronic
ation Provider
* Sync
hroniz
ation Provider
*
*
* @return the <code>String</code> detailing the vendor name of this
* @return the <code>String</code> detailing the vendor name of this
* SyncProvider
* SyncProvider
...
...
src/share/classes/com/sun/rowset/providers/RIXMLProvider.java
浏览文件 @
67166499
/*
/*
* Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
10
, 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
...
@@ -85,7 +85,7 @@ public final class RIXMLProvider extends SyncProvider {
...
@@ -85,7 +85,7 @@ public final class RIXMLProvider extends SyncProvider {
/**
/**
* The vendor name of this SyncProvider implementation.
* The vendor name of this SyncProvider implementation.
*/
*/
private
String
vendorName
=
"
Sun Microsystems Inc.
"
;
private
String
vendorName
=
"
Oracle Corporation
"
;
/**
/**
* The version number of this SyncProvider implementation.
* The version number of this SyncProvider implementation.
...
...
src/share/classes/com/sun/servicetag/Installer.java
浏览文件 @
67166499
...
@@ -43,7 +43,8 @@ public class Installer {
...
@@ -43,7 +43,8 @@ public class Installer {
"servicetag.dir.path"
;
"servicetag.dir.path"
;
private
static
String
SVCTAG_ENABLE_REGISTRATION
=
private
static
String
SVCTAG_ENABLE_REGISTRATION
=
"servicetag.registration.enabled"
;
"servicetag.registration.enabled"
;
private
final
static
String
SUN_VENDOR
=
"Sun Microsystems"
;
private
final
static
String
ORACLE
=
"Oracle"
;
private
final
static
String
SUN
=
"Sun Microsystems"
;
private
final
static
String
REGISTRATION_XML
=
"registration.xml"
;
private
final
static
String
REGISTRATION_XML
=
"registration.xml"
;
private
final
static
String
SERVICE_TAG_FILE
=
"servicetag"
;
private
final
static
String
SERVICE_TAG_FILE
=
"servicetag"
;
private
final
static
String
REGISTRATION_HTML_NAME
=
"register"
;
private
final
static
String
REGISTRATION_HTML_NAME
=
"register"
;
...
@@ -84,9 +85,10 @@ public class Installer {
...
@@ -84,9 +85,10 @@ public class Installer {
// Implementation of ServiceTag.getJavaServiceTag(String) method
// Implementation of ServiceTag.getJavaServiceTag(String) method
static
ServiceTag
getJavaServiceTag
(
String
source
)
throws
IOException
{
static
ServiceTag
getJavaServiceTag
(
String
source
)
throws
IOException
{
if
(!
System
.
getProperty
(
"java.vendor"
).
startsWith
(
SUN_VENDOR
))
{
String
vendor
=
System
.
getProperty
(
"java.vendor"
,
""
);
if
(!
vendor
.
startsWith
(
SUN
)
&&
!
vendor
.
startsWith
(
ORACLE
))
{
// Products bundling this implementation may run on
// Products bundling this implementation may run on
// Mac OS which is not a Sun JDK
// Mac OS which is not a Sun
/Oracle
JDK
return
null
;
return
null
;
}
}
boolean
cleanup
=
false
;
boolean
cleanup
=
false
;
...
@@ -365,7 +367,7 @@ public class Installer {
...
@@ -365,7 +367,7 @@ public class Installer {
props
.
getProperty
(
"servicetag.parent.name"
),
props
.
getProperty
(
"servicetag.parent.name"
),
props
.
getProperty
(
"servicetag.parent.urn"
),
props
.
getProperty
(
"servicetag.parent.urn"
),
getProductDefinedId
(),
getProductDefinedId
(),
S
UN_VENDOR
,
S
ystem
.
getProperty
(
"java.vendor"
)
,
System
.
getProperty
(
"os.arch"
),
System
.
getProperty
(
"os.arch"
),
getZoneName
(),
getZoneName
(),
svcTagSource
);
svcTagSource
);
...
...
src/share/classes/com/sun/servicetag/RegistrationData.java
浏览文件 @
67166499
...
@@ -80,12 +80,12 @@ import static com.sun.servicetag.RegistrationDocument.*;
...
@@ -80,12 +80,12 @@ import static com.sun.servicetag.RegistrationDocument.*;
* <tr>
* <tr>
* <td><tt>systemManufacturer</tt></td>
* <td><tt>systemManufacturer</tt></td>
* <td>System manufacturer</td>
* <td>System manufacturer</td>
* <td> e.g.
Sun Microsystems
</td>
* <td> e.g.
Oracle Corporation
</td>
* </tr>
* </tr>
* <tr>
* <tr>
* <td><tt>cpuManufacturer</tt></td>
* <td><tt>cpuManufacturer</tt></td>
* <td>CPU manufacturer</td>
* <td>CPU manufacturer</td>
* <td> e.g.
Sun Microsystems
</td>
* <td> e.g.
Oracle Corporation
</td>
* </tr>
* </tr>
* <tr>
* <tr>
* <td><tt>serialNumber</tt></td>
* <td><tt>serialNumber</tt></td>
...
...
src/share/classes/com/sun/servicetag/Registry.java
浏览文件 @
67166499
...
@@ -90,7 +90,7 @@ public class Registry {
...
@@ -90,7 +90,7 @@ public class Registry {
stclient
=
getWindowsStClientFile
();
stclient
=
getWindowsStClientFile
();
}
else
{
}
else
{
if
(
isVerbose
())
{
if
(
isVerbose
())
{
System
.
out
.
println
(
"Running on
non-Sun JDK
"
);
System
.
out
.
println
(
"Running on
unsupported platform
"
);
}
}
}
}
initialized
=
true
;
initialized
=
true
;
...
...
src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java
浏览文件 @
67166499
...
@@ -44,6 +44,7 @@ import java.io.*;
...
@@ -44,6 +44,7 @@ import java.io.*;
* Solaris implementation of the SystemEnvironment class.
* Solaris implementation of the SystemEnvironment class.
*/
*/
class
SolarisSystemEnvironment
extends
SystemEnvironment
{
class
SolarisSystemEnvironment
extends
SystemEnvironment
{
private
static
final
String
ORACLE
=
"Oracle Corporation"
;
SolarisSystemEnvironment
()
{
SolarisSystemEnvironment
()
{
setHostId
(
getCommandOutput
(
"/usr/bin/hostid"
));
setHostId
(
getCommandOutput
(
"/usr/bin/hostid"
));
setSystemModel
(
getCommandOutput
(
"/usr/bin/uname"
,
"-i"
));
setSystemModel
(
getCommandOutput
(
"/usr/bin/uname"
,
"-i"
));
...
@@ -59,7 +60,7 @@ class SolarisSystemEnvironment extends SystemEnvironment {
...
@@ -59,7 +60,7 @@ class SolarisSystemEnvironment extends SystemEnvironment {
private
String
getSolarisCpuManufacturer
()
{
private
String
getSolarisCpuManufacturer
()
{
// not fully accurate, this could be another manufacturer (fujitsu for example)
// not fully accurate, this could be another manufacturer (fujitsu for example)
if
(
"sparc"
.
equalsIgnoreCase
(
System
.
getProperty
(
"os.arch"
)))
{
if
(
"sparc"
.
equalsIgnoreCase
(
System
.
getProperty
(
"os.arch"
)))
{
return
"Sun Microsystems, Inc"
;
return
ORACLE
;
}
}
// if we're here, then we'll try smbios (type 4)
// if we're here, then we'll try smbios (type 4)
...
@@ -73,7 +74,7 @@ class SolarisSystemEnvironment extends SystemEnvironment {
...
@@ -73,7 +74,7 @@ class SolarisSystemEnvironment extends SystemEnvironment {
private
String
getSolarisSystemManufacturer
()
{
private
String
getSolarisSystemManufacturer
()
{
// not fully accurate, this could be another manufacturer (fujitsu for example)
// not fully accurate, this could be another manufacturer (fujitsu for example)
if
(
"sparc"
.
equalsIgnoreCase
(
System
.
getProperty
(
"os.arch"
)))
{
if
(
"sparc"
.
equalsIgnoreCase
(
System
.
getProperty
(
"os.arch"
)))
{
return
"Sun Microsystems, Inc"
;
return
ORACLE
;
}
}
// if we're here, then we'll try smbios (type 1)
// if we're here, then we'll try smbios (type 1)
...
@@ -117,7 +118,7 @@ class SolarisSystemEnvironment extends SystemEnvironment {
...
@@ -117,7 +118,7 @@ class SolarisSystemEnvironment extends SystemEnvironment {
// ID SIZE TYPE
// ID SIZE TYPE
// 1 150 SMB_TYPE_SYSTEM (system information)
// 1 150 SMB_TYPE_SYSTEM (system information)
//
//
// Manufacturer:
Sun Microsystems
// Manufacturer:
Oracle Corporation
// Product: Sun Fire X4600
// Product: Sun Fire X4600
// Version: To Be Filled By O.E.M.
// Version: To Be Filled By O.E.M.
// Serial Number: 00:14:4F:45:0C:2A
// Serial Number: 00:14:4F:45:0C:2A
...
...
src/share/classes/java/lang/System.java
浏览文件 @
67166499
...
@@ -1101,22 +1101,12 @@ public final class System {
...
@@ -1101,22 +1101,12 @@ public final class System {
lineSeparator
=
props
.
getProperty
(
"line.separator"
);
lineSeparator
=
props
.
getProperty
(
"line.separator"
);
sun
.
misc
.
Version
.
init
();
sun
.
misc
.
Version
.
init
();
// Workaround until DownloadManager initialization is revisited.
// Make JavaLangAccess available early enough for internal
// Shutdown hooks to be registered
setJavaLangAccess
();
// Gets and removes system properties that configure the Integer
// Gets and removes system properties that configure the Integer
// cache used to support the object identity semantics of autoboxing.
// cache used to support the object identity semantics of autoboxing.
// At this time, the size of the cache may be controlled by the
// At this time, the size of the cache may be controlled by the
// vm option -XX:AutoBoxCacheMax=<size>.
// vm option -XX:AutoBoxCacheMax=<size>.
Integer
.
getAndRemoveCacheProperties
();
Integer
.
getAndRemoveCacheProperties
();
// Load the zip library now in order to keep java.util.zip.ZipFile
// from trying to use itself to load this library later.
loadLibrary
(
"zip"
);
FileInputStream
fdIn
=
new
FileInputStream
(
FileDescriptor
.
in
);
FileInputStream
fdIn
=
new
FileInputStream
(
FileDescriptor
.
in
);
FileOutputStream
fdOut
=
new
FileOutputStream
(
FileDescriptor
.
out
);
FileOutputStream
fdOut
=
new
FileOutputStream
(
FileDescriptor
.
out
);
FileOutputStream
fdErr
=
new
FileOutputStream
(
FileDescriptor
.
err
);
FileOutputStream
fdErr
=
new
FileOutputStream
(
FileDescriptor
.
err
);
...
@@ -1124,6 +1114,10 @@ public final class System {
...
@@ -1124,6 +1114,10 @@ public final class System {
setOut0
(
new
PrintStream
(
new
BufferedOutputStream
(
fdOut
,
128
),
true
));
setOut0
(
new
PrintStream
(
new
BufferedOutputStream
(
fdOut
,
128
),
true
));
setErr0
(
new
PrintStream
(
new
BufferedOutputStream
(
fdErr
,
128
),
true
));
setErr0
(
new
PrintStream
(
new
BufferedOutputStream
(
fdErr
,
128
),
true
));
// Load the zip library now in order to keep java.util.zip.ZipFile
// from trying to use itself to load this library later.
loadLibrary
(
"zip"
);
// Setup Java signal handlers for HUP, TERM, and INT (where available).
// Setup Java signal handlers for HUP, TERM, and INT (where available).
Terminator
.
setup
();
Terminator
.
setup
();
...
@@ -1153,6 +1147,9 @@ public final class System {
...
@@ -1153,6 +1147,9 @@ public final class System {
// way as other threads; we must do it ourselves here.
// way as other threads; we must do it ourselves here.
Thread
current
=
Thread
.
currentThread
();
Thread
current
=
Thread
.
currentThread
();
current
.
getThreadGroup
().
add
(
current
);
current
.
getThreadGroup
().
add
(
current
);
// register shared secrets
setJavaLangAccess
();
}
}
private
static
void
setJavaLangAccess
()
{
private
static
void
setJavaLangAccess
()
{
...
...
src/share/classes/java/net/InetAddress.java
浏览文件 @
67166499
...
@@ -677,19 +677,20 @@ class InetAddress implements java.io.Serializable {
...
@@ -677,19 +677,20 @@ class InetAddress implements java.io.Serializable {
static
InetAddressImpl
impl
;
static
InetAddressImpl
impl
;
private
static
HashMap
lookupTable
=
new
HashMap
();
private
static
HashMap
<
String
,
InetAddress
[]>
lookupTable
=
new
HashMap
<
String
,
InetAddress
[]>();
/**
/**
* Represents a cache entry
* Represents a cache entry
*/
*/
static
final
class
CacheEntry
{
static
final
class
CacheEntry
{
CacheEntry
(
Object
addres
s
,
long
expiration
)
{
CacheEntry
(
InetAddress
[]
addresse
s
,
long
expiration
)
{
this
.
address
=
addres
s
;
this
.
address
es
=
addresse
s
;
this
.
expiration
=
expiration
;
this
.
expiration
=
expiration
;
}
}
Object
addres
s
;
InetAddress
[]
addresse
s
;
long
expiration
;
long
expiration
;
}
}
...
@@ -698,7 +699,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -698,7 +699,7 @@ class InetAddress implements java.io.Serializable {
* at creation time.
* at creation time.
*/
*/
static
final
class
Cache
{
static
final
class
Cache
{
private
LinkedHashMap
cache
;
private
LinkedHashMap
<
String
,
CacheEntry
>
cache
;
private
Type
type
;
private
Type
type
;
enum
Type
{
Positive
,
Negative
};
enum
Type
{
Positive
,
Negative
};
...
@@ -708,7 +709,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -708,7 +709,7 @@ class InetAddress implements java.io.Serializable {
*/
*/
public
Cache
(
Type
type
)
{
public
Cache
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
cache
=
new
LinkedHashMap
();
cache
=
new
LinkedHashMap
<
String
,
CacheEntry
>
();
}
}
private
int
getPolicy
()
{
private
int
getPolicy
()
{
...
@@ -724,7 +725,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -724,7 +725,7 @@ class InetAddress implements java.io.Serializable {
* entry then for this host then the entry will be
* entry then for this host then the entry will be
* replaced.
* replaced.
*/
*/
public
Cache
put
(
String
host
,
Object
addres
s
)
{
public
Cache
put
(
String
host
,
InetAddress
[]
addresse
s
)
{
int
policy
=
getPolicy
();
int
policy
=
getPolicy
();
if
(
policy
==
InetAddressCachePolicy
.
NEVER
)
{
if
(
policy
==
InetAddressCachePolicy
.
NEVER
)
{
return
this
;
return
this
;
...
@@ -736,12 +737,10 @@ class InetAddress implements java.io.Serializable {
...
@@ -736,12 +737,10 @@ class InetAddress implements java.io.Serializable {
// As we iterate in insertion order we can
// As we iterate in insertion order we can
// terminate when a non-expired entry is found.
// terminate when a non-expired entry is found.
LinkedList
expired
=
new
LinkedList
();
LinkedList
<
String
>
expired
=
new
LinkedList
<
String
>();
Iterator
i
=
cache
.
keySet
().
iterator
();
long
now
=
System
.
currentTimeMillis
();
long
now
=
System
.
currentTimeMillis
();
while
(
i
.
hasNext
())
{
for
(
String
key
:
cache
.
keySet
())
{
String
key
=
(
String
)
i
.
next
();
CacheEntry
entry
=
cache
.
get
(
key
);
CacheEntry
entry
=
(
CacheEntry
)
cache
.
get
(
key
);
if
(
entry
.
expiration
>=
0
&&
entry
.
expiration
<
now
)
{
if
(
entry
.
expiration
>=
0
&&
entry
.
expiration
<
now
)
{
expired
.
add
(
key
);
expired
.
add
(
key
);
...
@@ -750,9 +749,8 @@ class InetAddress implements java.io.Serializable {
...
@@ -750,9 +749,8 @@ class InetAddress implements java.io.Serializable {
}
}
}
}
i
=
expired
.
iterator
();
for
(
String
key
:
expired
)
{
while
(
i
.
hasNext
())
{
cache
.
remove
(
key
);
cache
.
remove
(
i
.
next
());
}
}
}
}
...
@@ -766,7 +764,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -766,7 +764,7 @@ class InetAddress implements java.io.Serializable {
}
else
{
}
else
{
expiration
=
System
.
currentTimeMillis
()
+
(
policy
*
1000
);
expiration
=
System
.
currentTimeMillis
()
+
(
policy
*
1000
);
}
}
CacheEntry
entry
=
new
CacheEntry
(
address
,
expiration
);
CacheEntry
entry
=
new
CacheEntry
(
address
es
,
expiration
);
cache
.
put
(
host
,
entry
);
cache
.
put
(
host
,
entry
);
return
this
;
return
this
;
}
}
...
@@ -780,7 +778,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -780,7 +778,7 @@ class InetAddress implements java.io.Serializable {
if
(
policy
==
InetAddressCachePolicy
.
NEVER
)
{
if
(
policy
==
InetAddressCachePolicy
.
NEVER
)
{
return
null
;
return
null
;
}
}
CacheEntry
entry
=
(
CacheEntry
)
cache
.
get
(
host
);
CacheEntry
entry
=
cache
.
get
(
host
);
// check if entry has expired
// check if entry has expired
if
(
entry
!=
null
&&
policy
!=
InetAddressCachePolicy
.
FOREVER
)
{
if
(
entry
!=
null
&&
policy
!=
InetAddressCachePolicy
.
FOREVER
)
{
...
@@ -814,42 +812,41 @@ class InetAddress implements java.io.Serializable {
...
@@ -814,42 +812,41 @@ class InetAddress implements java.io.Serializable {
}
}
/*
/*
* Cache the given hostname and address.
* Cache the given hostname and address
es
.
*/
*/
private
static
void
cacheAddress
(
String
hostname
,
Object
address
,
private
static
void
cacheAddresses
(
String
hostname
,
InetAddress
[]
addresses
,
boolean
success
)
{
boolean
success
)
{
hostname
=
hostname
.
toLowerCase
();
hostname
=
hostname
.
toLowerCase
();
synchronized
(
addressCache
)
{
synchronized
(
addressCache
)
{
cacheInitIfNeeded
();
cacheInitIfNeeded
();
if
(
success
)
{
if
(
success
)
{
addressCache
.
put
(
hostname
,
address
);
addressCache
.
put
(
hostname
,
address
es
);
}
else
{
}
else
{
negativeCache
.
put
(
hostname
,
address
);
negativeCache
.
put
(
hostname
,
address
es
);
}
}
}
}
}
}
/*
/*
* Lookup hostname in cache (positive & negative cache). If
* Lookup hostname in cache (positive & negative cache). If
* found return address, null if not found.
* found return address
es
, null if not found.
*/
*/
private
static
Object
getCachedAddres
s
(
String
hostname
)
{
private
static
InetAddress
[]
getCachedAddresse
s
(
String
hostname
)
{
hostname
=
hostname
.
toLowerCase
();
hostname
=
hostname
.
toLowerCase
();
// search both positive & negative caches
// search both positive & negative caches
synchronized
(
addressCache
)
{
synchronized
(
addressCache
)
{
CacheEntry
entry
;
cacheInitIfNeeded
();
cacheInitIfNeeded
();
entry
=
addressCache
.
get
(
hostname
);
CacheEntry
entry
=
addressCache
.
get
(
hostname
);
if
(
entry
==
null
)
{
if
(
entry
==
null
)
{
entry
=
negativeCache
.
get
(
hostname
);
entry
=
negativeCache
.
get
(
hostname
);
}
}
if
(
entry
!=
null
)
{
if
(
entry
!=
null
)
{
return
entry
.
address
;
return
entry
.
address
es
;
}
}
}
}
...
@@ -911,7 +908,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -911,7 +908,7 @@ class InetAddress implements java.io.Serializable {
static
{
static
{
// create the impl
// create the impl
impl
=
(
new
InetAddressImplFactory
())
.
create
();
impl
=
InetAddressImplFactory
.
create
();
// get name service if provided and requested
// get name service if provided and requested
String
provider
=
null
;;
String
provider
=
null
;;
...
@@ -931,7 +928,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -931,7 +928,7 @@ class InetAddress implements java.io.Serializable {
}
}
// if not designate any name services provider,
// if not designate any name services provider,
// creat a default one
// creat
e
a default one
if
(
nameServices
.
size
()
==
0
)
{
if
(
nameServices
.
size
()
==
0
)
{
NameService
ns
=
createNSProvider
(
"default"
);
NameService
ns
=
createNSProvider
(
"default"
);
nameServices
.
add
(
ns
);
nameServices
.
add
(
ns
);
...
@@ -939,7 +936,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -939,7 +936,7 @@ class InetAddress implements java.io.Serializable {
}
}
/**
/**
* Create
an InetAddress based on the provided host name and IP address
* Create
s an InetAddress based on the provided host name and IP address.
* No name service is checked for the validity of the address.
* No name service is checked for the validity of the address.
*
*
* <p> The host name can either be a machine name, such as
* <p> The host name can either be a machine name, such as
...
@@ -1067,13 +1064,13 @@ class InetAddress implements java.io.Serializable {
...
@@ -1067,13 +1064,13 @@ class InetAddress implements java.io.Serializable {
boolean
ipv6Expected
=
false
;
boolean
ipv6Expected
=
false
;
if
(
host
.
charAt
(
0
)
==
'['
)
{
if
(
host
.
charAt
(
0
)
==
'['
)
{
// This is supposed to be an IPv6 lit
t
eral
// This is supposed to be an IPv6 literal
if
(
host
.
length
()
>
2
&&
host
.
charAt
(
host
.
length
()-
1
)
==
']'
)
{
if
(
host
.
length
()
>
2
&&
host
.
charAt
(
host
.
length
()-
1
)
==
']'
)
{
host
=
host
.
substring
(
1
,
host
.
length
()
-
1
);
host
=
host
.
substring
(
1
,
host
.
length
()
-
1
);
ipv6Expected
=
true
;
ipv6Expected
=
true
;
}
else
{
}
else
{
// This was supposed to be a IPv6 address, but it's not!
// This was supposed to be a IPv6 address, but it's not!
throw
new
UnknownHostException
(
host
);
throw
new
UnknownHostException
(
host
+
": invalid IPv6 address"
);
}
}
}
}
...
@@ -1180,8 +1177,6 @@ class InetAddress implements java.io.Serializable {
...
@@ -1180,8 +1177,6 @@ class InetAddress implements java.io.Serializable {
throws
UnknownHostException
{
throws
UnknownHostException
{
/* If it gets here it is presumed to be a hostname */
/* If it gets here it is presumed to be a hostname */
/* Cache.get can return: null, unknownAddress, or InetAddress[] */
/* Cache.get can return: null, unknownAddress, or InetAddress[] */
Object
obj
=
null
;
Object
objcopy
=
null
;
/* make sure the connection to the host is allowed, before we
/* make sure the connection to the host is allowed, before we
* give out a hostname
* give out a hostname
...
@@ -1193,26 +1188,23 @@ class InetAddress implements java.io.Serializable {
...
@@ -1193,26 +1188,23 @@ class InetAddress implements java.io.Serializable {
}
}
}
}
obj
=
getCachedAddres
s
(
host
);
InetAddress
[]
addresses
=
getCachedAddresse
s
(
host
);
/* If no entry in cache, then do the host lookup */
/* If no entry in cache, then do the host lookup */
if
(
obj
==
null
)
{
if
(
addresses
==
null
)
{
obj
=
getAddres
sFromNameService
(
host
);
addresses
=
getAddresse
sFromNameService
(
host
);
}
}
if
(
obj
==
unknown_array
)
if
(
addresses
==
unknown_array
)
throw
new
UnknownHostException
(
host
);
throw
new
UnknownHostException
(
host
);
/* Make a copy of the InetAddress array */
return
addresses
.
clone
();
objcopy
=
((
InetAddress
[])
obj
).
clone
();
return
(
InetAddress
[])
objcopy
;
}
}
private
static
Object
getAddres
sFromNameService
(
String
host
)
private
static
InetAddress
[]
getAddresse
sFromNameService
(
String
host
)
throws
UnknownHostException
throws
UnknownHostException
{
{
Object
obj
=
null
;
InetAddress
[]
addresses
=
null
;
boolean
success
=
false
;
boolean
success
=
false
;
UnknownHostException
ex
=
null
;
UnknownHostException
ex
=
null
;
...
@@ -1226,16 +1218,16 @@ class InetAddress implements java.io.Serializable {
...
@@ -1226,16 +1218,16 @@ class InetAddress implements java.io.Serializable {
// would be blocked until the host is removed
// would be blocked until the host is removed
// from the lookupTable. Then this thread
// from the lookupTable. Then this thread
// should try to look up the addressCache.
// should try to look up the addressCache.
// i) if it found the address in the
// i) if it found the address
es
in the
// addressCache, checkLookupTable() would
// addressCache, checkLookupTable() would
// return the address.
// return the address
es
.
// ii) if it didn't find the address in the
// ii) if it didn't find the address
es
in the
// addressCache for any reason,
// addressCache for any reason,
// it should add the host in the
// it should add the host in the
// lookupTable and return null so the
// lookupTable and return null so the
// following code would do a lookup itself.
// following code would do a lookup itself.
if
((
obj
=
checkLookupTable
(
host
))
==
null
)
{
if
((
addresses
=
checkLookupTable
(
host
))
==
null
)
{
// This is the first thread which looks up the address
// This is the first thread which looks up the address
es
// this host or the cache entry for this host has been
// this host or the cache entry for this host has been
// expired so this thread should do the lookup.
// expired so this thread should do the lookup.
for
(
NameService
nameService
:
nameServices
)
{
for
(
NameService
nameService
:
nameServices
)
{
...
@@ -1246,26 +1238,26 @@ class InetAddress implements java.io.Serializable {
...
@@ -1246,26 +1238,26 @@ class InetAddress implements java.io.Serializable {
* allocating space when the lookup fails.
* allocating space when the lookup fails.
*/
*/
obj
=
nameService
.
lookupAllHostAddr
(
host
);
addresses
=
nameService
.
lookupAllHostAddr
(
host
);
success
=
true
;
success
=
true
;
break
;
break
;
}
catch
(
UnknownHostException
uhe
)
{
}
catch
(
UnknownHostException
uhe
)
{
if
(
host
.
equalsIgnoreCase
(
"localhost"
))
{
if
(
host
.
equalsIgnoreCase
(
"localhost"
))
{
InetAddress
[]
local
=
new
InetAddress
[]
{
impl
.
loopbackAddress
()
};
InetAddress
[]
local
=
new
InetAddress
[]
{
impl
.
loopbackAddress
()
};
obj
=
local
;
addresses
=
local
;
success
=
true
;
success
=
true
;
break
;
break
;
}
}
else
{
else
{
obj
=
unknown_array
;
addresses
=
unknown_array
;
success
=
false
;
success
=
false
;
ex
=
uhe
;
ex
=
uhe
;
}
}
}
}
}
}
// Cache the address.
// Cache the address
es
.
cacheAddress
(
host
,
obj
,
success
);
cacheAddress
es
(
host
,
addresses
,
success
);
// Delete the host from the lookupTable, and
// Delete the host from the lookupTable, and
// notify all threads waiting for the monitor
// notify all threads waiting for the monitor
// for lookupTable.
// for lookupTable.
...
@@ -1274,13 +1266,13 @@ class InetAddress implements java.io.Serializable {
...
@@ -1274,13 +1266,13 @@ class InetAddress implements java.io.Serializable {
throw
ex
;
throw
ex
;
}
}
return
obj
;
return
addresses
;
}
}
private
static
Object
checkLookupTable
(
String
host
)
{
private
static
InetAddress
[]
checkLookupTable
(
String
host
)
{
// make sure
obj
is null.
// make sure
addresses
is null.
Object
obj
=
null
;
InetAddress
[]
addresses
=
null
;
synchronized
(
lookupTable
)
{
synchronized
(
lookupTable
)
{
// If the host isn't in the lookupTable, add it in the
// If the host isn't in the lookupTable, add it in the
...
@@ -1288,11 +1280,11 @@ class InetAddress implements java.io.Serializable {
...
@@ -1288,11 +1280,11 @@ class InetAddress implements java.io.Serializable {
// the lookup.
// the lookup.
if
(
lookupTable
.
containsKey
(
host
)
==
false
)
{
if
(
lookupTable
.
containsKey
(
host
)
==
false
)
{
lookupTable
.
put
(
host
,
null
);
lookupTable
.
put
(
host
,
null
);
return
obj
;
return
addresses
;
}
}
// If the host is in the lookupTable, it means that another
// If the host is in the lookupTable, it means that another
// thread is trying to look up the address of this host.
// thread is trying to look up the address
es
of this host.
// This thread should wait.
// This thread should wait.
while
(
lookupTable
.
containsKey
(
host
))
{
while
(
lookupTable
.
containsKey
(
host
))
{
try
{
try
{
...
@@ -1302,18 +1294,18 @@ class InetAddress implements java.io.Serializable {
...
@@ -1302,18 +1294,18 @@ class InetAddress implements java.io.Serializable {
}
}
}
}
// The other thread has finished looking up the address of
// The other thread has finished looking up the address
es
of
// the host. This thread should retry to get the address
// the host. This thread should retry to get the address
es
// from the addressCache. If it doesn't get the address from
// from the addressCache. If it doesn't get the address
es
from
// the cache,
it will try to look up the addres
s itself.
// the cache,
it will try to look up the addresse
s itself.
obj
=
getCachedAddres
s
(
host
);
addresses
=
getCachedAddresse
s
(
host
);
if
(
obj
==
null
)
{
if
(
addresses
==
null
)
{
synchronized
(
lookupTable
)
{
synchronized
(
lookupTable
)
{
lookupTable
.
put
(
host
,
null
);
lookupTable
.
put
(
host
,
null
);
}
}
}
}
return
obj
;
return
addresses
;
}
}
private
static
void
updateLookupTable
(
String
host
)
{
private
static
void
updateLookupTable
(
String
host
)
{
...
@@ -1396,15 +1388,20 @@ class InetAddress implements java.io.Serializable {
...
@@ -1396,15 +1388,20 @@ class InetAddress implements java.io.Serializable {
cachedLocalHost
=
null
;
cachedLocalHost
=
null
;
}
}
// we are calling getAddressFromNameService directly
// we are calling getAddress
es
FromNameService directly
// to avoid getting localHost from cache
// to avoid getting localHost from cache
if
(
ret
==
null
)
{
if
(
ret
==
null
)
{
InetAddress
[]
localAddrs
;
InetAddress
[]
localAddrs
;
try
{
try
{
localAddrs
=
localAddrs
=
(
InetAddress
[])
InetAddress
.
getAddres
sFromNameService
(
local
);
InetAddress
.
getAddresse
sFromNameService
(
local
);
}
catch
(
UnknownHostException
uhe
)
{
}
catch
(
UnknownHostException
uhe
)
{
throw
new
UnknownHostException
(
local
+
": "
+
uhe
.
getMessage
());
// Rethrow with a more informative error message.
UnknownHostException
uhe2
=
new
UnknownHostException
(
local
+
": "
+
uhe
.
getMessage
());
uhe2
.
initCause
(
uhe
);
throw
uhe2
;
}
}
cachedLocalHost
=
localAddrs
[
0
];
cachedLocalHost
=
localAddrs
[
0
];
cacheTime
=
now
;
cacheTime
=
now
;
...
@@ -1434,8 +1431,8 @@ class InetAddress implements java.io.Serializable {
...
@@ -1434,8 +1431,8 @@ class InetAddress implements java.io.Serializable {
/*
/*
* Load and instantiate an underlying impl class
* Load and instantiate an underlying impl class
*/
*/
static
Object
loadImpl
(
String
implName
)
{
static
InetAddressImpl
loadImpl
(
String
implName
)
{
Object
impl
;
Object
impl
=
null
;
/*
/*
* Property "impl.prefix" will be prepended to the classname
* Property "impl.prefix" will be prepended to the classname
...
@@ -1446,7 +1443,6 @@ class InetAddress implements java.io.Serializable {
...
@@ -1446,7 +1443,6 @@ class InetAddress implements java.io.Serializable {
*/
*/
String
prefix
=
AccessController
.
doPrivileged
(
String
prefix
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"impl.prefix"
,
""
));
new
GetPropertyAction
(
"impl.prefix"
,
""
));
impl
=
null
;
try
{
try
{
impl
=
Class
.
forName
(
"java.net."
+
prefix
+
implName
).
newInstance
();
impl
=
Class
.
forName
(
"java.net."
+
prefix
+
implName
).
newInstance
();
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
ClassNotFoundException
e
)
{
...
@@ -1471,7 +1467,7 @@ class InetAddress implements java.io.Serializable {
...
@@ -1471,7 +1467,7 @@ class InetAddress implements java.io.Serializable {
}
}
}
}
return
impl
;
return
(
InetAddressImpl
)
impl
;
}
}
private
void
readObjectNoData
(
ObjectInputStream
s
)
throws
private
void
readObjectNoData
(
ObjectInputStream
s
)
throws
...
@@ -1498,13 +1494,8 @@ class InetAddress implements java.io.Serializable {
...
@@ -1498,13 +1494,8 @@ class InetAddress implements java.io.Serializable {
class
InetAddressImplFactory
{
class
InetAddressImplFactory
{
static
InetAddressImpl
create
()
{
static
InetAddressImpl
create
()
{
Object
o
;
return
InetAddress
.
loadImpl
(
isIPv6Supported
()
?
if
(
isIPv6Supported
())
{
"Inet6AddressImpl"
:
"Inet4AddressImpl"
);
o
=
InetAddress
.
loadImpl
(
"Inet6AddressImpl"
);
}
else
{
o
=
InetAddress
.
loadImpl
(
"Inet4AddressImpl"
);
}
return
(
InetAddressImpl
)
o
;
}
}
static
native
boolean
isIPv6Supported
();
static
native
boolean
isIPv6Supported
();
...
...
src/share/classes/java/nio/file/FileSystemLoopException.java
0 → 100644
浏览文件 @
67166499
/*
* Copyright (c) 2010, 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. 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
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
java.nio.file
;
/**
* Checked exception thrown when a file system loop, or cycle, is encountered.
*
* @since 1.7
* @see Files#walkFileTree
*/
public
class
FileSystemLoopException
extends
FileSystemException
{
private
static
final
long
serialVersionUID
=
4843039591949217617L
;
/**
* Constructs an instance of this class.
*
* @param file
* a string identifying the file causing the cycle or {@code null} if
* not known
*/
public
FileSystemLoopException
(
String
file
)
{
super
(
file
);
}
}
src/share/classes/java/nio/file/FileTreeWalker.java
浏览文件 @
67166499
...
@@ -38,7 +38,6 @@ import sun.nio.fs.BasicFileAttributesHolder;
...
@@ -38,7 +38,6 @@ import sun.nio.fs.BasicFileAttributesHolder;
class
FileTreeWalker
{
class
FileTreeWalker
{
private
final
boolean
followLinks
;
private
final
boolean
followLinks
;
private
final
boolean
detectCycles
;
private
final
LinkOption
[]
linkOptions
;
private
final
LinkOption
[]
linkOptions
;
private
final
FileVisitor
<?
super
Path
>
visitor
;
private
final
FileVisitor
<?
super
Path
>
visitor
;
private
final
int
maxDepth
;
private
final
int
maxDepth
;
...
@@ -48,17 +47,15 @@ class FileTreeWalker {
...
@@ -48,17 +47,15 @@ class FileTreeWalker {
int
maxDepth
)
int
maxDepth
)
{
{
boolean
fl
=
false
;
boolean
fl
=
false
;
boolean
dc
=
false
;
for
(
FileVisitOption
option:
options
)
{
for
(
FileVisitOption
option:
options
)
{
// will throw NPE if options contains null
switch
(
option
)
{
switch
(
option
)
{
case
FOLLOW_LINKS
:
fl
=
true
;
break
;
case
FOLLOW_LINKS
:
fl
=
true
;
break
;
case
DETECT_CYCLES
:
dc
=
true
;
break
;
default
:
default
:
throw
new
AssertionError
(
"Should not get here"
);
throw
new
AssertionError
(
"Should not get here"
);
}
}
}
}
this
.
followLinks
=
fl
;
this
.
followLinks
=
fl
;
this
.
detectCycles
=
fl
|
dc
;
this
.
linkOptions
=
(
fl
)
?
new
LinkOption
[
0
]
:
this
.
linkOptions
=
(
fl
)
?
new
LinkOption
[
0
]
:
new
LinkOption
[]
{
LinkOption
.
NOFOLLOW_LINKS
};
new
LinkOption
[]
{
LinkOption
.
NOFOLLOW_LINKS
};
this
.
visitor
=
visitor
;
this
.
visitor
=
visitor
;
...
@@ -68,13 +65,11 @@ class FileTreeWalker {
...
@@ -68,13 +65,11 @@ class FileTreeWalker {
/**
/**
* Walk file tree starting at the given file
* Walk file tree starting at the given file
*/
*/
void
walk
(
Path
start
)
{
void
walk
(
Path
start
)
throws
IOException
{
FileVisitResult
result
=
walk
(
start
,
FileVisitResult
result
=
walk
(
start
,
0
,
0
,
new
ArrayList
<
AncestorDirectory
>());
new
ArrayList
<
AncestorDirectory
>());
if
(
result
==
null
)
{
Objects
.
nonNull
(
result
,
"FileVisitor returned null"
);
throw
new
NullPointerException
(
"Visitor returned 'null'"
);
}
}
}
/**
/**
...
@@ -88,11 +83,8 @@ class FileTreeWalker {
...
@@ -88,11 +83,8 @@ class FileTreeWalker {
private
FileVisitResult
walk
(
Path
file
,
private
FileVisitResult
walk
(
Path
file
,
int
depth
,
int
depth
,
List
<
AncestorDirectory
>
ancestors
)
List
<
AncestorDirectory
>
ancestors
)
throws
IOException
{
{
// depth check
if
(
depth
>
maxDepth
)
return
FileVisitResult
.
CONTINUE
;
// if attributes are cached then use them if possible
// if attributes are cached then use them if possible
BasicFileAttributes
attrs
=
null
;
BasicFileAttributes
attrs
=
null
;
if
((
depth
>
0
)
&&
if
((
depth
>
0
)
&&
...
@@ -137,13 +129,13 @@ class FileTreeWalker {
...
@@ -137,13 +129,13 @@ class FileTreeWalker {
return
visitor
.
visitFileFailed
(
file
,
exc
);
return
visitor
.
visitFileFailed
(
file
,
exc
);
}
}
//
file is not a directory so invoke visitFile method
//
at maximum depth or file is not a directory
if
(!
attrs
.
isDirectory
())
{
if
(
depth
>=
maxDepth
||
!
attrs
.
isDirectory
())
{
return
visitor
.
visitFile
(
file
,
attrs
);
return
visitor
.
visitFile
(
file
,
attrs
);
}
}
// check for cycles
// check for cycles
when following links
if
(
detectCycle
s
)
{
if
(
followLink
s
)
{
Object
key
=
attrs
.
fileKey
();
Object
key
=
attrs
.
fileKey
();
// if this directory and ancestor has a file key then we compare
// if this directory and ancestor has a file key then we compare
...
@@ -153,19 +145,23 @@ class FileTreeWalker {
...
@@ -153,19 +145,23 @@ class FileTreeWalker {
if
(
key
!=
null
&&
ancestorKey
!=
null
)
{
if
(
key
!=
null
&&
ancestorKey
!=
null
)
{
if
(
key
.
equals
(
ancestorKey
))
{
if
(
key
.
equals
(
ancestorKey
))
{
// cycle detected
// cycle detected
return
visitor
.
visitFile
(
file
,
attrs
);
return
visitor
.
visitFileFailed
(
file
,
new
FileSystemLoopException
(
file
.
toString
()));
}
}
}
else
{
}
else
{
boolean
isSameFile
=
false
;
try
{
try
{
if
(
file
.
isSameFile
(
ancestor
.
file
()))
{
isSameFile
=
file
.
isSameFile
(
ancestor
.
file
());
// cycle detected
return
visitor
.
visitFile
(
file
,
attrs
);
}
}
catch
(
IOException
x
)
{
}
catch
(
IOException
x
)
{
// ignore
// ignore
}
catch
(
SecurityException
x
)
{
}
catch
(
SecurityException
x
)
{
// ignore
// ignore
}
}
if
(
isSameFile
)
{
// cycle detected
return
visitor
.
visitFileFailed
(
file
,
new
FileSystemLoopException
(
file
.
toString
()));
}
}
}
}
}
...
@@ -181,7 +177,7 @@ class FileTreeWalker {
...
@@ -181,7 +177,7 @@ class FileTreeWalker {
try
{
try
{
stream
=
file
.
newDirectoryStream
();
stream
=
file
.
newDirectoryStream
();
}
catch
(
IOException
x
)
{
}
catch
(
IOException
x
)
{
return
visitor
.
preVisitDirectory
Failed
(
file
,
x
);
return
visitor
.
visitFile
Failed
(
file
,
x
);
}
catch
(
SecurityException
x
)
{
}
catch
(
SecurityException
x
)
{
// ignore, as per spec
// ignore, as per spec
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
...
@@ -192,20 +188,14 @@ class FileTreeWalker {
...
@@ -192,20 +188,14 @@ class FileTreeWalker {
// invoke preVisitDirectory and then visit each entry
// invoke preVisitDirectory and then visit each entry
try
{
try
{
result
=
visitor
.
preVisitDirectory
(
file
);
result
=
visitor
.
preVisitDirectory
(
file
,
attrs
);
if
(
result
!=
FileVisitResult
.
CONTINUE
)
{
if
(
result
!=
FileVisitResult
.
CONTINUE
)
{
return
result
;
return
result
;
}
}
// if an I/O occurs during iteration then a CME is thrown. We
// need to distinguish this from a CME thrown by the visitor.
boolean
inAction
=
false
;
try
{
try
{
for
(
Path
entry:
stream
)
{
for
(
Path
entry:
stream
)
{
inAction
=
true
;
result
=
walk
(
entry
,
depth
+
1
,
ancestors
);
result
=
walk
(
entry
,
depth
+
1
,
ancestors
);
inAction
=
false
;
// returning null will cause NPE to be thrown
// returning null will cause NPE to be thrown
if
(
result
==
null
||
result
==
FileVisitResult
.
TERMINATE
)
if
(
result
==
null
||
result
==
FileVisitResult
.
TERMINATE
)
...
@@ -215,17 +205,9 @@ class FileTreeWalker {
...
@@ -215,17 +205,9 @@ class FileTreeWalker {
if
(
result
==
FileVisitResult
.
SKIP_SIBLINGS
)
if
(
result
==
FileVisitResult
.
SKIP_SIBLINGS
)
break
;
break
;
}
}
}
catch
(
ConcurrentModificationException
x
)
{
}
catch
(
DirectoryIteratorException
e
)
{
// if CME thrown because the iteration failed then remember
// IOException will be notified to postVisitDirectory
// the IOException so that it is notified to postVisitDirectory
ioe
=
e
.
getCause
();
if
(!
inAction
)
{
// iteration failed
Throwable
t
=
x
.
getCause
();
if
(
t
instanceof
IOException
)
ioe
=
(
IOException
)
t
;
}
if
(
ioe
==
null
)
throw
x
;
}
}
}
finally
{
}
finally
{
try
{
try
{
...
@@ -238,7 +220,7 @@ class FileTreeWalker {
...
@@ -238,7 +220,7 @@ class FileTreeWalker {
}
finally
{
}
finally
{
// remove key from trail if doing cycle detection
// remove key from trail if doing cycle detection
if
(
detectCycle
s
)
{
if
(
followLink
s
)
{
ancestors
.
remove
(
ancestors
.
size
()-
1
);
ancestors
.
remove
(
ancestors
.
size
()-
1
);
}
}
}
}
...
...
src/share/classes/java/nio/file/FileVisitOption.java
浏览文件 @
67166499
...
@@ -37,9 +37,5 @@ public enum FileVisitOption {
...
@@ -37,9 +37,5 @@ public enum FileVisitOption {
/**
/**
* Follow symbolic links.
* Follow symbolic links.
*/
*/
FOLLOW_LINKS
,
FOLLOW_LINKS
;
/**
* Detect cycles in the file tree.
*/
DETECT_CYCLES
;
}
}
src/share/classes/java/nio/file/FileVisitor.java
浏览文件 @
67166499
...
@@ -40,33 +40,28 @@ import java.io.IOException;
...
@@ -40,33 +40,28 @@ import java.io.IOException;
* Path start = ...
* Path start = ...
* Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
* Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
* @Override
* @Override
* public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
* public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
* try {
* throws IOException
* {
* file.delete();
* file.delete();
* } catch (IOException exc) {
* // failed to delete, do error handling here
* }
* return FileVisitResult.CONTINUE;
* return FileVisitResult.CONTINUE;
* }
* }
* @Override
* @Override
* public FileVisitResult postVisitDirectory(Path dir, IOException e) {
* public FileVisitResult postVisitDirectory(Path dir, IOException e)
* if (e == null) {
* throws IOException
* try {
* {
* dir.delete();
* if (e != null) {
* } catch (IOException exc) {
* // failed to delete, do error handling here
* }
* } else {
* // directory iteration failed
* // directory iteration failed
* throw e;
* }
* }
* dir.delete();
* return FileVisitResult.CONTINUE;
* return FileVisitResult.CONTINUE;
* }
* }
* });
* });
* </pre>
* </pre>
* <p> Furthermore, suppose we want to copy a file tree rooted at a source
* <p> Furthermore, suppose we want to copy a file tree to a target location.
* directory to a target location. In that case, symbolic links should be
* In that case, symbolic links should be followed and the target directory
* followed and the target directory should be created before the entries in
* should be created before the entries in the directory are copied.
* the directory are copied.
* <pre>
* <pre>
* final Path source = ...
* final Path source = ...
* final Path target = ...
* final Path target = ...
...
@@ -74,25 +69,21 @@ import java.io.IOException;
...
@@ -74,25 +69,21 @@ import java.io.IOException;
* Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
* Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
* new SimpleFileVisitor<Path>() {
* new SimpleFileVisitor<Path>() {
* @Override
* @Override
* public FileVisitResult preVisitDirectory(Path dir) {
* public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
* throws IOException
* {
* try {
* try {
* dir.copyTo(target.resolve(source.relativize(dir)));
* dir.copyTo(target.resolve(source.relativize(dir)));
* } catch (FileAlreadyExistsException e) {
* } catch (FileAlreadyExistsException e) {
* // ignore
* // ignore
* } catch (IOException e) {
* // copy failed, do error handling here
* // skip rest of directory and descendants
* return SKIP_SUBTREE;
* }
* }
* return CONTINUE;
* return CONTINUE;
* }
* }
* @Override
* @Override
* public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
* public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
* try {
* throws IOException
* {
* file.copyTo(target.resolve(source.relativize(file)));
* file.copyTo(target.resolve(source.relativize(file)));
* } catch (IOException e) {
* // copy failed, do error handling here
* }
* return CONTINUE;
* return CONTINUE;
* }
* }
* });
* });
...
@@ -114,22 +105,16 @@ public interface FileVisitor<T> {
...
@@ -114,22 +105,16 @@ public interface FileVisitor<T> {
*
*
* @param dir
* @param dir
* a reference to the directory
* a reference to the directory
* @param attrs
* the directory's basic attributes
*
*
* @return the visit result
* @return the visit result
*/
FileVisitResult
preVisitDirectory
(
T
dir
);
/**
* Invoked for a directory that could not be opened.
*
* @param dir
* a reference to the directory
* @param exc
* the I/O exception thrown from the attempt to open the directory
*
*
* @return the visit result
* @throws IOException
* if an I/O error occurs
*/
*/
FileVisitResult
preVisitDirectoryFailed
(
T
dir
,
IOException
exc
);
FileVisitResult
preVisitDirectory
(
T
dir
,
BasicFileAttributes
attrs
)
throws
IOException
;
/**
/**
* Invoked for a file in a directory.
* Invoked for a file in a directory.
...
@@ -140,21 +125,30 @@ public interface FileVisitor<T> {
...
@@ -140,21 +125,30 @@ public interface FileVisitor<T> {
* the file's basic attributes
* the file's basic attributes
*
*
* @return the visit result
* @return the visit result
*
* @throws IOException
* if an I/O error occurs
*/
*/
FileVisitResult
visitFile
(
T
file
,
BasicFileAttributes
attrs
);
FileVisitResult
visitFile
(
T
file
,
BasicFileAttributes
attrs
)
throws
IOException
;
/**
/**
* Invoked for a file when its basic file attributes could not be read.
* Invoked for a file that could not be visited. This method is invoked
* if the file's attributes could not be read, the file is a directory
* that could not be opened, and other reasons.
*
*
* @param file
* @param file
* a reference to the file
* a reference to the file
* @param exc
* @param exc
* the I/O exception thrown from the attempt to read the file
* the I/O exception that prevented the file from being visited
* attributes
*
*
* @return the visit result
* @return the visit result
*
* @throws IOException
* if an I/O error occurs
*/
*/
FileVisitResult
visitFileFailed
(
T
file
,
IOException
exc
);
FileVisitResult
visitFileFailed
(
T
file
,
IOException
exc
)
throws
IOException
;
/**
/**
* Invoked for a directory after entries in the directory, and all of their
* Invoked for a directory after entries in the directory, and all of their
...
@@ -171,6 +165,10 @@ public interface FileVisitor<T> {
...
@@ -171,6 +165,10 @@ public interface FileVisitor<T> {
* of the directory to complete prematurely
* of the directory to complete prematurely
*
*
* @return the visit result
* @return the visit result
*
* @throws IOException
* if an I/O error occurs
*/
*/
FileVisitResult
postVisitDirectory
(
T
dir
,
IOException
exc
);
FileVisitResult
postVisitDirectory
(
T
dir
,
IOException
exc
)
throws
IOException
;
}
}
src/share/classes/java/nio/file/Files.java
浏览文件 @
67166499
...
@@ -135,9 +135,9 @@ public final class Files {
...
@@ -135,9 +135,9 @@ public final class Files {
* FileVisitor} invoked for each file encountered. File tree traversal
* FileVisitor} invoked for each file encountered. File tree traversal
* completes when all accessible files in the tree have been visited, or a
* completes when all accessible files in the tree have been visited, or a
* visit method returns a result of {@link FileVisitResult#TERMINATE
* visit method returns a result of {@link FileVisitResult#TERMINATE
* TERMINATE}. Where a visit method terminates due an
uncaught error or
* TERMINATE}. Where a visit method terminates due an
{@code IOException},
*
runtime exception then the traversal is terminated and the error or
*
an uncaught error, or runtime exception, then the traversal is terminated
* exception is propagated to the caller of this method.
*
and the error or
exception is propagated to the caller of this method.
*
*
* <p> For each file encountered this method attempts to gets its {@link
* <p> For each file encountered this method attempts to gets its {@link
* java.nio.file.attribute.BasicFileAttributes}. If the file is not a
* java.nio.file.attribute.BasicFileAttributes}. If the file is not a
...
@@ -146,12 +146,10 @@ public final class Files {
...
@@ -146,12 +146,10 @@ public final class Files {
* due to an I/O exception, then the {@link FileVisitor#visitFileFailed
* due to an I/O exception, then the {@link FileVisitor#visitFileFailed
* visitFileFailed} method is invoked with the I/O exception.
* visitFileFailed} method is invoked with the I/O exception.
*
*
* <p> Where the file is a directory, this method attempts to open it by
* <p> Where the file is a directory, and the directory could not be opened,
* invoking its {@link Path#newDirectoryStream newDirectoryStream} method.
* then the {@code visitFileFailed} method is invoked with the I/O exception,
* Where the directory could not be opened, due to an {@code IOException},
* after which, the file tree walk continues, by default, at the next
* then the {@link FileVisitor#preVisitDirectoryFailed preVisitDirectoryFailed}
* <em>sibling</em> of the directory.
* method is invoked with the I/O exception, after which, the file tree walk
* continues, by default, at the next <em>sibling</em> of the directory.
*
*
* <p> Where the directory is opened successfully, then the entries in the
* <p> Where the directory is opened successfully, then the entries in the
* directory, and their <em>descendants</em> are visited. When all entries
* directory, and their <em>descendants</em> are visited. When all entries
...
@@ -171,26 +169,25 @@ public final class Files {
...
@@ -171,26 +169,25 @@ public final class Files {
* method is invoked as specified above).
* method is invoked as specified above).
*
*
* <p> If the {@code options} parameter contains the {@link
* <p> If the {@code options} parameter contains the {@link
* FileVisitOption#DETECT_CYCLES DETECT_CYCLES} or {@link
* FileVisitOption#FOLLOW_LINKS FOLLOW_LINKS} option then this method keeps
* FileVisitOption#FOLLOW_LINKS FOLLOW_LINKS} options then this method keeps
* track of directories visited so that cycles can be detected. A cycle
* track of directories visited so that cycles can be detected. A cycle
* arises when there is an entry in a directory that is an ancestor of the
* arises when there is an entry in a directory that is an ancestor of the
* directory. Cycle detection is done by recording the {@link
* directory. Cycle detection is done by recording the {@link
* java.nio.file.attribute.BasicFileAttributes#fileKey file-key} of directories,
* java.nio.file.attribute.BasicFileAttributes#fileKey file-key} of directories,
* or if file keys are not available, by invoking the {@link Path#isSameFile
* or if file keys are not available, by invoking the {@link Path#isSameFile
* isSameFile} method to test if a directory is the same file as an
* isSameFile} method to test if a directory is the same file as an
* ancestor. When a cycle is detected the {@link FileVisitor#visitFile
* ancestor. When a cycle is detected it is treated as an I/O error, and the
* visitFile} is invoked with the attributes of the directory. The {@link
* {@link FileVisitor#visitFileFailed visitFileFailed} method is invoked with
* java.nio.file.attribute.BasicFileAttributes#isDirectory isDirectory}
* an instance of {@link FileSystemLoopException}.
* method may be used to test if the file is a directory and that a cycle is
* detected. The {@code preVisitDirectory} and {@code postVisitDirectory}
* methods are not invoked.
*
*
* <p> The {@code maxDepth} parameter is the maximum number of levels of
* <p> The {@code maxDepth} parameter is the maximum number of levels of
* directories to visit. A value of {@code 0} means that only the starting
* directories to visit. A value of {@code 0} means that only the starting
* file is visited, unless denied by the security manager. A value of
* file is visited, unless denied by the security manager. A value of
* {@link Integer#MAX_VALUE MAX_VALUE} may be used to indicate that all
* {@link Integer#MAX_VALUE MAX_VALUE} may be used to indicate that all
* levels should be visited.
* levels should be visited. The {@code visitFile} method is invoked for all
* files, including directories, encountered at {@code maxDepth}, unless the
* basic file attributes cannot be read, in which case the {@code
* visitFileFailed} method is invoked.
*
*
* <p> If a visitor returns a result of {@code null} then {@code
* <p> If a visitor returns a result of {@code null} then {@code
* NullPointerException} is thrown.
* NullPointerException} is thrown.
...
@@ -215,11 +212,14 @@ public final class Files {
...
@@ -215,11 +212,14 @@ public final class Files {
* In the case of the default provider, the {@link
* In the case of the default provider, the {@link
* SecurityManager#checkRead(String) checkRead} method is invoked
* SecurityManager#checkRead(String) checkRead} method is invoked
* to check read access to the directory.
* to check read access to the directory.
* @throws IOException
* If an I/O error is thrown by a visitor method
*/
*/
public
static
void
walkFileTree
(
Path
start
,
public
static
void
walkFileTree
(
Path
start
,
Set
<
FileVisitOption
>
options
,
Set
<
FileVisitOption
>
options
,
int
maxDepth
,
int
maxDepth
,
FileVisitor
<?
super
Path
>
visitor
)
FileVisitor
<?
super
Path
>
visitor
)
throws
IOException
{
{
if
(
maxDepth
<
0
)
if
(
maxDepth
<
0
)
throw
new
IllegalArgumentException
(
"'maxDepth' is negative"
);
throw
new
IllegalArgumentException
(
"'maxDepth' is negative"
);
...
@@ -245,8 +245,12 @@ public final class Files {
...
@@ -245,8 +245,12 @@ public final class Files {
* In the case of the default provider, the {@link
* In the case of the default provider, the {@link
* SecurityManager#checkRead(String) checkRead} method is invoked
* SecurityManager#checkRead(String) checkRead} method is invoked
* to check read access to the directory.
* to check read access to the directory.
* @throws IOException
* If an I/O error is thrown by a visitor method
*/
*/
public
static
void
walkFileTree
(
Path
start
,
FileVisitor
<?
super
Path
>
visitor
)
{
public
static
void
walkFileTree
(
Path
start
,
FileVisitor
<?
super
Path
>
visitor
)
throws
IOException
{
walkFileTree
(
start
,
walkFileTree
(
start
,
EnumSet
.
noneOf
(
FileVisitOption
.
class
),
EnumSet
.
noneOf
(
FileVisitOption
.
class
),
Integer
.
MAX_VALUE
,
Integer
.
MAX_VALUE
,
...
...
src/share/classes/java/nio/file/SimpleFileVisitor.java
浏览文件 @
67166499
...
@@ -27,7 +27,7 @@ package java.nio.file;
...
@@ -27,7 +27,7 @@ package java.nio.file;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.
io.IOError
;
import
java.
util.Objects
;
/**
/**
* A simple visitor of files with default behavior to visit all files and to
* A simple visitor of files with default behavior to visit all files and to
...
@@ -47,14 +47,6 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
...
@@ -47,14 +47,6 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
protected
SimpleFileVisitor
()
{
protected
SimpleFileVisitor
()
{
}
}
/**
* Throws NullPointerException if obj is null.
*/
private
static
void
checkNotNull
(
Object
obj
)
{
if
(
obj
==
null
)
throw
new
NullPointerException
();
}
/**
/**
* Invoked for a directory before entries in the directory are visited.
* Invoked for a directory before entries in the directory are visited.
*
*
...
@@ -62,28 +54,14 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
...
@@ -62,28 +54,14 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
* CONTINUE}.
* CONTINUE}.
*/
*/
@Override
@Override
public
FileVisitResult
preVisitDirectory
(
T
dir
)
{
public
FileVisitResult
preVisitDirectory
(
T
dir
,
BasicFileAttributes
attrs
)
checkNotNull
(
dir
);
throws
IOException
{
Objects
.
nonNull
(
dir
);
Objects
.
nonNull
(
attrs
);
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
/**
* Invoked for a directory that could not be opened.
*
* <p> Unless overridden, this method throws {@link IOError} with the I/O
* exception as cause.
*
* @throws IOError
* with the I/O exception thrown when the attempt to open the
* directory failed
*/
@Override
public
FileVisitResult
preVisitDirectoryFailed
(
T
dir
,
IOException
exc
)
{
checkNotNull
(
dir
);
checkNotNull
(
exc
);
throw
new
IOError
(
exc
);
}
/**
/**
* Invoked for a file in a directory.
* Invoked for a file in a directory.
*
*
...
@@ -91,27 +69,26 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
...
@@ -91,27 +69,26 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
* CONTINUE}.
* CONTINUE}.
*/
*/
@Override
@Override
public
FileVisitResult
visitFile
(
T
file
,
BasicFileAttributes
attrs
)
{
public
FileVisitResult
visitFile
(
T
file
,
BasicFileAttributes
attrs
)
checkNotNull
(
file
);
throws
IOException
checkNotNull
(
attrs
);
{
Objects
.
nonNull
(
file
);
Objects
.
nonNull
(
attrs
);
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
/**
/**
* Invoked for a file when its basic file attributes could not be read.
* Invoked for a file that could not be visited.
*
* <p> Unless overridden, this method throws {@link IOError} with the I/O
* exception as cause.
*
*
* @throws IOError
* <p> Unless overridden, this method re-throws the I/O exception that prevented
* with the I/O exception thrown when the attempt to read the file
* the file from being visited.
* attributes failed
*/
*/
@Override
@Override
public
FileVisitResult
visitFileFailed
(
T
file
,
IOException
exc
)
{
public
FileVisitResult
visitFileFailed
(
T
file
,
IOException
exc
)
checkNotNull
(
file
);
throws
IOException
checkNotNull
(
exc
);
{
throw
new
IOError
(
exc
);
Objects
.
nonNull
(
file
);
throw
exc
;
}
}
/**
/**
...
@@ -120,18 +97,16 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
...
@@ -120,18 +97,16 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
*
*
* <p> Unless overridden, this method returns {@link FileVisitResult#CONTINUE
* <p> Unless overridden, this method returns {@link FileVisitResult#CONTINUE
* CONTINUE} if the directory iteration completes without an I/O exception;
* CONTINUE} if the directory iteration completes without an I/O exception;
* otherwise this method throws {@link IOError} with the I/O exception as
* otherwise this method re-throws the I/O exception that caused the iteration
* cause.
* of the directory to terminate prematurely.
*
* @throws IOError
* with the I/O exception thrown when iteration of the directory
* completed prematurely due to an I/O error
*/
*/
@Override
@Override
public
FileVisitResult
postVisitDirectory
(
T
dir
,
IOException
exc
)
{
public
FileVisitResult
postVisitDirectory
(
T
dir
,
IOException
exc
)
checkNotNull
(
dir
);
throws
IOException
{
Objects
.
nonNull
(
dir
);
if
(
exc
!=
null
)
if
(
exc
!=
null
)
throw
new
IOError
(
exc
)
;
throw
exc
;
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
}
}
src/share/classes/java/sql/DatabaseMetaData.java
浏览文件 @
67166499
...
@@ -3643,7 +3643,7 @@ public interface DatabaseMetaData extends Wrapper {
...
@@ -3643,7 +3643,7 @@ public interface DatabaseMetaData extends Wrapper {
/**
/**
* Retrieves whether a generated key will always be returned if the column
* Retrieves whether a generated key will always be returned if the column
* name(s) or index
e(
s) specified for the auto generated key column(s)
* name(s) or index
(e
s) specified for the auto generated key column(s)
* are valid and the statement succeeds. The key that is returned may or
* are valid and the statement succeeds. The key that is returned may or
* may not be based on the column(s) for the auto generated key.
* may not be based on the column(s) for the auto generated key.
* Consult your JDBC driver documentation for additional details.
* Consult your JDBC driver documentation for additional details.
...
...
src/share/classes/java/sql/Statement.java
浏览文件 @
67166499
...
@@ -1051,9 +1051,9 @@ public interface Statement extends Wrapper, AutoCloseable {
...
@@ -1051,9 +1051,9 @@ public interface Statement extends Wrapper, AutoCloseable {
/**
/**
* Returns a value indicating whether this {@code Statement} will be
* Returns a value indicating whether this {@code Statement} will be
* closed when all
dependent objects such as result
sets are closed.
* closed when all
its dependent result
sets are closed.
* @return {@code true} if the {@code Statement} will be closed when all
* @return {@code true} if the {@code Statement} will be closed when all
* of its dependent
objec
ts are closed; {@code false} otherwise
* of its dependent
result se
ts are closed; {@code false} otherwise
* @throws SQLException if this method is called on a closed
* @throws SQLException if this method is called on a closed
* {@code Statement}
* {@code Statement}
* @since 1.7
* @since 1.7
...
...
src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java
0 → 100644
浏览文件 @
67166499
/*
* 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. 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
* 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.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Written by Doug Lea and Martin Buchholz with assistance from members of
* JCP JSR-166 Expert Group and released to the public domain, as explained
* at http://creativecommons.org/licenses/publicdomain
*/
package
java.util.concurrent
;
import
java.util.AbstractCollection
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.ConcurrentModificationException
;
import
java.util.Deque
;
import
java.util.Iterator
;
import
java.util.NoSuchElementException
;
import
java.util.Queue
;
/**
* An unbounded concurrent {@linkplain Deque deque} based on linked nodes.
* Concurrent insertion, removal, and access operations execute safely
* across multiple threads.
* A {@code ConcurrentLinkedDeque} is an appropriate choice when
* many threads will share access to a common collection.
* Like most other concurrent collection implementations, this class
* does not permit the use of {@code null} elements.
*
* <p>Iterators are <i>weakly consistent</i>, returning elements
* reflecting the state of the deque at some point at or since the
* creation of the iterator. They do <em>not</em> throw {@link
* java.util.ConcurrentModificationException
* ConcurrentModificationException}, and may proceed concurrently with
* other operations.
*
* <p>Beware that, unlike in most collections, the {@code size}
* method is <em>NOT</em> a constant-time operation. Because of the
* asynchronous nature of these deques, determining the current number
* of elements requires a traversal of the elements.
*
* <p>This class and its iterator implement all of the <em>optional</em>
* methods of the {@link Deque} and {@link Iterator} interfaces.
*
* <p>Memory consistency effects: As with other concurrent collections,
* actions in a thread prior to placing an object into a
* {@code ConcurrentLinkedDeque}
* <a href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
* actions subsequent to the access or removal of that element from
* the {@code ConcurrentLinkedDeque} in another thread.
*
* <p>This class is a member of the
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>.
*
* @since 1.7
* @author Doug Lea
* @author Martin Buchholz
* @param <E> the type of elements held in this collection
*/
public
class
ConcurrentLinkedDeque
<
E
>
extends
AbstractCollection
<
E
>
implements
Deque
<
E
>,
java
.
io
.
Serializable
{
/*
* This is an implementation of a concurrent lock-free deque
* supporting interior removes but not interior insertions, as
* required to support the entire Deque interface.
*
* We extend the techniques developed for ConcurrentLinkedQueue and
* LinkedTransferQueue (see the internal docs for those classes).
* Understanding the ConcurrentLinkedQueue implementation is a
* prerequisite for understanding the implementation of this class.
*
* The data structure is a symmetrical doubly-linked "GC-robust"
* linked list of nodes. We minimize the number of volatile writes
* using two techniques: advancing multiple hops with a single CAS
* and mixing volatile and non-volatile writes of the same memory
* locations.
*
* A node contains the expected E ("item") and links to predecessor
* ("prev") and successor ("next") nodes:
*
* class Node<E> { volatile Node<E> prev, next; volatile E item; }
*
* A node p is considered "live" if it contains a non-null item
* (p.item != null). When an item is CASed to null, the item is
* atomically logically deleted from the collection.
*
* At any time, there is precisely one "first" node with a null
* prev reference that terminates any chain of prev references
* starting at a live node. Similarly there is precisely one
* "last" node terminating any chain of next references starting at
* a live node. The "first" and "last" nodes may or may not be live.
* The "first" and "last" nodes are always mutually reachable.
*
* A new element is added atomically by CASing the null prev or
* next reference in the first or last node to a fresh node
* containing the element. The element's node atomically becomes
* "live" at that point.
*
* A node is considered "active" if it is a live node, or the
* first or last node. Active nodes cannot be unlinked.
*
* A "self-link" is a next or prev reference that is the same node:
* p.prev == p or p.next == p
* Self-links are used in the node unlinking process. Active nodes
* never have self-links.
*
* A node p is active if and only if:
*
* p.item != null ||
* (p.prev == null && p.next != p) ||
* (p.next == null && p.prev != p)
*
* The deque object has two node references, "head" and "tail".
* The head and tail are only approximations to the first and last
* nodes of the deque. The first node can always be found by
* following prev pointers from head; likewise for tail. However,
* it is permissible for head and tail to be referring to deleted
* nodes that have been unlinked and so may not be reachable from
* any live node.
*
* There are 3 stages of node deletion;
* "logical deletion", "unlinking", and "gc-unlinking".
*
* 1. "logical deletion" by CASing item to null atomically removes
* the element from the collection, and makes the containing node
* eligible for unlinking.
*
* 2. "unlinking" makes a deleted node unreachable from active
* nodes, and thus eventually reclaimable by GC. Unlinked nodes
* may remain reachable indefinitely from an iterator.
*
* Physical node unlinking is merely an optimization (albeit a
* critical one), and so can be performed at our convenience. At
* any time, the set of live nodes maintained by prev and next
* links are identical, that is, the live nodes found via next
* links from the first node is equal to the elements found via
* prev links from the last node. However, this is not true for
* nodes that have already been logically deleted - such nodes may
* be reachable in one direction only.
*
* 3. "gc-unlinking" takes unlinking further by making active
* nodes unreachable from deleted nodes, making it easier for the
* GC to reclaim future deleted nodes. This step makes the data
* structure "gc-robust", as first described in detail by Boehm
* (http://portal.acm.org/citation.cfm?doid=503272.503282).
*
* GC-unlinked nodes may remain reachable indefinitely from an
* iterator, but unlike unlinked nodes, are never reachable from
* head or tail.
*
* Making the data structure GC-robust will eliminate the risk of
* unbounded memory retention with conservative GCs and is likely
* to improve performance with generational GCs.
*
* When a node is dequeued at either end, e.g. via poll(), we would
* like to break any references from the node to active nodes. We
* develop further the use of self-links that was very effective in
* other concurrent collection classes. The idea is to replace
* prev and next pointers with special values that are interpreted
* to mean off-the-list-at-one-end. These are approximations, but
* good enough to preserve the properties we want in our
* traversals, e.g. we guarantee that a traversal will never visit
* the same element twice, but we don't guarantee whether a
* traversal that runs out of elements will be able to see more
* elements later after enqueues at that end. Doing gc-unlinking
* safely is particularly tricky, since any node can be in use
* indefinitely (for example by an iterator). We must ensure that
* the nodes pointed at by head/tail never get gc-unlinked, since
* head/tail are needed to get "back on track" by other nodes that
* are gc-unlinked. gc-unlinking accounts for much of the
* implementation complexity.
*
* Since neither unlinking nor gc-unlinking are necessary for
* correctness, there are many implementation choices regarding
* frequency (eagerness) of these operations. Since volatile
* reads are likely to be much cheaper than CASes, saving CASes by
* unlinking multiple adjacent nodes at a time may be a win.
* gc-unlinking can be performed rarely and still be effective,
* since it is most important that long chains of deleted nodes
* are occasionally broken.
*
* The actual representation we use is that p.next == p means to
* goto the first node (which in turn is reached by following prev
* pointers from head), and p.next == null && p.prev == p means
* that the iteration is at an end and that p is a (final static)
* dummy node, NEXT_TERMINATOR, and not the last active node.
* Finishing the iteration when encountering such a TERMINATOR is
* good enough for read-only traversals, so such traversals can use
* p.next == null as the termination condition. When we need to
* find the last (active) node, for enqueueing a new node, we need
* to check whether we have reached a TERMINATOR node; if so,
* restart traversal from tail.
*
* The implementation is completely directionally symmetrical,
* except that most public methods that iterate through the list
* follow next pointers ("forward" direction).
*
* We believe (without full proof) that all single-element deque
* operations (e.g., addFirst, peekLast, pollLast) are linearizable
* (see Herlihy and Shavit's book). However, some combinations of
* operations are known not to be linearizable. In particular,
* when an addFirst(A) is racing with pollFirst() removing B, it is
* possible for an observer iterating over the elements to observe
* A B C and subsequently observe A C, even though no interior
* removes are ever performed. Nevertheless, iterators behave
* reasonably, providing the "weakly consistent" guarantees.
*
* Empirically, microbenchmarks suggest that this class adds about
* 40% overhead relative to ConcurrentLinkedQueue, which feels as
* good as we can hope for.
*/
private
static
final
long
serialVersionUID
=
876323262645176354L
;
/**
* A node from which the first node on list (that is, the unique node p
* with p.prev == null && p.next != p) can be reached in O(1) time.
* Invariants:
* - the first node is always O(1) reachable from head via prev links
* - all live nodes are reachable from the first node via succ()
* - head != null
* - (tmp = head).next != tmp || tmp != head
* - head is never gc-unlinked (but may be unlinked)
* Non-invariants:
* - head.item may or may not be null
* - head may not be reachable from the first or last node, or from tail
*/
private
transient
volatile
Node
<
E
>
head
;
/**
* A node from which the last node on list (that is, the unique node p
* with p.next == null && p.prev != p) can be reached in O(1) time.
* Invariants:
* - the last node is always O(1) reachable from tail via next links
* - all live nodes are reachable from the last node via pred()
* - tail != null
* - tail is never gc-unlinked (but may be unlinked)
* Non-invariants:
* - tail.item may or may not be null
* - tail may not be reachable from the first or last node, or from head
*/
private
transient
volatile
Node
<
E
>
tail
;
private
final
static
Node
<
Object
>
PREV_TERMINATOR
,
NEXT_TERMINATOR
;
static
{
PREV_TERMINATOR
=
new
Node
<
Object
>(
null
);
PREV_TERMINATOR
.
next
=
PREV_TERMINATOR
;
NEXT_TERMINATOR
=
new
Node
<
Object
>(
null
);
NEXT_TERMINATOR
.
prev
=
NEXT_TERMINATOR
;
}
@SuppressWarnings
(
"unchecked"
)
Node
<
E
>
prevTerminator
()
{
return
(
Node
<
E
>)
PREV_TERMINATOR
;
}
@SuppressWarnings
(
"unchecked"
)
Node
<
E
>
nextTerminator
()
{
return
(
Node
<
E
>)
NEXT_TERMINATOR
;
}
static
final
class
Node
<
E
>
{
volatile
Node
<
E
>
prev
;
volatile
E
item
;
volatile
Node
<
E
>
next
;
/**
* Constructs a new node. Uses relaxed write because item can
* only be seen after publication via casNext or casPrev.
*/
Node
(
E
item
)
{
UNSAFE
.
putObject
(
this
,
itemOffset
,
item
);
}
boolean
casItem
(
E
cmp
,
E
val
)
{
return
UNSAFE
.
compareAndSwapObject
(
this
,
itemOffset
,
cmp
,
val
);
}
void
lazySetNext
(
Node
<
E
>
val
)
{
UNSAFE
.
putOrderedObject
(
this
,
nextOffset
,
val
);
}
boolean
casNext
(
Node
<
E
>
cmp
,
Node
<
E
>
val
)
{
return
UNSAFE
.
compareAndSwapObject
(
this
,
nextOffset
,
cmp
,
val
);
}
void
lazySetPrev
(
Node
<
E
>
val
)
{
UNSAFE
.
putOrderedObject
(
this
,
prevOffset
,
val
);
}
boolean
casPrev
(
Node
<
E
>
cmp
,
Node
<
E
>
val
)
{
return
UNSAFE
.
compareAndSwapObject
(
this
,
prevOffset
,
cmp
,
val
);
}
// Unsafe mechanics
private
static
final
sun
.
misc
.
Unsafe
UNSAFE
=
sun
.
misc
.
Unsafe
.
getUnsafe
();
private
static
final
long
prevOffset
=
objectFieldOffset
(
UNSAFE
,
"prev"
,
Node
.
class
);
private
static
final
long
itemOffset
=
objectFieldOffset
(
UNSAFE
,
"item"
,
Node
.
class
);
private
static
final
long
nextOffset
=
objectFieldOffset
(
UNSAFE
,
"next"
,
Node
.
class
);
}
/**
* Links e as first element.
*/
private
void
linkFirst
(
E
e
)
{
checkNotNull
(
e
);
final
Node
<
E
>
newNode
=
new
Node
<
E
>(
e
);
restartFromHead:
for
(;;)
for
(
Node
<
E
>
h
=
head
,
p
=
h
,
q
;;)
{
if
((
q
=
p
.
prev
)
!=
null
&&
(
q
=
(
p
=
q
).
prev
)
!=
null
)
// Check for head updates every other hop.
// If p == q, we are sure to follow head instead.
p
=
(
h
!=
(
h
=
head
))
?
h
:
q
;
else
if
(
p
.
next
==
p
)
// PREV_TERMINATOR
continue
restartFromHead
;
else
{
// p is first node
newNode
.
lazySetNext
(
p
);
// CAS piggyback
if
(
p
.
casPrev
(
null
,
newNode
))
{
// Successful CAS is the linearization point
// for e to become an element of this deque,
// and for newNode to become "live".
if
(
p
!=
h
)
// hop two nodes at a time
casHead
(
h
,
newNode
);
// Failure is OK.
return
;
}
// Lost CAS race to another thread; re-read prev
}
}
}
/**
* Links e as last element.
*/
private
void
linkLast
(
E
e
)
{
checkNotNull
(
e
);
final
Node
<
E
>
newNode
=
new
Node
<
E
>(
e
);
restartFromTail:
for
(;;)
for
(
Node
<
E
>
t
=
tail
,
p
=
t
,
q
;;)
{
if
((
q
=
p
.
next
)
!=
null
&&
(
q
=
(
p
=
q
).
next
)
!=
null
)
// Check for tail updates every other hop.
// If p == q, we are sure to follow tail instead.
p
=
(
t
!=
(
t
=
tail
))
?
t
:
q
;
else
if
(
p
.
prev
==
p
)
// NEXT_TERMINATOR
continue
restartFromTail
;
else
{
// p is last node
newNode
.
lazySetPrev
(
p
);
// CAS piggyback
if
(
p
.
casNext
(
null
,
newNode
))
{
// Successful CAS is the linearization point
// for e to become an element of this deque,
// and for newNode to become "live".
if
(
p
!=
t
)
// hop two nodes at a time
casTail
(
t
,
newNode
);
// Failure is OK.
return
;
}
// Lost CAS race to another thread; re-read next
}
}
}
private
final
static
int
HOPS
=
2
;
/**
* Unlinks non-null node x.
*/
void
unlink
(
Node
<
E
>
x
)
{
// assert x != null;
// assert x.item == null;
// assert x != PREV_TERMINATOR;
// assert x != NEXT_TERMINATOR;
final
Node
<
E
>
prev
=
x
.
prev
;
final
Node
<
E
>
next
=
x
.
next
;
if
(
prev
==
null
)
{
unlinkFirst
(
x
,
next
);
}
else
if
(
next
==
null
)
{
unlinkLast
(
x
,
prev
);
}
else
{
// Unlink interior node.
//
// This is the common case, since a series of polls at the
// same end will be "interior" removes, except perhaps for
// the first one, since end nodes cannot be unlinked.
//
// At any time, all active nodes are mutually reachable by
// following a sequence of either next or prev pointers.
//
// Our strategy is to find the unique active predecessor
// and successor of x. Try to fix up their links so that
// they point to each other, leaving x unreachable from
// active nodes. If successful, and if x has no live
// predecessor/successor, we additionally try to gc-unlink,
// leaving active nodes unreachable from x, by rechecking
// that the status of predecessor and successor are
// unchanged and ensuring that x is not reachable from
// tail/head, before setting x's prev/next links to their
// logical approximate replacements, self/TERMINATOR.
Node
<
E
>
activePred
,
activeSucc
;
boolean
isFirst
,
isLast
;
int
hops
=
1
;
// Find active predecessor
for
(
Node
<
E
>
p
=
prev
;
;
++
hops
)
{
if
(
p
.
item
!=
null
)
{
activePred
=
p
;
isFirst
=
false
;
break
;
}
Node
<
E
>
q
=
p
.
prev
;
if
(
q
==
null
)
{
if
(
p
.
next
==
p
)
return
;
activePred
=
p
;
isFirst
=
true
;
break
;
}
else
if
(
p
==
q
)
return
;
else
p
=
q
;
}
// Find active successor
for
(
Node
<
E
>
p
=
next
;
;
++
hops
)
{
if
(
p
.
item
!=
null
)
{
activeSucc
=
p
;
isLast
=
false
;
break
;
}
Node
<
E
>
q
=
p
.
next
;
if
(
q
==
null
)
{
if
(
p
.
prev
==
p
)
return
;
activeSucc
=
p
;
isLast
=
true
;
break
;
}
else
if
(
p
==
q
)
return
;
else
p
=
q
;
}
// TODO: better HOP heuristics
if
(
hops
<
HOPS
// always squeeze out interior deleted nodes
&&
(
isFirst
|
isLast
))
return
;
// Squeeze out deleted nodes between activePred and
// activeSucc, including x.
skipDeletedSuccessors
(
activePred
);
skipDeletedPredecessors
(
activeSucc
);
// Try to gc-unlink, if possible
if
((
isFirst
|
isLast
)
&&
// Recheck expected state of predecessor and successor
(
activePred
.
next
==
activeSucc
)
&&
(
activeSucc
.
prev
==
activePred
)
&&
(
isFirst
?
activePred
.
prev
==
null
:
activePred
.
item
!=
null
)
&&
(
isLast
?
activeSucc
.
next
==
null
:
activeSucc
.
item
!=
null
))
{
updateHead
();
// Ensure x is not reachable from head
updateTail
();
// Ensure x is not reachable from tail
// Finally, actually gc-unlink
x
.
lazySetPrev
(
isFirst
?
prevTerminator
()
:
x
);
x
.
lazySetNext
(
isLast
?
nextTerminator
()
:
x
);
}
}
}
/**
* Unlinks non-null first node.
*/
private
void
unlinkFirst
(
Node
<
E
>
first
,
Node
<
E
>
next
)
{
// assert first != null;
// assert next != null;
// assert first.item == null;
for
(
Node
<
E
>
o
=
null
,
p
=
next
,
q
;;)
{
if
(
p
.
item
!=
null
||
(
q
=
p
.
next
)
==
null
)
{
if
(
o
!=
null
&&
p
.
prev
!=
p
&&
first
.
casNext
(
next
,
p
))
{
skipDeletedPredecessors
(
p
);
if
(
first
.
prev
==
null
&&
(
p
.
next
==
null
||
p
.
item
!=
null
)
&&
p
.
prev
==
first
)
{
updateHead
();
// Ensure o is not reachable from head
updateTail
();
// Ensure o is not reachable from tail
// Finally, actually gc-unlink
o
.
lazySetNext
(
o
);
o
.
lazySetPrev
(
prevTerminator
());
}
}
return
;
}
else
if
(
p
==
q
)
return
;
else
{
o
=
p
;
p
=
q
;
}
}
}
/**
* Unlinks non-null last node.
*/
private
void
unlinkLast
(
Node
<
E
>
last
,
Node
<
E
>
prev
)
{
// assert last != null;
// assert prev != null;
// assert last.item == null;
for
(
Node
<
E
>
o
=
null
,
p
=
prev
,
q
;;)
{
if
(
p
.
item
!=
null
||
(
q
=
p
.
prev
)
==
null
)
{
if
(
o
!=
null
&&
p
.
next
!=
p
&&
last
.
casPrev
(
prev
,
p
))
{
skipDeletedSuccessors
(
p
);
if
(
last
.
next
==
null
&&
(
p
.
prev
==
null
||
p
.
item
!=
null
)
&&
p
.
next
==
last
)
{
updateHead
();
// Ensure o is not reachable from head
updateTail
();
// Ensure o is not reachable from tail
// Finally, actually gc-unlink
o
.
lazySetPrev
(
o
);
o
.
lazySetNext
(
nextTerminator
());
}
}
return
;
}
else
if
(
p
==
q
)
return
;
else
{
o
=
p
;
p
=
q
;
}
}
}
/**
* Guarantees that any node which was unlinked before a call to
* this method will be unreachable from head after it returns.
* Does not guarantee to eliminate slack, only that head will
* point to a node that was active while this method was running.
*/
private
final
void
updateHead
()
{
// Either head already points to an active node, or we keep
// trying to cas it to the first node until it does.
Node
<
E
>
h
,
p
,
q
;
restartFromHead:
while
((
h
=
head
).
item
==
null
&&
(
p
=
h
.
prev
)
!=
null
)
{
for
(;;)
{
if
((
q
=
p
.
prev
)
==
null
||
(
q
=
(
p
=
q
).
prev
)
==
null
)
{
// It is possible that p is PREV_TERMINATOR,
// but if so, the CAS is guaranteed to fail.
if
(
casHead
(
h
,
p
))
return
;
else
continue
restartFromHead
;
}
else
if
(
h
!=
head
)
continue
restartFromHead
;
else
p
=
q
;
}
}
}
/**
* Guarantees that any node which was unlinked before a call to
* this method will be unreachable from tail after it returns.
* Does not guarantee to eliminate slack, only that tail will
* point to a node that was active while this method was running.
*/
private
final
void
updateTail
()
{
// Either tail already points to an active node, or we keep
// trying to cas it to the last node until it does.
Node
<
E
>
t
,
p
,
q
;
restartFromTail:
while
((
t
=
tail
).
item
==
null
&&
(
p
=
t
.
next
)
!=
null
)
{
for
(;;)
{
if
((
q
=
p
.
next
)
==
null
||
(
q
=
(
p
=
q
).
next
)
==
null
)
{
// It is possible that p is NEXT_TERMINATOR,
// but if so, the CAS is guaranteed to fail.
if
(
casTail
(
t
,
p
))
return
;
else
continue
restartFromTail
;
}
else
if
(
t
!=
tail
)
continue
restartFromTail
;
else
p
=
q
;
}
}
}
private
void
skipDeletedPredecessors
(
Node
<
E
>
x
)
{
whileActive:
do
{
Node
<
E
>
prev
=
x
.
prev
;
// assert prev != null;
// assert x != NEXT_TERMINATOR;
// assert x != PREV_TERMINATOR;
Node
<
E
>
p
=
prev
;
findActive:
for
(;;)
{
if
(
p
.
item
!=
null
)
break
findActive
;
Node
<
E
>
q
=
p
.
prev
;
if
(
q
==
null
)
{
if
(
p
.
next
==
p
)
continue
whileActive
;
break
findActive
;
}
else
if
(
p
==
q
)
continue
whileActive
;
else
p
=
q
;
}
// found active CAS target
if
(
prev
==
p
||
x
.
casPrev
(
prev
,
p
))
return
;
}
while
(
x
.
item
!=
null
||
x
.
next
==
null
);
}
private
void
skipDeletedSuccessors
(
Node
<
E
>
x
)
{
whileActive:
do
{
Node
<
E
>
next
=
x
.
next
;
// assert next != null;
// assert x != NEXT_TERMINATOR;
// assert x != PREV_TERMINATOR;
Node
<
E
>
p
=
next
;
findActive:
for
(;;)
{
if
(
p
.
item
!=
null
)
break
findActive
;
Node
<
E
>
q
=
p
.
next
;
if
(
q
==
null
)
{
if
(
p
.
prev
==
p
)
continue
whileActive
;
break
findActive
;
}
else
if
(
p
==
q
)
continue
whileActive
;
else
p
=
q
;
}
// found active CAS target
if
(
next
==
p
||
x
.
casNext
(
next
,
p
))
return
;
}
while
(
x
.
item
!=
null
||
x
.
prev
==
null
);
}
/**
* Returns the successor of p, or the first node if p.next has been
* linked to self, which will only be true if traversing with a
* stale pointer that is now off the list.
*/
final
Node
<
E
>
succ
(
Node
<
E
>
p
)
{
// TODO: should we skip deleted nodes here?
Node
<
E
>
q
=
p
.
next
;
return
(
p
==
q
)
?
first
()
:
q
;
}
/**
* Returns the predecessor of p, or the last node if p.prev has been
* linked to self, which will only be true if traversing with a
* stale pointer that is now off the list.
*/
final
Node
<
E
>
pred
(
Node
<
E
>
p
)
{
Node
<
E
>
q
=
p
.
prev
;
return
(
p
==
q
)
?
last
()
:
q
;
}
/**
* Returns the first node, the unique node p for which:
* p.prev == null && p.next != p
* The returned node may or may not be logically deleted.
* Guarantees that head is set to the returned node.
*/
Node
<
E
>
first
()
{
restartFromHead:
for
(;;)
for
(
Node
<
E
>
h
=
head
,
p
=
h
,
q
;;)
{
if
((
q
=
p
.
prev
)
!=
null
&&
(
q
=
(
p
=
q
).
prev
)
!=
null
)
// Check for head updates every other hop.
// If p == q, we are sure to follow head instead.
p
=
(
h
!=
(
h
=
head
))
?
h
:
q
;
else
if
(
p
==
h
// It is possible that p is PREV_TERMINATOR,
// but if so, the CAS is guaranteed to fail.
||
casHead
(
h
,
p
))
return
p
;
else
continue
restartFromHead
;
}
}
/**
* Returns the last node, the unique node p for which:
* p.next == null && p.prev != p
* The returned node may or may not be logically deleted.
* Guarantees that tail is set to the returned node.
*/
Node
<
E
>
last
()
{
restartFromTail:
for
(;;)
for
(
Node
<
E
>
t
=
tail
,
p
=
t
,
q
;;)
{
if
((
q
=
p
.
next
)
!=
null
&&
(
q
=
(
p
=
q
).
next
)
!=
null
)
// Check for tail updates every other hop.
// If p == q, we are sure to follow tail instead.
p
=
(
t
!=
(
t
=
tail
))
?
t
:
q
;
else
if
(
p
==
t
// It is possible that p is NEXT_TERMINATOR,
// but if so, the CAS is guaranteed to fail.
||
casTail
(
t
,
p
))
return
p
;
else
continue
restartFromTail
;
}
}
// Minor convenience utilities
/**
* Throws NullPointerException if argument is null.
*
* @param v the element
*/
private
static
void
checkNotNull
(
Object
v
)
{
if
(
v
==
null
)
throw
new
NullPointerException
();
}
/**
* Returns element unless it is null, in which case throws
* NoSuchElementException.
*
* @param v the element
* @return the element
*/
private
E
screenNullResult
(
E
v
)
{
if
(
v
==
null
)
throw
new
NoSuchElementException
();
return
v
;
}
/**
* Creates an array list and fills it with elements of this list.
* Used by toArray.
*
* @return the arrayList
*/
private
ArrayList
<
E
>
toArrayList
()
{
ArrayList
<
E
>
list
=
new
ArrayList
<
E
>();
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
)
list
.
add
(
item
);
}
return
list
;
}
/**
* Constructs an empty deque.
*/
public
ConcurrentLinkedDeque
()
{
head
=
tail
=
new
Node
<
E
>(
null
);
}
/**
* Constructs a deque initially containing the elements of
* the given collection, added in traversal order of the
* collection's iterator.
*
* @param c the collection of elements to initially contain
* @throws NullPointerException if the specified collection or any
* of its elements are null
*/
public
ConcurrentLinkedDeque
(
Collection
<?
extends
E
>
c
)
{
// Copy c into a private chain of Nodes
Node
<
E
>
h
=
null
,
t
=
null
;
for
(
E
e
:
c
)
{
checkNotNull
(
e
);
Node
<
E
>
newNode
=
new
Node
<
E
>(
e
);
if
(
h
==
null
)
h
=
t
=
newNode
;
else
{
t
.
lazySetNext
(
newNode
);
newNode
.
lazySetPrev
(
t
);
t
=
newNode
;
}
}
initHeadTail
(
h
,
t
);
}
/**
* Initializes head and tail, ensuring invariants hold.
*/
private
void
initHeadTail
(
Node
<
E
>
h
,
Node
<
E
>
t
)
{
if
(
h
==
t
)
{
if
(
h
==
null
)
h
=
t
=
new
Node
<
E
>(
null
);
else
{
// Avoid edge case of a single Node with non-null item.
Node
<
E
>
newNode
=
new
Node
<
E
>(
null
);
t
.
lazySetNext
(
newNode
);
newNode
.
lazySetPrev
(
t
);
t
=
newNode
;
}
}
head
=
h
;
tail
=
t
;
}
/**
* Inserts the specified element at the front of this deque.
*
* @throws NullPointerException {@inheritDoc}
*/
public
void
addFirst
(
E
e
)
{
linkFirst
(
e
);
}
/**
* Inserts the specified element at the end of this deque.
*
* <p>This method is equivalent to {@link #add}.
*
* @throws NullPointerException {@inheritDoc}
*/
public
void
addLast
(
E
e
)
{
linkLast
(
e
);
}
/**
* Inserts the specified element at the front of this deque.
*
* @return {@code true} always
* @throws NullPointerException {@inheritDoc}
*/
public
boolean
offerFirst
(
E
e
)
{
linkFirst
(
e
);
return
true
;
}
/**
* Inserts the specified element at the end of this deque.
*
* <p>This method is equivalent to {@link #add}.
*
* @return {@code true} always
* @throws NullPointerException {@inheritDoc}
*/
public
boolean
offerLast
(
E
e
)
{
linkLast
(
e
);
return
true
;
}
public
E
peekFirst
()
{
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
)
return
item
;
}
return
null
;
}
public
E
peekLast
()
{
for
(
Node
<
E
>
p
=
last
();
p
!=
null
;
p
=
pred
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
)
return
item
;
}
return
null
;
}
/**
* @throws NoSuchElementException {@inheritDoc}
*/
public
E
getFirst
()
{
return
screenNullResult
(
peekFirst
());
}
/**
* @throws NoSuchElementException {@inheritDoc}
*/
public
E
getLast
()
{
return
screenNullResult
(
peekLast
());
}
public
E
pollFirst
()
{
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
&&
p
.
casItem
(
item
,
null
))
{
unlink
(
p
);
return
item
;
}
}
return
null
;
}
public
E
pollLast
()
{
for
(
Node
<
E
>
p
=
last
();
p
!=
null
;
p
=
pred
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
&&
p
.
casItem
(
item
,
null
))
{
unlink
(
p
);
return
item
;
}
}
return
null
;
}
/**
* @throws NoSuchElementException {@inheritDoc}
*/
public
E
removeFirst
()
{
return
screenNullResult
(
pollFirst
());
}
/**
* @throws NoSuchElementException {@inheritDoc}
*/
public
E
removeLast
()
{
return
screenNullResult
(
pollLast
());
}
// *** Queue and stack methods ***
/**
* Inserts the specified element at the tail of this deque.
*
* @return {@code true} (as specified by {@link Queue#offer})
* @throws NullPointerException if the specified element is null
*/
public
boolean
offer
(
E
e
)
{
return
offerLast
(
e
);
}
/**
* Inserts the specified element at the tail of this deque.
*
* @return {@code true} (as specified by {@link Collection#add})
* @throws NullPointerException if the specified element is null
*/
public
boolean
add
(
E
e
)
{
return
offerLast
(
e
);
}
public
E
poll
()
{
return
pollFirst
();
}
public
E
remove
()
{
return
removeFirst
();
}
public
E
peek
()
{
return
peekFirst
();
}
public
E
element
()
{
return
getFirst
();
}
public
void
push
(
E
e
)
{
addFirst
(
e
);
}
public
E
pop
()
{
return
removeFirst
();
}
/**
* Removes the first element {@code e} such that
* {@code o.equals(e)}, if such an element exists in this deque.
* If the deque does not contain the element, it is unchanged.
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is {@code null}
*/
public
boolean
removeFirstOccurrence
(
Object
o
)
{
checkNotNull
(
o
);
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
&&
o
.
equals
(
item
)
&&
p
.
casItem
(
item
,
null
))
{
unlink
(
p
);
return
true
;
}
}
return
false
;
}
/**
* Removes the last element {@code e} such that
* {@code o.equals(e)}, if such an element exists in this deque.
* If the deque does not contain the element, it is unchanged.
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is {@code null}
*/
public
boolean
removeLastOccurrence
(
Object
o
)
{
checkNotNull
(
o
);
for
(
Node
<
E
>
p
=
last
();
p
!=
null
;
p
=
pred
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
&&
o
.
equals
(
item
)
&&
p
.
casItem
(
item
,
null
))
{
unlink
(
p
);
return
true
;
}
}
return
false
;
}
/**
* Returns {@code true} if this deque contains at least one
* element {@code e} such that {@code o.equals(e)}.
*
* @param o element whose presence in this deque is to be tested
* @return {@code true} if this deque contains the specified element
*/
public
boolean
contains
(
Object
o
)
{
if
(
o
==
null
)
return
false
;
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
&&
o
.
equals
(
item
))
return
true
;
}
return
false
;
}
/**
* Returns {@code true} if this collection contains no elements.
*
* @return {@code true} if this collection contains no elements
*/
public
boolean
isEmpty
()
{
return
peekFirst
()
==
null
;
}
/**
* Returns the number of elements in this deque. If this deque
* contains more than {@code Integer.MAX_VALUE} elements, it
* returns {@code Integer.MAX_VALUE}.
*
* <p>Beware that, unlike in most collections, this method is
* <em>NOT</em> a constant-time operation. Because of the
* asynchronous nature of these deques, determining the current
* number of elements requires traversing them all to count them.
* Additionally, it is possible for the size to change during
* execution of this method, in which case the returned result
* will be inaccurate. Thus, this method is typically not very
* useful in concurrent applications.
*
* @return the number of elements in this deque
*/
public
int
size
()
{
int
count
=
0
;
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
if
(
p
.
item
!=
null
)
// Collection.size() spec says to max out
if
(++
count
==
Integer
.
MAX_VALUE
)
break
;
return
count
;
}
/**
* Removes the first element {@code e} such that
* {@code o.equals(e)}, if such an element exists in this deque.
* If the deque does not contain the element, it is unchanged.
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is {@code null}
*/
public
boolean
remove
(
Object
o
)
{
return
removeFirstOccurrence
(
o
);
}
/**
* Appends all of the elements in the specified collection to the end of
* this deque, in the order that they are returned by the specified
* collection's iterator. Attempts to {@code addAll} of a deque to
* itself result in {@code IllegalArgumentException}.
*
* @param c the elements to be inserted into this deque
* @return {@code true} if this deque changed as a result of the call
* @throws NullPointerException if the specified collection or any
* of its elements are null
* @throws IllegalArgumentException if the collection is this deque
*/
public
boolean
addAll
(
Collection
<?
extends
E
>
c
)
{
if
(
c
==
this
)
// As historically specified in AbstractQueue#addAll
throw
new
IllegalArgumentException
();
// Copy c into a private chain of Nodes
Node
<
E
>
beginningOfTheEnd
=
null
,
last
=
null
;
for
(
E
e
:
c
)
{
checkNotNull
(
e
);
Node
<
E
>
newNode
=
new
Node
<
E
>(
e
);
if
(
beginningOfTheEnd
==
null
)
beginningOfTheEnd
=
last
=
newNode
;
else
{
last
.
lazySetNext
(
newNode
);
newNode
.
lazySetPrev
(
last
);
last
=
newNode
;
}
}
if
(
beginningOfTheEnd
==
null
)
return
false
;
// Atomically append the chain at the tail of this collection
restartFromTail:
for
(;;)
for
(
Node
<
E
>
t
=
tail
,
p
=
t
,
q
;;)
{
if
((
q
=
p
.
next
)
!=
null
&&
(
q
=
(
p
=
q
).
next
)
!=
null
)
// Check for tail updates every other hop.
// If p == q, we are sure to follow tail instead.
p
=
(
t
!=
(
t
=
tail
))
?
t
:
q
;
else
if
(
p
.
prev
==
p
)
// NEXT_TERMINATOR
continue
restartFromTail
;
else
{
// p is last node
beginningOfTheEnd
.
lazySetPrev
(
p
);
// CAS piggyback
if
(
p
.
casNext
(
null
,
beginningOfTheEnd
))
{
// Successful CAS is the linearization point
// for all elements to be added to this queue.
if
(!
casTail
(
t
,
last
))
{
// Try a little harder to update tail,
// since we may be adding many elements.
t
=
tail
;
if
(
last
.
next
==
null
)
casTail
(
t
,
last
);
}
return
true
;
}
// Lost CAS race to another thread; re-read next
}
}
}
/**
* Removes all of the elements from this deque.
*/
public
void
clear
()
{
while
(
pollFirst
()
!=
null
)
;
}
/**
* Returns an array containing all of the elements in this deque, in
* proper sequence (from first to last element).
*
* <p>The returned array will be "safe" in that no references to it are
* maintained by this deque. (In other words, this method must allocate
* a new array). The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all of the elements in this deque
*/
public
Object
[]
toArray
()
{
return
toArrayList
().
toArray
();
}
/**
* Returns an array containing all of the elements in this deque,
* in proper sequence (from first to last element); the runtime
* type of the returned array is that of the specified array. If
* the deque fits in the specified array, it is returned therein.
* Otherwise, a new array is allocated with the runtime type of
* the specified array and the size of this deque.
*
* <p>If this deque fits in the specified array with room to spare
* (i.e., the array has more elements than this deque), the element in
* the array immediately following the end of the deque is set to
* {@code null}.
*
* <p>Like the {@link #toArray()} method, this method acts as
* bridge between array-based and collection-based APIs. Further,
* this method allows precise control over the runtime type of the
* output array, and may, under certain circumstances, be used to
* save allocation costs.
*
* <p>Suppose {@code x} is a deque known to contain only strings.
* The following code can be used to dump the deque into a newly
* allocated array of {@code String}:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
* Note that {@code toArray(new Object[0])} is identical in function to
* {@code toArray()}.
*
* @param a the array into which the elements of the deque are to
* be stored, if it is big enough; otherwise, a new array of the
* same runtime type is allocated for this purpose
* @return an array containing all of the elements in this deque
* @throws ArrayStoreException if the runtime type of the specified array
* is not a supertype of the runtime type of every element in
* this deque
* @throws NullPointerException if the specified array is null
*/
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
return
toArrayList
().
toArray
(
a
);
}
/**
* Returns an iterator over the elements in this deque in proper sequence.
* The elements will be returned in order from first (head) to last (tail).
*
* <p>The returned {@code Iterator} is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
*
* @return an iterator over the elements in this deque in proper sequence
*/
public
Iterator
<
E
>
iterator
()
{
return
new
Itr
();
}
/**
* Returns an iterator over the elements in this deque in reverse
* sequential order. The elements will be returned in order from
* last (tail) to first (head).
*
* <p>The returned {@code Iterator} is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
*
* @return an iterator over the elements in this deque in reverse order
*/
public
Iterator
<
E
>
descendingIterator
()
{
return
new
DescendingItr
();
}
private
abstract
class
AbstractItr
implements
Iterator
<
E
>
{
/**
* Next node to return item for.
*/
private
Node
<
E
>
nextNode
;
/**
* nextItem holds on to item fields because once we claim
* that an element exists in hasNext(), we must return it in
* the following next() call even if it was in the process of
* being removed when hasNext() was called.
*/
private
E
nextItem
;
/**
* Node returned by most recent call to next. Needed by remove.
* Reset to null if this element is deleted by a call to remove.
*/
private
Node
<
E
>
lastRet
;
abstract
Node
<
E
>
startNode
();
abstract
Node
<
E
>
nextNode
(
Node
<
E
>
p
);
AbstractItr
()
{
advance
();
}
/**
* Sets nextNode and nextItem to next valid node, or to null
* if no such.
*/
private
void
advance
()
{
lastRet
=
nextNode
;
Node
<
E
>
p
=
(
nextNode
==
null
)
?
startNode
()
:
nextNode
(
nextNode
);
for
(;;
p
=
nextNode
(
p
))
{
if
(
p
==
null
)
{
// p might be active end or TERMINATOR node; both are OK
nextNode
=
null
;
nextItem
=
null
;
break
;
}
E
item
=
p
.
item
;
if
(
item
!=
null
)
{
nextNode
=
p
;
nextItem
=
item
;
break
;
}
}
}
public
boolean
hasNext
()
{
return
nextItem
!=
null
;
}
public
E
next
()
{
E
item
=
nextItem
;
if
(
item
==
null
)
throw
new
NoSuchElementException
();
advance
();
return
item
;
}
public
void
remove
()
{
Node
<
E
>
l
=
lastRet
;
if
(
l
==
null
)
throw
new
IllegalStateException
();
l
.
item
=
null
;
unlink
(
l
);
lastRet
=
null
;
}
}
/** Forward iterator */
private
class
Itr
extends
AbstractItr
{
Node
<
E
>
startNode
()
{
return
first
();
}
Node
<
E
>
nextNode
(
Node
<
E
>
p
)
{
return
succ
(
p
);
}
}
/** Descending iterator */
private
class
DescendingItr
extends
AbstractItr
{
Node
<
E
>
startNode
()
{
return
last
();
}
Node
<
E
>
nextNode
(
Node
<
E
>
p
)
{
return
pred
(
p
);
}
}
/**
* Saves the state to a stream (that is, serializes it).
*
* @serialData All of the elements (each an {@code E}) in
* the proper order, followed by a null
* @param s the stream
*/
private
void
writeObject
(
java
.
io
.
ObjectOutputStream
s
)
throws
java
.
io
.
IOException
{
// Write out any hidden stuff
s
.
defaultWriteObject
();
// Write out all elements in the proper order.
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
item
;
if
(
item
!=
null
)
s
.
writeObject
(
item
);
}
// Use trailing null as sentinel
s
.
writeObject
(
null
);
}
/**
* Reconstitutes the instance from a stream (that is, deserializes it).
* @param s the stream
*/
private
void
readObject
(
java
.
io
.
ObjectInputStream
s
)
throws
java
.
io
.
IOException
,
ClassNotFoundException
{
s
.
defaultReadObject
();
// Read in elements until trailing null sentinel found
Node
<
E
>
h
=
null
,
t
=
null
;
Object
item
;
while
((
item
=
s
.
readObject
())
!=
null
)
{
@SuppressWarnings
(
"unchecked"
)
Node
<
E
>
newNode
=
new
Node
<
E
>((
E
)
item
);
if
(
h
==
null
)
h
=
t
=
newNode
;
else
{
t
.
lazySetNext
(
newNode
);
newNode
.
lazySetPrev
(
t
);
t
=
newNode
;
}
}
initHeadTail
(
h
,
t
);
}
// Unsafe mechanics
private
static
final
sun
.
misc
.
Unsafe
UNSAFE
=
sun
.
misc
.
Unsafe
.
getUnsafe
();
private
static
final
long
headOffset
=
objectFieldOffset
(
UNSAFE
,
"head"
,
ConcurrentLinkedDeque
.
class
);
private
static
final
long
tailOffset
=
objectFieldOffset
(
UNSAFE
,
"tail"
,
ConcurrentLinkedDeque
.
class
);
private
boolean
casHead
(
Node
<
E
>
cmp
,
Node
<
E
>
val
)
{
return
UNSAFE
.
compareAndSwapObject
(
this
,
headOffset
,
cmp
,
val
);
}
private
boolean
casTail
(
Node
<
E
>
cmp
,
Node
<
E
>
val
)
{
return
UNSAFE
.
compareAndSwapObject
(
this
,
tailOffset
,
cmp
,
val
);
}
static
long
objectFieldOffset
(
sun
.
misc
.
Unsafe
UNSAFE
,
String
field
,
Class
<?>
klazz
)
{
try
{
return
UNSAFE
.
objectFieldOffset
(
klazz
.
getDeclaredField
(
field
));
}
catch
(
NoSuchFieldException
e
)
{
// Convert Exception to corresponding Error
NoSuchFieldError
error
=
new
NoSuchFieldError
(
field
);
error
.
initCause
(
e
);
throw
error
;
}
}
}
src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
浏览文件 @
67166499
...
@@ -28,9 +28,9 @@
...
@@ -28,9 +28,9 @@
* However, the following notice accompanied the original version of this
* However, the following notice accompanied the original version of this
* file:
* file:
*
*
* Written by Doug Lea
with assistance from members of JCP JSR-166
* Written by Doug Lea
and Martin Buchholz with assistance from members of
*
Expert Group and released to the public domain, as explained at
*
JCP JSR-166 Expert Group and released to the public domain, as explained
* http://creativecommons.org/licenses/publicdomain
*
at
http://creativecommons.org/licenses/publicdomain
*/
*/
package
java.util.concurrent
;
package
java.util.concurrent
;
...
@@ -53,7 +53,8 @@ import java.util.Queue;
...
@@ -53,7 +53,8 @@ import java.util.Queue;
* operations obtain elements at the head of the queue.
* operations obtain elements at the head of the queue.
* A {@code ConcurrentLinkedQueue} is an appropriate choice when
* A {@code ConcurrentLinkedQueue} is an appropriate choice when
* many threads will share access to a common collection.
* many threads will share access to a common collection.
* This queue does not permit {@code null} elements.
* Like most other concurrent collection implementations, this class
* does not permit the use of {@code null} elements.
*
*
* <p>This implementation employs an efficient "wait-free"
* <p>This implementation employs an efficient "wait-free"
* algorithm based on one described in <a
* algorithm based on one described in <a
...
@@ -61,14 +62,20 @@ import java.util.Queue;
...
@@ -61,14 +62,20 @@ import java.util.Queue;
* Fast, and Practical Non-Blocking and Blocking Concurrent Queue
* Fast, and Practical Non-Blocking and Blocking Concurrent Queue
* Algorithms</a> by Maged M. Michael and Michael L. Scott.
* Algorithms</a> by Maged M. Michael and Michael L. Scott.
*
*
* <p>Iterators are <i>weakly consistent</i>, returning elements
* reflecting the state of the queue at some point at or since the
* creation of the iterator. They do <em>not</em> throw {@link
* ConcurrentModificationException}, and may proceed concurrently with
* other operations. Elements contained in the queue since the creation
* of the iterator will be returned exactly once.
*
* <p>Beware that, unlike in most collections, the {@code size} method
* <p>Beware that, unlike in most collections, the {@code size} method
* is <em>NOT</em> a constant-time operation. Because of the
* is <em>NOT</em> a constant-time operation. Because of the
* asynchronous nature of these queues, determining the current number
* asynchronous nature of these queues, determining the current number
* of elements requires a traversal of the elements.
* of elements requires a traversal of the elements.
*
*
* <p>This class and its iterator implement all of the
* <p>This class and its iterator implement all of the <em>optional</em>
* <em>optional</em> methods of the {@link Collection} and {@link
* methods of the {@link Queue} and {@link Iterator} interfaces.
* Iterator} interfaces.
*
*
* <p>Memory consistency effects: As with other concurrent
* <p>Memory consistency effects: As with other concurrent
* collections, actions in a thread prior to placing an object into a
* collections, actions in a thread prior to placing an object into a
...
@@ -132,9 +139,10 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -132,9 +139,10 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
*
*
* Both head and tail are permitted to lag. In fact, failing to
* Both head and tail are permitted to lag. In fact, failing to
* update them every time one could is a significant optimization
* update them every time one could is a significant optimization
* (fewer CASes). This is controlled by local "hops" variables
* (fewer CASes). As with LinkedTransferQueue (see the internal
* that only trigger helping-CASes after experiencing multiple
* documentation for that class), we use a slack threshold of two;
* lags.
* that is, we update head/tail when the current pointer appears
* to be two or more steps away from the first/last node.
*
*
* Since head and tail are updated concurrently and independently,
* Since head and tail are updated concurrently and independently,
* it is possible for tail to lag behind head (why not)?
* it is possible for tail to lag behind head (why not)?
...
@@ -148,8 +156,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -148,8 +156,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* this is merely an optimization.
* this is merely an optimization.
*
*
* When constructing a Node (before enqueuing it) we avoid paying
* When constructing a Node (before enqueuing it) we avoid paying
* for a volatile write to item by using
lazySet instead of a
* for a volatile write to item by using
Unsafe.putObject instead
* normal write. This allows the cost of enqueue to be
*
of a
normal write. This allows the cost of enqueue to be
* "one-and-a-half" CASes.
* "one-and-a-half" CASes.
*
*
* Both head and tail may or may not point to a Node with a
* Both head and tail may or may not point to a Node with a
...
@@ -161,38 +169,25 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -161,38 +169,25 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
*/
*/
private
static
class
Node
<
E
>
{
private
static
class
Node
<
E
>
{
private
volatile
E
item
;
volatile
E
item
;
private
volatile
Node
<
E
>
next
;
volatile
Node
<
E
>
next
;
/**
* Constructs a new node. Uses relaxed write because item can
* only be seen after publication via casNext.
*/
Node
(
E
item
)
{
Node
(
E
item
)
{
// Piggyback on imminent casNext()
UNSAFE
.
putObject
(
this
,
itemOffset
,
item
);
lazySetItem
(
item
);
}
E
getItem
()
{
return
item
;
}
}
boolean
casItem
(
E
cmp
,
E
val
)
{
boolean
casItem
(
E
cmp
,
E
val
)
{
return
UNSAFE
.
compareAndSwapObject
(
this
,
itemOffset
,
cmp
,
val
);
return
UNSAFE
.
compareAndSwapObject
(
this
,
itemOffset
,
cmp
,
val
);
}
}
void
setItem
(
E
val
)
{
item
=
val
;
}
void
lazySetItem
(
E
val
)
{
UNSAFE
.
putOrderedObject
(
this
,
itemOffset
,
val
);
}
void
lazySetNext
(
Node
<
E
>
val
)
{
void
lazySetNext
(
Node
<
E
>
val
)
{
UNSAFE
.
putOrderedObject
(
this
,
nextOffset
,
val
);
UNSAFE
.
putOrderedObject
(
this
,
nextOffset
,
val
);
}
}
Node
<
E
>
getNext
()
{
return
next
;
}
boolean
casNext
(
Node
<
E
>
cmp
,
Node
<
E
>
val
)
{
boolean
casNext
(
Node
<
E
>
cmp
,
Node
<
E
>
val
)
{
return
UNSAFE
.
compareAndSwapObject
(
this
,
nextOffset
,
cmp
,
val
);
return
UNSAFE
.
compareAndSwapObject
(
this
,
nextOffset
,
cmp
,
val
);
}
}
...
@@ -219,7 +214,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -219,7 +214,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* - it is permitted for tail to lag behind head, that is, for tail
* - it is permitted for tail to lag behind head, that is, for tail
* to not be reachable from head!
* to not be reachable from head!
*/
*/
private
transient
volatile
Node
<
E
>
head
=
new
Node
<
E
>(
null
)
;
private
transient
volatile
Node
<
E
>
head
;
/**
/**
* A node from which the last node on list (that is, the unique
* A node from which the last node on list (that is, the unique
...
@@ -233,25 +228,41 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -233,25 +228,41 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* to not be reachable from head!
* to not be reachable from head!
* - tail.next may or may not be self-pointing to tail.
* - tail.next may or may not be self-pointing to tail.
*/
*/
private
transient
volatile
Node
<
E
>
tail
=
head
;
private
transient
volatile
Node
<
E
>
tail
;
/**
/**
* Creates a {@code ConcurrentLinkedQueue} that is initially empty.
* Creates a {@code ConcurrentLinkedQueue} that is initially empty.
*/
*/
public
ConcurrentLinkedQueue
()
{}
public
ConcurrentLinkedQueue
()
{
head
=
tail
=
new
Node
<
E
>(
null
);
}
/**
/**
* Creates a {@code ConcurrentLinkedQueue}
* Creates a {@code ConcurrentLinkedQueue}
* initially containing the elements of the given collection,
* initially containing the elements of the given collection,
* added in traversal order of the collection's iterator.
* added in traversal order of the collection's iterator.
*
* @param c the collection of elements to initially contain
* @param c the collection of elements to initially contain
* @throws NullPointerException if the specified collection or any
* @throws NullPointerException if the specified collection or any
* of its elements are null
* of its elements are null
*/
*/
public
ConcurrentLinkedQueue
(
Collection
<?
extends
E
>
c
)
{
public
ConcurrentLinkedQueue
(
Collection
<?
extends
E
>
c
)
{
for
(
E
e
:
c
)
Node
<
E
>
h
=
null
,
t
=
null
;
add
(
e
);
for
(
E
e
:
c
)
{
checkNotNull
(
e
);
Node
<
E
>
newNode
=
new
Node
<
E
>(
e
);
if
(
h
==
null
)
h
=
t
=
newNode
;
else
{
t
.
lazySetNext
(
newNode
);
t
=
newNode
;
}
}
if
(
h
==
null
)
h
=
t
=
new
Node
<
E
>(
null
);
head
=
h
;
tail
=
t
;
}
}
// Have to override just to update the javadoc
// Have to override just to update the javadoc
...
@@ -266,13 +277,6 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -266,13 +277,6 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
return
offer
(
e
);
return
offer
(
e
);
}
}
/**
* We don't bother to update head or tail pointers if fewer than
* HOPS links from "true" location. We assume that volatile
* writes are significantly more expensive than volatile reads.
*/
private
static
final
int
HOPS
=
1
;
/**
/**
* Try to CAS head to p. If successful, repoint old head to itself
* Try to CAS head to p. If successful, repoint old head to itself
* as sentinel for succ(), below.
* as sentinel for succ(), below.
...
@@ -288,7 +292,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -288,7 +292,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* stale pointer that is now off the list.
* stale pointer that is now off the list.
*/
*/
final
Node
<
E
>
succ
(
Node
<
E
>
p
)
{
final
Node
<
E
>
succ
(
Node
<
E
>
p
)
{
Node
<
E
>
next
=
p
.
getNext
()
;
Node
<
E
>
next
=
p
.
next
;
return
(
p
==
next
)
?
head
:
next
;
return
(
p
==
next
)
?
head
:
next
;
}
}
...
@@ -299,69 +303,76 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -299,69 +303,76 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* @throws NullPointerException if the specified element is null
* @throws NullPointerException if the specified element is null
*/
*/
public
boolean
offer
(
E
e
)
{
public
boolean
offer
(
E
e
)
{
if
(
e
==
null
)
throw
new
NullPointerException
();
checkNotNull
(
e
);
Node
<
E
>
n
=
new
Node
<
E
>(
e
);
final
Node
<
E
>
newNode
=
new
Node
<
E
>(
e
);
retry:
for
(;;)
{
for
(
Node
<
E
>
t
=
tail
,
p
=
t
;;)
{
Node
<
E
>
t
=
tail
;
Node
<
E
>
q
=
p
.
next
;
Node
<
E
>
p
=
t
;
if
(
q
==
null
)
{
for
(
int
hops
=
0
;
;
hops
++)
{
// p is last node
Node
<
E
>
next
=
succ
(
p
);
if
(
p
.
casNext
(
null
,
newNode
))
{
if
(
next
!=
null
)
{
// Successful CAS is the linearization point
if
(
hops
>
HOPS
&&
t
!=
tail
)
// for e to become an element of this queue,
continue
retry
;
// and for newNode to become "live".
p
=
next
;
if
(
p
!=
t
)
// hop two nodes at a time
}
else
if
(
p
.
casNext
(
null
,
n
))
{
casTail
(
t
,
newNode
);
// Failure is OK.
if
(
hops
>=
HOPS
)
casTail
(
t
,
n
);
// Failure is OK.
return
true
;
return
true
;
}
else
{
p
=
succ
(
p
);
}
}
// Lost CAS race to another thread; re-read next
}
}
else
if
(
p
==
q
)
// We have fallen off list. If tail is unchanged, it
// will also be off-list, in which case we need to
// jump to head, from which all live nodes are always
// reachable. Else the new tail is a better bet.
p
=
(
t
!=
(
t
=
tail
))
?
t
:
head
;
else
// Check for tail updates after two hops.
p
=
(
p
!=
t
&&
t
!=
(
t
=
tail
))
?
t
:
q
;
}
}
}
}
public
E
poll
()
{
public
E
poll
()
{
Node
<
E
>
h
=
head
;
restartFromHead:
Node
<
E
>
p
=
h
;
for
(;;)
{
for
(
int
hops
=
0
;
;
hops
++
)
{
for
(
Node
<
E
>
h
=
head
,
p
=
h
,
q
;;
)
{
E
item
=
p
.
getItem
()
;
E
item
=
p
.
item
;
if
(
item
!=
null
&&
p
.
casItem
(
item
,
null
))
{
if
(
item
!=
null
&&
p
.
casItem
(
item
,
null
))
{
if
(
hops
>=
HOPS
)
{
// Successful CAS is the linearization point
Node
<
E
>
q
=
p
.
getNext
();
// for item to be removed from this queue.
updateHead
(
h
,
(
q
!=
null
)
?
q
:
p
);
if
(
p
!=
h
)
// hop two nodes at a time
}
updateHead
(
h
,
((
q
=
p
.
next
)
!=
null
)
?
q
:
p
);
return
item
;
return
item
;
}
}
Node
<
E
>
next
=
succ
(
p
);
else
if
((
q
=
p
.
next
)
==
null
)
{
if
(
next
==
null
)
{
updateHead
(
h
,
p
);
updateHead
(
h
,
p
);
break
;
return
null
;
}
else
if
(
p
==
q
)
continue
restartFromHead
;
else
p
=
q
;
}
}
p
=
next
;
}
}
return
null
;
}
}
public
E
peek
()
{
public
E
peek
()
{
Node
<
E
>
h
=
head
;
restartFromHead:
Node
<
E
>
p
=
h
;
E
item
;
for
(;;)
{
for
(;;)
{
item
=
p
.
getItem
();
for
(
Node
<
E
>
h
=
head
,
p
=
h
,
q
;;)
{
if
(
item
!=
null
)
E
item
=
p
.
item
;
break
;
if
(
item
!=
null
||
(
q
=
p
.
next
)
==
null
)
{
Node
<
E
>
next
=
succ
(
p
);
if
(
next
==
null
)
{
break
;
}
p
=
next
;
}
updateHead
(
h
,
p
);
updateHead
(
h
,
p
);
return
item
;
return
item
;
}
}
else
if
(
p
==
q
)
continue
restartFromHead
;
else
p
=
q
;
}
}
}
/**
/**
* Returns the first live (non-deleted) node on list, or null if none.
* Returns the first live (non-deleted) node on list, or null if none.
...
@@ -372,24 +383,20 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -372,24 +383,20 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* of losing a race to a concurrent poll().
* of losing a race to a concurrent poll().
*/
*/
Node
<
E
>
first
()
{
Node
<
E
>
first
()
{
Node
<
E
>
h
=
head
;
restartFromHead:
Node
<
E
>
p
=
h
;
Node
<
E
>
result
;
for
(;;)
{
for
(;;)
{
E
item
=
p
.
getItem
();
for
(
Node
<
E
>
h
=
head
,
p
=
h
,
q
;;)
{
if
(
item
!=
null
)
{
boolean
hasItem
=
(
p
.
item
!=
null
);
result
=
p
;
if
(
hasItem
||
(
q
=
p
.
next
)
==
null
)
{
break
;
updateHead
(
h
,
p
);
return
hasItem
?
p
:
null
;
}
}
Node
<
E
>
next
=
succ
(
p
);
else
if
(
p
==
q
)
if
(
next
==
null
)
{
continue
restartFromHead
;
result
=
null
;
else
break
;
p
=
q
;
}
}
p
=
next
;
}
}
updateHead
(
h
,
p
);
return
result
;
}
}
/**
/**
...
@@ -410,18 +417,20 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -410,18 +417,20 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* <em>NOT</em> a constant-time operation. Because of the
* <em>NOT</em> a constant-time operation. Because of the
* asynchronous nature of these queues, determining the current
* asynchronous nature of these queues, determining the current
* number of elements requires an O(n) traversal.
* number of elements requires an O(n) traversal.
* Additionally, if elements are added or removed during execution
* of this method, the returned result may be inaccurate. Thus,
* this method is typically not very useful in concurrent
* applications.
*
*
* @return the number of elements in this queue
* @return the number of elements in this queue
*/
*/
public
int
size
()
{
public
int
size
()
{
int
count
=
0
;
int
count
=
0
;
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
if
(
p
.
getItem
()
!=
null
)
{
if
(
p
.
item
!=
null
)
// Collection
s
.size() spec says to max out
// Collection.size() spec says to max out
if
(++
count
==
Integer
.
MAX_VALUE
)
if
(++
count
==
Integer
.
MAX_VALUE
)
break
;
break
;
}
}
return
count
;
return
count
;
}
}
...
@@ -436,9 +445,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -436,9 +445,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
if
(
o
==
null
)
return
false
;
if
(
o
==
null
)
return
false
;
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
getItem
();
E
item
=
p
.
item
;
if
(
item
!=
null
&&
if
(
item
!=
null
&&
o
.
equals
(
item
))
o
.
equals
(
item
))
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -459,7 +467,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -459,7 +467,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
if
(
o
==
null
)
return
false
;
if
(
o
==
null
)
return
false
;
Node
<
E
>
pred
=
null
;
Node
<
E
>
pred
=
null
;
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
getItem
()
;
E
item
=
p
.
item
;
if
(
item
!=
null
&&
if
(
item
!=
null
&&
o
.
equals
(
item
)
&&
o
.
equals
(
item
)
&&
p
.
casItem
(
item
,
null
))
{
p
.
casItem
(
item
,
null
))
{
...
@@ -473,6 +481,69 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -473,6 +481,69 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
return
false
;
return
false
;
}
}
/**
* Appends all of the elements in the specified collection to the end of
* this queue, in the order that they are returned by the specified
* collection's iterator. Attempts to {@code addAll} of a queue to
* itself result in {@code IllegalArgumentException}.
*
* @param c the elements to be inserted into this queue
* @return {@code true} if this queue changed as a result of the call
* @throws NullPointerException if the specified collection or any
* of its elements are null
* @throws IllegalArgumentException if the collection is this queue
*/
public
boolean
addAll
(
Collection
<?
extends
E
>
c
)
{
if
(
c
==
this
)
// As historically specified in AbstractQueue#addAll
throw
new
IllegalArgumentException
();
// Copy c into a private chain of Nodes
Node
<
E
>
beginningOfTheEnd
=
null
,
last
=
null
;
for
(
E
e
:
c
)
{
checkNotNull
(
e
);
Node
<
E
>
newNode
=
new
Node
<
E
>(
e
);
if
(
beginningOfTheEnd
==
null
)
beginningOfTheEnd
=
last
=
newNode
;
else
{
last
.
lazySetNext
(
newNode
);
last
=
newNode
;
}
}
if
(
beginningOfTheEnd
==
null
)
return
false
;
// Atomically append the chain at the tail of this collection
for
(
Node
<
E
>
t
=
tail
,
p
=
t
;;)
{
Node
<
E
>
q
=
p
.
next
;
if
(
q
==
null
)
{
// p is last node
if
(
p
.
casNext
(
null
,
beginningOfTheEnd
))
{
// Successful CAS is the linearization point
// for all elements to be added to this queue.
if
(!
casTail
(
t
,
last
))
{
// Try a little harder to update tail,
// since we may be adding many elements.
t
=
tail
;
if
(
last
.
next
==
null
)
casTail
(
t
,
last
);
}
return
true
;
}
// Lost CAS race to another thread; re-read next
}
else
if
(
p
==
q
)
// We have fallen off list. If tail is unchanged, it
// will also be off-list, in which case we need to
// jump to head, from which all live nodes are always
// reachable. Else the new tail is a better bet.
p
=
(
t
!=
(
t
=
tail
))
?
t
:
head
;
else
// Check for tail updates after two hops.
p
=
(
p
!=
t
&&
t
!=
(
t
=
tail
))
?
t
:
q
;
}
}
/**
/**
* Returns an array containing all of the elements in this queue, in
* Returns an array containing all of the elements in this queue, in
* proper sequence.
* proper sequence.
...
@@ -490,7 +561,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -490,7 +561,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
// Use ArrayList to deal with resizing.
// Use ArrayList to deal with resizing.
ArrayList
<
E
>
al
=
new
ArrayList
<
E
>();
ArrayList
<
E
>
al
=
new
ArrayList
<
E
>();
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
E
item
=
p
.
getItem
()
;
E
item
=
p
.
item
;
if
(
item
!=
null
)
if
(
item
!=
null
)
al
.
add
(
item
);
al
.
add
(
item
);
}
}
...
@@ -539,7 +610,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -539,7 +610,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
int
k
=
0
;
int
k
=
0
;
Node
<
E
>
p
;
Node
<
E
>
p
;
for
(
p
=
first
();
p
!=
null
&&
k
<
a
.
length
;
p
=
succ
(
p
))
{
for
(
p
=
first
();
p
!=
null
&&
k
<
a
.
length
;
p
=
succ
(
p
))
{
E
item
=
p
.
getItem
()
;
E
item
=
p
.
item
;
if
(
item
!=
null
)
if
(
item
!=
null
)
a
[
k
++]
=
(
T
)
item
;
a
[
k
++]
=
(
T
)
item
;
}
}
...
@@ -552,7 +623,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -552,7 +623,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
// If won't fit, use ArrayList version
// If won't fit, use ArrayList version
ArrayList
<
E
>
al
=
new
ArrayList
<
E
>();
ArrayList
<
E
>
al
=
new
ArrayList
<
E
>();
for
(
Node
<
E
>
q
=
first
();
q
!=
null
;
q
=
succ
(
q
))
{
for
(
Node
<
E
>
q
=
first
();
q
!=
null
;
q
=
succ
(
q
))
{
E
item
=
q
.
getItem
()
;
E
item
=
q
.
item
;
if
(
item
!=
null
)
if
(
item
!=
null
)
al
.
add
(
item
);
al
.
add
(
item
);
}
}
...
@@ -561,7 +632,9 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -561,7 +632,9 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
/**
/**
* Returns an iterator over the elements in this queue in proper sequence.
* Returns an iterator over the elements in this queue in proper sequence.
* The returned iterator is a "weakly consistent" iterator that
* The elements will be returned in order from first (head) to last (tail).
*
* <p>The returned {@code Iterator} is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
* ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* and guarantees to traverse elements as they existed upon
...
@@ -620,7 +693,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -620,7 +693,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
nextItem
=
null
;
nextItem
=
null
;
return
x
;
return
x
;
}
}
E
item
=
p
.
getItem
()
;
E
item
=
p
.
item
;
if
(
item
!=
null
)
{
if
(
item
!=
null
)
{
nextNode
=
p
;
nextNode
=
p
;
nextItem
=
item
;
nextItem
=
item
;
...
@@ -648,13 +721,13 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -648,13 +721,13 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
Node
<
E
>
l
=
lastRet
;
Node
<
E
>
l
=
lastRet
;
if
(
l
==
null
)
throw
new
IllegalStateException
();
if
(
l
==
null
)
throw
new
IllegalStateException
();
// rely on a future traversal to relink.
// rely on a future traversal to relink.
l
.
setItem
(
null
)
;
l
.
item
=
null
;
lastRet
=
null
;
lastRet
=
null
;
}
}
}
}
/**
/**
* Save
the state to a stream (that is, serialize
it).
* Save
s the state to a stream (that is, serializes
it).
*
*
* @serialData All of the elements (each an {@code E}) in
* @serialData All of the elements (each an {@code E}) in
* the proper order, followed by a null
* the proper order, followed by a null
...
@@ -668,7 +741,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -668,7 +741,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
// Write out all elements in the proper order.
// Write out all elements in the proper order.
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
for
(
Node
<
E
>
p
=
first
();
p
!=
null
;
p
=
succ
(
p
))
{
Object
item
=
p
.
getItem
()
;
Object
item
=
p
.
item
;
if
(
item
!=
null
)
if
(
item
!=
null
)
s
.
writeObject
(
item
);
s
.
writeObject
(
item
);
}
}
...
@@ -678,25 +751,40 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -678,25 +751,40 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
}
}
/**
/**
* Reconstitute the Queue instance from a stream (that is,
* Reconstitutes the instance from a stream (that is, deserializes it).
* deserialize it).
* @param s the stream
* @param s the stream
*/
*/
private
void
readObject
(
java
.
io
.
ObjectInputStream
s
)
private
void
readObject
(
java
.
io
.
ObjectInputStream
s
)
throws
java
.
io
.
IOException
,
ClassNotFoundException
{
throws
java
.
io
.
IOException
,
ClassNotFoundException
{
// Read in capacity, and any hidden stuff
s
.
defaultReadObject
();
s
.
defaultReadObject
();
head
=
new
Node
<
E
>(
null
);
tail
=
head
;
// Read in elements until trailing null sentinel found
// Read in all elements and place in queue
Node
<
E
>
h
=
null
,
t
=
null
;
for
(;;)
{
Object
item
;
while
((
item
=
s
.
readObject
())
!=
null
)
{
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
E
item
=
(
E
)
s
.
readObject
();
Node
<
E
>
newNode
=
new
Node
<
E
>((
E
)
item
);
if
(
item
==
null
)
if
(
h
==
null
)
break
;
h
=
t
=
newNode
;
else
else
{
offer
(
item
);
t
.
lazySetNext
(
newNode
);
t
=
newNode
;
}
}
}
if
(
h
==
null
)
h
=
t
=
new
Node
<
E
>(
null
);
head
=
h
;
tail
=
t
;
}
/**
* Throws NullPointerException if argument is null.
*
* @param v the element
*/
private
static
void
checkNotNull
(
Object
v
)
{
if
(
v
==
null
)
throw
new
NullPointerException
();
}
}
// Unsafe mechanics
// Unsafe mechanics
...
@@ -715,10 +803,6 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
...
@@ -715,10 +803,6 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
return
UNSAFE
.
compareAndSwapObject
(
this
,
headOffset
,
cmp
,
val
);
return
UNSAFE
.
compareAndSwapObject
(
this
,
headOffset
,
cmp
,
val
);
}
}
private
void
lazySetHead
(
Node
<
E
>
val
)
{
UNSAFE
.
putOrderedObject
(
this
,
headOffset
,
val
);
}
static
long
objectFieldOffset
(
sun
.
misc
.
Unsafe
UNSAFE
,
static
long
objectFieldOffset
(
sun
.
misc
.
Unsafe
UNSAFE
,
String
field
,
Class
<?>
klazz
)
{
String
field
,
Class
<?>
klazz
)
{
try
{
try
{
...
...
src/share/classes/java/util/concurrent/ForkJoinPool.java
浏览文件 @
67166499
...
@@ -42,7 +42,6 @@ import java.util.Collections;
...
@@ -42,7 +42,6 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.AbstractExecutorService
;
import
java.util.concurrent.AbstractExecutorService
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.RejectedExecutionException
;
import
java.util.concurrent.RejectedExecutionException
;
...
@@ -823,15 +822,13 @@ public class ForkJoinPool extends AbstractExecutorService {
...
@@ -823,15 +822,13 @@ public class ForkJoinPool extends AbstractExecutorService {
(
workerCounts
&
RUNNING_COUNT_MASK
)
<=
1
);
(
workerCounts
&
RUNNING_COUNT_MASK
)
<=
1
);
long
startTime
=
untimed
?
0
:
System
.
nanoTime
();
long
startTime
=
untimed
?
0
:
System
.
nanoTime
();
Thread
.
interrupted
();
// clear/ignore interrupt
Thread
.
interrupted
();
// clear/ignore interrupt
if
(
eventCount
!=
ec
||
w
.
runState
!=
0
||
if
(
eventCount
!=
ec
||
w
.
isTerminating
())
runState
>=
TERMINATING
)
// recheck after clear
break
;
// recheck after clear
break
;
if
(
untimed
)
if
(
untimed
)
LockSupport
.
park
(
w
);
LockSupport
.
park
(
w
);
else
{
else
{
LockSupport
.
parkNanos
(
w
,
SHRINK_RATE_NANOS
);
LockSupport
.
parkNanos
(
w
,
SHRINK_RATE_NANOS
);
if
(
eventCount
!=
ec
||
w
.
runState
!=
0
||
if
(
eventCount
!=
ec
||
w
.
isTerminating
())
runState
>=
TERMINATING
)
break
;
break
;
if
(
System
.
nanoTime
()
-
startTime
>=
SHRINK_RATE_NANOS
)
if
(
System
.
nanoTime
()
-
startTime
>=
SHRINK_RATE_NANOS
)
tryShutdownUnusedWorker
(
ec
);
tryShutdownUnusedWorker
(
ec
);
...
@@ -899,16 +896,23 @@ public class ForkJoinPool extends AbstractExecutorService {
...
@@ -899,16 +896,23 @@ public class ForkJoinPool extends AbstractExecutorService {
UNSAFE
.
compareAndSwapInt
(
this
,
workerCountsOffset
,
wc
,
UNSAFE
.
compareAndSwapInt
(
this
,
workerCountsOffset
,
wc
,
wc
+
(
ONE_RUNNING
|
ONE_TOTAL
)))
{
wc
+
(
ONE_RUNNING
|
ONE_TOTAL
)))
{
ForkJoinWorkerThread
w
=
null
;
ForkJoinWorkerThread
w
=
null
;
Throwable
fail
=
null
;
try
{
try
{
w
=
factory
.
newThread
(
this
);
w
=
factory
.
newThread
(
this
);
}
finally
{
// adjust on null or exceptional factory return
}
catch
(
Throwable
ex
)
{
if
(
w
==
null
)
{
fail
=
ex
;
}
if
(
w
==
null
)
{
// null or exceptional factory return
decrementWorkerCounts
(
ONE_RUNNING
,
ONE_TOTAL
);
decrementWorkerCounts
(
ONE_RUNNING
,
ONE_TOTAL
);
tryTerminate
(
false
);
// handle failure during shutdown
tryTerminate
(
false
);
// handle failure during shutdown
}
// If originating from an external caller,
}
// propagate exception, else ignore
if
(
w
==
null
)
if
(
fail
!=
null
&&
runState
<
TERMINATING
&&
!(
Thread
.
currentThread
()
instanceof
ForkJoinWorkerThread
))
UNSAFE
.
throwException
(
fail
);
break
;
break
;
}
w
.
start
(
recordWorker
(
w
),
ueh
);
w
.
start
(
recordWorker
(
w
),
ueh
);
if
((
workerCounts
>>>
TOTAL_COUNT_SHIFT
)
>=
pc
)
{
if
((
workerCounts
>>>
TOTAL_COUNT_SHIFT
)
>=
pc
)
{
int
c
;
// advance event count
int
c
;
// advance event count
...
@@ -997,8 +1001,12 @@ public class ForkJoinPool extends AbstractExecutorService {
...
@@ -997,8 +1001,12 @@ public class ForkJoinPool extends AbstractExecutorService {
boolean
active
=
w
.
active
;
boolean
active
=
w
.
active
;
boolean
inactivate
=
false
;
boolean
inactivate
=
false
;
int
pc
=
parallelism
;
int
pc
=
parallelism
;
int
rs
;
while
(
w
.
runState
==
0
)
{
while
(
w
.
runState
==
0
&&
(
rs
=
runState
)
<
TERMINATING
)
{
int
rs
=
runState
;
if
(
rs
>=
TERMINATING
)
{
// propagate shutdown
w
.
shutdown
();
break
;
}
if
((
inactivate
||
(
active
&&
(
rs
&
ACTIVE_COUNT_MASK
)
>=
pc
))
&&
if
((
inactivate
||
(
active
&&
(
rs
&
ACTIVE_COUNT_MASK
)
>=
pc
))
&&
UNSAFE
.
compareAndSwapInt
(
this
,
runStateOffset
,
rs
,
rs
-
1
))
UNSAFE
.
compareAndSwapInt
(
this
,
runStateOffset
,
rs
,
rs
-
1
))
inactivate
=
active
=
w
.
active
=
false
;
inactivate
=
active
=
w
.
active
=
false
;
...
@@ -1126,6 +1134,7 @@ public class ForkJoinPool extends AbstractExecutorService {
...
@@ -1126,6 +1134,7 @@ public class ForkJoinPool extends AbstractExecutorService {
return
true
;
return
true
;
}
}
/**
/**
* Actions on transition to TERMINATING
* Actions on transition to TERMINATING
*
*
...
@@ -1149,7 +1158,7 @@ public class ForkJoinPool extends AbstractExecutorService {
...
@@ -1149,7 +1158,7 @@ public class ForkJoinPool extends AbstractExecutorService {
if
(
passes
>
0
&&
!
w
.
isTerminated
())
{
if
(
passes
>
0
&&
!
w
.
isTerminated
())
{
w
.
cancelTasks
();
w
.
cancelTasks
();
LockSupport
.
unpark
(
w
);
LockSupport
.
unpark
(
w
);
if
(
passes
>
1
)
{
if
(
passes
>
1
&&
!
w
.
isInterrupted
()
)
{
try
{
try
{
w
.
interrupt
();
w
.
interrupt
();
}
catch
(
SecurityException
ignore
)
{
}
catch
(
SecurityException
ignore
)
{
...
@@ -1725,6 +1734,13 @@ public class ForkJoinPool extends AbstractExecutorService {
...
@@ -1725,6 +1734,13 @@ public class ForkJoinPool extends AbstractExecutorService {
return
(
runState
&
(
TERMINATING
|
TERMINATED
))
==
TERMINATING
;
return
(
runState
&
(
TERMINATING
|
TERMINATED
))
==
TERMINATING
;
}
}
/**
* Returns true if terminating or terminated. Used by ForkJoinWorkerThread.
*/
final
boolean
isAtLeastTerminating
()
{
return
runState
>=
TERMINATING
;
}
/**
/**
* Returns {@code true} if this pool has been shut down.
* Returns {@code true} if this pool has been shut down.
*
*
...
...
src/share/classes/java/util/concurrent/ForkJoinTask.java
浏览文件 @
67166499
...
@@ -55,10 +55,10 @@ import java.util.WeakHashMap;
...
@@ -55,10 +55,10 @@ import java.util.WeakHashMap;
* start other subtasks. As indicated by the name of this class,
* start other subtasks. As indicated by the name of this class,
* many programs using {@code ForkJoinTask} employ only methods
* many programs using {@code ForkJoinTask} employ only methods
* {@link #fork} and {@link #join}, or derivatives such as {@link
* {@link #fork} and {@link #join}, or derivatives such as {@link
* #invokeAll
}. However, this class also provides a number of other
* #invokeAll
(ForkJoinTask...) invokeAll}. However, this class also
*
methods that can come into play in advanced usages, as well as
*
provides a number of other methods that can come into play in
*
extension mechanics that allow support of new forms of fork/join
*
advanced usages, as well as extension mechanics that allow
* processing.
*
support of new forms of fork/join
processing.
*
*
* <p>A {@code ForkJoinTask} is a lightweight form of {@link Future}.
* <p>A {@code ForkJoinTask} is a lightweight form of {@link Future}.
* The efficiency of {@code ForkJoinTask}s stems from a set of
* The efficiency of {@code ForkJoinTask}s stems from a set of
...
@@ -250,7 +250,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
...
@@ -250,7 +250,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
int
s
;
// the odd construction reduces lock bias effects
int
s
;
// the odd construction reduces lock bias effects
while
((
s
=
status
)
>=
0
)
{
while
((
s
=
status
)
>=
0
)
{
try
{
try
{
synchronized
(
this
)
{
synchronized
(
this
)
{
if
(
UNSAFE
.
compareAndSwapInt
(
this
,
statusOffset
,
s
,
SIGNAL
))
if
(
UNSAFE
.
compareAndSwapInt
(
this
,
statusOffset
,
s
,
SIGNAL
))
wait
();
wait
();
}
}
...
@@ -270,7 +270,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
...
@@ -270,7 +270,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
int
s
;
int
s
;
if
((
s
=
status
)
>=
0
)
{
if
((
s
=
status
)
>=
0
)
{
try
{
try
{
synchronized
(
this
)
{
synchronized
(
this
)
{
if
(
UNSAFE
.
compareAndSwapInt
(
this
,
statusOffset
,
s
,
SIGNAL
))
if
(
UNSAFE
.
compareAndSwapInt
(
this
,
statusOffset
,
s
,
SIGNAL
))
wait
(
millis
,
0
);
wait
(
millis
,
0
);
}
}
...
@@ -288,7 +288,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
...
@@ -288,7 +288,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
private
void
externalAwaitDone
()
{
private
void
externalAwaitDone
()
{
int
s
;
int
s
;
while
((
s
=
status
)
>=
0
)
{
while
((
s
=
status
)
>=
0
)
{
synchronized
(
this
)
{
synchronized
(
this
)
{
if
(
UNSAFE
.
compareAndSwapInt
(
this
,
statusOffset
,
s
,
SIGNAL
)){
if
(
UNSAFE
.
compareAndSwapInt
(
this
,
statusOffset
,
s
,
SIGNAL
)){
boolean
interrupted
=
false
;
boolean
interrupted
=
false
;
while
(
status
>=
0
)
{
while
(
status
>=
0
)
{
...
@@ -669,11 +669,34 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
...
@@ -669,11 +669,34 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
setCompletion
(
NORMAL
);
setCompletion
(
NORMAL
);
}
}
/**
* Waits if necessary for the computation to complete, and then
* retrieves its result.
*
* @return the computed result
* @throws CancellationException if the computation was cancelled
* @throws ExecutionException if the computation threw an
* exception
* @throws InterruptedException if the current thread is not a
* member of a ForkJoinPool and was interrupted while waiting
*/
public
final
V
get
()
throws
InterruptedException
,
ExecutionException
{
public
final
V
get
()
throws
InterruptedException
,
ExecutionException
{
int
s
;
if
(
Thread
.
currentThread
()
instanceof
ForkJoinWorkerThread
)
{
quietlyJoin
();
quietlyJoin
();
if
(
Thread
.
interrupted
())
s
=
status
;
throw
new
InterruptedException
();
}
int
s
=
status
;
else
{
while
((
s
=
status
)
>=
0
)
{
synchronized
(
this
)
{
// interruptible form of awaitDone
if
(
UNSAFE
.
compareAndSwapInt
(
this
,
statusOffset
,
s
,
SIGNAL
))
{
while
(
status
>=
0
)
wait
();
}
}
}
}
if
(
s
<
NORMAL
)
{
if
(
s
<
NORMAL
)
{
Throwable
ex
;
Throwable
ex
;
if
(
s
==
CANCELLED
)
if
(
s
==
CANCELLED
)
...
@@ -684,6 +707,20 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
...
@@ -684,6 +707,20 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
return
getRawResult
();
return
getRawResult
();
}
}
/**
* Waits if necessary for at most the given time for the computation
* to complete, and then retrieves its result, if available.
*
* @param timeout the maximum time to wait
* @param unit the time unit of the timeout argument
* @return the computed result
* @throws CancellationException if the computation was cancelled
* @throws ExecutionException if the computation threw an
* exception
* @throws InterruptedException if the current thread is not a
* member of a ForkJoinPool and was interrupted while waiting
* @throws TimeoutException if the wait timed out
*/
public
final
V
get
(
long
timeout
,
TimeUnit
unit
)
public
final
V
get
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
,
ExecutionException
,
TimeoutException
{
throws
InterruptedException
,
ExecutionException
,
TimeoutException
{
Thread
t
=
Thread
.
currentThread
();
Thread
t
=
Thread
.
currentThread
();
...
@@ -725,7 +762,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
...
@@ -725,7 +762,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
long
ms
=
nt
/
1000000
;
long
ms
=
nt
/
1000000
;
int
ns
=
(
int
)
(
nt
%
1000000
);
int
ns
=
(
int
)
(
nt
%
1000000
);
try
{
try
{
synchronized
(
this
)
{
synchronized
(
this
)
{
if
(
status
>=
0
)
if
(
status
>=
0
)
wait
(
ms
,
ns
);
wait
(
ms
,
ns
);
}
}
...
...
src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
浏览文件 @
67166499
...
@@ -778,11 +778,20 @@ public class ForkJoinWorkerThread extends Thread {
...
@@ -778,11 +778,20 @@ public class ForkJoinWorkerThread extends Thread {
// status check methods used mainly by ForkJoinPool
// status check methods used mainly by ForkJoinPool
final
boolean
isRunning
()
{
return
runState
==
0
;
}
final
boolean
isRunning
()
{
return
runState
==
0
;
}
final
boolean
isTerminating
()
{
return
(
runState
&
TERMINATING
)
!=
0
;
}
final
boolean
isTerminated
()
{
return
(
runState
&
TERMINATED
)
!=
0
;
}
final
boolean
isTerminated
()
{
return
(
runState
&
TERMINATED
)
!=
0
;
}
final
boolean
isSuspended
()
{
return
(
runState
&
SUSPENDED
)
!=
0
;
}
final
boolean
isSuspended
()
{
return
(
runState
&
SUSPENDED
)
!=
0
;
}
final
boolean
isTrimmed
()
{
return
(
runState
&
TRIMMED
)
!=
0
;
}
final
boolean
isTrimmed
()
{
return
(
runState
&
TRIMMED
)
!=
0
;
}
final
boolean
isTerminating
()
{
if
((
runState
&
TERMINATING
)
!=
0
)
return
true
;
if
(
pool
.
isAtLeastTerminating
())
{
// propagate pool state
shutdown
();
return
true
;
}
return
false
;
}
/**
/**
* Sets state to TERMINATING. Does NOT unpark or interrupt
* Sets state to TERMINATING. Does NOT unpark or interrupt
* to wake up if currently blocked. Callers must do so if desired.
* to wake up if currently blocked. Callers must do so if desired.
...
...
src/share/classes/java/util/concurrent/RecursiveAction.java
浏览文件 @
67166499
...
@@ -138,7 +138,7 @@ package java.util.concurrent;
...
@@ -138,7 +138,7 @@ package java.util.concurrent;
* if (right.tryUnfork()) // directly calculate if not stolen
* if (right.tryUnfork()) // directly calculate if not stolen
* sum += right.atLeaf(right.lo, right.hi);
* sum += right.atLeaf(right.lo, right.hi);
* else {
* else {
* right.
helpJ
oin();
* right.
j
oin();
* sum += right.result;
* sum += right.result;
* }
* }
* right = right.next;
* right = right.next;
...
...
src/share/classes/java/util/logging/LogManager.java
浏览文件 @
67166499
...
@@ -690,6 +690,11 @@ public class LogManager {
...
@@ -690,6 +690,11 @@ public class LogManager {
* Note that since untrusted code may create loggers with
* Note that since untrusted code may create loggers with
* arbitrary names this method should not be relied on to
* arbitrary names this method should not be relied on to
* find Loggers for security sensitive logging.
* find Loggers for security sensitive logging.
* It is also important to note that the Logger associated with the
* String {@code name} may be garbage collected at any time if there
* is no strong reference to the Logger. The caller of this method
* must check the return value for null in order to properly handle
* the case where the Logger has been garbage collected.
* <p>
* <p>
* @param name name of the logger
* @param name name of the logger
* @return matching logger or null if none is found
* @return matching logger or null if none is found
...
@@ -713,6 +718,14 @@ public class LogManager {
...
@@ -713,6 +718,14 @@ public class LogManager {
* <p>
* <p>
* Note: Loggers may be added dynamically as new classes are loaded.
* Note: Loggers may be added dynamically as new classes are loaded.
* This method only reports on the loggers that are currently registered.
* This method only reports on the loggers that are currently registered.
* It is also important to note that this method only returns the name
* of a Logger, not a strong reference to the Logger itself.
* The returned String does nothing to prevent the Logger from being
* garbage collected. In particular, if the returned name is passed
* to {@code LogManager.getLogger()}, then the caller must check the
* return value from {@code LogManager.getLogger()} for null to properly
* handle the case where the Logger has been garbage collected in the
* time since its name was returned by this method.
* <p>
* <p>
* @return enumeration of logger name strings
* @return enumeration of logger name strings
*/
*/
...
...
src/share/classes/java/util/logging/Logger.java
浏览文件 @
67166499
...
@@ -42,7 +42,10 @@ import java.lang.ref.WeakReference;
...
@@ -42,7 +42,10 @@ import java.lang.ref.WeakReference;
* <p>
* <p>
* Logger objects may be obtained by calls on one of the getLogger
* Logger objects may be obtained by calls on one of the getLogger
* factory methods. These will either create a new Logger or
* factory methods. These will either create a new Logger or
* return a suitable existing Logger.
* return a suitable existing Logger. It is important to note that
* the Logger returned by one of the {@code getLogger} factory methods
* may be garbage collected at any time if a strong reference to the
* Logger is not kept.
* <p>
* <p>
* Logging messages will be forwarded to registered Handler
* Logging messages will be forwarded to registered Handler
* objects, which can forward the messages to a variety of
* objects, which can forward the messages to a variety of
...
@@ -210,7 +213,9 @@ public class Logger {
...
@@ -210,7 +213,9 @@ public class Logger {
* who are making serious use of the logging package (for example
* who are making serious use of the logging package (for example
* in products) should create and use their own Logger objects,
* in products) should create and use their own Logger objects,
* with appropriate names, so that logging can be controlled on a
* with appropriate names, so that logging can be controlled on a
* suitable per-Logger granularity.
* suitable per-Logger granularity. Developers also need to keep a
* strong reference to their Logger objects to prevent them from
* being garbage collected.
* <p>
* <p>
* @deprecated Initialization of this field is prone to deadlocks.
* @deprecated Initialization of this field is prone to deadlocks.
* The field must be initialized by the Logger class initialization
* The field must be initialized by the Logger class initialization
...
@@ -287,6 +292,15 @@ public class Logger {
...
@@ -287,6 +292,15 @@ public class Logger {
* based on the LogManager configuration and it will configured
* based on the LogManager configuration and it will configured
* to also send logging output to its parent's Handlers. It will
* to also send logging output to its parent's Handlers. It will
* be registered in the LogManager global namespace.
* be registered in the LogManager global namespace.
* <p>
* Note: The LogManager may only retain a weak reference to the newly
* created Logger. It is important to understand that a previously
* created Logger with the given name may be garbage collected at any
* time if there is no strong reference to the Logger. In particular,
* this means that two back-to-back calls like
* {@code getLogger("MyLogger").log(...)} may use different Logger
* objects named "MyLogger" if there is no strong reference to the
* Logger named "MyLogger" elsewhere in the program.
*
*
* @param name A name for the logger. This should
* @param name A name for the logger. This should
* be a dot-separated name and should normally
* be a dot-separated name and should normally
...
@@ -311,6 +325,15 @@ public class Logger {
...
@@ -311,6 +325,15 @@ public class Logger {
* output to its parent's Handlers. It will be registered in
* output to its parent's Handlers. It will be registered in
* the LogManager global namespace.
* the LogManager global namespace.
* <p>
* <p>
* Note: The LogManager may only retain a weak reference to the newly
* created Logger. It is important to understand that a previously
* created Logger with the given name may be garbage collected at any
* time if there is no strong reference to the Logger. In particular,
* this means that two back-to-back calls like
* {@code getLogger("MyLogger", ...).log(...)} may use different Logger
* objects named "MyLogger" if there is no strong reference to the
* Logger named "MyLogger" elsewhere in the program.
* <p>
* If the named Logger already exists and does not yet have a
* If the named Logger already exists and does not yet have a
* localization resource bundle then the given resource bundle
* localization resource bundle then the given resource bundle
* name is used. If the named Logger already exists and has
* name is used. If the named Logger already exists and has
...
...
src/share/classes/javax/sql/rowset/BaseRowSet.java
浏览文件 @
67166499
/*
/*
* Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
10
, 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
...
@@ -734,7 +734,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -734,7 +734,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw
new
SQLException
(
"Set initParams() before setCommand"
);
throw
new
SQLException
(
"Set initParams() before setCommand"
);
}
}
params
.
clear
();
params
.
clear
();
command
=
new
String
(
cmd
)
;
command
=
cmd
;
}
}
}
}
...
@@ -797,7 +797,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -797,7 +797,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw
new
SQLException
(
"Invalid url string detected. "
+
throw
new
SQLException
(
"Invalid url string detected. "
+
"Cannot be of length less than 1"
);
"Cannot be of length less than 1"
);
}
else
{
}
else
{
URL
=
new
String
(
url
)
;
URL
=
url
;
}
}
dataSource
=
null
;
dataSource
=
null
;
...
@@ -854,7 +854,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -854,7 +854,7 @@ public static final int ASCII_STREAM_PARAM = 2;
}
else
if
(
name
.
equals
(
""
))
{
}
else
if
(
name
.
equals
(
""
))
{
throw
new
SQLException
(
"DataSource name cannot be empty string"
);
throw
new
SQLException
(
"DataSource name cannot be empty string"
);
}
else
{
}
else
{
dataSource
=
n
ew
String
(
name
)
;
dataSource
=
n
ame
;
}
}
URL
=
null
;
URL
=
null
;
...
@@ -889,7 +889,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -889,7 +889,7 @@ public static final int ASCII_STREAM_PARAM = 2;
{
{
username
=
null
;
username
=
null
;
}
else
{
}
else
{
username
=
n
ew
String
(
name
)
;
username
=
n
ame
;
}
}
}
}
...
@@ -924,7 +924,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -924,7 +924,7 @@ public static final int ASCII_STREAM_PARAM = 2;
{
{
password
=
null
;
password
=
null
;
}
else
{
}
else
{
password
=
new
String
(
pass
)
;
password
=
pass
;
}
}
}
}
...
@@ -1563,13 +1563,13 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1563,13 +1563,13 @@ public static final int ASCII_STREAM_PARAM = 2;
nullVal
=
new
Object
[
2
];
nullVal
=
new
Object
[
2
];
nullVal
[
0
]
=
null
;
nullVal
[
0
]
=
null
;
nullVal
[
1
]
=
new
Integer
(
sqlType
);
nullVal
[
1
]
=
Integer
.
valueOf
(
sqlType
);
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setNull"
);
throw
new
SQLException
(
"Set initParams() before setNull"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
nullVal
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
nullVal
);
}
}
/**
/**
...
@@ -1644,14 +1644,14 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1644,14 +1644,14 @@ public static final int ASCII_STREAM_PARAM = 2;
nullVal
=
new
Object
[
3
];
nullVal
=
new
Object
[
3
];
nullVal
[
0
]
=
null
;
nullVal
[
0
]
=
null
;
nullVal
[
1
]
=
new
Integer
(
sqlType
);
nullVal
[
1
]
=
Integer
.
valueOf
(
sqlType
);
nullVal
[
2
]
=
new
String
(
typeName
)
;
nullVal
[
2
]
=
typeName
;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setNull"
);
throw
new
SQLException
(
"Set initParams() before setNull"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
nullVal
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
nullVal
);
}
}
...
@@ -1686,7 +1686,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1686,7 +1686,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw
new
SQLException
(
"Set initParams() before setNull"
);
throw
new
SQLException
(
"Set initParams() before setNull"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
Boolean
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
Boolean
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -1720,7 +1720,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1720,7 +1720,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw
new
SQLException
(
"Set initParams() before setByte"
);
throw
new
SQLException
(
"Set initParams() before setByte"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
Byte
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
Byte
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -1754,7 +1754,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1754,7 +1754,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw
new
SQLException
(
"Set initParams() before setShort"
);
throw
new
SQLException
(
"Set initParams() before setShort"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
Short
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
Short
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -1786,7 +1786,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1786,7 +1786,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setInt"
);
throw
new
SQLException
(
"Set initParams() before setInt"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
Integer
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
Integer
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -1818,7 +1818,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1818,7 +1818,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setLong"
);
throw
new
SQLException
(
"Set initParams() before setLong"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
Long
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
Long
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -1850,7 +1850,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1850,7 +1850,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setFloat"
);
throw
new
SQLException
(
"Set initParams() before setFloat"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
Float
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
new
Float
(
x
));
}
}
/**
/**
...
@@ -1882,7 +1882,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1882,7 +1882,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setDouble"
);
throw
new
SQLException
(
"Set initParams() before setDouble"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
Double
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
new
Double
(
x
));
}
}
/**
/**
...
@@ -1914,7 +1914,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1914,7 +1914,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setBigDecimal"
);
throw
new
SQLException
(
"Set initParams() before setBigDecimal"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
x
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
x
);
}
}
/**
/**
...
@@ -1948,7 +1948,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1948,7 +1948,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setString"
);
throw
new
SQLException
(
"Set initParams() before setString"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
x
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
x
);
}
}
/**
/**
...
@@ -1982,7 +1982,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -1982,7 +1982,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setBytes"
);
throw
new
SQLException
(
"Set initParams() before setBytes"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
x
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
x
);
}
}
/**
/**
...
@@ -2024,7 +2024,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2024,7 +2024,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setDate"
);
throw
new
SQLException
(
"Set initParams() before setDate"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
x
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
x
);
}
}
/**
/**
...
@@ -2069,7 +2069,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2069,7 +2069,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw
new
SQLException
(
"Set initParams() before setTime"
);
throw
new
SQLException
(
"Set initParams() before setTime"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
x
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
x
);
}
}
/**
/**
...
@@ -2112,7 +2112,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2112,7 +2112,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw
new
SQLException
(
"Set initParams() before setTimestamp"
);
throw
new
SQLException
(
"Set initParams() before setTimestamp"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
x
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
x
);
}
}
/**
/**
...
@@ -2185,14 +2185,14 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2185,14 +2185,14 @@ public static final int ASCII_STREAM_PARAM = 2;
asciiStream
=
new
Object
[
3
];
asciiStream
=
new
Object
[
3
];
asciiStream
[
0
]
=
x
;
asciiStream
[
0
]
=
x
;
asciiStream
[
1
]
=
new
Integer
(
length
);
asciiStream
[
1
]
=
Integer
.
valueOf
(
length
);
asciiStream
[
2
]
=
new
Integer
(
ASCII_STREAM_PARAM
);
asciiStream
[
2
]
=
Integer
.
valueOf
(
ASCII_STREAM_PARAM
);
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setAsciiStream"
);
throw
new
SQLException
(
"Set initParams() before setAsciiStream"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
asciiStream
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
asciiStream
);
}
}
/**
/**
...
@@ -2290,13 +2290,13 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2290,13 +2290,13 @@ public static final int ASCII_STREAM_PARAM = 2;
binaryStream
=
new
Object
[
3
];
binaryStream
=
new
Object
[
3
];
binaryStream
[
0
]
=
x
;
binaryStream
[
0
]
=
x
;
binaryStream
[
1
]
=
new
Integer
(
length
);
binaryStream
[
1
]
=
Integer
.
valueOf
(
length
);
binaryStream
[
2
]
=
new
Integer
(
BINARY_STREAM_PARAM
);
binaryStream
[
2
]
=
Integer
.
valueOf
(
BINARY_STREAM_PARAM
);
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setBinaryStream"
);
throw
new
SQLException
(
"Set initParams() before setBinaryStream"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
binaryStream
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
binaryStream
);
}
}
...
@@ -2396,12 +2396,12 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2396,12 +2396,12 @@ public static final int ASCII_STREAM_PARAM = 2;
unicodeStream
=
new
Object
[
3
];
unicodeStream
=
new
Object
[
3
];
unicodeStream
[
0
]
=
x
;
unicodeStream
[
0
]
=
x
;
unicodeStream
[
1
]
=
new
Integer
(
length
);
unicodeStream
[
1
]
=
Integer
.
valueOf
(
length
);
unicodeStream
[
2
]
=
new
Integer
(
UNICODE_STREAM_PARAM
);
unicodeStream
[
2
]
=
Integer
.
valueOf
(
UNICODE_STREAM_PARAM
);
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setUnicodeStream"
);
throw
new
SQLException
(
"Set initParams() before setUnicodeStream"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
unicodeStream
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
unicodeStream
);
}
}
/**
/**
...
@@ -2475,11 +2475,11 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2475,11 +2475,11 @@ public static final int ASCII_STREAM_PARAM = 2;
charStream
=
new
Object
[
2
];
charStream
=
new
Object
[
2
];
charStream
[
0
]
=
reader
;
charStream
[
0
]
=
reader
;
charStream
[
1
]
=
new
Integer
(
length
);
charStream
[
1
]
=
Integer
.
valueOf
(
length
);
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setCharacterStream"
);
throw
new
SQLException
(
"Set initParams() before setCharacterStream"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
charStream
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
charStream
);
}
}
/**
/**
...
@@ -2591,12 +2591,12 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2591,12 +2591,12 @@ public static final int ASCII_STREAM_PARAM = 2;
obj
=
new
Object
[
3
];
obj
=
new
Object
[
3
];
obj
[
0
]
=
x
;
obj
[
0
]
=
x
;
obj
[
1
]
=
new
Integer
(
targetSqlType
);
obj
[
1
]
=
Integer
.
valueOf
(
targetSqlType
);
obj
[
2
]
=
new
Integer
(
scale
);
obj
[
2
]
=
Integer
.
valueOf
(
scale
);
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setObject"
);
throw
new
SQLException
(
"Set initParams() before setObject"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
obj
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
obj
);
}
}
/**
/**
...
@@ -2654,11 +2654,11 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2654,11 +2654,11 @@ public static final int ASCII_STREAM_PARAM = 2;
obj
=
new
Object
[
2
];
obj
=
new
Object
[
2
];
obj
[
0
]
=
x
;
obj
[
0
]
=
x
;
obj
[
1
]
=
new
Integer
(
targetSqlType
);
obj
[
1
]
=
Integer
.
valueOf
(
targetSqlType
);
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setObject"
);
throw
new
SQLException
(
"Set initParams() before setObject"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
obj
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
obj
);
}
}
/**
/**
...
@@ -2726,7 +2726,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2726,7 +2726,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
)
{
if
(
params
==
null
)
{
throw
new
SQLException
(
"Set initParams() before setObject"
);
throw
new
SQLException
(
"Set initParams() before setObject"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
x
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
x
);
}
}
/**
/**
...
@@ -2773,7 +2773,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2773,7 +2773,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
)
{
if
(
params
==
null
)
{
throw
new
SQLException
(
"Set initParams() before setRef"
);
throw
new
SQLException
(
"Set initParams() before setRef"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
SerialRef
(
ref
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
new
SerialRef
(
ref
));
}
}
/**
/**
...
@@ -2817,7 +2817,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2817,7 +2817,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setBlob"
);
throw
new
SQLException
(
"Set initParams() before setBlob"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
SerialBlob
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
new
SerialBlob
(
x
));
}
}
/**
/**
...
@@ -2862,7 +2862,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2862,7 +2862,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setClob"
);
throw
new
SQLException
(
"Set initParams() before setClob"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
SerialClob
(
x
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
new
SerialClob
(
x
));
}
}
/**
/**
...
@@ -2910,7 +2910,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2910,7 +2910,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setArray"
);
throw
new
SQLException
(
"Set initParams() before setArray"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
new
SerialArray
(
array
));
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
new
SerialArray
(
array
));
}
}
/**
/**
...
@@ -2975,7 +2975,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -2975,7 +2975,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setDate"
);
throw
new
SQLException
(
"Set initParams() before setDate"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
date
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
date
);
}
}
/**
/**
...
@@ -3041,7 +3041,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -3041,7 +3041,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setTime"
);
throw
new
SQLException
(
"Set initParams() before setTime"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
time
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
time
);
}
}
/**
/**
...
@@ -3107,7 +3107,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -3107,7 +3107,7 @@ public static final int ASCII_STREAM_PARAM = 2;
if
(
params
==
null
){
if
(
params
==
null
){
throw
new
SQLException
(
"Set initParams() before setTimestamp"
);
throw
new
SQLException
(
"Set initParams() before setTimestamp"
);
}
}
params
.
put
(
new
Integer
(
parameterIndex
-
1
),
timestamp
);
params
.
put
(
Integer
.
valueOf
(
parameterIndex
-
1
),
timestamp
);
}
}
/**
/**
...
@@ -3181,7 +3181,7 @@ public static final int ASCII_STREAM_PARAM = 2;
...
@@ -3181,7 +3181,7 @@ public static final int ASCII_STREAM_PARAM = 2;
Object
[]
paramsArray
=
new
Object
[
params
.
size
()];
Object
[]
paramsArray
=
new
Object
[
params
.
size
()];
for
(
int
i
=
0
;
i
<
params
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
params
.
size
();
i
++)
{
paramsArray
[
i
]
=
params
.
get
(
new
Integer
(
i
));
paramsArray
[
i
]
=
params
.
get
(
Integer
.
valueOf
(
i
));
if
(
paramsArray
[
i
]
==
null
)
{
if
(
paramsArray
[
i
]
==
null
)
{
throw
new
SQLException
(
"missing parameter: "
+
(
i
+
1
));
throw
new
SQLException
(
"missing parameter: "
+
(
i
+
1
));
}
//end if
}
//end if
...
...
src/share/classes/javax/sql/rowset/CachedRowSet.java
浏览文件 @
67166499
...
@@ -39,7 +39,7 @@ import javax.sql.rowset.spi.*;
...
@@ -39,7 +39,7 @@ import javax.sql.rowset.spi.*;
* <code>CachedRowSet</code> must implement.
* <code>CachedRowSet</code> must implement.
* <P>
* <P>
* The reference implementation of the <code>CachedRowSet</code> interface provided
* The reference implementation of the <code>CachedRowSet</code> interface provided
* by
Sun Microsystems
is a standard implementation. Developers may use this implementation
* by
Oracle Corporation
is a standard implementation. Developers may use this implementation
* just as it is, they may extend it, or they may choose to write their own implementations
* just as it is, they may extend it, or they may choose to write their own implementations
* of this interface.
* of this interface.
* <P>
* <P>
...
@@ -1623,4 +1623,3 @@ public interface CachedRowSet extends RowSet, Joinable {
...
@@ -1623,4 +1623,3 @@ public interface CachedRowSet extends RowSet, Joinable {
public
boolean
previousPage
()
throws
SQLException
;
public
boolean
previousPage
()
throws
SQLException
;
}
}
src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java
浏览文件 @
67166499
/*
/*
* Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
10
, 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
...
@@ -306,9 +306,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
...
@@ -306,9 +306,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public
void
setColumnLabel
(
int
columnIndex
,
String
label
)
throws
SQLException
{
public
void
setColumnLabel
(
int
columnIndex
,
String
label
)
throws
SQLException
{
checkColRange
(
columnIndex
);
checkColRange
(
columnIndex
);
if
(
label
!=
null
)
{
if
(
label
!=
null
)
{
colInfo
[
columnIndex
].
columnLabel
=
new
String
(
label
)
;
colInfo
[
columnIndex
].
columnLabel
=
label
;
}
else
{
}
else
{
colInfo
[
columnIndex
].
columnLabel
=
new
String
(
""
)
;
colInfo
[
columnIndex
].
columnLabel
=
""
;
}
}
}
}
...
@@ -326,9 +326,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
...
@@ -326,9 +326,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public
void
setColumnName
(
int
columnIndex
,
String
columnName
)
throws
SQLException
{
public
void
setColumnName
(
int
columnIndex
,
String
columnName
)
throws
SQLException
{
checkColRange
(
columnIndex
);
checkColRange
(
columnIndex
);
if
(
columnName
!=
null
)
{
if
(
columnName
!=
null
)
{
colInfo
[
columnIndex
].
columnName
=
new
String
(
columnName
)
;
colInfo
[
columnIndex
].
columnName
=
columnName
;
}
else
{
}
else
{
colInfo
[
columnIndex
].
columnName
=
new
String
(
""
)
;
colInfo
[
columnIndex
].
columnName
=
""
;
}
}
}
}
...
@@ -348,9 +348,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
...
@@ -348,9 +348,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public
void
setSchemaName
(
int
columnIndex
,
String
schemaName
)
throws
SQLException
{
public
void
setSchemaName
(
int
columnIndex
,
String
schemaName
)
throws
SQLException
{
checkColRange
(
columnIndex
);
checkColRange
(
columnIndex
);
if
(
schemaName
!=
null
)
{
if
(
schemaName
!=
null
)
{
colInfo
[
columnIndex
].
schemaName
=
new
String
(
schemaName
)
;
colInfo
[
columnIndex
].
schemaName
=
schemaName
;
}
else
{
}
else
{
colInfo
[
columnIndex
].
schemaName
=
new
String
(
""
)
;
colInfo
[
columnIndex
].
schemaName
=
""
;
}
}
}
}
...
@@ -411,9 +411,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
...
@@ -411,9 +411,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public
void
setTableName
(
int
columnIndex
,
String
tableName
)
throws
SQLException
{
public
void
setTableName
(
int
columnIndex
,
String
tableName
)
throws
SQLException
{
checkColRange
(
columnIndex
);
checkColRange
(
columnIndex
);
if
(
tableName
!=
null
)
{
if
(
tableName
!=
null
)
{
colInfo
[
columnIndex
].
tableName
=
new
String
(
tableName
)
;
colInfo
[
columnIndex
].
tableName
=
tableName
;
}
else
{
}
else
{
colInfo
[
columnIndex
].
tableName
=
new
String
(
""
)
;
colInfo
[
columnIndex
].
tableName
=
""
;
}
}
}
}
...
@@ -432,9 +432,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
...
@@ -432,9 +432,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public
void
setCatalogName
(
int
columnIndex
,
String
catalogName
)
throws
SQLException
{
public
void
setCatalogName
(
int
columnIndex
,
String
catalogName
)
throws
SQLException
{
checkColRange
(
columnIndex
);
checkColRange
(
columnIndex
);
if
(
catalogName
!=
null
)
if
(
catalogName
!=
null
)
colInfo
[
columnIndex
].
catName
=
new
String
(
catalogName
)
;
colInfo
[
columnIndex
].
catName
=
catalogName
;
else
else
colInfo
[
columnIndex
].
catName
=
new
String
(
""
)
;
colInfo
[
columnIndex
].
catName
=
""
;
}
}
/**
/**
...
@@ -474,9 +474,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
...
@@ -474,9 +474,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
throws
SQLException
{
throws
SQLException
{
checkColRange
(
columnIndex
);
checkColRange
(
columnIndex
);
if
(
typeName
!=
null
)
{
if
(
typeName
!=
null
)
{
colInfo
[
columnIndex
].
colTypeName
=
new
String
(
typeName
)
;
colInfo
[
columnIndex
].
colTypeName
=
typeName
;
}
else
{
}
else
{
colInfo
[
columnIndex
].
colTypeName
=
new
String
(
""
)
;
colInfo
[
columnIndex
].
colTypeName
=
""
;
}
}
}
}
...
@@ -827,7 +827,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
...
@@ -827,7 +827,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
* or the given column number is out of bounds
* or the given column number is out of bounds
*/
*/
public
String
getColumnClassName
(
int
columnIndex
)
throws
SQLException
{
public
String
getColumnClassName
(
int
columnIndex
)
throws
SQLException
{
String
className
=
(
new
String
()).
getClass
()
.
getName
();
String
className
=
String
.
class
.
getName
();
int
sqlType
=
getColumnType
(
columnIndex
);
int
sqlType
=
getColumnType
(
columnIndex
);
...
@@ -835,65 +835,62 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
...
@@ -835,65 +835,62 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
case
Types
.
NUMERIC
:
case
Types
.
NUMERIC
:
case
Types
.
DECIMAL
:
case
Types
.
DECIMAL
:
className
=
(
new
java
.
math
.
BigDecimal
(
0
)).
getClass
().
getName
();
className
=
java
.
math
.
BigDecimal
.
class
.
getName
();
break
;
break
;
case
Types
.
BIT
:
case
Types
.
BIT
:
className
=
(
new
Boolean
(
false
)).
getClass
().
getName
();
className
=
java
.
lang
.
Boolean
.
class
.
getName
();
break
;
break
;
case
Types
.
TINYINT
:
case
Types
.
TINYINT
:
className
=
(
new
Byte
(
"0"
)).
getClass
().
getName
();
className
=
java
.
lang
.
Byte
.
class
.
getName
();
break
;
break
;
case
Types
.
SMALLINT
:
case
Types
.
SMALLINT
:
className
=
(
new
Short
(
"0"
)).
getClass
().
getName
();
className
=
java
.
lang
.
Short
.
class
.
getName
();
break
;
break
;
case
Types
.
INTEGER
:
case
Types
.
INTEGER
:
className
=
(
new
Integer
(
0
)).
getClass
().
getName
();
className
=
java
.
lang
.
Integer
.
class
.
getName
();
break
;
break
;
case
Types
.
BIGINT
:
case
Types
.
BIGINT
:
className
=
(
new
Long
(
0
)).
getClass
().
getName
();
className
=
java
.
lang
.
Long
.
class
.
getName
();
break
;
break
;
case
Types
.
REAL
:
case
Types
.
REAL
:
className
=
(
new
Float
(
0
)).
getClass
().
getName
();
className
=
java
.
lang
.
Float
.
class
.
getName
();
break
;
break
;
case
Types
.
FLOAT
:
case
Types
.
FLOAT
:
case
Types
.
DOUBLE
:
case
Types
.
DOUBLE
:
className
=
(
new
Double
(
0
)).
getClass
()
.
getName
();
className
=
java
.
lang
.
Double
.
class
.
getName
();
break
;
break
;
case
Types
.
BINARY
:
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
case
Types
.
VARBINARY
:
case
Types
.
LONGVARBINARY
:
case
Types
.
LONGVARBINARY
:
byte
[]
b
=
{};
className
=
"byte[]"
;
className
=
(
b
.
getClass
()).
getName
();
break
;
break
;
case
Types
.
DATE
:
case
Types
.
DATE
:
className
=
(
new
java
.
sql
.
Date
(
123456
)).
getClass
().
getName
();
className
=
java
.
sql
.
Date
.
class
.
getName
();
break
;
break
;
case
Types
.
TIME
:
case
Types
.
TIME
:
className
=
(
new
java
.
sql
.
Time
(
123456
)).
getClass
().
getName
();
className
=
java
.
sql
.
Time
.
class
.
getName
();
break
;
break
;
case
Types
.
TIMESTAMP
:
case
Types
.
TIMESTAMP
:
className
=
(
new
java
.
sql
.
Timestamp
(
123456
)).
getClass
().
getName
();
className
=
java
.
sql
.
Timestamp
.
class
.
getName
();
break
;
break
;
case
Types
.
BLOB
:
case
Types
.
BLOB
:
byte
[]
blob
=
{};
className
=
java
.
sql
.
Blob
.
class
.
getName
();
className
=
(
blob
.
getClass
()).
getName
();
break
;
break
;
case
Types
.
CLOB
:
case
Types
.
CLOB
:
char
[]
c
=
{};
className
=
java
.
sql
.
Clob
.
class
.
getName
();
className
=
(
c
.
getClass
()).
getName
();
break
;
break
;
}
}
...
...
src/share/classes/javax/sql/rowset/RowSetProvider.java
浏览文件 @
67166499
...
@@ -29,7 +29,6 @@ import java.security.AccessController;
...
@@ -29,7 +29,6 @@ import java.security.AccessController;
import
java.security.PrivilegedAction
;
import
java.security.PrivilegedAction
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ServiceLoader
;
import
java.util.ServiceLoader
;
import
javax.sql.rowset.RowSetFactory
;
/**
/**
* A factory API that enables applications to obtain a
* A factory API that enables applications to obtain a
...
@@ -82,15 +81,15 @@ public class RowSetProvider {
...
@@ -82,15 +81,15 @@ public class RowSetProvider {
* the <code>RowSetFactory</code> implementation class to load:</p>
* the <code>RowSetFactory</code> implementation class to load:</p>
* <ul>
* <ul>
* <li>
* <li>
* The System property {@code javax.sql.rowset.Row
s
etFactory}. For example:
* The System property {@code javax.sql.rowset.Row
S
etFactory}. For example:
* <ul>
* <ul>
* <li>
* <li>
* -Djavax.sql.rowset.Row
s
etFactory=com.sun.rowset.RowSetFactoryImpl
* -Djavax.sql.rowset.Row
S
etFactory=com.sun.rowset.RowSetFactoryImpl
* </li>
* </li>
* </ul>
* </ul>
* <li>
* <li>
* The
ServiceLocator API. The ServiceLocator
API will look
* The
{@link ServiceLoader} API. The {@code ServiceLoader}
API will look
* for a classname in the file
* for a class
name in the file
* {@code META-INF/services/javax.sql.rowset.RowSetFactory}
* {@code META-INF/services/javax.sql.rowset.RowSetFactory}
* in jars available to the runtime. For example, to have the the RowSetFactory
* in jars available to the runtime. For example, to have the the RowSetFactory
* implementation {@code com.sun.rowset.RowSetFactoryImpl } loaded, the
* implementation {@code com.sun.rowset.RowSetFactoryImpl } loaded, the
...
@@ -271,7 +270,7 @@ public class RowSetProvider {
...
@@ -271,7 +270,7 @@ public class RowSetProvider {
/**
/**
* Returns the requested System Property. If a {@code SecurityException}
* Returns the requested System Property. If a {@code SecurityException}
* occurs, just return NULL
* occurs, just return NULL
* @param propName - System property to retr
ei
ve
* @param propName - System property to retr
ie
ve
* @return The System property value or NULL if the property does not exist
* @return The System property value or NULL if the property does not exist
* or a {@code SecurityException} occurs.
* or a {@code SecurityException} occurs.
*/
*/
...
...
src/share/classes/javax/sql/rowset/WebRowSet.java
浏览文件 @
67166499
/*
/*
* Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
10
, 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
...
@@ -115,7 +115,7 @@ import org.xml.sax.*;
...
@@ -115,7 +115,7 @@ import org.xml.sax.*;
* <<font color=red>url</font>>jdbc:thin:oracle<<font color=red>/url</font>>
* <<font color=red>url</font>>jdbc:thin:oracle<<font color=red>/url</font>>
* <<font color=red>sync-provider</font>>
* <<font color=red>sync-provider</font>>
* <<font color=red>sync-provider-name</font>>.com.rowset.provider.RIOptimisticProvider<<font color=red>/sync-provider-name</font>>
* <<font color=red>sync-provider-name</font>>.com.rowset.provider.RIOptimisticProvider<<font color=red>/sync-provider-name</font>>
* <<font color=red>sync-provider-vendor</font>>
Sun Microsystems
<<font color=red>/sync-provider-vendor</font>>
* <<font color=red>sync-provider-vendor</font>>
Oracle Corporation
<<font color=red>/sync-provider-vendor</font>>
* <<font color=red>sync-provider-version</font>>1.0<<font color=red>/sync-provider-name</font>>
* <<font color=red>sync-provider-version</font>>1.0<<font color=red>/sync-provider-name</font>>
* <<font color=red>sync-provider-grade</font>>LOW<<font color=red>/sync-provider-grade</font>>
* <<font color=red>sync-provider-grade</font>>LOW<<font color=red>/sync-provider-grade</font>>
* <<font color=red>data-source-lock</font>>NONE<<font color=red>/data-source-lock</font>>
* <<font color=red>data-source-lock</font>>NONE<<font color=red>/data-source-lock</font>>
...
@@ -489,7 +489,7 @@ public interface WebRowSet extends CachedRowSet {
...
@@ -489,7 +489,7 @@ public interface WebRowSet extends CachedRowSet {
* tags and their valid values for a <code>WebRowSet</code> implementation.
* tags and their valid values for a <code>WebRowSet</code> implementation.
*/
*/
public
static
String
PUBLIC_XML_SCHEMA
=
public
static
String
PUBLIC_XML_SCHEMA
=
"--//
Sun Microsystems, Inc.
//XSD Schema//EN"
;
"--//
Oracle Corporation
//XSD Schema//EN"
;
/**
/**
* The URL for the XML Schema definition file that defines the XML tags and
* The URL for the XML Schema definition file that defines the XML tags and
...
...
src/share/classes/javax/sql/rowset/rowset.properties
浏览文件 @
67166499
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
# Optimistic synchonriztaion provider
# Optimistic synchonriztaion provider
rowset.provider.classname.0
=
com.sun.rowset.providers.RIOptimisticProvider
rowset.provider.classname.0
=
com.sun.rowset.providers.RIOptimisticProvider
rowset.provider.vendor.0
=
Sun Microsystems Inc
rowset.provider.vendor.0
=
Oracle Corporation
rowset.provider.version.0
=
1.0
rowset.provider.version.0
=
1.0
# XML Provider using standard XML schema
# XML Provider using standard XML schema
rowset.provider.classname.1
=
com.sun.rowset.providers.RIXMLProvider
rowset.provider.classname.1
=
com.sun.rowset.providers.RIXMLProvider
rowset.provider.vendor.1
=
Sun Microsystems Inc.
rowset.provider.vendor.1
=
Oracle Corporation
rowset.provider.version.1
=
1.0
rowset.provider.version.1
=
1.0
src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java
浏览文件 @
67166499
/*
/*
* Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
10
, 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
...
@@ -137,7 +137,7 @@ public class SQLOutputImpl implements SQLOutput {
...
@@ -137,7 +137,7 @@ public class SQLOutputImpl implements SQLOutput {
* values of a UDT to the database.
* values of a UDT to the database.
*/
*/
public
void
writeBoolean
(
boolean
x
)
throws
SQLException
{
public
void
writeBoolean
(
boolean
x
)
throws
SQLException
{
attribs
.
add
(
new
Boolean
(
x
));
attribs
.
add
(
Boolean
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -151,7 +151,7 @@ public class SQLOutputImpl implements SQLOutput {
...
@@ -151,7 +151,7 @@ public class SQLOutputImpl implements SQLOutput {
* values of a UDT to the database.
* values of a UDT to the database.
*/
*/
public
void
writeByte
(
byte
x
)
throws
SQLException
{
public
void
writeByte
(
byte
x
)
throws
SQLException
{
attribs
.
add
(
new
Byte
(
x
));
attribs
.
add
(
Byte
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -165,7 +165,7 @@ public class SQLOutputImpl implements SQLOutput {
...
@@ -165,7 +165,7 @@ public class SQLOutputImpl implements SQLOutput {
* values of a UDT to the database.
* values of a UDT to the database.
*/
*/
public
void
writeShort
(
short
x
)
throws
SQLException
{
public
void
writeShort
(
short
x
)
throws
SQLException
{
attribs
.
add
(
new
Short
(
x
));
attribs
.
add
(
Short
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -179,7 +179,7 @@ public class SQLOutputImpl implements SQLOutput {
...
@@ -179,7 +179,7 @@ public class SQLOutputImpl implements SQLOutput {
* values of a UDT to the database.
* values of a UDT to the database.
*/
*/
public
void
writeInt
(
int
x
)
throws
SQLException
{
public
void
writeInt
(
int
x
)
throws
SQLException
{
attribs
.
add
(
new
Integer
(
x
));
attribs
.
add
(
Integer
.
valueOf
(
x
));
}
}
/**
/**
...
@@ -193,7 +193,7 @@ public class SQLOutputImpl implements SQLOutput {
...
@@ -193,7 +193,7 @@ public class SQLOutputImpl implements SQLOutput {
* values of a UDT to the database.
* values of a UDT to the database.
*/
*/
public
void
writeLong
(
long
x
)
throws
SQLException
{
public
void
writeLong
(
long
x
)
throws
SQLException
{
attribs
.
add
(
new
Long
(
x
));
attribs
.
add
(
Long
.
valueOf
(
x
));
}
}
/**
/**
...
...
src/share/classes/javax/sql/rowset/serial/SerialRef.java
浏览文件 @
67166499
/*
/*
* Copyright (c) 2003, 20
04
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
10
, 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
...
@@ -77,7 +77,7 @@ public class SerialRef implements Ref, Serializable, Cloneable {
...
@@ -77,7 +77,7 @@ public class SerialRef implements Ref, Serializable, Cloneable {
throw
new
SQLException
(
"Cannot instantiate a SerialRef object "
+
throw
new
SQLException
(
"Cannot instantiate a SerialRef object "
+
"that returns a null base type name"
);
"that returns a null base type name"
);
}
else
{
}
else
{
baseTypeName
=
new
String
(
ref
.
getBaseTypeName
()
);
baseTypeName
=
ref
.
getBaseTypeName
(
);
}
}
}
}
...
@@ -110,7 +110,7 @@ public class SerialRef implements Ref, Serializable, Cloneable {
...
@@ -110,7 +110,7 @@ public class SerialRef implements Ref, Serializable, Cloneable {
throws
SerialException
throws
SerialException
{
{
map
=
new
Hashtable
(
map
);
map
=
new
Hashtable
(
map
);
if
(
!
object
.
equals
(
null
)
)
{
if
(
object
!=
null
)
{
return
map
.
get
(
object
);
return
map
.
get
(
object
);
}
else
{
}
else
{
throw
new
SerialException
(
"The object is not set"
);
throw
new
SerialException
(
"The object is not set"
);
...
...
src/share/classes/javax/sql/rowset/serial/SerialStruct.java
浏览文件 @
67166499
/*
/*
* Copyright (c) 2003, 20
04
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
10
, 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
...
@@ -94,7 +94,7 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
...
@@ -94,7 +94,7 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
try
{
try
{
// get the type name
// get the type name
SQLTypeName
=
new
String
(
in
.
getSQLTypeName
()
);
SQLTypeName
=
in
.
getSQLTypeName
(
);
System
.
out
.
println
(
"SQLTypeName: "
+
SQLTypeName
);
System
.
out
.
println
(
"SQLTypeName: "
+
SQLTypeName
);
// get the attributes of the struct
// get the attributes of the struct
...
@@ -137,7 +137,7 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
...
@@ -137,7 +137,7 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
try
{
try
{
//set the type name
//set the type name
SQLTypeName
=
new
String
(
in
.
getSQLTypeName
()
);
SQLTypeName
=
in
.
getSQLTypeName
(
);
Vector
tmp
=
new
Vector
();
Vector
tmp
=
new
Vector
();
in
.
writeSQL
(
new
SQLOutputImpl
(
tmp
,
map
));
in
.
writeSQL
(
new
SQLOutputImpl
(
tmp
,
map
));
...
...
src/share/classes/javax/sql/rowset/spi/SyncFactory.java
浏览文件 @
67166499
...
@@ -125,12 +125,12 @@ import javax.naming.*;
...
@@ -125,12 +125,12 @@ import javax.naming.*;
*
*
* # Optimistic synchronization provider
* # Optimistic synchronization provider
* rowset.provider.classname.0=com.sun.rowset.providers.RIOptimisticProvider
* rowset.provider.classname.0=com.sun.rowset.providers.RIOptimisticProvider
* rowset.provider.vendor.0=
Sun Microsystems Inc
* rowset.provider.vendor.0=
Oracle Corporation
* rowset.provider.version.0=1.0
* rowset.provider.version.0=1.0
*
*
* # XML Provider using standard XML schema
* # XML Provider using standard XML schema
* rowset.provider.classname.1=com.sun.rowset.providers.RIXMLProvider
* rowset.provider.classname.1=com.sun.rowset.providers.RIXMLProvider
* rowset.provider.vendor.1=
Sun Microsystems Inc.
* rowset.provider.vendor.1=
Oracle Corporation
* rowset.provider.version.1=1.0
* rowset.provider.version.1=1.0
* </PRE>
* </PRE>
* The <code>SyncFactory</code> checks this file and registers the
* The <code>SyncFactory</code> checks this file and registers the
...
@@ -369,7 +369,7 @@ public class SyncFactory {
...
@@ -369,7 +369,7 @@ public class SyncFactory {
try
{
try
{
// check if user is supplying his Synchronisation Provider
// check if user is supplying his Synchronisation Provider
// Implementation
if not use Sun
's implementation.
// Implementation
if not using Oracle
's implementation.
// properties.load(new FileInputStream(ROWSET_PROPERTIES));
// properties.load(new FileInputStream(ROWSET_PROPERTIES));
// The rowset.properties needs to be in jdk/jre/lib when
// The rowset.properties needs to be in jdk/jre/lib when
...
...
src/share/classes/javax/sql/rowset/spi/SyncProvider.java
浏览文件 @
67166499
...
@@ -91,8 +91,8 @@ import javax.sql.*;
...
@@ -91,8 +91,8 @@ import javax.sql.*;
* </pre>
* </pre>
* <p>
* <p>
* A vendor can register a <code>SyncProvider</code> implementation class name
* A vendor can register a <code>SyncProvider</code> implementation class name
* with
Sun Microsystems, Inc.
by sending email to jdbc@sun.com.
* with
Oracle Corporation
by sending email to jdbc@sun.com.
*
Sun
will maintain a database listing the
*
Oracle
will maintain a database listing the
* available <code>SyncProvider</code> implementations for use with compliant
* available <code>SyncProvider</code> implementations for use with compliant
* <code>RowSet</code> implementations. This database will be similar to the
* <code>RowSet</code> implementations. This database will be similar to the
* one already maintained to list available JDBC drivers.
* one already maintained to list available JDBC drivers.
...
...
src/share/classes/javax/sql/rowset/spi/package.html
浏览文件 @
67166499
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<meta
name=
"GENERATOR"
<meta
name=
"GENERATOR"
content=
"Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]"
>
content=
"Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]"
>
<!--
<!--
Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 20
10
, 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
...
@@ -199,7 +199,7 @@ specification for further details.
...
@@ -199,7 +199,7 @@ specification for further details.
Vendors may develop a
<tt>
SyncProvider
</tt>
implementation with any one of the possible
Vendors may develop a
<tt>
SyncProvider
</tt>
implementation with any one of the possible
levels of synchronization, thus giving
<code>
RowSet
</code>
objects a choice of
levels of synchronization, thus giving
<code>
RowSet
</code>
objects a choice of
synchronization mechanisms. A vendor can make its implementation available by
synchronization mechanisms. A vendor can make its implementation available by
registering the fully qualified class name with
Sun Microsystems at
registering the fully qualified class name with
Oracle Corporation at
<code>
jdbc@sun.com
</code>
. This process is discussed in further detail below.
<code>
jdbc@sun.com
</code>
. This process is discussed in further detail below.
<P>
<P>
...
...
src/share/classes/sun/net/www/http/HttpClient.java
浏览文件 @
67166499
...
@@ -55,6 +55,9 @@ public class HttpClient extends NetworkClient {
...
@@ -55,6 +55,9 @@ public class HttpClient extends NetworkClient {
// Http data we send with the headers
// Http data we send with the headers
PosterOutputStream
poster
=
null
;
PosterOutputStream
poster
=
null
;
// true if we are in streaming mode (fixed length or chunked)
boolean
streaming
;
// if we've had one io error
// if we've had one io error
boolean
failedOnce
=
false
;
boolean
failedOnce
=
false
;
...
@@ -275,6 +278,10 @@ public class HttpClient extends NetworkClient {
...
@@ -275,6 +278,10 @@ public class HttpClient extends NetworkClient {
ret
.
cachedHttpClient
=
true
;
ret
.
cachedHttpClient
=
true
;
assert
ret
.
inCache
;
assert
ret
.
inCache
;
ret
.
inCache
=
false
;
ret
.
inCache
=
false
;
PlatformLogger
logger
=
HttpURLConnection
.
getHttpLogger
();
if
(
logger
.
isLoggable
(
PlatformLogger
.
FINEST
))
{
logger
.
finest
(
"KeepAlive stream retrieved from the cache, "
+
ret
);
}
}
}
}
else
{
}
else
{
// We cannot return this connection to the cache as it's
// We cannot return this connection to the cache as it's
...
@@ -545,6 +552,13 @@ public class HttpClient extends NetworkClient {
...
@@ -545,6 +552,13 @@ public class HttpClient extends NetworkClient {
serverOutput
.
flush
();
serverOutput
.
flush
();
}
}
public
void
writeRequests
(
MessageHeader
head
,
PosterOutputStream
pos
,
boolean
streaming
)
throws
IOException
{
this
.
streaming
=
streaming
;
writeRequests
(
head
,
pos
);
}
/** Parse the first line of the HTTP request. It usually looks
/** Parse the first line of the HTTP request. It usually looks
something like: "HTTP/1.0 <number> comment\r\n". */
something like: "HTTP/1.0 <number> comment\r\n". */
...
@@ -577,11 +591,11 @@ public class HttpClient extends NetworkClient {
...
@@ -577,11 +591,11 @@ public class HttpClient extends NetworkClient {
closeServer
();
closeServer
();
cachedHttpClient
=
false
;
cachedHttpClient
=
false
;
if
(!
failedOnce
&&
requests
!=
null
)
{
if
(!
failedOnce
&&
requests
!=
null
)
{
if
(
httpuc
.
getRequestMethod
().
equals
(
"POST"
)
&&
!
retryPostProp
)
{
failedOnce
=
true
;
if
(
httpuc
.
getRequestMethod
().
equals
(
"POST"
)
&&
(!
retryPostProp
||
streaming
))
{
// do not retry the request
// do not retry the request
}
else
{
}
else
{
// try once more
// try once more
failedOnce
=
true
;
openServer
();
openServer
();
if
(
needsTunneling
())
{
if
(
needsTunneling
())
{
httpuc
.
doTunneling
();
httpuc
.
doTunneling
();
...
@@ -684,10 +698,10 @@ public class HttpClient extends NetworkClient {
...
@@ -684,10 +698,10 @@ public class HttpClient extends NetworkClient {
}
}
}
else
if
(
nread
!=
8
)
{
}
else
if
(
nread
!=
8
)
{
if
(!
failedOnce
&&
requests
!=
null
)
{
if
(!
failedOnce
&&
requests
!=
null
)
{
if
(
httpuc
.
getRequestMethod
().
equals
(
"POST"
)
&&
!
retryPostProp
)
{
failedOnce
=
true
;
if
(
httpuc
.
getRequestMethod
().
equals
(
"POST"
)
&&
(!
retryPostProp
||
streaming
))
{
// do not retry the request
// do not retry the request
}
else
{
}
else
{
failedOnce
=
true
;
closeServer
();
closeServer
();
cachedHttpClient
=
false
;
cachedHttpClient
=
false
;
openServer
();
openServer
();
...
...
src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
浏览文件 @
67166499
...
@@ -494,7 +494,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
...
@@ -494,7 +494,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
if
(
logger
.
isLoggable
(
PlatformLogger
.
FINE
))
{
if
(
logger
.
isLoggable
(
PlatformLogger
.
FINE
))
{
logger
.
fine
(
requests
.
toString
());
logger
.
fine
(
requests
.
toString
());
}
}
http
.
writeRequests
(
requests
,
poster
);
http
.
writeRequests
(
requests
,
poster
,
streaming
()
);
if
(
ps
.
checkError
())
{
if
(
ps
.
checkError
())
{
String
proxyHost
=
http
.
getProxyHostUsed
();
String
proxyHost
=
http
.
getProxyHostUsed
();
int
proxyPort
=
http
.
getProxyPortUsed
();
int
proxyPort
=
http
.
getProxyPortUsed
();
...
@@ -2825,6 +2825,38 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
...
@@ -2825,6 +2825,38 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
}
}
}
}
/* skip() calls read() in order to ensure that entire response gets
* cached. same implementation as InputStream.skip */
private
byte
[]
skipBuffer
;
private
static
final
int
SKIP_BUFFER_SIZE
=
8096
;
@Override
public
long
skip
(
long
n
)
throws
IOException
{
long
remaining
=
n
;
int
nr
;
if
(
skipBuffer
==
null
)
skipBuffer
=
new
byte
[
SKIP_BUFFER_SIZE
];
byte
[]
localSkipBuffer
=
skipBuffer
;
if
(
n
<=
0
)
{
return
0
;
}
while
(
remaining
>
0
)
{
nr
=
read
(
localSkipBuffer
,
0
,
(
int
)
Math
.
min
(
SKIP_BUFFER_SIZE
,
remaining
));
if
(
nr
<
0
)
{
break
;
}
remaining
-=
nr
;
}
return
n
-
remaining
;
}
@Override
@Override
public
void
close
()
throws
IOException
{
public
void
close
()
throws
IOException
{
try
{
try
{
...
...
src/share/classes/sun/security/tools/KeyTool.java
浏览文件 @
67166499
...
@@ -281,7 +281,7 @@ public final class KeyTool {
...
@@ -281,7 +281,7 @@ public final class KeyTool {
RFC
(
"rfc"
,
null
,
"output in RFC style"
),
RFC
(
"rfc"
,
null
,
"output in RFC style"
),
SIGALG
(
"sigalg"
,
"<sigalg>"
,
"signature algorithm name"
),
SIGALG
(
"sigalg"
,
"<sigalg>"
,
"signature algorithm name"
),
SRCALIAS
(
"srcalias"
,
"<srcalias>"
,
"source alias"
),
SRCALIAS
(
"srcalias"
,
"<srcalias>"
,
"source alias"
),
SRCKEYPASS
(
"srckeypass"
,
"<arg>"
,
"source key
store
password"
),
SRCKEYPASS
(
"srckeypass"
,
"<arg>"
,
"source key password"
),
SRCKEYSTORE
(
"srckeystore"
,
"<srckeystore>"
,
"source keystore name"
),
SRCKEYSTORE
(
"srckeystore"
,
"<srckeystore>"
,
"source keystore name"
),
SRCPROTECTED
(
"srcprotected"
,
null
,
"source keystore password protected"
),
SRCPROTECTED
(
"srcprotected"
,
null
,
"source keystore password protected"
),
SRCPROVIDERNAME
(
"srcprovidername"
,
"<srcprovidername>"
,
"source keystore provider name"
),
SRCPROVIDERNAME
(
"srcprovidername"
,
"<srcprovidername>"
,
"source keystore provider name"
),
...
...
src/share/classes/sun/security/util/Resources.java
浏览文件 @
67166499
...
@@ -116,11 +116,9 @@ public class Resources extends java.util.ListResourceBundle {
...
@@ -116,11 +116,9 @@ public class Resources extends java.util.ListResourceBundle {
{
"X.509 extension"
,
{
"X.509 extension"
,
"X.509 extension"
},
//-ext
"X.509 extension"
},
//-ext
{
"output file name"
,
{
"output file name"
,
"output file name"
},
//-file
"output file name"
},
//-file
and -outfile
{
"input file name"
,
{
"input file name"
,
"input file name"
},
//-file
"input file name"
},
//-file and -infile
{
"input file name"
,
"input file name"
},
//-infile
{
"key algorithm name"
,
{
"key algorithm name"
,
"key algorithm name"
},
//-keyalg
"key algorithm name"
},
//-keyalg
{
"key password"
,
{
"key password"
,
...
@@ -133,8 +131,6 @@ public class Resources extends java.util.ListResourceBundle {
...
@@ -133,8 +131,6 @@ public class Resources extends java.util.ListResourceBundle {
"new password"
},
//-new
"new password"
},
//-new
{
"do not prompt"
,
{
"do not prompt"
,
"do not prompt"
},
//-noprompt
"do not prompt"
},
//-noprompt
{
"output file name"
,
"output file name"
},
//-outfile
{
"password through protected mechanism"
,
{
"password through protected mechanism"
,
"password through protected mechanism"
},
//-protected
"password through protected mechanism"
},
//-protected
{
"provider argument"
,
{
"provider argument"
,
...
@@ -151,8 +147,8 @@ public class Resources extends java.util.ListResourceBundle {
...
@@ -151,8 +147,8 @@ public class Resources extends java.util.ListResourceBundle {
"signature algorithm name"
},
//-sigalg
"signature algorithm name"
},
//-sigalg
{
"source alias"
,
{
"source alias"
,
"source alias"
},
//-srcalias
"source alias"
},
//-srcalias
{
"source key
store
password"
,
{
"source key password"
,
"source key
store
password"
},
//-srckeypass
"source key password"
},
//-srckeypass
{
"source keystore name"
,
{
"source keystore name"
,
"source keystore name"
},
//-srckeystore
"source keystore name"
},
//-srckeystore
{
"source keystore password protected"
,
{
"source keystore password protected"
,
...
@@ -276,8 +272,6 @@ public class Resources extends java.util.ListResourceBundle {
...
@@ -276,8 +272,6 @@ public class Resources extends java.util.ListResourceBundle {
"Alias <{0}> has no certificate"
},
"Alias <{0}> has no certificate"
},
{
"Key pair not generated, alias <alias> already exists"
,
{
"Key pair not generated, alias <alias> already exists"
,
"Key pair not generated, alias <{0}> already exists"
},
"Key pair not generated, alias <{0}> already exists"
},
{
"Cannot derive signature algorithm"
,
"Cannot derive signature algorithm"
},
{
"Generating keysize bit keyAlgName key pair and self-signed certificate (sigAlgName) with a validity of validality days\n\tfor: x500Name"
,
{
"Generating keysize bit keyAlgName key pair and self-signed certificate (sigAlgName) with a validity of validality days\n\tfor: x500Name"
,
"Generating {0} bit {1} key pair and self-signed certificate ({2}) with a validity of {3} days\n\tfor: {4}"
},
"Generating {0} bit {1} key pair and self-signed certificate ({2}) with a validity of {3} days\n\tfor: {4}"
},
{
"Enter key password for <alias>"
,
"Enter key password for <{0}>"
},
{
"Enter key password for <alias>"
,
"Enter key password for <{0}>"
},
...
@@ -321,8 +315,6 @@ public class Resources extends java.util.ListResourceBundle {
...
@@ -321,8 +315,6 @@ public class Resources extends java.util.ListResourceBundle {
{
"Failed to parse input"
,
"Failed to parse input"
},
{
"Failed to parse input"
,
"Failed to parse input"
},
{
"Empty input"
,
"Empty input"
},
{
"Empty input"
,
"Empty input"
},
{
"Not X.509 certificate"
,
"Not X.509 certificate"
},
{
"Not X.509 certificate"
,
"Not X.509 certificate"
},
{
"Cannot derive signature algorithm"
,
"Cannot derive signature algorithm"
},
{
"alias has no public key"
,
"{0} has no public key"
},
{
"alias has no public key"
,
"{0} has no public key"
},
{
"alias has no X.509 certificate"
,
"{0} has no X.509 certificate"
},
{
"alias has no X.509 certificate"
,
"{0} has no X.509 certificate"
},
{
"New certificate (self-signed):"
,
"New certificate (self-signed):"
},
{
"New certificate (self-signed):"
,
"New certificate (self-signed):"
},
...
@@ -552,7 +544,6 @@ public class Resources extends java.util.ListResourceBundle {
...
@@ -552,7 +544,6 @@ public class Resources extends java.util.ListResourceBundle {
{
"package name"
,
"package name"
},
{
"package name"
,
"package name"
},
{
"policy type"
,
"policy type"
},
{
"policy type"
,
"policy type"
},
{
"property name"
,
"property name"
},
{
"property name"
,
"property name"
},
{
"provider name"
,
"provider name"
},
{
"Principal List"
,
"Principal List"
},
{
"Principal List"
,
"Principal List"
},
{
"Permission List"
,
"Permission List"
},
{
"Permission List"
,
"Permission List"
},
{
"Code Base"
,
"Code Base"
},
{
"Code Base"
,
"Code Base"
},
...
...
src/share/native/java/lang/System.c
浏览文件 @
67166499
...
@@ -97,14 +97,20 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
...
@@ -97,14 +97,20 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
} else ((void) 0)
} else ((void) 0)
#ifndef VENDOR
/* Third party may overwrite this. */
#ifndef VENDOR
/* Third party may overwrite this. */
#define VENDOR "
Sun Microsystems Inc.
"
#define VENDOR "
Oracle Corporation
"
#define VENDOR_URL "http://java.
sun
.com/"
#define VENDOR_URL "http://java.
oracle
.com/"
#define VENDOR_URL_BUG "http://java.sun.com/cgi-bin/bugreport.cgi"
#define VENDOR_URL_BUG "http://java.sun.com/cgi-bin/bugreport.cgi"
#endif
#endif
#define JAVA_MAX_SUPPORTED_VERSION 51
#define JAVA_MAX_SUPPORTED_VERSION 51
#define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
#define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
#ifdef JAVA_SPECIFICATION_VENDOR
/* Third party may NOT overwrite this. */
#error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed"
#else
#define JAVA_SPECIFICATION_VENDOR "Oracle Corporation"
#endif
static
int
fmtdefault
;
// boolean value
static
int
fmtdefault
;
// boolean value
jobject
fillI18nProps
(
JNIEnv
*
env
,
jobject
props
,
char
*
baseKey
,
jobject
fillI18nProps
(
JNIEnv
*
env
,
jobject
props
,
char
*
baseKey
,
char
*
platformDispVal
,
char
*
platformFmtVal
,
char
*
platformDispVal
,
char
*
platformFmtVal
,
...
@@ -185,7 +191,8 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
...
@@ -185,7 +191,8 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
JDK_MAJOR_VERSION
"."
JDK_MINOR_VERSION
);
JDK_MAJOR_VERSION
"."
JDK_MINOR_VERSION
);
PUTPROP
(
props
,
"java.specification.name"
,
PUTPROP
(
props
,
"java.specification.name"
,
"Java Platform API Specification"
);
"Java Platform API Specification"
);
PUTPROP
(
props
,
"java.specification.vendor"
,
"Sun Microsystems Inc."
);
PUTPROP
(
props
,
"java.specification.vendor"
,
JAVA_SPECIFICATION_VENDOR
);
PUTPROP
(
props
,
"java.version"
,
RELEASE
);
PUTPROP
(
props
,
"java.version"
,
RELEASE
);
PUTPROP
(
props
,
"java.vendor"
,
VENDOR
);
PUTPROP
(
props
,
"java.vendor"
,
VENDOR
);
...
@@ -239,7 +246,7 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
...
@@ -239,7 +246,7 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
/* Printing properties */
/* Printing properties */
/* Note: java.awt.printerjob is an implementation private property which
/* Note: java.awt.printerjob is an implementation private property which
* just happens to have a java.* name because it is referenced in
* just happens to have a java.* name because it is referenced in
* a java.awt class. It is the mechanism by which the
Sun
implementation
* a java.awt class. It is the mechanism by which the implementation
* finds the appropriate class in the JRE for the platform.
* finds the appropriate class in the JRE for the platform.
* It is explicitly not designed to be overridden by clients as
* It is explicitly not designed to be overridden by clients as
* a way of replacing the implementation class, and in any case
* a way of replacing the implementation class, and in any case
...
@@ -267,7 +274,7 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
...
@@ -267,7 +274,7 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
/* Java2D properties */
/* Java2D properties */
/* Note: java.awt.graphicsenv is an implementation private property which
/* Note: java.awt.graphicsenv is an implementation private property which
* just happens to have a java.* name because it is referenced in
* just happens to have a java.* name because it is referenced in
* a java.awt class. It is the mechanism by which the
Sun
implementation
* a java.awt class. It is the mechanism by which the implementation
* finds the appropriate class in the JRE for the platform.
* finds the appropriate class in the JRE for the platform.
* It is explicitly not designed to be overridden by clients as
* It is explicitly not designed to be overridden by clients as
* a way of replacing the implementation class, and in any case
* a way of replacing the implementation class, and in any case
...
...
src/share/sample/nio/file/Chmod.java
浏览文件 @
67166499
...
@@ -285,17 +285,11 @@ public class Chmod {
...
@@ -285,17 +285,11 @@ public class Chmod {
}
}
@Override
@Override
public
FileVisitResult
preVisitDirectory
(
FileRef
dir
)
{
public
FileVisitResult
preVisitDirectory
(
FileRef
dir
,
BasicFileAttributes
attrs
)
{
chmod
(
dir
,
changer
);
chmod
(
dir
,
changer
);
return
CONTINUE
;
return
CONTINUE
;
}
}
@Override
public
FileVisitResult
preVisitDirectoryFailed
(
FileRef
dir
,
IOException
exc
)
{
System
.
err
.
println
(
"WARNING: "
+
exc
);
return
CONTINUE
;
}
@Override
@Override
public
FileVisitResult
visitFile
(
FileRef
file
,
BasicFileAttributes
attrs
)
{
public
FileVisitResult
visitFile
(
FileRef
file
,
BasicFileAttributes
attrs
)
{
chmod
(
file
,
changer
);
chmod
(
file
,
changer
);
...
...
src/share/sample/nio/file/Copy.java
浏览文件 @
67166499
...
@@ -85,7 +85,7 @@ public class Copy {
...
@@ -85,7 +85,7 @@ public class Copy {
}
}
@Override
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
)
{
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
{
// before visiting entries in a directory we copy the directory
// before visiting entries in a directory we copy the directory
// (okay if directory already exists).
// (okay if directory already exists).
CopyOption
[]
options
=
(
preserve
)
?
CopyOption
[]
options
=
(
preserve
)
?
...
@@ -103,20 +103,10 @@ public class Copy {
...
@@ -103,20 +103,10 @@ public class Copy {
return
CONTINUE
;
return
CONTINUE
;
}
}
@Override
public
FileVisitResult
preVisitDirectoryFailed
(
Path
dir
,
IOException
exc
)
{
System
.
err
.
format
(
"Unable to copy: %s: %s%n"
,
dir
,
exc
);
return
CONTINUE
;
}
@Override
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
{
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
{
if
(
attrs
.
isDirectory
())
{
System
.
err
.
println
(
"cycle detected: "
+
file
);
}
else
{
copyFile
(
file
,
target
.
resolve
(
source
.
relativize
(
file
)),
copyFile
(
file
,
target
.
resolve
(
source
.
relativize
(
file
)),
prompt
,
preserve
);
prompt
,
preserve
);
}
return
CONTINUE
;
return
CONTINUE
;
}
}
...
@@ -137,7 +127,11 @@ public class Copy {
...
@@ -137,7 +127,11 @@ public class Copy {
@Override
@Override
public
FileVisitResult
visitFileFailed
(
Path
file
,
IOException
exc
)
{
public
FileVisitResult
visitFileFailed
(
Path
file
,
IOException
exc
)
{
if
(
exc
instanceof
FileSystemLoopException
)
{
System
.
err
.
println
(
"cycle detected: "
+
file
);
}
else
{
System
.
err
.
format
(
"Unable to copy: %s: %s%n"
,
file
,
exc
);
System
.
err
.
format
(
"Unable to copy: %s: %s%n"
,
file
,
exc
);
}
return
CONTINUE
;
return
CONTINUE
;
}
}
}
}
...
...
src/share/sample/nio/file/WatchDir.java
浏览文件 @
67166499
...
@@ -78,12 +78,10 @@ public class WatchDir {
...
@@ -78,12 +78,10 @@ public class WatchDir {
// register directory and sub-directories
// register directory and sub-directories
Files
.
walkFileTree
(
start
,
new
SimpleFileVisitor
<
Path
>()
{
Files
.
walkFileTree
(
start
,
new
SimpleFileVisitor
<
Path
>()
{
@Override
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
)
{
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
try
{
throws
IOException
{
register
(
dir
);
register
(
dir
);
}
catch
(
IOException
x
)
{
throw
new
IOError
(
x
);
}
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
});
});
...
...
src/solaris/classes/java/lang/UNIXProcess.java.linux
浏览文件 @
67166499
...
@@ -176,7 +176,13 @@ final class UNIXProcess extends Process {
...
@@ -176,7 +176,13 @@ final class UNIXProcess extends Process {
}});
}});
}
}
synchronized
void
processExited
(
int
exitcode
)
{
void
processExited
(
int
exitcode
)
{
synchronized
(
this
)
{
this
.
exitcode
=
exitcode
;
hasExited
=
true
;
notifyAll
();
}
if
(
stdout
instanceof
ProcessPipeInputStream
)
if
(
stdout
instanceof
ProcessPipeInputStream
)
((
ProcessPipeInputStream
)
stdout
).
processExited
();
((
ProcessPipeInputStream
)
stdout
).
processExited
();
...
@@ -185,10 +191,6 @@ final class UNIXProcess extends Process {
...
@@ -185,10 +191,6 @@ final class UNIXProcess extends Process {
if
(
stdin
instanceof
ProcessPipeOutputStream
)
if
(
stdin
instanceof
ProcessPipeOutputStream
)
((
ProcessPipeOutputStream
)
stdin
).
processExited
();
((
ProcessPipeOutputStream
)
stdin
).
processExited
();
this
.
exitcode
=
exitcode
;
hasExited
=
true
;
notifyAll
();
}
}
public
OutputStream
getOutputStream
()
{
public
OutputStream
getOutputStream
()
{
...
...
src/solaris/classes/sun/nio/fs/LinuxFileStore.java
浏览文件 @
67166499
...
@@ -156,9 +156,4 @@ class LinuxFileStore
...
@@ -156,9 +156,4 @@ class LinuxFileStore
return
supportsFileAttributeView
(
UserDefinedFileAttributeView
.
class
);
return
supportsFileAttributeView
(
UserDefinedFileAttributeView
.
class
);
return
super
.
supportsFileAttributeView
(
name
);
return
super
.
supportsFileAttributeView
(
name
);
}
}
@Override
boolean
isLoopback
()
{
return
false
;
}
}
}
src/solaris/classes/sun/nio/fs/SolarisFileStore.java
浏览文件 @
67166499
...
@@ -108,9 +108,4 @@ class SolarisFileStore
...
@@ -108,9 +108,4 @@ class SolarisFileStore
return
supportsFileAttributeView
(
UserDefinedFileAttributeView
.
class
);
return
supportsFileAttributeView
(
UserDefinedFileAttributeView
.
class
);
return
super
.
supportsFileAttributeView
(
name
);
return
super
.
supportsFileAttributeView
(
name
);
}
}
@Override
boolean
isLoopback
()
{
return
type
().
equals
(
"lofs"
);
}
}
}
src/solaris/classes/sun/nio/fs/UnixFileStore.java
浏览文件 @
67166499
...
@@ -76,12 +76,6 @@ abstract class UnixFileStore
...
@@ -76,12 +76,6 @@ abstract class UnixFileStore
*/
*/
abstract
UnixMountEntry
findMountEntry
()
throws
IOException
;
abstract
UnixMountEntry
findMountEntry
()
throws
IOException
;
/**
* Returns true if this file store represents a loopback file system that
* will have the same device ID as underlying file system.
*/
abstract
boolean
isLoopback
();
UnixPath
file
()
{
UnixPath
file
()
{
return
file
;
return
file
;
}
}
...
@@ -169,22 +163,13 @@ abstract class UnixFileStore
...
@@ -169,22 +163,13 @@ abstract class UnixFileStore
if
(!(
ob
instanceof
UnixFileStore
))
if
(!(
ob
instanceof
UnixFileStore
))
return
false
;
return
false
;
UnixFileStore
other
=
(
UnixFileStore
)
ob
;
UnixFileStore
other
=
(
UnixFileStore
)
ob
;
if
(
dev
!=
other
.
dev
)
return
(
this
.
dev
==
other
.
dev
)
&&
return
false
;
Arrays
.
equals
(
this
.
entry
.
dir
(),
other
.
entry
.
dir
());
// deviceIDs are equal but they may not be equal if one or both of
// them is a loopback file system
boolean
thisIsLoopback
=
isLoopback
();
if
(
thisIsLoopback
!=
other
.
isLoopback
())
return
false
;
// one, but not both, are lofs
if
(!
thisIsLoopback
)
return
true
;
// neither is lofs
// both are lofs so compare mount points
return
Arrays
.
equals
(
this
.
entry
.
dir
(),
other
.
entry
.
dir
());
}
}
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
(
int
)(
dev
^
(
dev
>>>
32
));
return
(
int
)(
dev
^
(
dev
>>>
32
))
^
Arrays
.
hashCode
(
entry
.
dir
())
;
}
}
@Override
@Override
...
...
src/solaris/native/java/io/io_util_md.c
浏览文件 @
67166499
...
@@ -83,8 +83,6 @@ fileClose(JNIEnv *env, jobject this, jfieldID fid)
...
@@ -83,8 +83,6 @@ fileClose(JNIEnv *env, jobject this, jfieldID fid)
close
(
devnull
);
close
(
devnull
);
}
}
}
else
if
(
JVM_Close
(
fd
)
==
-
1
)
{
}
else
if
(
JVM_Close
(
fd
)
==
-
1
)
{
SET_FD
(
this
,
fd
,
fid
);
// restore fd
printf
(
"JVM_Close returned -1
\n
"
);
JNU_ThrowIOExceptionWithLastError
(
env
,
"close failed"
);
JNU_ThrowIOExceptionWithLastError
(
env
,
"close failed"
);
}
}
}
}
src/solaris/native/java/net/Inet6AddressImpl.c
浏览文件 @
67166499
...
@@ -124,7 +124,7 @@ static jfieldID ni_ia6ipaddressID;
...
@@ -124,7 +124,7 @@ static jfieldID ni_ia6ipaddressID;
static
int
initialized
=
0
;
static
int
initialized
=
0
;
/*
/*
* Find an internet address for a given hostname. Not
this
this
* Find an internet address for a given hostname. Not
e that
this
* code only works for addresses of type INET. The translation
* code only works for addresses of type INET. The translation
* of %d.%d.%d.%d to an address (int) occurs in java now, so the
* of %d.%d.%d.%d to an address (int) occurs in java now, so the
* String "host" shouldn't *ever* be a %d.%d.%d.%d string
* String "host" shouldn't *ever* be a %d.%d.%d.%d string
...
@@ -200,7 +200,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -200,7 +200,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
*/
*/
if
(
isspace
((
unsigned
char
)
hostname
[
0
]))
{
if
(
isspace
((
unsigned
char
)
hostname
[
0
]))
{
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"UnknownHostException"
,
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"UnknownHostException"
,
(
char
*
)
hostname
);
hostname
);
JNU_ReleaseStringPlatformChars
(
env
,
host
,
hostname
);
JNU_ReleaseStringPlatformChars
(
env
,
host
,
hostname
);
return
NULL
;
return
NULL
;
}
}
...
@@ -210,8 +210,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
...
@@ -210,8 +210,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
if
(
error
)
{
if
(
error
)
{
/* report error */
/* report error */
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"UnknownHostException"
,
ThrowUnknownHostExceptionWithGaiError
(
env
,
hostname
,
error
);
(
char
*
)
hostname
);
JNU_ReleaseStringPlatformChars
(
env
,
host
,
hostname
);
JNU_ReleaseStringPlatformChars
(
env
,
host
,
hostname
);
return
NULL
;
return
NULL
;
}
else
{
}
else
{
...
@@ -407,7 +406,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
...
@@ -407,7 +406,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
addr
|=
((
caddr
[
1
]
<<
16
)
&
0xff0000
);
addr
|=
((
caddr
[
1
]
<<
16
)
&
0xff0000
);
addr
|=
((
caddr
[
2
]
<<
8
)
&
0xff00
);
addr
|=
((
caddr
[
2
]
<<
8
)
&
0xff00
);
addr
|=
(
caddr
[
3
]
&
0xff
);
addr
|=
(
caddr
[
3
]
&
0xff
);
memset
((
char
*
)
&
him4
,
0
,
sizeof
(
him4
));
memset
((
void
*
)
&
him4
,
0
,
sizeof
(
him4
));
him4
.
sin_addr
.
s_addr
=
(
uint32_t
)
htonl
(
addr
);
him4
.
sin_addr
.
s_addr
=
(
uint32_t
)
htonl
(
addr
);
him4
.
sin_family
=
AF_INET
;
him4
.
sin_family
=
AF_INET
;
sa
=
(
struct
sockaddr
*
)
&
him4
;
sa
=
(
struct
sockaddr
*
)
&
him4
;
...
@@ -417,7 +416,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
...
@@ -417,7 +416,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
* For IPv6 address construct a sockaddr_in6 structure.
* For IPv6 address construct a sockaddr_in6 structure.
*/
*/
(
*
env
)
->
GetByteArrayRegion
(
env
,
addrArray
,
0
,
16
,
caddr
);
(
*
env
)
->
GetByteArrayRegion
(
env
,
addrArray
,
0
,
16
,
caddr
);
memset
((
char
*
)
&
him6
,
0
,
sizeof
(
him6
));
memset
((
void
*
)
&
him6
,
0
,
sizeof
(
him6
));
memcpy
((
void
*
)
&
(
him6
.
sin6_addr
),
caddr
,
sizeof
(
struct
in6_addr
)
);
memcpy
((
void
*
)
&
(
him6
.
sin6_addr
),
caddr
,
sizeof
(
struct
in6_addr
)
);
him6
.
sin6_family
=
AF_INET6
;
him6
.
sin6_family
=
AF_INET6
;
sa
=
(
struct
sockaddr
*
)
&
him6
;
sa
=
(
struct
sockaddr
*
)
&
him6
;
...
@@ -579,8 +578,8 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
...
@@ -579,8 +578,8 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
ifArray
,
ttl
);
ifArray
,
ttl
);
}
}
memset
((
char
*
)
caddr
,
0
,
16
);
memset
((
void
*
)
caddr
,
0
,
16
);
memset
((
char
*
)
&
him6
,
0
,
sizeof
(
him6
));
memset
((
void
*
)
&
him6
,
0
,
sizeof
(
him6
));
(
*
env
)
->
GetByteArrayRegion
(
env
,
addrArray
,
0
,
16
,
caddr
);
(
*
env
)
->
GetByteArrayRegion
(
env
,
addrArray
,
0
,
16
,
caddr
);
memcpy
((
void
*
)
&
(
him6
.
sin6_addr
),
caddr
,
sizeof
(
struct
in6_addr
)
);
memcpy
((
void
*
)
&
(
him6
.
sin6_addr
),
caddr
,
sizeof
(
struct
in6_addr
)
);
him6
.
sin6_family
=
AF_INET6
;
him6
.
sin6_family
=
AF_INET6
;
...
@@ -600,8 +599,8 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
...
@@ -600,8 +599,8 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
* for it.
* for it.
*/
*/
if
(
!
(
IS_NULL
(
ifArray
)))
{
if
(
!
(
IS_NULL
(
ifArray
)))
{
memset
((
char
*
)
caddr
,
0
,
16
);
memset
((
void
*
)
caddr
,
0
,
16
);
memset
((
char
*
)
&
inf6
,
0
,
sizeof
(
inf6
));
memset
((
void
*
)
&
inf6
,
0
,
sizeof
(
inf6
));
(
*
env
)
->
GetByteArrayRegion
(
env
,
ifArray
,
0
,
16
,
caddr
);
(
*
env
)
->
GetByteArrayRegion
(
env
,
ifArray
,
0
,
16
,
caddr
);
memcpy
((
void
*
)
&
(
inf6
.
sin6_addr
),
caddr
,
sizeof
(
struct
in6_addr
)
);
memcpy
((
void
*
)
&
(
inf6
.
sin6_addr
),
caddr
,
sizeof
(
struct
in6_addr
)
);
inf6
.
sin6_family
=
AF_INET6
;
inf6
.
sin6_family
=
AF_INET6
;
...
...
src/solaris/native/java/net/net_util_md.c
浏览文件 @
67166499
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
getaddrinfo_f
getaddrinfo_ptr
=
NULL
;
getaddrinfo_f
getaddrinfo_ptr
=
NULL
;
freeaddrinfo_f
freeaddrinfo_ptr
=
NULL
;
freeaddrinfo_f
freeaddrinfo_ptr
=
NULL
;
gai_strerror_f
gai_strerror_ptr
=
NULL
;
getnameinfo_f
getnameinfo_ptr
=
NULL
;
getnameinfo_f
getnameinfo_ptr
=
NULL
;
/*
/*
...
@@ -342,11 +343,14 @@ jint IPv6_supported()
...
@@ -342,11 +343,14 @@ jint IPv6_supported()
freeaddrinfo_ptr
=
(
freeaddrinfo_f
)
freeaddrinfo_ptr
=
(
freeaddrinfo_f
)
JVM_FindLibraryEntry
(
RTLD_DEFAULT
,
"freeaddrinfo"
);
JVM_FindLibraryEntry
(
RTLD_DEFAULT
,
"freeaddrinfo"
);
gai_strerror_ptr
=
(
gai_strerror_f
)
JVM_FindLibraryEntry
(
RTLD_DEFAULT
,
"gai_strerror"
);
getnameinfo_ptr
=
(
getnameinfo_f
)
getnameinfo_ptr
=
(
getnameinfo_f
)
JVM_FindLibraryEntry
(
RTLD_DEFAULT
,
"getnameinfo"
);
JVM_FindLibraryEntry
(
RTLD_DEFAULT
,
"getnameinfo"
);
if
(
freeaddrinfo_ptr
==
NULL
||
getnameinfo_ptr
==
NULL
)
{
if
(
freeaddrinfo_ptr
==
NULL
||
getnameinfo_ptr
==
NULL
)
{
/* We
e
need all 3 of them */
/* We need all 3 of them */
getaddrinfo_ptr
=
NULL
;
getaddrinfo_ptr
=
NULL
;
}
}
...
@@ -355,6 +359,35 @@ jint IPv6_supported()
...
@@ -355,6 +359,35 @@ jint IPv6_supported()
#endif
/* AF_INET6 */
#endif
/* AF_INET6 */
}
}
void
ThrowUnknownHostExceptionWithGaiError
(
JNIEnv
*
env
,
const
char
*
hostname
,
int
gai_error
)
{
int
size
;
char
*
buf
;
const
char
*
format
=
"%s: %s"
;
const
char
*
error_string
=
(
gai_strerror_ptr
==
NULL
)
?
NULL
:
(
*
gai_strerror_ptr
)(
gai_error
);
if
(
error_string
==
NULL
)
error_string
=
"unknown error"
;
size
=
strlen
(
format
)
+
strlen
(
hostname
)
+
strlen
(
error_string
)
+
2
;
buf
=
(
char
*
)
malloc
(
size
);
if
(
buf
)
{
jstring
s
;
sprintf
(
buf
,
format
,
hostname
,
error_string
);
s
=
JNU_NewStringPlatform
(
env
,
buf
);
if
(
s
!=
NULL
)
{
jobject
x
=
JNU_NewObjectByName
(
env
,
"java/net/UnknownHostException"
,
"(Ljava/lang/String;)V"
,
s
);
if
(
x
!=
NULL
)
(
*
env
)
->
Throw
(
env
,
x
);
}
free
(
buf
);
}
}
void
void
NET_AllocSockaddr
(
struct
sockaddr
**
him
,
int
*
len
)
{
NET_AllocSockaddr
(
struct
sockaddr
**
him
,
int
*
len
)
{
#ifdef AF_INET6
#ifdef AF_INET6
...
@@ -1173,19 +1206,26 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg,
...
@@ -1173,19 +1206,26 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg,
}
}
/*
/*
* SOL_SOCKET/{SO_SNDBUF,SO_RCVBUF} - On Solaris need to
* SOL_SOCKET/{SO_SNDBUF,SO_RCVBUF} - On Solaris we may need to clamp
* ensure that value is <= max_buf as otherwise we get
* the value when it exceeds the system limit.
* an invalid argument.
*/
*/
#ifdef __solaris__
#ifdef __solaris__
if
(
level
==
SOL_SOCKET
)
{
if
(
level
==
SOL_SOCKET
)
{
if
(
opt
==
SO_SNDBUF
||
opt
==
SO_RCVBUF
)
{
if
(
opt
==
SO_SNDBUF
||
opt
==
SO_RCVBUF
)
{
int
sotype
,
arglen
;
int
sotype
,
arglen
;
int
*
bufsize
,
maxbuf
;
int
*
bufsize
,
maxbuf
;
int
ret
;
/* Attempt with the original size */
ret
=
setsockopt
(
fd
,
level
,
opt
,
arg
,
len
);
if
((
ret
==
0
)
||
(
ret
==
-
1
&&
errno
!=
ENOBUFS
))
return
ret
;
/* Exceeded system limit so clamp and retry */
if
(
!
init_max_buf
)
{
if
(
!
init_max_buf
)
{
tcp_max_buf
=
getParam
(
"/dev/tcp"
,
"tcp_max_buf"
,
6
4
*
1024
);
tcp_max_buf
=
getParam
(
"/dev/tcp"
,
"tcp_max_buf"
,
102
4
*
1024
);
udp_max_buf
=
getParam
(
"/dev/udp"
,
"udp_max_buf"
,
64
*
1024
);
udp_max_buf
=
getParam
(
"/dev/udp"
,
"udp_max_buf"
,
2048
*
1024
);
init_max_buf
=
1
;
init_max_buf
=
1
;
}
}
...
...
src/solaris/native/java/net/net_util_md.h
浏览文件 @
67166499
...
@@ -89,6 +89,8 @@ typedef int (*getaddrinfo_f)(const char *nodename, const char *servname,
...
@@ -89,6 +89,8 @@ typedef int (*getaddrinfo_f)(const char *nodename, const char *servname,
typedef
void
(
*
freeaddrinfo_f
)(
struct
addrinfo
*
);
typedef
void
(
*
freeaddrinfo_f
)(
struct
addrinfo
*
);
typedef
const
char
*
(
*
gai_strerror_f
)(
int
ecode
);
typedef
int
(
*
getnameinfo_f
)(
const
struct
sockaddr
*
,
size_t
,
typedef
int
(
*
getnameinfo_f
)(
const
struct
sockaddr
*
,
size_t
,
char
*
,
size_t
,
char
*
,
size_t
,
int
);
char
*
,
size_t
,
char
*
,
size_t
,
int
);
...
@@ -96,6 +98,10 @@ extern getaddrinfo_f getaddrinfo_ptr;
...
@@ -96,6 +98,10 @@ extern getaddrinfo_f getaddrinfo_ptr;
extern
freeaddrinfo_f
freeaddrinfo_ptr
;
extern
freeaddrinfo_f
freeaddrinfo_ptr
;
extern
getnameinfo_f
getnameinfo_ptr
;
extern
getnameinfo_f
getnameinfo_ptr
;
void
ThrowUnknownHostExceptionWithGaiError
(
JNIEnv
*
env
,
const
char
*
hostname
,
int
gai_error
);
/* do we have address translation support */
/* do we have address translation support */
extern
jboolean
NET_addrtransAvailable
();
extern
jboolean
NET_addrtransAvailable
();
...
...
src/windows/native/java/io/io_util_md.c
浏览文件 @
67166499
...
@@ -531,7 +531,6 @@ handleClose(JNIEnv *env, jobject this, jfieldID fid)
...
@@ -531,7 +531,6 @@ handleClose(JNIEnv *env, jobject this, jfieldID fid)
SET_FD
(
this
,
-
1
,
fid
);
SET_FD
(
this
,
-
1
,
fid
);
if
(
CloseHandle
(
h
)
==
0
)
{
/* Returns zero on failure */
if
(
CloseHandle
(
h
)
==
0
)
{
/* Returns zero on failure */
SET_FD
(
this
,
fd
,
fid
);
// restore fd
JNU_ThrowIOExceptionWithLastError
(
env
,
"close failed"
);
JNU_ThrowIOExceptionWithLastError
(
env
,
"close failed"
);
}
}
return
0
;
return
0
;
...
...
src/windows/native/sun/net/spi/DefaultProxySelector.c
浏览文件 @
67166499
...
@@ -250,6 +250,10 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
...
@@ -250,6 +250,10 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
return
proxy
;
return
proxy
;
}
}
}
}
}
else
{
/* ProxyEnable == 0 or Query failed */
/* close the handle to the registry key */
RegCloseKey
(
hKey
);
}
}
}
}
...
...
test/ProblemList.txt
浏览文件 @
67166499
...
@@ -165,6 +165,12 @@ java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java generic-all
...
@@ -165,6 +165,12 @@ java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java generic-all
# very small tests and could greatly benefit from a samevm test run.
# very small tests and could greatly benefit from a samevm test run.
# So a large batch of beans tests are currently run with othervm mode.
# So a large batch of beans tests are currently run with othervm mode.
# Filed 6986807
java/beans/Introspector/TestTypeResolver.java generic-all
# Filed 6986813
java/beans/Introspector/memory/Test4508780.java generic-all
# Linux, some kind of problems with X11 display
# Linux, some kind of problems with X11 display
java/beans/PropertyChangeSupport/Test4682386.java generic-all
java/beans/PropertyChangeSupport/Test4682386.java generic-all
java/beans/PropertyChangeSupport/TestSynchronization.java generic-all
java/beans/PropertyChangeSupport/TestSynchronization.java generic-all
...
@@ -493,6 +499,9 @@ java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
...
@@ -493,6 +499,9 @@ java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
# jdk_security
# jdk_security
# Filed 6986868
sun/security/tools/jarsigner/crl.sh generic-all
# Filed 6951285, not sure how often this fails, last was Linux 64bit Fedora 9
# Filed 6951285, not sure how often this fails, last was Linux 64bit Fedora 9
sun/security/krb5/auto/MaxRetries.java generic-all
sun/security/krb5/auto/MaxRetries.java generic-all
...
@@ -689,10 +698,22 @@ java/text/Bidi/Bug6665028.java linux-x64
...
@@ -689,10 +698,22 @@ java/text/Bidi/Bug6665028.java linux-x64
# jdk_tools
# jdk_tools
# Filed 6952105
com/sun/jdi/SuspendThreadTest.java generic-all
# Filed 6986875
sun/tools/jps/jps-Vvml.sh generic-all
# Filed 6979016
sun/tools/jconsole/ResourceCheckTest.sh generic-all
############################################################################
############################################################################
# jdk_util
# jdk_util
# Filed 6933803
java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all
# Fails with assertion error on windows
# Fails with assertion error on windows
# 11 separate stacktraces created... file reuse problem?
# 11 separate stacktraces created... file reuse problem?
java/util/zip/ZipFile/ReadLongZipFileName.java generic-all
java/util/zip/ZipFile/ReadLongZipFileName.java generic-all
...
...
test/com/sun/security/sasl/ntlm/NTLMTest.java
浏览文件 @
67166499
...
@@ -31,8 +31,6 @@ import javax.security.sasl.*;
...
@@ -31,8 +31,6 @@ import javax.security.sasl.*;
import
javax.security.auth.callback.*
;
import
javax.security.auth.callback.*
;
import
java.util.*
;
import
java.util.*
;
import
com.sun.security.ntlm.NTLMException
;
public
class
NTLMTest
{
public
class
NTLMTest
{
private
static
final
String
MECH
=
"NTLM"
;
private
static
final
String
MECH
=
"NTLM"
;
...
@@ -95,19 +93,13 @@ public class NTLMTest {
...
@@ -95,19 +93,13 @@ public class NTLMTest {
checkVersion
(
"LM/NTLM"
,
"LMv2"
);
checkVersion
(
"LM/NTLM"
,
"LMv2"
);
throw
new
Exception
(
"Should not succeed"
);
throw
new
Exception
(
"Should not succeed"
);
}
catch
(
SaslException
se
)
{
}
catch
(
SaslException
se
)
{
NTLMException
ne
=
(
NTLMException
)
se
.
getCause
();
// OK
if
(
ne
.
errorCode
()
!=
NTLMException
.
AUTH_FAILED
)
{
throw
new
Exception
(
"Failed false"
);
}
}
}
try
{
try
{
checkVersion
(
"LMv2/NTLMv2"
,
"LM"
);
checkVersion
(
"LMv2/NTLMv2"
,
"LM"
);
throw
new
Exception
(
"Should not succeed"
);
throw
new
Exception
(
"Should not succeed"
);
}
catch
(
SaslException
se
)
{
}
catch
(
SaslException
se
)
{
NTLMException
ne
=
(
NTLMException
)
se
.
getCause
();
// OK
if
(
ne
.
errorCode
()
!=
NTLMException
.
AUTH_FAILED
)
{
throw
new
Exception
(
"Failed false"
);
}
}
}
}
}
...
...
test/com/sun/servicetag/JavaServiceTagTest.java
浏览文件 @
67166499
...
@@ -124,8 +124,9 @@ public class JavaServiceTagTest {
...
@@ -124,8 +124,9 @@ public class JavaServiceTagTest {
throw
new
RuntimeException
(
"Unexpected platform_arch: "
+
throw
new
RuntimeException
(
"Unexpected platform_arch: "
+
st
.
getPlatformArch
());
st
.
getPlatformArch
());
}
}
String
vendor
=
System
.
getProperty
(
"java.vendor"
);
if
(!
st
.
getProductVendor
().
if
(!
st
.
getProductVendor
().
equals
(
"Sun Microsystems"
))
{
equals
(
vendor
))
{
throw
new
RuntimeException
(
"Unexpected product_vendor: "
+
throw
new
RuntimeException
(
"Unexpected product_vendor: "
+
st
.
getProductVendor
());
st
.
getProductVendor
());
}
}
...
...
test/com/sun/servicetag/JavaServiceTagTest1.java
浏览文件 @
67166499
...
@@ -196,8 +196,10 @@ public class JavaServiceTagTest1 {
...
@@ -196,8 +196,10 @@ public class JavaServiceTagTest1 {
throw
new
RuntimeException
(
"Unexpected platform_arch: "
+
throw
new
RuntimeException
(
"Unexpected platform_arch: "
+
st
.
getPlatformArch
());
st
.
getPlatformArch
());
}
}
String
vendor
=
System
.
getProperty
(
"java.vendor"
);
if
(!
st
.
getProductVendor
().
if
(!
st
.
getProductVendor
().
equals
(
"Sun Microsystems"
))
{
equals
(
vendor
))
{
throw
new
RuntimeException
(
"Unexpected product_vendor: "
+
throw
new
RuntimeException
(
"Unexpected product_vendor: "
+
st
.
getProductVendor
());
st
.
getProductVendor
());
}
}
...
...
test/com/sun/servicetag/Util.java
浏览文件 @
67166499
...
@@ -162,6 +162,8 @@ public class Util {
...
@@ -162,6 +162,8 @@ public class Util {
for
(
ServiceTag
st
:
svcTags
)
{
for
(
ServiceTag
st
:
svcTags
)
{
ServiceTag
st1
=
stMap
.
get
(
st
.
getInstanceURN
());
ServiceTag
st1
=
stMap
.
get
(
st
.
getInstanceURN
());
if
(!
matches
(
st
,
st1
))
{
if
(!
matches
(
st
,
st1
))
{
System
.
err
.
println
(
st
);
System
.
err
.
println
(
st1
);
throw
new
RuntimeException
(
"ServiceTag in the registry "
+
throw
new
RuntimeException
(
"ServiceTag in the registry "
+
"does not match the one in the map"
);
"does not match the one in the map"
);
}
}
...
...
test/com/sun/servicetag/environ.properties
浏览文件 @
67166499
...
@@ -4,6 +4,6 @@ osName=SunOS
...
@@ -4,6 +4,6 @@ osName=SunOS
osVersion
=
5.10
osVersion
=
5.10
osArchitecture
=
sparc
osArchitecture
=
sparc
systemModel
=
Sun-Fire-V440
systemModel
=
Sun-Fire-V440
systemManufacturer
=
Sun Microsystems
systemManufacturer
=
Oracle Corporation
cpuManufacturer
=
Sun Microsystems
cpuManufacturer
=
Oracle Corporation
serialNumber
=
BEL078932
serialNumber
=
BEL078932
test/com/sun/servicetag/missing-environ-field.xml
浏览文件 @
67166499
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_defined_inst_id>
id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
</product_defined_inst_id>
<product_defined_inst_id>
id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
</product_defined_inst_id>
<product_vendor>
Sun Microsystems
</product_vendor>
<product_vendor>
Oracle Corporation
</product_vendor>
<platform_arch>
sparc
</platform_arch>
<platform_arch>
sparc
</platform_arch>
<timestamp>
2007-11-12 06:15:11 GMT
</timestamp>
<timestamp>
2007-11-12 06:15:11 GMT
</timestamp>
<container>
global
</container>
<container>
global
</container>
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_defined_inst_id>
id=1.6.0_05-b01 sparc,dir=/myjdk/solaris-i586
</product_defined_inst_id>
<product_defined_inst_id>
id=1.6.0_05-b01 sparc,dir=/myjdk/solaris-i586
</product_defined_inst_id>
<product_vendor>
Sun Microsystems
</product_vendor>
<product_vendor>
Oracle Corporation
</product_vendor>
<platform_arch>
i386
</platform_arch>
<platform_arch>
i386
</platform_arch>
<timestamp>
2007-11-12 06:15:11 GMT
</timestamp>
<timestamp>
2007-11-12 06:15:11 GMT
</timestamp>
<container>
global
</container>
<container>
global
</container>
...
...
test/com/sun/servicetag/newer-registry-version.xml
浏览文件 @
67166499
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_defined_inst_id>
id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
</product_defined_inst_id>
<product_defined_inst_id>
id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
</product_defined_inst_id>
<product_vendor>
Sun Microsystems
</product_vendor>
<product_vendor>
Oracle Corporation
</product_vendor>
<platform_arch>
sparc
</platform_arch>
<platform_arch>
sparc
</platform_arch>
<timestamp>
2007-11-13 00:49:01 GMT
</timestamp>
<timestamp>
2007-11-13 00:49:01 GMT
</timestamp>
<container>
global
</container>
<container>
global
</container>
...
...
test/com/sun/servicetag/registration.xml
浏览文件 @
67166499
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
<osVersion>
5.10
</osVersion>
<osVersion>
5.10
</osVersion>
<osArchitecture>
sparc
</osArchitecture>
<osArchitecture>
sparc
</osArchitecture>
<systemModel>
Sun-Fire-V440
</systemModel>
<systemModel>
Sun-Fire-V440
</systemModel>
<systemManufacturer>
Sun Microsystems
</systemManufacturer>
<systemManufacturer>
Oracle Corporation
</systemManufacturer>
<cpuManufacturer>
Sun Microsystems
</cpuManufacturer>
<cpuManufacturer>
Oracle Corporation
</cpuManufacturer>
<serialNumber>
BEL078932
</serialNumber>
<serialNumber>
BEL078932
</serialNumber>
</environment>
</environment>
<registry
urn=
"urn:st:9543ffaa-a4f1-4f77-b2d1-f561922d4e4a"
version=
"1.0"
>
<registry
urn=
"urn:st:9543ffaa-a4f1-4f77-b2d1-f561922d4e4a"
version=
"1.0"
>
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_defined_inst_id>
id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
</product_defined_inst_id>
<product_defined_inst_id>
id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
</product_defined_inst_id>
<product_vendor>
Sun Microsystems
</product_vendor>
<product_vendor>
Oracle Corporation
</product_vendor>
<platform_arch>
sparc
</platform_arch>
<platform_arch>
sparc
</platform_arch>
<timestamp>
2007-11-13 00:49:01 GMT
</timestamp>
<timestamp>
2007-11-13 00:49:01 GMT
</timestamp>
<container>
global
</container>
<container>
global
</container>
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent_urn>
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
</product_parent_urn>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_parent>
Java Platform Standard Edition 6 (Java SE 6)
</product_parent>
<product_defined_inst_id>
id=1.6.0_05-b01 i386,dir=/myjdk/solaris-i586
</product_defined_inst_id>
<product_defined_inst_id>
id=1.6.0_05-b01 i386,dir=/myjdk/solaris-i586
</product_defined_inst_id>
<product_vendor>
Sun Microsystems
</product_vendor>
<product_vendor>
Oracle Corporation
</product_vendor>
<platform_arch>
i386
</platform_arch>
<platform_arch>
i386
</platform_arch>
<timestamp>
2007-11-13 00:49:01 GMT
</timestamp>
<timestamp>
2007-11-13 00:49:01 GMT
</timestamp>
<container>
global
</container>
<container>
global
</container>
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
<product_parent_urn>
urn:uuid:596ffcfa-63d5-11d7-9886-ac816a682f92
</product_parent_urn>
<product_parent_urn>
urn:uuid:596ffcfa-63d5-11d7-9886-ac816a682f92
</product_parent_urn>
<product_parent>
Solaris Operating System
</product_parent>
<product_parent>
Solaris Operating System
</product_parent>
<product_defined_inst_id/>
<product_defined_inst_id/>
<product_vendor>
Sun Microsystems
</product_vendor>
<product_vendor>
Oracle Corporation
</product_vendor>
<platform_arch>
sparc
</platform_arch>
<platform_arch>
sparc
</platform_arch>
<timestamp>
2007-11-13 00:49:01 GMT
</timestamp>
<timestamp>
2007-11-13 00:49:01 GMT
</timestamp>
<container>
global
</container>
<container>
global
</container>
...
...
test/com/sun/servicetag/servicetag1.properties
浏览文件 @
67166499
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
product_parent_urn
=
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
product_parent_urn
=
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
product_parent
=
Java Platform Standard Edition 6 (Java SE 6)
product_parent
=
Java Platform Standard Edition 6 (Java SE 6)
product_defined_inst_id
=
id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
product_defined_inst_id
=
id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
product_vendor
=
Sun Microsystems
product_vendor
=
Oracle Corporation
platform_arch
=
sparc
platform_arch
=
sparc
timestamp
=
2007-11-12 05:19:40 GMT
timestamp
=
2007-11-12 05:19:40 GMT
container
=
global
container
=
global
...
...
test/com/sun/servicetag/servicetag2.properties
浏览文件 @
67166499
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:b58ef9a8-5ae8-11db-a023-080020a9ed93
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:b58ef9a8-5ae8-11db-a023-080020a9ed93
product_parent_urn
=
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
product_parent_urn
=
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
product_parent
=
Java Platform Standard Edition 6 (Java SE 6)
product_parent
=
Java Platform Standard Edition 6 (Java SE 6)
product_defined_inst_id
=
id=1.6.0_05-b01 i386,dir=/myjdk/solaris-i586
product_defined_inst_id
=
id=1.6.0_05-b01 i386,dir=/myjdk/solaris-i586
product_vendor
=
Sun Microsystems
product_vendor
=
Oracle Corporation
platform_arch
=
i386
platform_arch
=
i386
timestamp
=
2007-11-12 06:12:21 GMT
timestamp
=
2007-11-12 06:12:21 GMT
container
=
global
container
=
global
...
...
test/com/sun/servicetag/servicetag3.properties
浏览文件 @
67166499
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113
product_parent_urn
=
urn:uuid:596ffcfa-63d5-11d7-9886-ac816a682f92
product_parent_urn
=
urn:uuid:596ffcfa-63d5-11d7-9886-ac816a682f92
product_parent
=
Solaris Operating System
product_parent
=
Solaris Operating System
product_defined_inst_id
=
product_defined_inst_id
=
product_vendor
=
Sun Microsystems
product_vendor
=
Oracle Corporation
platform_arch
=
sparc
platform_arch
=
sparc
timestamp
=
2007-06-20 22:07:11 GMT
timestamp
=
2007-06-20 22:07:11 GMT
container
=
global
container
=
global
...
...
test/com/sun/servicetag/servicetag4.properties
浏览文件 @
67166499
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
product_parent_urn
=
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
product_parent_urn
=
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
product_parent
=
Java Platform Standard Edition 6 (Java SE 6)
product_parent
=
Java Platform Standard Edition 6 (Java SE 6)
product_defined_inst_id
=
id=1.6.0_05-b01 amd64,dir=/myjdk/linux-amd64
product_defined_inst_id
=
id=1.6.0_05-b01 amd64,dir=/myjdk/linux-amd64
product_vendor
=
Sun Microsystems
product_vendor
=
Oracle Corporation
platform_arch
=
x64
platform_arch
=
x64
timestamp
=
2007-12-12 05:19:40 GMT
timestamp
=
2007-12-12 05:19:40 GMT
container
=
global
container
=
global
...
...
test/com/sun/servicetag/servicetag5.properties
浏览文件 @
67166499
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
...
@@ -5,7 +5,7 @@ product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
product_parent_urn
=
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
product_parent_urn
=
urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
product_parent
=
Java Platform Standard Edition 6 (Java SE 6)
product_parent
=
Java Platform Standard Edition 6 (Java SE 6)
product_defined_inst_id
=
id=1.6.0_06-b06 i386,dir=/w/mchung/bundles/jdk1.6.0_05/jre
product_defined_inst_id
=
id=1.6.0_06-b06 i386,dir=/w/mchung/bundles/jdk1.6.0_05/jre
product_vendor
=
Sun Microsystems
product_vendor
=
Oracle Corporation
platform_arch
=
x86
platform_arch
=
x86
timestamp
=
2007-11-29 17:59:42 GMT
timestamp
=
2007-11-29 17:59:42 GMT
container
=
global
container
=
global
...
...
test/java/lang/ProcessBuilder/Basic.java
浏览文件 @
67166499
...
@@ -1824,6 +1824,64 @@ public class Basic {
...
@@ -1824,6 +1824,64 @@ public class Basic {
}
}
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
// Check that subprocesses which create subprocesses of their
// own do not cause parent to hang waiting for file
// descriptors to be closed.
//----------------------------------------------------------------
try
{
if
(
Unix
.
is
()
&&
new
File
(
"/bin/bash"
).
exists
()
&&
new
File
(
"/bin/sleep"
).
exists
())
{
final
String
[]
cmd
=
{
"/bin/bash"
,
"-c"
,
"(/bin/sleep 6666)"
};
final
ProcessBuilder
pb
=
new
ProcessBuilder
(
cmd
);
final
Process
p
=
pb
.
start
();
final
InputStream
stdout
=
p
.
getInputStream
();
final
InputStream
stderr
=
p
.
getErrorStream
();
final
OutputStream
stdin
=
p
.
getOutputStream
();
final
Thread
reader
=
new
Thread
()
{
public
void
run
()
{
try
{
stdout
.
read
();
}
catch
(
IOException
e
)
{
// e.printStackTrace();
if
(
EnglishUnix
.
is
()
&&
!
(
e
.
getMessage
().
matches
(
".*Bad file descriptor.*"
)))
unexpected
(
e
);
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}}};
reader
.
setDaemon
(
true
);
reader
.
start
();
Thread
.
sleep
(
100
);
p
.
destroy
();
// Subprocess is now dead, but file descriptors remain open.
check
(
p
.
waitFor
()
!=
0
);
check
(
p
.
exitValue
()
!=
0
);
stdout
.
close
();
stderr
.
close
();
stdin
.
close
();
//----------------------------------------------------------
// There remain unsolved issues with asynchronous close.
// Here's a highly non-portable experiment to demonstrate:
//----------------------------------------------------------
if
(
Boolean
.
getBoolean
(
"wakeupJeff!"
))
{
System
.
out
.
println
(
"wakeupJeff!"
);
// Initialize signal handler for INTERRUPT_SIGNAL.
new
FileInputStream
(
"/bin/sleep"
).
getChannel
().
close
();
// Send INTERRUPT_SIGNAL to every thread in this java.
String
[]
wakeupJeff
=
{
"/bin/bash"
,
"-c"
,
"/bin/ps --noheaders -Lfp $PPID | "
+
"/usr/bin/perl -nale 'print $F[3]' | "
+
// INTERRUPT_SIGNAL == 62 on my machine du jour.
"/usr/bin/xargs kill -62"
};
new
ProcessBuilder
(
wakeupJeff
).
start
().
waitFor
();
// If wakeupJeff worked, reader probably got EBADF.
reader
.
join
();
}
}
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
//----------------------------------------------------------------
// Attempt to start process with insufficient permissions fails.
// Attempt to start process with insufficient permissions fails.
//----------------------------------------------------------------
//----------------------------------------------------------------
...
...
test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java
浏览文件 @
67166499
...
@@ -29,7 +29,9 @@
...
@@ -29,7 +29,9 @@
import
java.nio.channels.*
;
import
java.nio.channels.*
;
import
java.net.*
;
import
java.net.*
;
import
static
java
.
net
.
StandardSocketOption
.*;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Set
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.concurrent.atomic.AtomicReference
;
...
@@ -39,6 +41,7 @@ public class Basic {
...
@@ -39,6 +41,7 @@ public class Basic {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
testBind
();
testBind
();
testAccept
();
testAccept
();
testSocketOptions
();
}
}
static
void
testBind
()
throws
Exception
{
static
void
testBind
()
throws
Exception
{
...
@@ -131,4 +134,39 @@ public class Basic {
...
@@ -131,4 +134,39 @@ public class Basic {
}
}
}
}
static
void
testSocketOptions
()
throws
Exception
{
System
.
out
.
println
(
"-- socket options --"
);
AsynchronousServerSocketChannel
ch
=
AsynchronousServerSocketChannel
.
open
();
try
{
// check supported options
Set
<
SocketOption
<?>>
options
=
ch
.
supportedOptions
();
if
(!
options
.
contains
(
SO_REUSEADDR
))
throw
new
RuntimeException
(
"SO_REUSEADDR should be supported"
);
if
(!
options
.
contains
(
SO_RCVBUF
))
throw
new
RuntimeException
(
"SO_RCVBUF should be supported"
);
// allowed to change when not bound
ch
.
setOption
(
SO_RCVBUF
,
256
*
1024
);
// can't check
int
before
=
ch
.
getOption
(
SO_RCVBUF
);
int
after
=
ch
.
setOption
(
SO_RCVBUF
,
Integer
.
MAX_VALUE
).
getOption
(
SO_RCVBUF
);
if
(
after
<
before
)
throw
new
RuntimeException
(
"setOption caused SO_RCVBUF to decrease"
);
ch
.
setOption
(
SO_REUSEADDR
,
true
);
checkOption
(
ch
,
SO_REUSEADDR
,
true
);
ch
.
setOption
(
SO_REUSEADDR
,
false
);
checkOption
(
ch
,
SO_REUSEADDR
,
false
);
}
finally
{
ch
.
close
();
}
}
static
void
checkOption
(
AsynchronousServerSocketChannel
ch
,
SocketOption
name
,
Object
expectedValue
)
throws
IOException
{
Object
value
=
ch
.
getOption
(
name
);
if
(!
value
.
equals
(
expectedValue
))
throw
new
RuntimeException
(
"value not as expected"
);
}
}
}
test/java/nio/channels/AsynchronousSocketChannel/Basic.java
浏览文件 @
67166499
...
@@ -121,8 +121,20 @@ public class Basic {
...
@@ -121,8 +121,20 @@ public class Basic {
AsynchronousSocketChannel
ch
=
AsynchronousSocketChannel
.
open
()
AsynchronousSocketChannel
ch
=
AsynchronousSocketChannel
.
open
()
.
setOption
(
SO_RCVBUF
,
128
*
1024
)
.
setOption
(
SO_RCVBUF
,
128
*
1024
)
.
setOption
(
SO_SNDBUF
,
128
*
1024
)
.
setOption
(
SO_SNDBUF
,
128
*
1024
)
.
setOption
(
SO_REUSEADDR
,
true
)
.
setOption
(
SO_REUSEADDR
,
true
);
.
bind
(
new
InetSocketAddress
(
0
));
// check SO_SNDBUF/SO_RCVBUF limits
int
before
,
after
;
before
=
ch
.
getOption
(
SO_SNDBUF
);
after
=
ch
.
setOption
(
SO_SNDBUF
,
Integer
.
MAX_VALUE
).
getOption
(
SO_SNDBUF
);
if
(
after
<
before
)
throw
new
RuntimeException
(
"setOption caused SO_SNDBUF to decrease"
);
before
=
ch
.
getOption
(
SO_RCVBUF
);
after
=
ch
.
setOption
(
SO_RCVBUF
,
Integer
.
MAX_VALUE
).
getOption
(
SO_RCVBUF
);
if
(
after
<
before
)
throw
new
RuntimeException
(
"setOption caused SO_RCVBUF to decrease"
);
ch
.
bind
(
new
InetSocketAddress
(
0
));
// default values
// default values
if
((
Boolean
)
ch
.
getOption
(
SO_KEEPALIVE
))
if
((
Boolean
)
ch
.
getOption
(
SO_KEEPALIVE
))
...
...
test/java/nio/channels/DatagramChannel/SocketOptionTests.java
浏览文件 @
67166499
...
@@ -68,8 +68,17 @@ public class SocketOptionTests {
...
@@ -68,8 +68,17 @@ public class SocketOptionTests {
checkOption
(
dc
,
SO_BROADCAST
,
true
);
checkOption
(
dc
,
SO_BROADCAST
,
true
);
dc
.
setOption
(
SO_BROADCAST
,
false
);
dc
.
setOption
(
SO_BROADCAST
,
false
);
checkOption
(
dc
,
SO_BROADCAST
,
false
);
checkOption
(
dc
,
SO_BROADCAST
,
false
);
dc
.
setOption
(
SO_SNDBUF
,
16
*
1024
);
// can't check
dc
.
setOption
(
SO_SNDBUF
,
128
*
1024
);
// can't check
dc
.
setOption
(
SO_RCVBUF
,
16
*
1024
);
// can't check
dc
.
setOption
(
SO_RCVBUF
,
128
*
1024
);
// can't check
int
before
,
after
;
before
=
dc
.
getOption
(
SO_SNDBUF
);
after
=
dc
.
setOption
(
SO_SNDBUF
,
Integer
.
MAX_VALUE
).
getOption
(
SO_SNDBUF
);
if
(
after
<
before
)
throw
new
RuntimeException
(
"setOption caused SO_SNDBUF to decrease"
);
before
=
dc
.
getOption
(
SO_RCVBUF
);
after
=
dc
.
setOption
(
SO_RCVBUF
,
Integer
.
MAX_VALUE
).
getOption
(
SO_RCVBUF
);
if
(
after
<
before
)
throw
new
RuntimeException
(
"setOption caused SO_RCVBUF to decrease"
);
dc
.
setOption
(
SO_REUSEADDR
,
true
);
dc
.
setOption
(
SO_REUSEADDR
,
true
);
checkOption
(
dc
,
SO_REUSEADDR
,
true
);
checkOption
(
dc
,
SO_REUSEADDR
,
true
);
dc
.
setOption
(
SO_REUSEADDR
,
false
);
dc
.
setOption
(
SO_REUSEADDR
,
false
);
...
...
test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java
浏览文件 @
67166499
...
@@ -56,6 +56,10 @@ public class SocketOptionTests {
...
@@ -56,6 +56,10 @@ public class SocketOptionTests {
// allowed to change when not bound
// allowed to change when not bound
ssc
.
setOption
(
SO_RCVBUF
,
256
*
1024
);
// can't check
ssc
.
setOption
(
SO_RCVBUF
,
256
*
1024
);
// can't check
int
before
=
ssc
.
getOption
(
SO_RCVBUF
);
int
after
=
ssc
.
setOption
(
SO_RCVBUF
,
Integer
.
MAX_VALUE
).
getOption
(
SO_RCVBUF
);
if
(
after
<
before
)
throw
new
RuntimeException
(
"setOption caused SO_RCVBUF to decrease"
);
ssc
.
setOption
(
SO_REUSEADDR
,
true
);
ssc
.
setOption
(
SO_REUSEADDR
,
true
);
checkOption
(
ssc
,
SO_REUSEADDR
,
true
);
checkOption
(
ssc
,
SO_REUSEADDR
,
true
);
ssc
.
setOption
(
SO_REUSEADDR
,
false
);
ssc
.
setOption
(
SO_REUSEADDR
,
false
);
...
...
test/java/nio/channels/SocketChannel/SocketOptionTests.java
浏览文件 @
67166499
...
@@ -70,6 +70,15 @@ public class SocketOptionTests {
...
@@ -70,6 +70,15 @@ public class SocketOptionTests {
checkOption
(
sc
,
SO_KEEPALIVE
,
false
);
checkOption
(
sc
,
SO_KEEPALIVE
,
false
);
sc
.
setOption
(
SO_SNDBUF
,
128
*
1024
);
// can't check
sc
.
setOption
(
SO_SNDBUF
,
128
*
1024
);
// can't check
sc
.
setOption
(
SO_RCVBUF
,
256
*
1024
);
// can't check
sc
.
setOption
(
SO_RCVBUF
,
256
*
1024
);
// can't check
int
before
,
after
;
before
=
sc
.
getOption
(
SO_SNDBUF
);
after
=
sc
.
setOption
(
SO_SNDBUF
,
Integer
.
MAX_VALUE
).
getOption
(
SO_SNDBUF
);
if
(
after
<
before
)
throw
new
RuntimeException
(
"setOption caused SO_SNDBUF to decrease"
);
before
=
sc
.
getOption
(
SO_RCVBUF
);
after
=
sc
.
setOption
(
SO_RCVBUF
,
Integer
.
MAX_VALUE
).
getOption
(
SO_RCVBUF
);
if
(
after
<
before
)
throw
new
RuntimeException
(
"setOption caused SO_RCVBUF to decrease"
);
sc
.
setOption
(
SO_REUSEADDR
,
true
);
sc
.
setOption
(
SO_REUSEADDR
,
true
);
checkOption
(
sc
,
SO_REUSEADDR
,
true
);
checkOption
(
sc
,
SO_REUSEADDR
,
true
);
sc
.
setOption
(
SO_REUSEADDR
,
false
);
sc
.
setOption
(
SO_REUSEADDR
,
false
);
...
...
test/java/nio/file/FileStore/Basic.java
浏览文件 @
67166499
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
*/
*/
/* @test
/* @test
* @bug 4313887 6873621
* @bug 4313887 6873621
6979526
* @summary Unit test for java.nio.file.FileStore
* @summary Unit test for java.nio.file.FileStore
* @library ..
* @library ..
*/
*/
...
...
test/java/nio/file/Files/MaxDepth.java
0 → 100644
浏览文件 @
67166499
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.nio.file.*
;
import
java.nio.file.attribute.*
;
import
java.io.IOException
;
import
java.util.*
;
/**
* Unit test for Files.walkFileTree to test maxDepth parameter
*/
public
class
MaxDepth
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
final
Path
top
=
Paths
.
get
(
args
[
0
]);
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
Set
<
FileVisitOption
>
opts
=
Collections
.
emptySet
();
final
int
maxDepth
=
i
;
Files
.
walkFileTree
(
top
,
opts
,
maxDepth
,
new
SimpleFileVisitor
<
Path
>()
{
// compute depth based on relative path to top directory
private
int
depth
(
Path
file
)
{
Path
rp
=
file
.
relativize
(
top
);
return
(
rp
==
null
)
?
0
:
rp
.
getNameCount
();
}
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
{
int
d
=
depth
(
dir
);
if
(
d
==
maxDepth
)
throw
new
RuntimeException
(
"Should not open directories at maxDepth"
);
if
(
d
>
maxDepth
)
throw
new
RuntimeException
(
"Too deep"
);
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
{
int
d
=
depth
(
file
);
if
(
d
>
maxDepth
)
throw
new
RuntimeException
(
"Too deep"
);
return
FileVisitResult
.
CONTINUE
;
}
});
}
}
}
test/java/nio/file/Files/Misc.java
浏览文件 @
67166499
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
import
java.nio.file.*
;
import
java.nio.file.*
;
import
java.nio.file.attribute.Attributes
;
import
java.nio.file.attribute.Attributes
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
...
@@ -117,25 +118,25 @@ public class Misc {
...
@@ -117,25 +118,25 @@ public class Misc {
SimpleFileVisitor
<
Path
>
visitor
=
new
SimpleFileVisitor
<
Path
>()
{
};
SimpleFileVisitor
<
Path
>
visitor
=
new
SimpleFileVisitor
<
Path
>()
{
};
boolean
ranTheGauntlet
=
false
;
boolean
ranTheGauntlet
=
false
;
try
{
visitor
.
preVisitDirectory
(
null
);
BasicFileAttributes
attrs
=
Attributes
.
readBasicFileAttributes
(
Paths
.
get
(
"."
));
try
{
visitor
.
preVisitDirectory
(
null
,
attrs
);
}
catch
(
NullPointerException
x0
)
{
}
catch
(
NullPointerException
x0
)
{
try
{
visitor
.
preVisitDirectory
Failed
(
null
,
new
IOException
()
);
try
{
visitor
.
preVisitDirectory
(
dir
,
null
);
}
catch
(
NullPointerException
x1
)
{
}
catch
(
NullPointerException
x1
)
{
try
{
visitor
.
preVisitDirectoryFailed
(
dir
,
null
);
try
{
visitor
.
visitFile
(
null
,
attrs
);
}
catch
(
NullPointerException
x2
)
{
}
catch
(
NullPointerException
x2
)
{
try
{
visitor
.
visitFile
(
null
,
Attributes
.
readBasicFileAttributes
(
Paths
.
get
(
"."
)));
}
catch
(
NullPointerException
x3
)
{
try
{
visitor
.
visitFile
(
dir
,
null
);
try
{
visitor
.
visitFile
(
dir
,
null
);
}
catch
(
NullPointerException
x
4
)
{
}
catch
(
NullPointerException
x
3
)
{
try
{
visitor
.
visitFileFailed
(
null
,
new
IOException
());
try
{
visitor
.
visitFileFailed
(
null
,
new
IOException
());
}
catch
(
NullPointerException
x
5
)
{
}
catch
(
NullPointerException
x
4
)
{
try
{
visitor
.
visitFileFailed
(
dir
,
null
);
try
{
visitor
.
visitFileFailed
(
dir
,
null
);
}
catch
(
NullPointerException
x
6
)
{
}
catch
(
NullPointerException
x
5
)
{
try
{
visitor
.
postVisitDirectory
(
null
,
new
IOException
());
try
{
visitor
.
postVisitDirectory
(
null
,
new
IOException
());
}
catch
(
NullPointerException
x
7
)
{
}
catch
(
NullPointerException
x
6
)
{
// if we get here then all visit* methods threw NPE as expected
// if we get here then all visit* methods threw NPE as expected
ranTheGauntlet
=
true
;
ranTheGauntlet
=
true
;
}}}}}}}
}
}}}}}}}
if
(!
ranTheGauntlet
)
if
(!
ranTheGauntlet
)
throw
new
RuntimeException
(
"A visit method did not throw NPE"
);
throw
new
RuntimeException
(
"A visit method did not throw NPE"
);
}
}
...
...
test/java/nio/file/Files/PrintFileTree.java
浏览文件 @
67166499
...
@@ -56,29 +56,34 @@ public class PrintFileTree {
...
@@ -56,29 +56,34 @@ public class PrintFileTree {
final
boolean
reportCycles
=
printCycles
;
final
boolean
reportCycles
=
printCycles
;
Files
.
walkFileTree
(
dir
,
options
,
Integer
.
MAX_VALUE
,
new
FileVisitor
<
FileRef
>()
{
Files
.
walkFileTree
(
dir
,
options
,
Integer
.
MAX_VALUE
,
new
FileVisitor
<
FileRef
>()
{
public
FileVisitResult
preVisitDirectory
(
FileRef
dir
)
{
@Override
public
FileVisitResult
preVisitDirectory
(
FileRef
dir
,
BasicFileAttributes
attrs
)
{
System
.
out
.
println
(
dir
);
System
.
out
.
println
(
dir
);
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
public
FileVisitResult
preVisitDirectoryFailed
(
FileRef
dir
,
IOException
exc
)
{
@Override
exc
.
printStackTrace
();
return
FileVisitResult
.
CONTINUE
;
}
public
FileVisitResult
visitFile
(
FileRef
file
,
BasicFileAttributes
attrs
)
{
public
FileVisitResult
visitFile
(
FileRef
file
,
BasicFileAttributes
attrs
)
{
if
(!
attrs
.
isDirectory
()
||
reportCycles
)
if
(!
attrs
.
isDirectory
()
||
reportCycles
)
System
.
out
.
println
(
file
);
System
.
out
.
println
(
file
);
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
public
FileVisitResult
postVisitDirectory
(
FileRef
dir
,
IOException
exc
)
{
@Override
if
(
exc
!=
null
)
{
public
FileVisitResult
postVisitDirectory
(
FileRef
dir
,
IOException
exc
)
exc
.
printStackTrace
();
throws
IOException
return
FileVisitResult
.
TERMINATE
;
{
if
(
exc
!=
null
)
throw
exc
;
return
FileVisitResult
.
CONTINUE
;
}
}
@Override
public
FileVisitResult
visitFileFailed
(
FileRef
file
,
IOException
exc
)
throws
IOException
{
if
(
reportCycles
&&
(
exc
instanceof
FileSystemLoopException
))
{
System
.
out
.
println
(
file
);
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
public
FileVisitResult
visitFileFailed
(
FileRef
file
,
IOException
exc
)
{
throw
exc
;
exc
.
printStackTrace
();
return
FileVisitResult
.
TERMINATE
;
}
}
});
});
}
}
...
...
test/java/nio/file/Files/SkipSiblings.java
浏览文件 @
67166499
...
@@ -54,32 +54,28 @@ public class SkipSiblings {
...
@@ -54,32 +54,28 @@ public class SkipSiblings {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Path
dir
=
Paths
.
get
(
args
[
0
]);
Path
dir
=
Paths
.
get
(
args
[
0
]);
Files
.
walkFileTree
(
dir
,
new
FileVisitor
<
Path
>()
{
Files
.
walkFileTree
(
dir
,
new
SimpleFileVisitor
<
Path
>()
{
public
FileVisitResult
preVisitDirectory
(
Path
dir
)
{
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
{
check
(
dir
);
check
(
dir
);
if
(
skip
(
dir
))
if
(
skip
(
dir
))
return
FileVisitResult
.
SKIP_SIBLINGS
;
return
FileVisitResult
.
SKIP_SIBLINGS
;
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
public
FileVisitResult
preVisitDirectoryFailed
(
Path
dir
,
IOException
exc
)
{
@Override
throw
new
RuntimeException
(
exc
);
}
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
{
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
{
check
(
file
);
check
(
file
);
if
(
skip
(
file
))
if
(
skip
(
file
))
return
FileVisitResult
.
SKIP_SIBLINGS
;
return
FileVisitResult
.
SKIP_SIBLINGS
;
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
@Override
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
x
)
{
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
x
)
{
if
(
x
!=
null
)
if
(
x
!=
null
)
throw
new
RuntimeException
(
x
);
throw
new
RuntimeException
(
x
);
check
(
dir
);
check
(
dir
);
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
public
FileVisitResult
visitFileFailed
(
Path
file
,
IOException
x
)
{
throw
new
RuntimeException
(
x
);
}
});
});
}
}
}
}
test/java/nio/file/Files/TerminateWalk.java
浏览文件 @
67166499
...
@@ -49,22 +49,19 @@ public class TerminateWalk {
...
@@ -49,22 +49,19 @@ public class TerminateWalk {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Path
dir
=
Paths
.
get
(
args
[
0
]);
Path
dir
=
Paths
.
get
(
args
[
0
]);
Files
.
walkFileTree
(
dir
,
new
FileVisitor
<
Path
>()
{
Files
.
walkFileTree
(
dir
,
new
SimpleFileVisitor
<
Path
>()
{
public
FileVisitResult
preVisitDirectory
(
Path
dir
)
{
@Override
return
maybeTerminate
();
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
{
}
public
FileVisitResult
preVisitDirectoryFailed
(
Path
dir
,
IOException
exc
)
{
return
maybeTerminate
();
return
maybeTerminate
();
}
}
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
{
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
{
return
maybeTerminate
();
return
maybeTerminate
();
}
}
@Override
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
x
)
{
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
x
)
{
return
maybeTerminate
();
return
maybeTerminate
();
}
}
public
FileVisitResult
visitFileFailed
(
Path
file
,
IOException
x
)
{
return
maybeTerminate
();
}
});
});
}
}
}
}
test/java/nio/file/Files/WalkWithSecurity.java
浏览文件 @
67166499
...
@@ -116,7 +116,7 @@ public class WalkWithSecurity {
...
@@ -116,7 +116,7 @@ public class WalkWithSecurity {
}
}
@Override
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
)
{
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
{
System
.
out
.
println
(
dir
);
System
.
out
.
println
(
dir
);
count
++;
count
++;
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
...
...
test/java/nio/file/Files/walk_file_tree.sh
浏览文件 @
67166499
...
@@ -22,9 +22,9 @@
...
@@ -22,9 +22,9 @@
#
#
# @test
# @test
# @bug 4313887
# @bug 4313887
6907737
# @summary Unit test for walkFileTree method
# @summary Unit test for walkFileTree method
# @build CreateFileTree PrintFileTree SkipSiblings TerminateWalk
# @build CreateFileTree PrintFileTree SkipSiblings TerminateWalk
MaxDepth
# @run shell walk_file_tree.sh
# @run shell walk_file_tree.sh
# if TESTJAVA isn't set then we assume an interactive run.
# if TESTJAVA isn't set then we assume an interactive run.
...
@@ -84,6 +84,10 @@ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
...
@@ -84,6 +84,10 @@ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
$JAVA
TerminateWalk
"
$ROOT
"
$JAVA
TerminateWalk
"
$ROOT
"
if
[
$?
!=
0
]
;
then
failures
=
`
expr
$failures
+ 1
`
;
fi
if
[
$?
!=
0
]
;
then
failures
=
`
expr
$failures
+ 1
`
;
fi
# test maxDepth
$JAVA
MaxDepth
"
$ROOT
"
if
[
$?
!=
0
]
;
then
failures
=
`
expr
$failures
+ 1
`
;
fi
# clean-up
# clean-up
rm
-r
"
$ROOT
"
rm
-r
"
$ROOT
"
...
...
test/java/nio/file/TestUtil.java
浏览文件 @
67166499
...
@@ -44,15 +44,10 @@ public class TestUtil {
...
@@ -44,15 +44,10 @@ public class TestUtil {
return
createTemporaryDirectory
(
System
.
getProperty
(
"java.io.tmpdir"
));
return
createTemporaryDirectory
(
System
.
getProperty
(
"java.io.tmpdir"
));
}
}
static
void
removeAll
(
Path
dir
)
{
static
void
removeAll
(
Path
dir
)
throws
IOException
{
Files
.
walkFileTree
(
dir
,
new
FileVisitor
<
Path
>()
{
Files
.
walkFileTree
(
dir
,
new
FileVisitor
<
Path
>()
{
@Override
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
)
{
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
{
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
preVisitDirectoryFailed
(
Path
dir
,
IOException
exc
)
{
System
.
err
.
format
(
"Error occured accessing directory %s\n"
,
dir
,
exc
);
return
FileVisitResult
.
CONTINUE
;
return
FileVisitResult
.
CONTINUE
;
}
}
@Override
@Override
...
...
test/java/util/Collection/BiggernYours.java
浏览文件 @
67166499
...
@@ -173,6 +173,11 @@ public class BiggernYours {
...
@@ -173,6 +173,11 @@ public class BiggernYours {
new
ConcurrentHashMap
()
{
new
ConcurrentHashMap
()
{
public
int
size
()
{
return
randomize
(
super
.
size
());}});
public
int
size
()
{
return
randomize
(
super
.
size
());}});
testCollections
(
new
ConcurrentLinkedDeque
(),
new
ConcurrentLinkedDeque
()
{
public
int
size
()
{
return
randomize
(
super
.
size
());}});
testCollections
(
testCollections
(
new
ConcurrentLinkedQueue
(),
new
ConcurrentLinkedQueue
(),
new
ConcurrentLinkedQueue
()
{
new
ConcurrentLinkedQueue
()
{
...
...
test/java/util/Collection/IteratorAtEnd.java
浏览文件 @
67166499
...
@@ -48,6 +48,7 @@ public class IteratorAtEnd {
...
@@ -48,6 +48,7 @@ public class IteratorAtEnd {
testCollection
(
new
PriorityQueue
());
testCollection
(
new
PriorityQueue
());
testCollection
(
new
LinkedBlockingQueue
());
testCollection
(
new
LinkedBlockingQueue
());
testCollection
(
new
ArrayBlockingQueue
(
100
));
testCollection
(
new
ArrayBlockingQueue
(
100
));
testCollection
(
new
ConcurrentLinkedDeque
());
testCollection
(
new
ConcurrentLinkedQueue
());
testCollection
(
new
ConcurrentLinkedQueue
());
testCollection
(
new
LinkedTransferQueue
());
testCollection
(
new
LinkedTransferQueue
());
...
...
test/java/util/Collection/MOAT.java
浏览文件 @
67166499
...
@@ -75,6 +75,7 @@ public class MOAT {
...
@@ -75,6 +75,7 @@ public class MOAT {
testCollection
(
new
ArrayBlockingQueue
<
Integer
>(
20
));
testCollection
(
new
ArrayBlockingQueue
<
Integer
>(
20
));
testCollection
(
new
LinkedBlockingQueue
<
Integer
>(
20
));
testCollection
(
new
LinkedBlockingQueue
<
Integer
>(
20
));
testCollection
(
new
LinkedBlockingDeque
<
Integer
>(
20
));
testCollection
(
new
LinkedBlockingDeque
<
Integer
>(
20
));
testCollection
(
new
ConcurrentLinkedDeque
<
Integer
>());
testCollection
(
new
ConcurrentLinkedQueue
<
Integer
>());
testCollection
(
new
ConcurrentLinkedQueue
<
Integer
>());
testCollection
(
new
LinkedTransferQueue
<
Integer
>());
testCollection
(
new
LinkedTransferQueue
<
Integer
>());
testCollection
(
new
ConcurrentSkipListSet
<
Integer
>());
testCollection
(
new
ConcurrentSkipListSet
<
Integer
>());
...
@@ -433,6 +434,7 @@ public class MOAT {
...
@@ -433,6 +434,7 @@ public class MOAT {
checkFunctionalInvariants
(
q
);
checkFunctionalInvariants
(
q
);
if
((
q
instanceof
LinkedBlockingQueue
)
||
if
((
q
instanceof
LinkedBlockingQueue
)
||
(
q
instanceof
LinkedBlockingDeque
)
||
(
q
instanceof
LinkedBlockingDeque
)
||
(
q
instanceof
ConcurrentLinkedDeque
)
||
(
q
instanceof
ConcurrentLinkedQueue
))
{
(
q
instanceof
ConcurrentLinkedQueue
))
{
testQueueIteratorRemove
(
q
);
testQueueIteratorRemove
(
q
);
}
}
...
...
test/java/util/Collections/RacingCollections.java
浏览文件 @
67166499
...
@@ -235,6 +235,7 @@ public class RacingCollections {
...
@@ -235,6 +235,7 @@ public class RacingCollections {
new
ArrayList
<
Queue
<
Integer
>>(
newConcurrentDeques
());
new
ArrayList
<
Queue
<
Integer
>>(
newConcurrentDeques
());
list
.
add
(
new
LinkedBlockingQueue
<
Integer
>(
10
));
list
.
add
(
new
LinkedBlockingQueue
<
Integer
>(
10
));
list
.
add
(
new
LinkedTransferQueue
<
Integer
>());
list
.
add
(
new
LinkedTransferQueue
<
Integer
>());
list
.
add
(
new
ConcurrentLinkedQueue
<
Integer
>());
return
list
;
return
list
;
}
}
...
@@ -248,6 +249,7 @@ public class RacingCollections {
...
@@ -248,6 +249,7 @@ public class RacingCollections {
private
static
List
<
Deque
<
Integer
>>
newConcurrentDeques
()
{
private
static
List
<
Deque
<
Integer
>>
newConcurrentDeques
()
{
List
<
Deque
<
Integer
>>
list
=
new
ArrayList
<
Deque
<
Integer
>>();
List
<
Deque
<
Integer
>>
list
=
new
ArrayList
<
Deque
<
Integer
>>();
list
.
add
(
new
LinkedBlockingDeque
<
Integer
>(
10
));
list
.
add
(
new
LinkedBlockingDeque
<
Integer
>(
10
));
list
.
add
(
new
ConcurrentLinkedDeque
<
Integer
>());
return
list
;
return
list
;
}
}
...
...
test/java/util/Deque/ChorusLine.java
浏览文件 @
67166499
...
@@ -129,6 +129,7 @@ public class ChorusLine {
...
@@ -129,6 +129,7 @@ public class ChorusLine {
deqs
.
add
(
new
ArrayDeque
<
Integer
>());
deqs
.
add
(
new
ArrayDeque
<
Integer
>());
deqs
.
add
(
new
LinkedList
<
Integer
>());
deqs
.
add
(
new
LinkedList
<
Integer
>());
deqs
.
add
(
new
LinkedBlockingDeque
<
Integer
>());
deqs
.
add
(
new
LinkedBlockingDeque
<
Integer
>());
deqs
.
add
(
new
ConcurrentLinkedDeque
<
Integer
>());
equal
(
deqs
);
equal
(
deqs
);
...
...
test/java/util/concurrent/ConcurrentQueues/ConcurrentQueueLoops.java
浏览文件 @
67166499
...
@@ -55,6 +55,7 @@ public class ConcurrentQueueLoops {
...
@@ -55,6 +55,7 @@ public class ConcurrentQueueLoops {
Collection
<
Queue
<
Integer
>>
concurrentQueues
()
{
Collection
<
Queue
<
Integer
>>
concurrentQueues
()
{
List
<
Queue
<
Integer
>>
queues
=
new
ArrayList
<
Queue
<
Integer
>>();
List
<
Queue
<
Integer
>>
queues
=
new
ArrayList
<
Queue
<
Integer
>>();
queues
.
add
(
new
ConcurrentLinkedDeque
<
Integer
>());
queues
.
add
(
new
ConcurrentLinkedQueue
<
Integer
>());
queues
.
add
(
new
ConcurrentLinkedQueue
<
Integer
>());
queues
.
add
(
new
ArrayBlockingQueue
<
Integer
>(
items
,
false
));
queues
.
add
(
new
ArrayBlockingQueue
<
Integer
>(
items
,
false
));
//queues.add(new ArrayBlockingQueue<Integer>(count, true));
//queues.add(new ArrayBlockingQueue<Integer>(count, true));
...
@@ -105,7 +106,7 @@ public class ConcurrentQueueLoops {
...
@@ -105,7 +106,7 @@ public class ConcurrentQueueLoops {
final
Queue
<
Integer
>
queue
;
final
Queue
<
Integer
>
queue
;
final
CyclicBarrier
barrier
;
final
CyclicBarrier
barrier
;
int
items
;
int
items
;
Stage
(
Queue
<
Integer
>
q
,
CyclicBarrier
b
,
int
items
)
{
Stage
(
Queue
<
Integer
>
q
,
CyclicBarrier
b
,
int
items
)
{
queue
=
q
;
queue
=
q
;
barrier
=
b
;
barrier
=
b
;
this
.
items
=
items
;
this
.
items
=
items
;
...
...
test/java/util/concurrent/ConcurrentQueues/GCRetention.java
浏览文件 @
67166499
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentLinkedDeque
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.LinkedBlockingDeque
;
import
java.util.concurrent.LinkedBlockingDeque
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
@@ -62,6 +63,7 @@ public class GCRetention {
...
@@ -62,6 +63,7 @@ public class GCRetention {
Collection
<
Queue
<
Boolean
>>
queues
()
{
Collection
<
Queue
<
Boolean
>>
queues
()
{
List
<
Queue
<
Boolean
>>
queues
=
new
ArrayList
<
Queue
<
Boolean
>>();
List
<
Queue
<
Boolean
>>
queues
=
new
ArrayList
<
Queue
<
Boolean
>>();
queues
.
add
(
new
ConcurrentLinkedDeque
<
Boolean
>());
queues
.
add
(
new
ConcurrentLinkedQueue
<
Boolean
>());
queues
.
add
(
new
ConcurrentLinkedQueue
<
Boolean
>());
queues
.
add
(
new
ArrayBlockingQueue
<
Boolean
>(
count
,
false
));
queues
.
add
(
new
ArrayBlockingQueue
<
Boolean
>(
count
,
false
));
queues
.
add
(
new
ArrayBlockingQueue
<
Boolean
>(
count
,
true
));
queues
.
add
(
new
ArrayBlockingQueue
<
Boolean
>(
count
,
true
));
...
...
test/java/util/concurrent/ConcurrentQueues/IteratorWeakConsistency.java
浏览文件 @
67166499
...
@@ -48,6 +48,7 @@ public class IteratorWeakConsistency {
...
@@ -48,6 +48,7 @@ public class IteratorWeakConsistency {
test
(
new
LinkedBlockingQueue
(
20
));
test
(
new
LinkedBlockingQueue
(
20
));
test
(
new
LinkedBlockingDeque
());
test
(
new
LinkedBlockingDeque
());
test
(
new
LinkedBlockingDeque
(
20
));
test
(
new
LinkedBlockingDeque
(
20
));
test
(
new
ConcurrentLinkedDeque
());
test
(
new
ConcurrentLinkedQueue
());
test
(
new
ConcurrentLinkedQueue
());
test
(
new
LinkedTransferQueue
());
test
(
new
LinkedTransferQueue
());
// Other concurrent queues (e.g. ArrayBlockingQueue) do not
// Other concurrent queues (e.g. ArrayBlockingQueue) do not
...
...
test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java
浏览文件 @
67166499
...
@@ -55,6 +55,7 @@ public class OfferRemoveLoops {
...
@@ -55,6 +55,7 @@ public class OfferRemoveLoops {
testQueue
(
new
LinkedBlockingDeque
());
testQueue
(
new
LinkedBlockingDeque
());
testQueue
(
new
ArrayBlockingQueue
(
10
));
testQueue
(
new
ArrayBlockingQueue
(
10
));
testQueue
(
new
PriorityBlockingQueue
(
10
));
testQueue
(
new
PriorityBlockingQueue
(
10
));
testQueue
(
new
ConcurrentLinkedDeque
());
testQueue
(
new
ConcurrentLinkedQueue
());
testQueue
(
new
ConcurrentLinkedQueue
());
testQueue
(
new
LinkedTransferQueue
());
testQueue
(
new
LinkedTransferQueue
());
}
}
...
...
test/java/util/concurrent/ConcurrentQueues/RemovePollRace.java
浏览文件 @
67166499
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentLinkedDeque
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.LinkedBlockingDeque
;
import
java.util.concurrent.LinkedBlockingDeque
;
...
@@ -62,6 +63,7 @@ public class RemovePollRace {
...
@@ -62,6 +63,7 @@ public class RemovePollRace {
Collection
<
Queue
<
Boolean
>>
concurrentQueues
()
{
Collection
<
Queue
<
Boolean
>>
concurrentQueues
()
{
List
<
Queue
<
Boolean
>>
queues
=
new
ArrayList
<
Queue
<
Boolean
>>();
List
<
Queue
<
Boolean
>>
queues
=
new
ArrayList
<
Queue
<
Boolean
>>();
queues
.
add
(
new
ConcurrentLinkedDeque
<
Boolean
>());
queues
.
add
(
new
ConcurrentLinkedQueue
<
Boolean
>());
queues
.
add
(
new
ConcurrentLinkedQueue
<
Boolean
>());
queues
.
add
(
new
ArrayBlockingQueue
<
Boolean
>(
count
,
false
));
queues
.
add
(
new
ArrayBlockingQueue
<
Boolean
>(
count
,
false
));
queues
.
add
(
new
ArrayBlockingQueue
<
Boolean
>(
count
,
true
));
queues
.
add
(
new
ArrayBlockingQueue
<
Boolean
>(
count
,
true
));
...
...
test/sun/net/www/http/ChunkedInputStream/ChunkedCharEncoding.sh
已删除
100644 → 0
浏览文件 @
f7a6ec10
#
# Copyright (c) 2006, 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 6502503
# @run shell/timeout=140 ChunkedCharEncoding.sh
# @summary Http URL connection don't work when default encoding is Cp037: HTTP Transfer-Encoding:chunked
OS
=
`
uname
-s
`
case
"
$OS
"
in
SunOS
|
Linux
)
PS
=
":"
FS
=
"/"
;;
CYGWIN
*
)
PS
=
";"
FS
=
"/"
;;
Windows
*
)
PS
=
";"
FS
=
"
\\
"
;;
*
)
echo
"Unrecognized system!"
exit
1
;
;;
esac
# compile
${
TESTJAVA
}${
FS
}
bin
${
FS
}
javac
-d
.
${
TESTSRC
}${
FS
}
TestAvailable.java
# run with CP037 encoding specified.
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java
-Dfile
.encoding
=
Cp037 TestAvailable 2>&1
result
=
$?
if
[
"
$result
"
-ne
"0"
]
;
then
exit
1
fi
# no failures, exit.
exit
0
test/sun/net/www/http/HttpClient/StreamingRetry.java
0 → 100644
浏览文件 @
67166499
/*
* Copyright (c) 2010, 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 6672144
* @summary HttpURLConnection.getInputStream sends POST request after failed chunked send
*/
import
java.net.HttpURLConnection
;
import
java.net.ServerSocket
;
import
java.net.URL
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
public
class
StreamingRetry
implements
Runnable
{
static
final
int
ACCEPT_TIMEOUT
=
20
*
1000
;
// 20 seconds
ServerSocket
ss
;
public
static
void
main
(
String
[]
args
)
throws
IOException
{
(
new
StreamingRetry
()).
instanceMain
();
}
void
instanceMain
()
throws
IOException
{
test
();
if
(
failed
>
0
)
throw
new
RuntimeException
(
"Some tests failed"
);
}
void
test
()
throws
IOException
{
ss
=
new
ServerSocket
(
0
);
ss
.
setSoTimeout
(
ACCEPT_TIMEOUT
);
int
port
=
ss
.
getLocalPort
();
(
new
Thread
(
this
)).
start
();
try
{
URL
url
=
new
URL
(
"http://localhost:"
+
port
+
"/"
);
HttpURLConnection
uc
=
(
HttpURLConnection
)
url
.
openConnection
();
uc
.
setDoOutput
(
true
);
uc
.
setChunkedStreamingMode
(
4096
);
OutputStream
os
=
uc
.
getOutputStream
();
os
.
write
(
"Hello there"
.
getBytes
());
InputStream
is
=
uc
.
getInputStream
();
is
.
close
();
}
catch
(
IOException
expected
)
{
//expected.printStackTrace();
}
finally
{
ss
.
close
();
}
}
// Server
public
void
run
()
{
try
{
(
ss
.
accept
()).
close
();
(
ss
.
accept
()).
close
();
ss
.
close
();
fail
(
"The server shouldn't accept a second connection"
);
}
catch
(
IOException
e
)
{
//OK, the clien will close the server socket if successfull
}
}
volatile
int
failed
=
0
;
void
fail
()
{
failed
++;
Thread
.
dumpStack
();}
void
fail
(
String
msg
)
{
System
.
err
.
println
(
msg
);
fail
();}
}
test/sun/net/www/protocol/http/6550798/TestCache.java
0 → 100644
浏览文件 @
67166499
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.net.*
;
import
java.io.*
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.BufferedInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.PrintStream
;
import
java.io.InputStream
;
import
java.io.File
;
import
java.net.CacheRequest
;
import
java.net.CacheResponse
;
import
java.net.ResponseCache
;
import
java.net.URI
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.List
;
import
java.util.Iterator
;
import
java.util.StringTokenizer
;
import
java.util.jar.JarInputStream
;
import
java.util.jar.JarFile
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.security.PrivilegedExceptionAction
;
import
java.security.PrivilegedActionException
;
import
java.security.Principal
;
import
java.security.cert.Certificate
;
import
javax.net.ssl.SSLPeerUnverifiedException
;
public
class
TestCache
extends
java
.
net
.
ResponseCache
{
private
boolean
inCacheHandler
=
false
;
private
boolean
_downloading
=
false
;
public
static
volatile
boolean
fail
=
false
;
public
static
void
reset
()
{
// Set system wide cache handler
System
.
out
.
println
(
"install deploy cache handler"
);
ResponseCache
.
setDefault
(
new
TestCache
());
}
public
synchronized
CacheResponse
get
(
final
URI
uri
,
String
rqstMethod
,
Map
requestHeaders
)
throws
IOException
{
System
.
out
.
println
(
"get: "
+
uri
);
Thread
.
currentThread
().
dumpStack
();
return
null
;
}
public
synchronized
CacheRequest
put
(
URI
uri
,
URLConnection
conn
)
throws
IOException
{
System
.
out
.
println
(
"put: "
+
uri
);
Thread
.
currentThread
().
dumpStack
();
URL
url
=
uri
.
toURL
();
return
new
DeployCacheRequest
(
url
,
conn
);
}
}
class
DeployByteArrayOutputStream
extends
java
.
io
.
ByteArrayOutputStream
{
private
URL
_url
;
private
URLConnection
_conn
;
DeployByteArrayOutputStream
(
URL
url
,
URLConnection
conn
)
{
_url
=
url
;
_conn
=
conn
;
}
public
void
close
()
throws
IOException
{
System
.
out
.
println
(
"contentLength: "
+
_conn
.
getContentLength
());
System
.
out
.
println
(
"byte array size: "
+
size
());
if
(
_conn
.
getContentLength
()
==
size
())
{
System
.
out
.
println
(
"correct content length"
);
}
else
{
System
.
out
.
println
(
"wrong content length"
);
System
.
out
.
println
(
"TEST FAILED"
);
TestCache
.
fail
=
true
;
}
super
.
close
();
}
}
class
DeployCacheRequest
extends
java
.
net
.
CacheRequest
{
private
URL
_url
;
private
URLConnection
_conn
;
private
boolean
_downloading
=
false
;
DeployCacheRequest
(
URL
url
,
URLConnection
conn
)
{
System
.
out
.
println
(
"DeployCacheRequest ctor for: "
+
url
);
_url
=
url
;
_conn
=
conn
;
}
public
void
abort
()
{
System
.
out
.
println
(
"abort called"
);
}
public
OutputStream
getBody
()
throws
IOException
{
System
.
out
.
println
(
"getBody called"
);
return
new
DeployByteArrayOutputStream
(
_url
,
_conn
);
}
}
test/sun/net/www/protocol/http/6550798/test.java
0 → 100644
浏览文件 @
67166499
/*
* Copyright (c) 2010, 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 6550798
* @summary Using InputStream.skip with ResponseCache will cause partial data to be cached
* @run main/othervm test
*/
import
java.net.*
;
import
com.sun.net.httpserver.*
;
import
java.io.*
;
public
class
test
{
final
static
int
LEN
=
16
*
1024
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
TestCache
.
reset
();
HttpServer
s
=
HttpServer
.
create
(
new
InetSocketAddress
(
0
),
10
);
s
.
createContext
(
"/"
,
new
HttpHandler
()
{
public
void
handle
(
HttpExchange
e
)
{
try
{
byte
[]
buf
=
new
byte
[
LEN
];
OutputStream
o
=
e
.
getResponseBody
();
e
.
sendResponseHeaders
(
200
,
LEN
);
o
.
write
(
buf
);
e
.
close
();
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
TestCache
.
fail
=
true
;
}
}
});
s
.
start
();
System
.
out
.
println
(
"http request with cache hander"
);
URL
u
=
new
URL
(
"http://127.0.0.1:"
+
s
.
getAddress
().
getPort
()+
"/f"
);
URLConnection
conn
=
u
.
openConnection
();
InputStream
is
=
null
;
try
{
// this calls into TestCache.get
byte
[]
buf
=
new
byte
[
8192
];
is
=
new
BufferedInputStream
(
conn
.
getInputStream
());
is
.
skip
(
1000
);
while
(
is
.
read
(
buf
)
!=
-
1
)
{
}
}
finally
{
if
(
is
!=
null
)
{
// this calls into TestCache.put
// TestCache.put will check if the resource
// should be cached
is
.
close
();
}
s
.
stop
(
0
);
}
if
(
TestCache
.
fail
)
{
System
.
out
.
println
(
"TEST FAILED"
);
throw
new
RuntimeException
();
}
else
{
System
.
out
.
println
(
"TEST OK"
);
}
}
}
test/sun/security/tools/jarsigner/crl.sh
浏览文件 @
67166499
...
@@ -63,7 +63,15 @@ $KT -alias a -gencrl -id 3:3 -id 4:4 -file crl2
...
@@ -63,7 +63,15 @@ $KT -alias a -gencrl -id 3:3 -id 4:4 -file crl2
$KT
-alias
b
-dname
CN
=
b
-keyalg
rsa
-genkey
-validity
300
$KT
-alias
b
-dname
CN
=
b
-keyalg
rsa
-genkey
-validity
300
$KT
-alias
b
-gencrl
-id
5:1
-id
6:2
-file
crl3
$KT
-alias
b
-gencrl
-id
5:1
-id
6:2
-file
crl3
$TESTJAVA
${
FS
}
bin
${
FS
}
jrunscript
-e
'println(new File("crl1").toURI())'
>
uri
cat
>
ToURI.java
<<
EOF
class ToURI {
public static void main(String[] args) throws Exception {
System.out.println(new java.io.File("crl1").toURI());
}
}
EOF
$TESTJAVA
${
FS
}
bin
${
FS
}
javac ToURI.java
$TESTJAVA
${
FS
}
bin
${
FS
}
java ToURI
>
uri
$KT
-alias
c
-dname
CN
=
c
-keyalg
rsa
-genkey
-validity
300
\
$KT
-alias
c
-dname
CN
=
c
-keyalg
rsa
-genkey
-validity
300
\
-ext
crl
=
uri:
`
cat
uri
`
-ext
crl
=
uri:
`
cat
uri
`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录