Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
be646e7d
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看板
提交
be646e7d
编写于
6月 11, 2010
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6958836: javadoc should support -Xmaxerrs and -Xmaxwarns
Reviewed-by: darcy
上级
b9e9c3c6
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
295 addition
and
33 deletion
+295
-33
src/share/classes/com/sun/tools/javac/util/Log.java
src/share/classes/com/sun/tools/javac/util/Log.java
+14
-2
src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
+6
-14
src/share/classes/com/sun/tools/javadoc/Messager.java
src/share/classes/com/sun/tools/javadoc/Messager.java
+24
-10
src/share/classes/com/sun/tools/javadoc/Start.java
src/share/classes/com/sun/tools/javadoc/Start.java
+29
-6
src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties
...lasses/com/sun/tools/javadoc/resources/javadoc.properties
+7
-1
test/tools/javadoc/6958836/Test.java
test/tools/javadoc/6958836/Test.java
+120
-0
test/tools/javadoc/6958836/errs/Errors.java
test/tools/javadoc/6958836/errs/Errors.java
+38
-0
test/tools/javadoc/6958836/warns/Warnings.java
test/tools/javadoc/6958836/warns/Warnings.java
+57
-0
未找到文件。
src/share/classes/com/sun/tools/javac/util/Log.java
浏览文件 @
be646e7d
...
...
@@ -125,8 +125,8 @@ public class Log extends AbstractLog {
this
.
promptOnError
=
options
.
get
(
"-prompt"
)
!=
null
;
this
.
emitWarnings
=
options
.
get
(
"-Xlint:none"
)
==
null
;
this
.
suppressNotes
=
options
.
get
(
"suppressNotes"
)
!=
null
;
this
.
MaxErrors
=
getIntOption
(
options
,
"-Xmaxerrs"
,
100
);
this
.
MaxWarnings
=
getIntOption
(
options
,
"-Xmaxwarns"
,
100
);
this
.
MaxErrors
=
getIntOption
(
options
,
"-Xmaxerrs"
,
getDefaultMaxErrors
()
);
this
.
MaxWarnings
=
getIntOption
(
options
,
"-Xmaxwarns"
,
getDefaultMaxWarnings
()
);
boolean
rawDiagnostics
=
options
.
get
(
"rawDiagnostics"
)
!=
null
;
messages
=
JavacMessages
.
instance
(
context
);
...
...
@@ -155,6 +155,18 @@ public class Log extends AbstractLog {
return
defaultValue
;
}
/** Default value for -Xmaxerrs.
*/
protected
int
getDefaultMaxErrors
()
{
return
100
;
}
/** Default value for -Xmaxwarns.
*/
protected
int
getDefaultMaxWarnings
()
{
return
100
;
}
/** The default writer for diagnostics
*/
static
final
PrintWriter
defaultWriter
(
Context
context
)
{
...
...
src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
浏览文件 @
be646e7d
...
...
@@ -155,10 +155,8 @@ public class DocletInvoker {
public
boolean
start
(
RootDoc
root
)
{
Object
retVal
;
String
methodName
=
"start"
;
Class
<?>[]
paramTypes
=
new
Class
<?>[
1
];
Object
[]
params
=
new
Object
[
1
];
paramTypes
[
0
]
=
RootDoc
.
class
;
params
[
0
]
=
root
;
Class
<?>[]
paramTypes
=
{
RootDoc
.
class
};
Object
[]
params
=
{
root
};
try
{
retVal
=
invoke
(
methodName
,
null
,
paramTypes
,
params
);
}
catch
(
DocletInvokeException
exc
)
{
...
...
@@ -181,10 +179,8 @@ public class DocletInvoker {
public
int
optionLength
(
String
option
)
{
Object
retVal
;
String
methodName
=
"optionLength"
;
Class
<?>[]
paramTypes
=
new
Class
<?>[
1
];
Object
[]
params
=
new
Object
[
1
];
paramTypes
[
0
]
=
option
.
getClass
();
params
[
0
]
=
option
;
Class
<?>[]
paramTypes
=
{
String
.
class
};
Object
[]
params
=
{
option
};
try
{
retVal
=
invoke
(
methodName
,
new
Integer
(
0
),
paramTypes
,
params
);
}
catch
(
DocletInvokeException
exc
)
{
...
...
@@ -208,12 +204,8 @@ public class DocletInvoker {
String
options
[][]
=
optlist
.
toArray
(
new
String
[
optlist
.
length
()][]);
String
methodName
=
"validOptions"
;
DocErrorReporter
reporter
=
messager
;
Class
<?>[]
paramTypes
=
new
Class
<?>[
2
];
Object
[]
params
=
new
Object
[
2
];
paramTypes
[
0
]
=
options
.
getClass
();
paramTypes
[
1
]
=
DocErrorReporter
.
class
;
params
[
0
]
=
options
;
params
[
1
]
=
reporter
;
Class
<?>[]
paramTypes
=
{
String
[][].
class
,
DocErrorReporter
.
class
};
Object
[]
params
=
{
options
,
reporter
};
try
{
retVal
=
invoke
(
methodName
,
Boolean
.
TRUE
,
paramTypes
,
params
);
}
catch
(
DocletInvokeException
exc
)
{
...
...
src/share/classes/com/sun/tools/javadoc/Messager.java
浏览文件 @
be646e7d
...
...
@@ -86,7 +86,7 @@ public class Messager extends Log implements DocErrorReporter {
private
static
final
long
serialVersionUID
=
0
;
}
private
final
String
programName
;
final
String
programName
;
private
ResourceBundle
messageRB
=
null
;
...
...
@@ -121,6 +121,16 @@ public class Messager extends Log implements DocErrorReporter {
this
.
programName
=
programName
;
}
@Override
protected
int
getDefaultMaxErrors
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
protected
int
getDefaultMaxWarnings
()
{
return
Integer
.
MAX_VALUE
;
}
/**
* Reset resource bundle, eg. locale has changed.
*/
...
...
@@ -231,11 +241,13 @@ public class Messager extends Log implements DocErrorReporter {
* @param msg message to print
*/
public
void
printError
(
SourcePosition
pos
,
String
msg
)
{
String
prefix
=
(
pos
==
null
)
?
programName
:
pos
.
toString
();
errWriter
.
println
(
prefix
+
": "
+
getText
(
"javadoc.error"
)
+
" - "
+
msg
);
errWriter
.
flush
();
prompt
();
nerrors
++;
if
(
nerrors
<
MaxErrors
)
{
String
prefix
=
(
pos
==
null
)
?
programName
:
pos
.
toString
();
errWriter
.
println
(
prefix
+
": "
+
getText
(
"javadoc.error"
)
+
" - "
+
msg
);
errWriter
.
flush
();
prompt
();
nerrors
++;
}
}
/**
...
...
@@ -256,10 +268,12 @@ public class Messager extends Log implements DocErrorReporter {
* @param msg message to print
*/
public
void
printWarning
(
SourcePosition
pos
,
String
msg
)
{
String
prefix
=
(
pos
==
null
)
?
programName
:
pos
.
toString
();
warnWriter
.
println
(
prefix
+
": "
+
getText
(
"javadoc.warning"
)
+
" - "
+
msg
);
warnWriter
.
flush
();
nwarnings
++;
if
(
nwarnings
<
MaxWarnings
)
{
String
prefix
=
(
pos
==
null
)
?
programName
:
pos
.
toString
();
warnWriter
.
println
(
prefix
+
": "
+
getText
(
"javadoc.warning"
)
+
" - "
+
msg
);
warnWriter
.
flush
();
nwarnings
++;
}
}
/**
...
...
src/share/classes/com/sun/tools/javadoc/Start.java
浏览文件 @
be646e7d
...
...
@@ -51,8 +51,6 @@ import static com.sun.tools.javac.code.Flags.*;
* @author Neal Gafter (rewrite)
*/
class
Start
{
/** Context for this invocation. */
private
final
Context
context
;
private
final
String
defaultDocletClassName
;
private
final
ClassLoader
docletParentClassLoader
;
...
...
@@ -98,8 +96,8 @@ class Start {
PrintWriter
noticeWriter
,
String
defaultDocletClassName
,
ClassLoader
docletParentClassLoader
)
{
context
=
new
Context
();
messager
=
new
Messager
(
c
ontext
,
programName
,
errWriter
,
warnWriter
,
noticeWriter
);
Context
tempContext
=
new
Context
();
// interim context until option decoding completed
messager
=
new
Messager
(
tempC
ontext
,
programName
,
errWriter
,
warnWriter
,
noticeWriter
);
this
.
defaultDocletClassName
=
defaultDocletClassName
;
this
.
docletParentClassLoader
=
docletParentClassLoader
;
}
...
...
@@ -110,8 +108,8 @@ class Start {
Start
(
String
programName
,
String
defaultDocletClassName
,
ClassLoader
docletParentClassLoader
)
{
context
=
new
Context
();
messager
=
new
Messager
(
c
ontext
,
programName
);
Context
tempContext
=
new
Context
();
// interim context until option decoding completed
messager
=
new
Messager
(
tempC
ontext
,
programName
);
this
.
defaultDocletClassName
=
defaultDocletClassName
;
this
.
docletParentClassLoader
=
docletParentClassLoader
;
}
...
...
@@ -144,6 +142,13 @@ class Start {
}
}
/**
* Usage
*/
private
void
Xusage
()
{
messager
.
notice
(
"main.Xusage"
);
}
/**
* Exit
*/
...
...
@@ -213,6 +218,15 @@ class Start {
setDocletInvoker
(
argv
);
ListBuffer
<
String
>
subPackages
=
new
ListBuffer
<
String
>();
ListBuffer
<
String
>
excludedPackages
=
new
ListBuffer
<
String
>();
Context
context
=
new
Context
();
// Setup a new Messager, using the same initial parameters as the
// existing Messager, except that this one will be able to use any
// options that may be set up below.
Messager
.
preRegister
(
context
,
messager
.
programName
,
messager
.
errWriter
,
messager
.
warnWriter
,
messager
.
noticeWriter
);
Options
compOpts
=
Options
.
instance
(
context
);
boolean
docClasses
=
false
;
...
...
@@ -310,6 +324,15 @@ class Start {
usageError
(
"main.locale_first"
);
oneArg
(
argv
,
i
++);
docLocale
=
argv
[
i
];
}
else
if
(
arg
.
equals
(
"-Xmaxerrs"
)
||
arg
.
equals
(
"-Xmaxwarns"
))
{
oneArg
(
argv
,
i
++);
if
(
compOpts
.
get
(
arg
)
!=
null
)
{
usageError
(
"main.option.already.seen"
,
arg
);
}
compOpts
.
put
(
arg
,
argv
[
i
]);
}
else
if
(
arg
.
equals
(
"-X"
))
{
Xusage
();
exit
();
}
else
if
(
arg
.
startsWith
(
"-XD"
))
{
String
s
=
arg
.
substring
(
"-XD"
.
length
());
int
eq
=
s
.
indexOf
(
'='
);
...
...
src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties
浏览文件 @
be646e7d
...
...
@@ -49,7 +49,13 @@ main.usage=usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
-locale <name> Locale to be used, e.g. en_US or en_US_WIN
\n\
-encoding <name> Source file encoding name
\n\
-quiet Do not display status messages
\n\
-J<flag> Pass <flag> directly to the runtime system
\n
-J<flag> Pass <flag> directly to the runtime system
\n\
-X Print a synopsis of nonstandard options
\n
main.Xusage
=
\
-Xmaxerrs <number> Set the maximum number of errors to print
\n\
-Xmaxwarns <number> Set the maximum number of warnings to print
\n\
\n\
These options are non-standard and subject to change without notice.
main.option.already.seen
=
The {0} option may be specified no more than once.
main.requires_argument
=
option {0} requires an argument.
main.locale_first
=
option -locale must be first on the command line.
...
...
test/tools/javadoc/6958836/Test.java
0 → 100644
浏览文件 @
be646e7d
/*
* 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 6958836
* @summary javadoc should support -Xmaxerrs and -Xmaxwarns
*/
import
java.io.*
;
import
java.util.*
;
public
class
Test
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
Test
().
run
();
}
void
run
()
throws
Exception
{
javadoc
(
"errs"
,
list
(),
10
,
0
);
javadoc
(
"errs"
,
list
(
"-Xmaxerrs"
,
"0"
),
10
,
0
);
javadoc
(
"errs"
,
list
(
"-Xmaxerrs"
,
"2"
),
2
,
0
);
javadoc
(
"errs"
,
list
(
"-Xmaxerrs"
,
"4"
),
4
,
0
);
javadoc
(
"errs"
,
list
(
"-Xmaxerrs"
,
"20"
),
10
,
0
);
javadoc
(
"warns"
,
list
(),
0
,
10
);
javadoc
(
"warns"
,
list
(
"-Xmaxwarns"
,
"0"
),
0
,
10
);
javadoc
(
"warns"
,
list
(
"-Xmaxwarns"
,
"2"
),
0
,
2
);
javadoc
(
"warns"
,
list
(
"-Xmaxwarns"
,
"4"
),
0
,
4
);
javadoc
(
"warns"
,
list
(
"-Xmaxwarns"
,
"20"
),
0
,
10
);
if
(
errors
>
0
)
throw
new
Exception
(
errors
+
" errors occurred."
);
}
void
javadoc
(
String
pkg
,
List
<
String
>
testOpts
,
int
expectErrs
,
int
expectWarns
)
{
System
.
err
.
println
(
"Test "
+
(++
count
)
+
": "
+
pkg
+
" "
+
testOpts
);
File
testOutDir
=
new
File
(
"test"
+
count
);
List
<
String
>
opts
=
new
ArrayList
<
String
>();
// Force en_US locale in lieu of something like -XDrawDiagnostics.
// For some reason, this must be the first option when used.
opts
.
addAll
(
list
(
"-locale"
,
"en_US"
));
opts
.
addAll
(
list
(
"-classpath"
,
System
.
getProperty
(
"test.src"
)));
opts
.
addAll
(
list
(
"-d"
,
testOutDir
.
getPath
()));
opts
.
addAll
(
testOpts
);
opts
.
add
(
pkg
);
StringWriter
errSW
=
new
StringWriter
();
PrintWriter
errPW
=
new
PrintWriter
(
errSW
);
StringWriter
warnSW
=
new
StringWriter
();
PrintWriter
warnPW
=
new
PrintWriter
(
warnSW
);
StringWriter
noteSW
=
new
StringWriter
();
PrintWriter
notePW
=
new
PrintWriter
(
noteSW
);
int
rc
=
com
.
sun
.
tools
.
javadoc
.
Main
.
execute
(
"javadoc"
,
errPW
,
warnPW
,
notePW
,
"com.sun.tools.doclets.standard.Standard"
,
getClass
().
getClassLoader
(),
opts
.
toArray
(
new
String
[
opts
.
size
()]));
System
.
err
.
println
(
"rc: "
+
rc
);
errPW
.
close
();
String
errOut
=
errSW
.
toString
();
System
.
err
.
println
(
"Errors:\n"
+
errOut
);
warnPW
.
close
();
String
warnOut
=
warnSW
.
toString
();
System
.
err
.
println
(
"Warnings:\n"
+
warnOut
);
notePW
.
close
();
String
noteOut
=
noteSW
.
toString
();
System
.
err
.
println
(
"Notes:\n"
+
noteOut
);
check
(
errOut
,
"Errors.java"
,
expectErrs
);
check
(
warnOut
,
" warning "
,
expectWarns
);
// requires -locale en_US
}
void
check
(
String
text
,
String
expectText
,
int
expectCount
)
{
int
foundCount
=
0
;
for
(
String
line:
text
.
split
(
"[\r\n]+"
))
{
if
(
line
.
contains
(
expectText
))
foundCount
++;
}
if
(
foundCount
!=
expectCount
)
{
error
(
"incorrect number of matches found: "
+
foundCount
+
", expected: "
+
expectCount
);
}
}
private
List
<
String
>
list
(
String
...
args
)
{
return
Arrays
.
asList
(
args
);
}
void
error
(
String
msg
)
{
System
.
err
.
println
(
msg
);
errors
++;
}
int
count
;
int
errors
;
}
test/tools/javadoc/6958836/errs/Errors.java
0 → 100644
浏览文件 @
be646e7d
/*
* 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.
*/
package
errs
;
// class with 10 errors
class
Errors
{
X
m0
()
{
}
X
m1
()
{
}
X
m2
()
{
}
X
m3
()
{
}
X
m4
()
{
}
X
m5
()
{
}
X
m6
()
{
}
X
m7
()
{
}
X
m8
()
{
}
X
m9
()
{
}
}
test/tools/javadoc/6958836/warns/Warnings.java
0 → 100644
浏览文件 @
be646e7d
/*
* 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.
*/
package
warns
;
// class with 10 warnings
public
class
Warnings
{
/** @param x */
public
void
m0
()
{
}
/** @param x */
public
void
m1
()
{
}
/** @param x */
public
void
m2
()
{
}
/** @param x */
public
void
m3
()
{
}
/** @param x */
public
void
m4
()
{
}
/** @param x */
public
void
m5
()
{
}
/** @param x */
public
void
m6
()
{
}
/** @param x */
public
void
m7
()
{
}
/** @param x */
public
void
m8
()
{
}
/** @param x */
public
void
m9
()
{
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录