Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
d4f7e595
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d4f7e595
编写于
1月 21, 2013
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8006263: Supplementary test cases needed for doclint
Reviewed-by: mcimadamore Contributed-by: peter.jensen@oracle.com
上级
3e658696
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
954 addition
and
16 deletion
+954
-16
src/share/classes/com/sun/tools/doclint/Checker.java
src/share/classes/com/sun/tools/doclint/Checker.java
+1
-1
src/share/classes/com/sun/tools/doclint/DocLint.java
src/share/classes/com/sun/tools/doclint/DocLint.java
+8
-6
src/share/classes/com/sun/tools/doclint/Entity.java
src/share/classes/com/sun/tools/doclint/Entity.java
+2
-2
src/share/classes/com/sun/tools/doclint/HtmlTag.java
src/share/classes/com/sun/tools/doclint/HtmlTag.java
+3
-3
test/tools/doclint/CoverageExtras.java
test/tools/doclint/CoverageExtras.java
+71
-0
test/tools/doclint/DocLintTester.java
test/tools/doclint/DocLintTester.java
+19
-4
test/tools/doclint/html/EntitiesTest.java
test/tools/doclint/html/EntitiesTest.java
+317
-0
test/tools/doclint/html/EntitiesTest.out
test/tools/doclint/html/EntitiesTest.out
+19
-0
test/tools/doclint/tool/HelpTest.java
test/tools/doclint/tool/HelpTest.java
+38
-0
test/tools/doclint/tool/HelpTest.out
test/tools/doclint/tool/HelpTest.out
+43
-0
test/tools/doclint/tool/MaxDiagsTest.java
test/tools/doclint/tool/MaxDiagsTest.java
+21
-0
test/tools/doclint/tool/MaxDiagsTest.out
test/tools/doclint/tool/MaxDiagsTest.out
+14
-0
test/tools/doclint/tool/PathsTest.java
test/tools/doclint/tool/PathsTest.java
+136
-0
test/tools/doclint/tool/RunTest.java
test/tools/doclint/tool/RunTest.java
+200
-0
test/tools/doclint/tool/StatsTest.java
test/tools/doclint/tool/StatsTest.java
+19
-0
test/tools/doclint/tool/StatsTest.out
test/tools/doclint/tool/StatsTest.out
+43
-0
未找到文件。
src/share/classes/com/sun/tools/doclint/Checker.java
浏览文件 @
d4f7e595
...
...
@@ -92,7 +92,7 @@ public class Checker extends DocTreeScanner<Void, Void> {
boolean
foundInheritDoc
=
false
;
boolean
foundReturn
=
false
;
enum
Flag
{
public
enum
Flag
{
TABLE_HAS_CAPTION
,
HAS_ELEMENT
,
HAS_TEXT
...
...
src/share/classes/com/sun/tools/doclint/DocLint.java
浏览文件 @
d4f7e595
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
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
...
...
@@ -122,7 +122,7 @@ public class DocLint implements Plugin {
if
(
javacFiles
.
isEmpty
())
{
if
(!
needHelp
)
System
.
out
.
println
(
"no files given"
);
out
.
println
(
"no files given"
);
}
JavacTool
tool
=
JavacTool
.
create
();
...
...
@@ -179,11 +179,11 @@ public class DocLint implements Plugin {
}
}
else
if
(
arg
.
equals
(
STATS
))
{
env
.
messages
.
setStatsEnabled
(
true
);
}
else
if
(
arg
.
matche
s
(
"-bootclasspath"
)
&&
i
+
1
<
args
.
length
)
{
}
else
if
(
arg
.
equal
s
(
"-bootclasspath"
)
&&
i
+
1
<
args
.
length
)
{
javacBootClassPath
=
splitPath
(
args
[++
i
]);
}
else
if
(
arg
.
matche
s
(
"-classpath"
)
&&
i
+
1
<
args
.
length
)
{
}
else
if
(
arg
.
equal
s
(
"-classpath"
)
&&
i
+
1
<
args
.
length
)
{
javacClassPath
=
splitPath
(
args
[++
i
]);
}
else
if
(
arg
.
matche
s
(
"-sourcepath"
)
&&
i
+
1
<
args
.
length
)
{
}
else
if
(
arg
.
equal
s
(
"-sourcepath"
)
&&
i
+
1
<
args
.
length
)
{
javacSourcePath
=
splitPath
(
args
[++
i
]);
}
else
if
(
arg
.
equals
(
XMSGS_OPTION
))
{
env
.
messages
.
setOptions
(
null
);
...
...
@@ -234,6 +234,8 @@ public class DocLint implements Plugin {
out
.
println
(
" equivalent to -Xmsgs:all/protected, meaning that"
);
out
.
println
(
" all messages are reported for protected and public"
);
out
.
println
(
" declarations only. "
);
out
.
println
(
" -stats"
);
out
.
println
(
" Report statistics on the reported issues."
);
out
.
println
(
" -h -help --help -usage -?"
);
out
.
println
(
" Show this message."
);
out
.
println
(
""
);
...
...
@@ -247,7 +249,7 @@ public class DocLint implements Plugin {
List
<
File
>
splitPath
(
String
path
)
{
List
<
File
>
files
=
new
ArrayList
<
File
>();
for
(
String
f:
path
.
split
(
File
.
s
eparator
))
{
for
(
String
f:
path
.
split
(
File
.
pathS
eparator
))
{
if
(
f
.
length
()
>
0
)
files
.
add
(
new
File
(
f
));
}
...
...
src/share/classes/com/sun/tools/doclint/Entity.java
浏览文件 @
d4f7e595
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
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
...
...
@@ -43,7 +43,7 @@ import java.util.Map;
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
enum
Entity
{
public
enum
Entity
{
nbsp
(
160
),
iexcl
(
161
),
cent
(
162
),
...
...
src/share/classes/com/sun/tools/doclint/HtmlTag.java
浏览文件 @
d4f7e595
/*
* Copyright (c) 2010, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
3
, 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
...
...
@@ -273,7 +273,7 @@ public enum HtmlTag {
static
final
Map
<
String
,
Attr
>
index
=
new
HashMap
<
String
,
Attr
>();
static
{
for
(
Attr
t:
values
())
{
index
.
put
(
t
.
name
().
toLowerCase
(),
t
);
index
.
put
(
t
.
getText
(),
t
);
}
}
}
...
...
@@ -346,7 +346,7 @@ public enum HtmlTag {
private
static
final
Map
<
String
,
HtmlTag
>
index
=
new
HashMap
<
String
,
HtmlTag
>();
static
{
for
(
HtmlTag
t:
values
())
{
index
.
put
(
t
.
name
().
toLowerCase
(),
t
);
index
.
put
(
t
.
getText
(),
t
);
}
}
...
...
test/tools/doclint/CoverageExtras.java
0 → 100644
浏览文件 @
d4f7e595
/*
* Copyright (c) 2013, 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 8006263
* @summary Supplementary test cases needed for doclint
*/
import
com.sun.tools.doclint.Checker
;
import
com.sun.tools.doclint.Entity
;
import
com.sun.tools.doclint.HtmlTag
;
import
com.sun.tools.doclint.Messages
;
import
java.util.Objects
;
public
class
CoverageExtras
{
public
static
void
main
(
String
...
args
)
{
new
CoverageExtras
().
run
();
}
void
run
()
{
check
(
HtmlTag
.
A
,
HtmlTag
.
valueOf
(
"A"
),
HtmlTag
.
values
());
check
(
HtmlTag
.
Attr
.
ABBR
,
HtmlTag
.
Attr
.
valueOf
(
"ABBR"
),
HtmlTag
.
Attr
.
values
());
check
(
HtmlTag
.
AttrKind
.
INVALID
,
HtmlTag
.
AttrKind
.
valueOf
(
"INVALID"
),
HtmlTag
.
AttrKind
.
values
());
check
(
HtmlTag
.
BlockType
.
BLOCK
,
HtmlTag
.
BlockType
.
valueOf
(
"BLOCK"
),
HtmlTag
.
BlockType
.
values
());
check
(
HtmlTag
.
EndKind
.
NONE
,
HtmlTag
.
EndKind
.
valueOf
(
"NONE"
),
HtmlTag
.
EndKind
.
values
());
check
(
HtmlTag
.
Flag
.
EXPECT_CONTENT
,
HtmlTag
.
Flag
.
valueOf
(
"EXPECT_CONTENT"
),
HtmlTag
.
Flag
.
values
());
check
(
Checker
.
Flag
.
TABLE_HAS_CAPTION
,
Checker
.
Flag
.
valueOf
(
"TABLE_HAS_CAPTION"
),
Checker
.
Flag
.
values
());
check
(
Entity
.
nbsp
,
Entity
.
valueOf
(
"nbsp"
),
Entity
.
values
());
check
(
Messages
.
Group
.
ACCESSIBILITY
,
Messages
.
Group
.
valueOf
(
"ACCESSIBILITY"
),
Messages
.
Group
.
values
());
}
<
T
extends
Enum
<
T
>>
void
check
(
T
expect
,
T
value
,
T
[]
values
)
{
if
(!
Objects
.
equals
(
expect
,
value
))
{
error
(
"Mismatch: '"
+
expect
+
"', '"
+
value
+
"'"
);
}
if
(!
Objects
.
equals
(
expect
,
values
[
0
]))
{
error
(
"Mismatch: '"
+
expect
+
"', '"
+
values
[
0
]
+
"'"
);
}
}
void
error
(
String
msg
)
{
System
.
err
.
println
(
"Error: "
+
msg
);
errors
++;
}
int
errors
;
}
test/tools/doclint/DocLintTester.java
浏览文件 @
d4f7e595
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
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
...
...
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
com.sun.tools.doclint.DocLint
;
import
com.sun.tools.doclint.DocLint.BadArgs
;
import
java.io.BufferedReader
;
import
java.io.FileReader
;
import
java.io.IOException
;
...
...
@@ -45,6 +46,7 @@ public class DocLintTester {
public
void
run
(
String
...
args
)
throws
Exception
{
String
testSrc
=
System
.
getProperty
(
"test.src"
);
boolean
badArgs
=
false
;
File
refFile
=
null
;
List
<
String
>
opts
=
new
ArrayList
<
String
>();
List
<
File
>
files
=
new
ArrayList
<
File
>();
...
...
@@ -52,19 +54,25 @@ public class DocLintTester {
String
arg
=
args
[
i
];
if
(
arg
.
equals
(
"-ref"
))
{
refFile
=
new
File
(
testSrc
,
args
[++
i
]);
}
else
if
(
arg
.
equals
(
"-badargs"
))
{
badArgs
=
true
;
}
else
if
(
arg
.
startsWith
(
"-Xmsgs"
))
{
opts
.
add
(
arg
);
}
else
if
(
arg
.
startsWith
(
"-"
))
{
opts
.
add
(
arg
);
if
(
i
<
args
.
length
-
1
&&
!
args
[
i
+
1
].
startsWith
(
"-"
))
opts
.
add
(
args
[++
i
]);
}
else
files
.
add
(
new
File
(
testSrc
,
arg
));
}
check
(
opts
,
files
,
refFile
);
check
(
opts
,
files
,
badArgs
,
refFile
);
if
(
errors
>
0
)
throw
new
Exception
(
errors
+
" errors occurred"
);
}
void
check
(
List
<
String
>
opts
,
List
<
File
>
files
,
File
refFile
)
throws
Exception
{
void
check
(
List
<
String
>
opts
,
List
<
File
>
files
,
boolean
expectBadArgs
,
File
refFile
)
throws
Exception
{
List
<
String
>
args
=
new
ArrayList
<
String
>();
args
.
addAll
(
opts
);
for
(
File
file:
files
)
...
...
@@ -72,7 +80,14 @@ public class DocLintTester {
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
new
DocLint
().
run
(
pw
,
args
.
toArray
(
new
String
[
args
.
size
()]));
try
{
new
DocLint
().
run
(
pw
,
args
.
toArray
(
new
String
[
args
.
size
()]));
if
(
expectBadArgs
)
error
(
"expected exception not thrown"
);
}
catch
(
BadArgs
e
)
{
if
(!
expectBadArgs
)
error
(
"unexpected exception caught: "
+
e
);
}
pw
.
flush
();
String
out
=
normalizeNewlines
(
removeFileNames
(
sw
.
toString
())).
trim
();
if
(
out
!=
null
)
...
...
test/tools/doclint/html/EntitiesTest.java
0 → 100644
浏览文件 @
d4f7e595
/*
* Copyright (c) 2013, 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 8006263
* @summary Supplementary test cases needed for doclint
* @library ..
* @build DocLintTester
* @run main DocLintTester -Xmsgs:-html EntitiesTest.java
* @run main DocLintTester -Xmsgs:html -ref EntitiesTest.out EntitiesTest.java
*/
/** */
class
EntitiesTest
{
/**
*    
* ࡎ ࡎ ࡎ
*/
void
range_test
()
{
}
/**
*  
* ¡ ¡
* ¢ ¢
* £ £
* ¤ ¤
* ¥ ¥
* ¦ ¦
* § §
* ¨ ¨
* © ©
* ª ª
* « «
* ¬ ¬
* ­ ­
* ® ®
* ¯ ¯
* ° °
* ± ±
* ² ²
* ³ ³
* ´ ´
* µ µ
* ¶ ¶
* · ·
* ¸ ¸
* ¹ ¹
* º º
* » »
* ¼ ¼
* ½ ½
* ¾ ¾
* ¿ ¿
* À À
* Á Á
* Â Â
* Ã Ã
* Ä Ä
* Å Å
* Æ Æ
* Ç Ç
* È È
* É É
* Ê Ê
* Ë Ë
* Ì Ì
* Í Í
* Î Î
* Ï Ï
* Ð Ð
* Ñ Ñ
* Ò Ò
* Ó Ó
* Ô Ô
* Õ Õ
* Ö Ö
* × ×
* Ø Ø
* Ù Ù
* Ú Ú
* Û Û
* Ü Ü
* Ý Ý
* Þ Þ
* ß ß
* à à
* á á
* â â
* ã ã
* ä ä
* å å
* æ æ
* ç ç
* è è
* é é
* ê ê
* ë ë
* ì ì
* í í
* î î
* ï ï
* ð ð
* ñ ñ
* ò ò
* ó ó
* ô ô
* õ õ
* ö ö
* ÷ ÷
* ø ø
* ù ù
* ú ú
* û û
* ü ü
* ý ý
* þ þ
* ÿ ÿ
* ƒ ƒ
* Α Α
* Β Β
* Γ Γ
* Δ Δ
* Ε Ε
* Ζ Ζ
* Η Η
* Θ Θ
* Ι Ι
* Κ Κ
* Λ Λ
* Μ Μ
* Ν Ν
* Ξ Ξ
* Ο Ο
* Π Π
* Ρ Ρ
* Σ Σ
* Τ Τ
* Υ Υ
* Φ Φ
* Χ Χ
* Ψ Ψ
* Ω Ω
* α α
* β β
* γ γ
* δ δ
* ε ε
* ζ ζ
* η η
* θ θ
* ι ι
* κ κ
* λ λ
* μ μ
* ν ν
* ξ ξ
* ο ο
* π π
* ρ ρ
* ς ς
* σ σ
* τ τ
* υ υ
* φ φ
* χ χ
* ψ ψ
* ω ω
* ϑ ϑ
* ϒ ϒ
* ϖ ϖ
* • •
* … …
* ′ ′
* ″ ″
* ‾ ‾
* ⁄ ⁄
* ℘ ℘
* ℑ ℑ
* ℜ ℜ
* ™ ™
* ℵ ℵ
* ← ←
* ↑ ↑
* → →
* ↓ ↓
* ↔ ↔
* ↵ ↵
* ⇐ ⇐
* ⇑ ⇑
* ⇒ ⇒
* ⇓ ⇓
* ⇔ ⇔
* ∀ ∀
* ∂ ∂
* ∃ ∃
* ∅ ∅
* ∇ ∇
* ∈ ∈
* ∉ ∉
* ∋ ∋
* ∏ ∏
* ∑ ∑
* − −
* ∗ ∗
* √ √
* ∝ ∝
* ∞ ∞
* ∠ ∠
* ∧ ∧
* ∨ ∨
* ∩ ∩
* ∪ ∪
* &_int; ∫
* ∴ ∴
* ∼ ∼
* ≅ ≅
* ≈ ≈
* ≠ ≠
* ≡ ≡
* ≤ ≤
* ≥ ≥
* ⊂ ⊂
* ⊃ ⊃
* ⊄ ⊄
* ⊆ ⊆
* ⊇ ⊇
* ⊕ ⊕
* ⊗ ⊗
* ⊥ ⊥
* ⋅ ⋅
* ⌈ ⌈
* ⌉ ⌉
* ⌊ ⌊
* ⌋ ⌋
* ⟨ 〈
* ⟩ 〉
* ◊ ◊
* ♠ ♠
* ♣ ♣
* ♥ ♥
* ♦ ♦
* " "
* & &
* < <
* > >
* Œ Œ
* œ œ
* Š Š
* š š
* Ÿ Ÿ
* ˆ ˆ
* ˜ ˜
*    
*    
*    
* ‌ ‌
* ‍ ‍
* ‎ ‎
* ‏ ‏
* – –
* — —
* ‘ ‘
* ’ ’
* ‚ ‚
* “ “
* ” ”
* „ „
* † †
* ‡ ‡
* ‰ ‰
* ‹ ‹
* › ›
* € €
*/
void
symbolic_entities
()
{
}
/**
* &bad;
*/
void
bad_name
()
{
}
/**
* 
* ࡏ
*/
void
out_of_range
()
{
}
/**
* ―
* ⌫
* 
*/
void
sparse_negative
()
{
}
}
test/tools/doclint/html/EntitiesTest.out
0 → 100644
浏览文件 @
d4f7e595
EntitiesTest.java:300: error: invalid entity &bad;
* &bad;
^
EntitiesTest.java:305: error: invalid entity 
* 
^
EntitiesTest.java:306: error: invalid entity ࡏ
* ࡏ
^
EntitiesTest.java:311: error: invalid entity ―
* ―
^
EntitiesTest.java:312: error: invalid entity ⌫
* ⌫
^
EntitiesTest.java:313: error: invalid entity 
* 
^
6 errors
test/tools/doclint/tool/HelpTest.java
0 → 100644
浏览文件 @
d4f7e595
/*
* Copyright (c) 2013, 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 8006263
* @summary Supplementary test cases needed for doclint
* @library ..
* @build DocLintTester
* @run main DocLintTester -ref HelpTest.out
* @run main DocLintTester -ref HelpTest.out -h
* @run main DocLintTester -ref HelpTest.out -help
* @run main DocLintTester -ref HelpTest.out --help
* @run main DocLintTester -ref HelpTest.out -usage
* @run main DocLintTester -ref HelpTest.out -?
*/
test/tools/doclint/tool/HelpTest.out
0 → 100644
浏览文件 @
d4f7e595
Usage:
doclint [options] source-files...
Options:
-Xmsgs
Same as -Xmsgs:all
-Xmsgs:values
Specify categories of issues to be checked, where 'values'
is a comma-separated list of any of the following:
reference show places where comments contain incorrect
references to Java source code elements
syntax show basic syntax errors within comments
html show issues with HTML tags and attributes
accessibility show issues for accessibility
missing show issues with missing documentation
all all of the above
Precede a value with '-' to negate it
Categories may be qualified by one of:
/public /protected /package /private
For positive categories (not beginning with '-')
the qualifier applies to that access level and above.
For negative categories (beginning with '-')
the qualifier applies to that access level and below.
If a qualifier is missing, the category applies to
all access levels.
For example, -Xmsgs:all,-syntax/private
This will enable all messages, except syntax errors
in the doc comments of private methods.
If no -Xmsgs options are provided, the default is
equivalent to -Xmsgs:all/protected, meaning that
all messages are reported for protected and public
declarations only.
-stats
Report statistics on the reported issues.
-h -help --help -usage -?
Show this message.
The following javac options are also supported
-bootclasspath, -classpath, -sourcepath, -Xmaxerrs, -Xmaxwarns
To run doclint on part of a project, put the compiled classes for your
project on the classpath (or bootclasspath), then specify the source files
to be checked on the command line.
test/tools/doclint/tool/MaxDiagsTest.java
0 → 100644
浏览文件 @
d4f7e595
/*
* @test /nodynamiccopyright/
* @bug 8006263
* @summary Supplementary test cases needed for doclint
* @library ..
* @build DocLintTester
* @run main DocLintTester -ref MaxDiagsTest.out -Xmaxerrs 2 -Xmaxwarns 2 MaxDiagsTest.java
* @run main DocLintTester -badargs -Xmaxerrs
* @run main DocLintTester -badargs -Xmaxwarns
* @run main DocLintTester -badargs -Xmaxerrs two -Xmaxwarns two MaxDiagsTest.java
*/
public
class
MaxDiagsTest
{
/**
* � � � �
*/
public
void
errors
()
{
}
/** 4 undocumented signature items */
public
int
warnings
(
int
a1
,
int
a2
)
throws
Exception
{
return
0
;
}
}
test/tools/doclint/tool/MaxDiagsTest.out
0 → 100644
浏览文件 @
d4f7e595
MaxDiagsTest.java:13: warning: no comment
public class MaxDiagsTest {
^
MaxDiagsTest.java:15: error: invalid entity �
* � � � �
^
MaxDiagsTest.java:15: error: invalid entity �
* � � � �
^
MaxDiagsTest.java:20: warning: no @param for a1
public int warnings(int a1, int a2) throws Exception { return 0; }
^
2 errors
2 warnings
test/tools/doclint/tool/PathsTest.java
0 → 100644
浏览文件 @
d4f7e595
/*
* Copyright (c) 2013, 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 8006263
* @summary Supplementary test cases needed for doclint
*/
import
com.sun.tools.doclint.DocLint
;
import
com.sun.tools.doclint.DocLint.BadArgs
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.util.regex.Pattern
;
public
class
PathsTest
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
PathsTest
().
run
();
}
void
run
()
throws
Exception
{
String
PS
=
File
.
pathSeparator
;
writeFile
(
"src1/p/A.java"
,
"package p; public class A { }"
);
compile
(
"-d"
,
"classes1"
,
"src1/p/A.java"
);
writeFile
(
"src2/q/B.java"
,
"package q; public class B extends p.A { }"
);
compile
(
"-d"
,
"classes2"
,
"-classpath"
,
"classes1"
,
"src2/q/B.java"
);
writeFile
(
"src/Test.java"
,
"/** &0; */ class Test extends q.B { }"
);
test
(
"src/Test.java"
,
"-sourcepath"
,
"src1"
+
PS
+
"src2"
);
test
(
"src/Test.java"
,
"-classpath"
,
"classes1"
+
PS
+
"classes2"
);
String
sysBootClassPath
=
System
.
getProperty
(
"sun.boot.class.path"
);
test
(
"src/Test.java"
,
"-bootclasspath"
,
sysBootClassPath
+
PS
+
"classes1"
+
PS
+
"classes2"
);
if
(
errors
>
0
)
throw
new
Exception
(
errors
+
" errors found"
);
}
Pattern
pkgNotFound
=
Pattern
.
compile
(
"package [a-z]+ does not exist"
);
Pattern
badHtmlEntity
=
Pattern
.
compile
(
"bad HTML entity"
);
void
test
(
String
file
,
String
pathOpt
,
String
path
)
throws
BadArgs
,
IOException
{
System
.
err
.
println
(
"test "
+
pathOpt
);
String
out1
=
doclint
(
"-Xmsgs"
,
file
);
if
(!
pkgNotFound
.
matcher
(
out1
).
find
())
error
(
"message not found: "
+
pkgNotFound
);
String
out2
=
doclint
(
"-Xmsgs"
,
pathOpt
,
path
,
file
);
if
(
pkgNotFound
.
matcher
(
out2
).
find
())
error
(
"unexpected message found: "
+
pkgNotFound
);
if
(!
badHtmlEntity
.
matcher
(
out1
).
find
())
error
(
"message not found: "
+
badHtmlEntity
);
try
{
doclint
(
"-Xmsgs"
,
pathOpt
);
error
(
"expected exception not thrown"
);
}
catch
(
BadArgs
e
)
{
System
.
err
.
println
(
e
);
}
}
void
compile
(
String
...
args
)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
args
[
i
].
equals
(
"-d"
))
{
new
File
(
args
[++
i
]).
mkdirs
();
break
;
}
}
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
int
rc
=
com
.
sun
.
tools
.
javac
.
Main
.
compile
(
args
,
pw
);
pw
.
close
();
String
out
=
sw
.
toString
();
if
(!
out
.
isEmpty
())
System
.
err
.
println
(
out
);
if
(
rc
!=
0
)
error
(
"compilation failed: rc="
+
rc
);
}
String
doclint
(
String
...
args
)
throws
BadArgs
,
IOException
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
DocLint
dl
=
new
DocLint
();
dl
.
run
(
pw
,
args
);
pw
.
close
();
String
out
=
sw
.
toString
();
if
(!
out
.
isEmpty
())
System
.
err
.
println
(
out
);
return
out
;
}
File
writeFile
(
String
path
,
String
body
)
throws
IOException
{
File
f
=
new
File
(
path
);
f
.
getParentFile
().
mkdirs
();
try
(
FileWriter
fw
=
new
FileWriter
(
path
))
{
fw
.
write
(
body
);
}
return
f
;
}
void
error
(
String
msg
)
{
System
.
err
.
println
(
"Error: "
+
msg
);
errors
++;
}
int
errors
;
}
test/tools/doclint/tool/RunTest.java
0 → 100644
浏览文件 @
d4f7e595
/*
* Copyright (c) 2013, 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 8006263
* @summary Supplementary test cases needed for doclint
*/
import
com.sun.source.util.JavacTask
;
import
com.sun.tools.doclint.DocLint
;
import
com.sun.tools.doclint.DocLint.BadArgs
;
import
com.sun.tools.javac.api.JavacTool
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.net.URI
;
import
java.security.Permission
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Objects
;
import
javax.tools.JavaFileObject
;
import
javax.tools.SimpleJavaFileObject
;
public
class
RunTest
{
static
class
SimpleSecurityManager
extends
SecurityManager
{
boolean
allowExit
=
false
;
@Override
public
void
checkExit
(
int
status
)
{
if
(!
allowExit
)
throw
new
SecurityException
(
"System.exit("
+
status
+
")"
);
}
@Override
public
void
checkPermission
(
Permission
perm
)
{
}
}
public
static
void
main
(
String
...
args
)
throws
Exception
{
// if no security manager already installed, install one to
// prevent System.exit
SimpleSecurityManager
secmgr
=
null
;
if
(
System
.
getSecurityManager
()
==
null
)
{
System
.
setSecurityManager
(
secmgr
=
new
SimpleSecurityManager
()
{
});
}
try
{
new
RunTest
().
run
();
}
finally
{
if
(
secmgr
!=
null
)
secmgr
.
allowExit
=
true
;
}
}
void
run
()
throws
Exception
{
testMain
();
testRun
();
testInit
();
testArgsNoFiles
();
if
(
errors
>
0
)
throw
new
Exception
(
errors
+
" errors found"
);
}
void
testMain
()
{
System
.
err
.
println
(
"test main(String[])"
);
testMain
(
true
,
"-help"
);
testMain
(
false
,
"-unknownOption"
);
}
void
testMain
(
boolean
expectOK
,
String
...
args
)
{
try
{
DocLint
.
main
(
args
);
if
(!
expectOK
)
error
(
"expected SecurityException (from System.exit) not thrown"
);
}
catch
(
SecurityException
e
)
{
System
.
err
.
println
(
e
);
if
(
expectOK
)
error
(
"unexpected SecurityException caught"
);
}
}
void
testRun
()
throws
BadArgs
,
IOException
{
System
.
err
.
println
(
"test run(String[])"
);
DocLint
dl
=
new
DocLint
();
String
[]
args
=
{
"-help"
};
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
PrintStream
ps
=
new
PrintStream
(
baos
);
PrintStream
prev
=
System
.
out
;
try
{
System
.
setOut
(
ps
);
dl
.
run
(
args
);
}
finally
{
System
.
setOut
(
prev
);
}
ps
.
close
();
String
stdout
=
baos
.
toString
();
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
dl
.
run
(
pw
,
args
);
pw
.
close
();
String
direct
=
sw
.
toString
();
if
(!
stdout
.
equals
(
direct
))
{
error
(
"unexpected output"
);
System
.
err
.
println
(
"EXPECT>>"
+
direct
+
"<<"
);
System
.
err
.
println
(
"FOUND>>"
+
stdout
+
"<<"
);
}
}
void
testInit
()
{
System
.
err
.
println
(
"test init"
);
DocLint
dl
=
new
DocLint
();
String
name
=
dl
.
getName
();
if
(!
Objects
.
equals
(
name
,
"doclint"
))
error
(
"unexpected result for DocLint.getName()"
);
List
<?
extends
JavaFileObject
>
files
=
Arrays
.
asList
(
createFile
(
"Test.java"
,
"/** &0; */ class Test{ }"
));
String
[]
goodArgs
=
{
"-Xmsgs"
};
testInit
(
true
,
goodArgs
,
files
);
String
[]
badArgs
=
{
"-unknown"
};
testInit
(
false
,
badArgs
,
files
);
}
void
testInit
(
boolean
expectOK
,
String
[]
args
,
List
<?
extends
JavaFileObject
>
files
)
{
JavacTool
javac
=
JavacTool
.
create
();
JavacTask
task
=
javac
.
getTask
(
null
,
null
,
null
,
null
,
null
,
files
);
try
{
DocLint
dl
=
new
DocLint
();
dl
.
init
(
task
,
args
,
true
);
if
(!
expectOK
)
error
(
"expected IllegalArgumentException not thrown"
);
task
.
call
();
}
catch
(
IllegalArgumentException
e
)
{
System
.
err
.
println
(
e
);
if
(
expectOK
)
error
(
"unexpected IllegalArgumentException caught"
);
}
}
void
testArgsNoFiles
()
throws
BadArgs
,
IOException
{
System
.
err
.
println
(
"test args, no files"
);
DocLint
dl
=
new
DocLint
();
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
dl
.
run
(
pw
,
"-Xmsgs"
);
pw
.
close
();
String
out
=
sw
.
toString
();
String
expect
=
"no files given"
;
if
(!
Objects
.
equals
(
out
.
trim
(),
expect
))
{
error
(
"unexpected output"
);
System
.
err
.
println
(
"EXPECT>>"
+
expect
+
"<<"
);
System
.
err
.
println
(
"FOUND>>"
+
out
+
"<<"
);
}
}
JavaFileObject
createFile
(
String
name
,
final
String
body
)
{
return
new
SimpleJavaFileObject
(
URI
.
create
(
name
),
JavaFileObject
.
Kind
.
SOURCE
)
{
@Override
public
CharSequence
getCharContent
(
boolean
ignoreEncodingErrors
)
throws
IOException
{
return
body
;
}
};
}
void
error
(
String
msg
)
{
System
.
err
.
println
(
"Error: "
+
msg
);
errors
++;
}
int
errors
;
}
test/tools/doclint/tool/StatsTest.java
0 → 100644
浏览文件 @
d4f7e595
/*
* @test /nodynamiccopyright/
* @bug 8006263
* @summary Supplementary test cases needed for doclint
* @library ..
* @build DocLintTester
* @run main DocLintTester -ref StatsTest.out -stats -Xmsgs:all StatsTest.java
*/
// warning: missing comment
public
class
StatsTest
{
/**
* � � � �
*/
public
void
errors
()
{
}
/** 4 undocumented signature items */
public
int
warnings
(
int
a1
,
int
a2
)
throws
Exception
{
return
0
;
}
}
test/tools/doclint/tool/StatsTest.out
0 → 100644
浏览文件 @
d4f7e595
StatsTest.java:11: warning: no comment
public class StatsTest {
^
StatsTest.java:13: error: invalid entity �
* � � � �
^
StatsTest.java:13: error: invalid entity �
* � � � �
^
StatsTest.java:13: error: invalid entity �
* � � � �
^
StatsTest.java:13: error: invalid entity �
* � � � �
^
StatsTest.java:18: warning: no @param for a1
public int warnings(int a1, int a2) throws Exception { return 0; }
^
StatsTest.java:18: warning: no @param for a2
public int warnings(int a1, int a2) throws Exception { return 0; }
^
StatsTest.java:18: warning: no @return
public int warnings(int a1, int a2) throws Exception { return 0; }
^
StatsTest.java:18: warning: no @throws for java.lang.Exception
public int warnings(int a1, int a2) throws Exception { return 0; }
^
By group...
5: missing
4: html
By diagnostic kind...
5: warning
4: error
By message kind...
4: invalid entity &{0};
2: no @param for {0}
1: no @return
1: no @throws for {0}
1: no comment
4 errors
5 warnings
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录