Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
35b98e79
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看板
提交
35b98e79
编写于
3月 14, 2011
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7010608: the string 'error' should appear in error messages
Reviewed-by: mcimadamore
上级
02c40c9b
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
143 addition
and
25 deletion
+143
-25
src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
...es/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
+35
-16
test/tools/apt/Compile/golden.txt
test/tools/apt/Compile/golden.txt
+1
-1
test/tools/javac/4846262/Test.out
test/tools/javac/4846262/Test.out
+2
-2
test/tools/javac/Diagnostics/6769027/T6769027.java
test/tools/javac/Diagnostics/6769027/T6769027.java
+2
-2
test/tools/javac/Diagnostics/7010608/Test.java
test/tools/javac/Diagnostics/7010608/Test.java
+92
-0
test/tools/javac/diags/examples/CountError.java
test/tools/javac/diags/examples/CountError.java
+2
-1
test/tools/javac/diags/examples/CountErrorPlural.java
test/tools/javac/diags/examples/CountErrorPlural.java
+2
-1
test/tools/javac/diags/examples/IdentifierExpected.java
test/tools/javac/diags/examples/IdentifierExpected.java
+2
-1
test/tools/javac/diags/examples/KindnameClass.java
test/tools/javac/diags/examples/KindnameClass.java
+1
-0
test/tools/javac/diags/examples/KindnameConstructor.java
test/tools/javac/diags/examples/KindnameConstructor.java
+2
-1
test/tools/javac/diags/examples/KindnameMethod.java
test/tools/javac/diags/examples/KindnameMethod.java
+1
-0
test/tools/javac/diags/examples/KindnameVariable.java
test/tools/javac/diags/examples/KindnameVariable.java
+1
-0
未找到文件。
src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
浏览文件 @
35b98e79
/*
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
1
, 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
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
package
com.sun.tools.javac.util
;
package
com.sun.tools.javac.util
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.EnumMap
;
import
java.util.EnumSet
;
import
java.util.EnumSet
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -226,17 +227,14 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
...
@@ -226,17 +227,14 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
DiagnosticPart
.
SOURCE
));
DiagnosticPart
.
SOURCE
));
initFormat
();
initFormat
();
initIndentation
();
initIndentation
();
if
(
options
.
isSet
(
"oldDiags"
))
initOldFormat
();
String
fmt
=
options
.
get
(
"diagsFormat"
);
String
fmt
=
options
.
get
(
"diagsFormat"
);
if
(
fmt
!=
null
)
{
if
(
fmt
!=
null
)
{
String
[]
formats
=
fmt
.
split
(
"\\|"
);
if
(
fmt
.
equals
(
"OLD"
))
switch
(
formats
.
length
)
{
initOldFormat
();
case
3
:
else
setFormat
(
BasicFormatKind
.
DEFAULT_CLASS_FORMAT
,
formats
[
2
]);
initFormats
(
fmt
);
case
2
:
setFormat
(
BasicFormatKind
.
DEFAULT_NO_POS_FORMAT
,
formats
[
1
]);
default
:
setFormat
(
BasicFormatKind
.
DEFAULT_POS_FORMAT
,
formats
[
0
]);
}
}
}
String
srcPos
=
null
;
String
srcPos
=
null
;
if
((((
srcPos
=
options
.
get
(
"sourcePosition"
))
!=
null
))
&&
if
((((
srcPos
=
options
.
get
(
"sourcePosition"
))
!=
null
))
&&
...
@@ -280,14 +278,35 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
...
@@ -280,14 +278,35 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
initFormat
();
initFormat
();
initIndentation
();
initIndentation
();
}
}
//where
private
void
initFormat
()
{
private
void
initFormat
()
{
availableFormats
=
new
HashMap
<
BasicFormatKind
,
String
>();
initFormats
(
"%f:%l:%_%p%L%m"
,
"%p%L%m"
,
"%f:%_%p%L%m"
);
setFormat
(
BasicFormatKind
.
DEFAULT_POS_FORMAT
,
"%f:%l:%_%t%L%m"
);
setFormat
(
BasicFormatKind
.
DEFAULT_NO_POS_FORMAT
,
"%p%L%m"
);
setFormat
(
BasicFormatKind
.
DEFAULT_CLASS_FORMAT
,
"%f:%_%t%L%m"
);
}
}
//where
private
void
initOldFormat
()
{
initFormats
(
"%f:%l:%_%t%L%m"
,
"%p%L%m"
,
"%f:%_%t%L%m"
);
}
private
void
initFormats
(
String
pos
,
String
nopos
,
String
clazz
)
{
availableFormats
=
new
EnumMap
<
BasicFormatKind
,
String
>(
BasicFormatKind
.
class
);
setFormat
(
BasicFormatKind
.
DEFAULT_POS_FORMAT
,
pos
);
setFormat
(
BasicFormatKind
.
DEFAULT_NO_POS_FORMAT
,
nopos
);
setFormat
(
BasicFormatKind
.
DEFAULT_CLASS_FORMAT
,
clazz
);
}
@SuppressWarnings
(
"fallthrough"
)
private
void
initFormats
(
String
fmt
)
{
String
[]
formats
=
fmt
.
split
(
"\\|"
);
switch
(
formats
.
length
)
{
case
3
:
setFormat
(
BasicFormatKind
.
DEFAULT_CLASS_FORMAT
,
formats
[
2
]);
case
2
:
setFormat
(
BasicFormatKind
.
DEFAULT_NO_POS_FORMAT
,
formats
[
1
]);
default
:
setFormat
(
BasicFormatKind
.
DEFAULT_POS_FORMAT
,
formats
[
0
]);
}
}
private
void
initIndentation
()
{
private
void
initIndentation
()
{
indentationLevels
=
new
HashMap
<
DiagnosticPart
,
Integer
>();
indentationLevels
=
new
HashMap
<
DiagnosticPart
,
Integer
>();
setIndentation
(
DiagnosticPart
.
SUMMARY
,
0
);
setIndentation
(
DiagnosticPart
.
SUMMARY
,
0
);
...
...
test/tools/apt/Compile/golden.txt
浏览文件 @
35b98e79
error: It's a mad, mad, mad, mad world
error: It's a mad, mad, mad, mad world
error: Something wicked this way comes
error: Something wicked this way comes
HelloWorld.java:2: Boring class name
HelloWorld.java:2:
error:
Boring class name
public class HelloWorld {
public class HelloWorld {
^
^
3 errors
3 errors
test/tools/javac/4846262/Test.out
浏览文件 @
35b98e79
Test.java:4: not a statement
Test.java:4:
error:
not a statement
abcdefg
abcdefg
^
^
Test.java:4: ';' expected
Test.java:4:
error:
';' expected
abcdefg
abcdefg
^
^
2 errors
2 errors
test/tools/javac/Diagnostics/6769027/T6769027.java
浏览文件 @
35b98e79
/*
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009,
2011,
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
...
@@ -261,7 +261,7 @@ public class T6769027 {
...
@@ -261,7 +261,7 @@ public class T6769027 {
enum
PositionKind
{
enum
PositionKind
{
NOPOS
(
Position
.
NOPOS
,
"- "
,
"error: "
),
NOPOS
(
Position
.
NOPOS
,
"- "
,
"error: "
),
POS
(
5
,
"Test.java:1:6: "
,
"/Test.java:1: "
);
POS
(
5
,
"Test.java:1:6: "
,
"/Test.java:1:
error:
"
);
int
pos
;
int
pos
;
String
rawOutput
;
String
rawOutput
;
...
...
test/tools/javac/Diagnostics/7010608/Test.java
0 → 100644
浏览文件 @
35b98e79
/*
* Copyright (c) 2011, 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 7010608
* @summary the string 'error' should appear in error messages
*/
import
java.io.*
;
import
java.net.URI
;
import
java.util.*
;
import
javax.tools.*
;
import
javax.tools.JavaCompiler.CompilationTask
;
public
class
Test
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
Test
().
run
();
}
void
run
()
throws
Exception
{
Locale
prev
=
Locale
.
getDefault
();
Locale
.
setDefault
(
Locale
.
ENGLISH
);
try
{
test
(
Arrays
.<
String
>
asList
(),
"myfo://test:1: error: cannot find symbol"
);
test
(
Arrays
.
asList
(
"-XDdiagsFormat=OLD"
),
"myfo://test:1: cannot find symbol"
);
test
(
Arrays
.
asList
(
"-XDoldDiags"
),
"myfo://test:1: cannot find symbol"
);
}
finally
{
Locale
.
setDefault
(
prev
);
}
}
void
test
(
List
<
String
>
options
,
String
expect
)
throws
Exception
{
System
.
err
.
println
(
"test: "
+
options
);
JavaCompiler
javac
=
ToolProvider
.
getSystemJavaCompiler
();
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
JavaFileObject
f
=
new
MyFileObject
(
"myfo://test"
,
"class Bad { Missing x; }"
);
List
<?
extends
JavaFileObject
>
files
=
Arrays
.
asList
(
f
);
CompilationTask
task
=
javac
.
getTask
(
pw
,
null
,
null
,
options
,
null
,
files
);
boolean
ok
=
task
.
call
();
pw
.
close
();
String
out
=
sw
.
toString
();
if
(!
out
.
isEmpty
())
System
.
err
.
println
(
out
);
if
(
ok
)
throw
new
Exception
(
"Compilation succeeded unexpectedly"
);
if
(!
out
.
contains
(
expect
))
throw
new
Exception
(
"expected text not found: "
+
expect
);
}
class
MyFileObject
extends
SimpleJavaFileObject
{
MyFileObject
(
String
uri
,
String
text
)
{
super
(
URI
.
create
(
uri
),
JavaFileObject
.
Kind
.
SOURCE
);
this
.
text
=
text
;
}
@Override
public
String
getName
()
{
return
uri
.
toString
();
}
@Override
public
String
getCharContent
(
boolean
ignoreEncodingErrors
)
{
return
text
;
}
final
String
text
;
}
}
test/tools/javac/diags/examples/CountError.java
浏览文件 @
35b98e79
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
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
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
// key: compiler.misc.count.error
// key: compiler.misc.count.error
// key: compiler.err.unreported.exception.need.to.catch.or.throw
// key: compiler.err.unreported.exception.need.to.catch.or.throw
// key: compiler.err.error
// run: backdoor
// run: backdoor
class
CountError
{
class
CountError
{
...
...
test/tools/javac/diags/examples/CountErrorPlural.java
浏览文件 @
35b98e79
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
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
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
// key: compiler.misc.count.error.plural
// key: compiler.misc.count.error.plural
// key: compiler.err.unreported.exception.need.to.catch.or.throw
// key: compiler.err.unreported.exception.need.to.catch.or.throw
// key: compiler.err.error
// run: backdoor
// run: backdoor
class
CountErrorPlural
{
class
CountErrorPlural
{
...
...
test/tools/javac/diags/examples/IdentifierExpected.java
浏览文件 @
35b98e79
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
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
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
// key: compiler.err.expected
// key: compiler.err.expected
// key: compiler.err.invalid.binary.number
// key: compiler.err.invalid.binary.number
// key: compiler.misc.count.error.plural
// key: compiler.misc.count.error.plural
// key: compiler.err.error
// run: backdoor
// run: backdoor
class
IdentifierExpected
{
class
IdentifierExpected
{
...
...
test/tools/javac/diags/examples/KindnameClass.java
浏览文件 @
35b98e79
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
// key: compiler.err.cant.resolve.location
// key: compiler.err.cant.resolve.location
// key: compiler.misc.location
// key: compiler.misc.location
// key: compiler.misc.count.error
// key: compiler.misc.count.error
// key: compiler.err.error
// run: backdoor
// run: backdoor
class
KindnameClass
{
class
KindnameClass
{
...
...
test/tools/javac/diags/examples/KindnameConstructor.java
浏览文件 @
35b98e79
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
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
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
// key: compiler.misc.arg.length.mismatch
// key: compiler.misc.arg.length.mismatch
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.count.error.plural
// key: compiler.misc.count.error.plural
// key: compiler.err.error
// run: backdoor
// run: backdoor
class
KindnameConstructor
{
class
KindnameConstructor
{
...
...
test/tools/javac/diags/examples/KindnameMethod.java
浏览文件 @
35b98e79
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
// key: compiler.err.cant.resolve.location.args
// key: compiler.err.cant.resolve.location.args
// key: compiler.misc.location
// key: compiler.misc.location
// key: compiler.misc.count.error
// key: compiler.misc.count.error
// key: compiler.err.error
// run: backdoor
// run: backdoor
class
KindnameMethod
{
class
KindnameMethod
{
...
...
test/tools/javac/diags/examples/KindnameVariable.java
浏览文件 @
35b98e79
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
// key: compiler.err.cant.resolve.location
// key: compiler.err.cant.resolve.location
// key: compiler.misc.location
// key: compiler.misc.location
// key: compiler.misc.count.error
// key: compiler.misc.count.error
// key: compiler.err.error
// run: backdoor
// run: backdoor
class
KindnameVariable
{
class
KindnameVariable
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录