Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
f60e877e
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看板
提交
f60e877e
编写于
1月 19, 2009
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6794959: add new switch -XDexpectKeys=key,key....
Reviewed-by: mcimadamore
上级
9a74d458
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
8 deletion
+69
-8
src/share/classes/com/sun/tools/javac/main/Main.java
src/share/classes/com/sun/tools/javac/main/Main.java
+18
-6
src/share/classes/com/sun/tools/javac/util/Log.java
src/share/classes/com/sun/tools/javac/util/Log.java
+15
-2
test/tools/javac/T6794959.java
test/tools/javac/T6794959.java
+36
-0
未找到文件。
src/share/classes/com/sun/tools/javac/main/Main.java
浏览文件 @
f60e877e
...
...
@@ -338,13 +338,13 @@ public class Main {
return
EXIT_CMDERR
;
}
List
<
File
>
file
name
s
;
List
<
File
>
files
;
try
{
file
name
s
=
processArgs
(
CommandLine
.
parse
(
args
));
if
(
file
name
s
==
null
)
{
files
=
processArgs
(
CommandLine
.
parse
(
args
));
if
(
files
==
null
)
{
// null signals an error in options, abort
return
EXIT_CMDERR
;
}
else
if
(
file
name
s
.
isEmpty
()
&&
fileObjects
.
isEmpty
()
&&
classnames
.
isEmpty
())
{
}
else
if
(
files
.
isEmpty
()
&&
fileObjects
.
isEmpty
()
&&
classnames
.
isEmpty
())
{
// it is allowed to compile nothing if just asking for help or version info
if
(
options
.
get
(
"-help"
)
!=
null
||
options
.
get
(
"-X"
)
!=
null
...
...
@@ -380,12 +380,14 @@ public class Main {
comp
=
JavaCompiler
.
instance
(
context
);
if
(
comp
==
null
)
return
EXIT_SYSERR
;
if
(!
filenames
.
isEmpty
())
{
Log
log
=
Log
.
instance
(
context
);
if
(!
files
.
isEmpty
())
{
// add filenames to fileObjects
comp
=
JavaCompiler
.
instance
(
context
);
List
<
JavaFileObject
>
otherFiles
=
List
.
nil
();
JavacFileManager
dfm
=
(
JavacFileManager
)
fileManager
;
for
(
JavaFileObject
fo
:
dfm
.
getJavaFileObjectsFromFiles
(
file
name
s
))
for
(
JavaFileObject
fo
:
dfm
.
getJavaFileObjectsFromFiles
(
files
))
otherFiles
=
otherFiles
.
prepend
(
fo
);
for
(
JavaFileObject
fo
:
otherFiles
)
fileObjects
=
fileObjects
.
prepend
(
fo
);
...
...
@@ -394,6 +396,16 @@ public class Main {
classnames
.
toList
(),
processors
);
if
(
log
.
expectDiagKeys
!=
null
)
{
if
(
log
.
expectDiagKeys
.
size
()
==
0
)
{
Log
.
printLines
(
log
.
noticeWriter
,
"all expected diagnostics found"
);
return
EXIT_OK
;
}
else
{
Log
.
printLines
(
log
.
noticeWriter
,
"expected diagnostic keys not found: "
+
log
.
expectDiagKeys
);
return
EXIT_ERROR
;
}
}
if
(
comp
.
errorCount
()
!=
0
||
options
.
get
(
"-Werror"
)
!=
null
&&
comp
.
warningCount
()
!=
0
)
return
EXIT_ERROR
;
...
...
src/share/classes/com/sun/tools/javac/util/Log.java
浏览文件 @
f60e877e
...
...
@@ -26,6 +26,7 @@
package
com.sun.tools.javac.util
;
import
java.io.*
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -96,6 +97,11 @@ public class Log extends AbstractLog {
*/
private
DiagnosticFormatter
<
JCDiagnostic
>
diagFormatter
;
/**
* Keys for expected diagnostics
*/
public
Set
<
String
>
expectDiagKeys
;
/**
* JavacMessages object used for localization
*/
...
...
@@ -123,9 +129,13 @@ public class Log extends AbstractLog {
this
.
diagFormatter
=
rawDiagnostics
?
new
RawDiagnosticFormatter
(
options
)
:
new
BasicDiagnosticFormatter
(
options
,
messages
);
@SuppressWarnings
(
"unchecked"
)
// FIXME
DiagnosticListener
<?
super
JavaFileObject
>
d
iagListener
=
DiagnosticListener
<?
super
JavaFileObject
>
d
l
=
context
.
get
(
DiagnosticListener
.
class
);
this
.
diagListener
=
diagListener
;
this
.
diagListener
=
dl
;
String
ek
=
options
.
get
(
"expectKeys"
);
if
(
ek
!=
null
)
expectDiagKeys
=
new
HashSet
<
String
>(
Arrays
.
asList
(
ek
.
split
(
", *"
)));
}
// where
private
int
getIntOption
(
Options
options
,
String
optionName
,
int
defaultValue
)
{
...
...
@@ -291,6 +301,9 @@ public class Log extends AbstractLog {
* reported so far, the diagnostic may be handed off to writeDiagnostic.
*/
public
void
report
(
JCDiagnostic
diagnostic
)
{
if
(
expectDiagKeys
!=
null
)
expectDiagKeys
.
remove
(
diagnostic
.
getCode
());
switch
(
diagnostic
.
getType
())
{
case
FRAGMENT:
throw
new
IllegalArgumentException
();
...
...
test/tools/javac/T6794959.java
0 → 100644
浏览文件 @
f60e877e
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6794959
* @summary add new switch -XDexpectKeys=key,key,...
* @compile T6794959.java
* @compile/fail -XDfailcomplete=java.lang.String T6794959.java
* @compile -XDfailcomplete=java.lang.String -XDexpectKeys=compiler.err.cant.resolve.location T6794959.java
* @compile/fail -XDexpectKeys=compiler.err.cant.resolve.location T6794959.java
*/
class
T6794959
{
String
s
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录