Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1a728fca
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1a728fca
编写于
12月 19, 2012
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8005248: (props) Integrate small footprint parser into Properties
Reviewed-by: joehw, mchung, psandoz, erikj
上级
4ab17280
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
163 addition
and
55 deletion
+163
-55
make/jdk/Makefile
make/jdk/Makefile
+11
-9
make/jdk/asm/Makefile
make/jdk/asm/Makefile
+0
-40
src/share/classes/java/util/Properties.java
src/share/classes/java/util/Properties.java
+1
-1
src/share/classes/jdk/internal/util/xml/BasicXmlPropertiesProvider.java
...ses/jdk/internal/util/xml/BasicXmlPropertiesProvider.java
+59
-0
test/java/util/Properties/LoadAndStoreXML.java
test/java/util/Properties/LoadAndStoreXML.java
+40
-5
test/java/util/Properties/invalidxml/BadCase.xml
test/java/util/Properties/invalidxml/BadCase.xml
+9
-0
test/java/util/Properties/invalidxml/BadDocType.xml.excluded
test/java/util/Properties/invalidxml/BadDocType.xml.excluded
+9
-0
test/java/util/Properties/invalidxml/NoClosingTag.xml
test/java/util/Properties/invalidxml/NoClosingTag.xml
+8
-0
test/java/util/Properties/invalidxml/NoDocType.xml.excluded
test/java/util/Properties/invalidxml/NoDocType.xml.excluded
+8
-0
test/java/util/Properties/invalidxml/NoRoot.xml
test/java/util/Properties/invalidxml/NoRoot.xml
+4
-0
test/java/util/Properties/invalidxml/NotQuoted.xml
test/java/util/Properties/invalidxml/NotQuoted.xml
+9
-0
test/java/util/Properties/invalidxml/README.txt
test/java/util/Properties/invalidxml/README.txt
+5
-0
未找到文件。
make/jdk/Makefile
浏览文件 @
1a728fca
#
# Copyright (c)
1997,
2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
...
...
@@ -23,16 +23,18 @@
# questions.
#
#
# Makefile for building all of java
#
BUILDDIR
=
..
PACKAGE
=
jdk
PRODUCT
=
jdk
JAVAC_LINT_OPTIONS
=
-Xlint
:all
include
$(BUILDDIR)/common/Defs.gmk
SUBDIRS
=
asm
include
$(BUILDDIR)/common/Subdirs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS
=
jdk
all build clean clobber
::
$
(
SUBDIRS-loop
)
#
# Rules
#
include
$(BUILDDIR)/common/Classes.gmk
make/jdk/asm/Makefile
已删除
100644 → 0
浏览文件 @
4ab17280
#
# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. 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.
#
BUILDDIR
=
../..
PACKAGE
=
jdk.internal.org.objectweb.asm
PRODUCT
=
jdk
JAVAC_LINT_OPTIONS
=
-Xlint
:all
include
$(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS
=
jdk/internal/org/objectweb/asm
#
# Rules
#
include
$(BUILDDIR)/common/Classes.gmk
src/share/classes/java/util/Properties.java
浏览文件 @
1a728fca
...
...
@@ -1188,7 +1188,7 @@ class Properties extends Hashtable<Object,Object> {
provider
=
loadProviderAsService
(
cl
);
if
(
provider
!=
null
)
return
provider
;
throw
new
InternalError
(
"No fallback"
);
return
new
jdk
.
internal
.
util
.
xml
.
BasicXmlPropertiesProvider
(
);
}});
}
...
...
src/share/classes/jdk/internal/util/xml/BasicXmlPropertiesProvider.java
0 → 100644
浏览文件 @
1a728fca
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. 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
jdk.internal.util.xml
;
import
java.util.Properties
;
import
java.util.InvalidPropertiesFormatException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.IOException
;
import
sun.util.spi.XmlPropertiesProvider
;
/**
* A {@code XmlPropertiesProvider} implementation that uses the UKit XML parser.
*/
public
class
BasicXmlPropertiesProvider
extends
XmlPropertiesProvider
{
private
final
PropertiesDefaultHandler
handler
=
new
PropertiesDefaultHandler
();
public
BasicXmlPropertiesProvider
()
{
}
@Override
public
void
load
(
Properties
props
,
InputStream
in
)
throws
IOException
,
InvalidPropertiesFormatException
{
handler
.
load
(
props
,
in
);
}
@Override
public
void
store
(
Properties
props
,
OutputStream
os
,
String
comment
,
String
encoding
)
throws
IOException
{
handler
.
store
(
props
,
os
,
comment
,
encoding
);
}
}
test/java/util/Properties/LoadAndStoreXML.java
浏览文件 @
1a728fca
...
...
@@ -23,13 +23,16 @@
/*
* @test
* @bug 8000354 8000685
* @bug 8000354 8000685
8004371
* @summary Basic test of storeToXML and loadToXML
* @run main LoadAndStoreXML
* @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=jdk.internal.util.xml.BasicXmlPropertiesProvider LoadAndStoreXML
*/
import
java.io.*
;
import
java.util.*
;
import
java.security.*
;
import
java.nio.file.*
;
public
class
LoadAndStoreXML
{
...
...
@@ -67,6 +70,8 @@ public class LoadAndStoreXML {
* read with Properties#loadFromXML.
*/
static
void
testLoadAndStore
(
String
encoding
)
throws
IOException
{
System
.
out
.
println
(
"testLoadAndStore, encoding="
+
encoding
);
Properties
props
=
new
Properties
();
props
.
put
(
"k1"
,
"foo"
);
props
.
put
(
"k2"
,
"bar"
);
...
...
@@ -89,6 +94,8 @@ public class LoadAndStoreXML {
* Test loadFromXML with a document that does not have an encoding declaration
*/
static
void
testLoadWithoutEncoding
()
throws
IOException
{
System
.
out
.
println
(
"testLoadWithoutEncoding"
);
Properties
expected
=
new
Properties
();
expected
.
put
(
"foo"
,
"bar"
);
...
...
@@ -107,10 +114,11 @@ public class LoadAndStoreXML {
}
}
/**
* Test loadFromXML with unsupported encoding
*/
static
void
testLoadWithBadEncoding
()
throws
IOException
{
/**
* Test loadFromXML with unsupported encoding
*/
static
void
testLoadWithBadEncoding
()
throws
IOException
{
System
.
out
.
println
(
"testLoadWithBadEncoding"
);
String
s
=
"<?xml version=\"1.0\" encoding=\"BAD\"?>"
+
"<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">"
+
"<properties>"
+
...
...
@@ -128,6 +136,7 @@ public class LoadAndStoreXML {
* Test storeToXML with unsupported encoding
*/
static
void
testStoreWithBadEncoding
()
throws
IOException
{
System
.
out
.
println
(
"testStoreWithBadEncoding"
);
Properties
props
=
new
Properties
();
props
.
put
(
"foo"
,
"bar"
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
...
...
@@ -137,6 +146,26 @@ public class LoadAndStoreXML {
}
catch
(
UnsupportedEncodingException
expected
)
{
}
}
/**
* Test loadFromXML with malformed documents
*/
static
void
testLoadWithMalformedDoc
(
Path
dir
)
throws
IOException
{
try
(
DirectoryStream
<
Path
>
stream
=
Files
.
newDirectoryStream
(
dir
,
"*.xml"
))
{
for
(
Path
file:
stream
)
{
System
.
out
.
println
(
"testLoadWithMalformedDoc, file="
+
file
.
getFileName
());
try
(
InputStream
in
=
Files
.
newInputStream
(
file
))
{
Properties
props
=
new
Properties
();
try
{
props
.
loadFromXML
(
in
);
throw
new
RuntimeException
(
"InvalidPropertiesFormatException not thrown"
);
}
catch
(
InvalidPropertiesFormatException
x
)
{
System
.
out
.
println
(
x
);
}
}
}
}
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
testLoadAndStore
(
"UTF-8"
);
...
...
@@ -145,6 +174,12 @@ public class LoadAndStoreXML {
testLoadWithBadEncoding
();
testStoreWithBadEncoding
();
// malformed documents
String
src
=
System
.
getProperty
(
"test.src"
);
String
subdir
=
"invalidxml"
;
Path
dir
=
(
src
==
null
)
?
Paths
.
get
(
subdir
)
:
Paths
.
get
(
src
,
subdir
);
testLoadWithMalformedDoc
(
dir
);
// re-run sanity test with security manager
Policy
orig
=
Policy
.
getPolicy
();
Policy
p
=
new
SimplePolicy
(
new
RuntimePermission
(
"setSecurityManager"
),
...
...
test/java/util/Properties/invalidxml/BadCase.xml
0 → 100644
浏览文件 @
1a728fca
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<!-- XML tags are case sensitve, opening and closing tags must use same case -->
<properties>
<entry
key=
"foo"
>
bar
</entry>
<entry
key=
"gus"
>
baz
</entry>
</PROPERTIES>
test/java/util/Properties/invalidxml/BadDocType.xml.excluded
0 → 100644
浏览文件 @
1a728fca
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE namevaluepairs SYSTEM "http://java.sun.com/dtd/properties.dtd">
<!-- The root element for a XML properties document is properties -->
<properties>
<entry
key=
"foo"
>
bar
</entry>
<entry
key=
"gus"
>
baz
</entry>
</properties>
test/java/util/Properties/invalidxml/NoClosingTag.xml
0 → 100644
浏览文件 @
1a728fca
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<!-- XML elements must having a closing tag -->
<properties>
<entry
key=
"foo"
>
bar
</entry>
<entry
key=
"gus"
>
baz
</entry>
test/java/util/Properties/invalidxml/NoDocType.xml.excluded
0 → 100644
浏览文件 @
1a728fca
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- An XML properties document has the DOCTYPE declaration with the properties root element -->
<properties>
<entry
key=
"foo"
>
bar
</entry>
<entry
key=
"gus"
>
baz
</entry>
</properties>
test/java/util/Properties/invalidxml/NoRoot.xml
0 → 100644
浏览文件 @
1a728fca
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<!-- XML documents must have a root element -->
test/java/util/Properties/invalidxml/NotQuoted.xml
0 → 100644
浏览文件 @
1a728fca
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<!-- XML attribute values must be quoted -->
<properties>
<entry
key=
foo
>
bar
</entry>
<entry
key=
gus
>
baz
</entry>
</properties>
test/java/util/Properties/invalidxml/README.txt
0 → 100644
浏览文件 @
1a728fca
This directory contains test cases for the LoadAndStoreXML test case. Each file
in this directory should be a malformed XML document that should cause the
java.util.Properties loadFromXML method to throw InvalidPropertiesFormatException.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录