Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
0a737416
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看板
提交
0a737416
编写于
2月 25, 2010
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4880220: Add a warning when accessing a static method via an reference
Reviewed-by: darcy
上级
c1ac816e
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
78 addition
and
2 deletion
+78
-2
make/build.properties
make/build.properties
+1
-1
src/share/classes/com/sun/tools/javac/code/Lint.java
src/share/classes/com/sun/tools/javac/code/Lint.java
+6
-1
src/share/classes/com/sun/tools/javac/comp/Attr.java
src/share/classes/com/sun/tools/javac/comp/Attr.java
+4
-0
src/share/classes/com/sun/tools/javac/comp/Check.java
src/share/classes/com/sun/tools/javac/comp/Check.java
+5
-0
src/share/classes/com/sun/tools/javac/resources/compiler.properties
...classes/com/sun/tools/javac/resources/compiler.properties
+3
-0
test/tools/javac/4880220/T4880220.empty.out
test/tools/javac/4880220/T4880220.empty.out
+0
-0
test/tools/javac/4880220/T4880220.error.out
test/tools/javac/4880220/T4880220.error.out
+9
-0
test/tools/javac/4880220/T4880220.java
test/tools/javac/4880220/T4880220.java
+43
-0
test/tools/javac/4880220/T4880220.warn.out
test/tools/javac/4880220/T4880220.warn.out
+7
-0
未找到文件。
make/build.properties
浏览文件 @
0a737416
...
...
@@ -68,7 +68,7 @@ javac.no.jdk.warnings = -XDignore.symbol.file=true
# set the following to -version to verify the versions of javac being used
javac.version.opt
=
# in time, there should be no exceptions to -Xlint:all
javac.lint.opts
=
-Xlint:all,-deprecation -Werror
javac.lint.opts
=
-Xlint:all,-deprecation
,-static
-Werror
# options for the <javadoc> task for javac
javadoc.jls3.url
=
http://java.sun.com/docs/books/jls/
...
...
src/share/classes/com/sun/tools/javac/code/Lint.java
浏览文件 @
0a737416
...
...
@@ -198,7 +198,12 @@ public class Lint
/**
* Warn about Sun proprietary API that may be removed in a future release.
*/
SUNAPI
(
"sunapi"
,
true
);
SUNAPI
(
"sunapi"
,
true
),
/**
* Warn about issues relating to use of statics
*/
STATIC
(
"static"
);
LintCategory
(
String
option
)
{
this
(
option
,
false
);
...
...
src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
0a737416
...
...
@@ -2020,6 +2020,10 @@ public class Attr extends JCTree.Visitor {
tree
.
pos
(),
site
,
sym
.
name
,
true
);
}
}
}
else
if
(
sym
.
kind
!=
ERR
&&
(
sym
.
flags
()
&
STATIC
)
!=
0
&&
sym
.
name
!=
names
.
_class
)
{
// If the qualified item is not a type and the selected item is static, report
// a warning. Make allowance for the class of an array type e.g. Object[].class)
chk
.
warnStatic
(
tree
,
"static.not.qualified.by.type"
,
Kinds
.
kindName
(
sym
.
kind
),
sym
.
owner
);
}
// If we are selecting an instance member via a `super', ...
...
...
src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
0a737416
...
...
@@ -189,6 +189,11 @@ public class Check {
sunApiHandler
.
report
(
pos
,
msg
,
args
);
}
public
void
warnStatic
(
DiagnosticPosition
pos
,
String
msg
,
Object
...
args
)
{
if
(
lint
.
isEnabled
(
LintCategory
.
STATIC
))
log
.
warning
(
pos
,
msg
,
args
);
}
/**
* Report any deferred diagnostics.
*/
...
...
src/share/classes/com/sun/tools/javac/resources/compiler.properties
浏览文件 @
0a737416
...
...
@@ -720,6 +720,9 @@ compiler.warn.big.major.version=\
{0}: major version {1} is newer than {2}, the highest major version supported by this compiler.
\n\
It is recommended that the compiler be upgraded.
compiler.warn.static.not.qualified.by.type
=
\
[static] static {0} should be qualified by type name, {1}, instead of by an expression
# Warnings related to annotation processing
compiler.warn.proc.package.does.not.exist
=
\
package {0} does not exist
...
...
test/tools/javac/4880220/T4880220.empty.out
0 → 100644
浏览文件 @
0a737416
test/tools/javac/4880220/T4880220.error.out
0 → 100644
浏览文件 @
0a737416
T4880220.java:20:27: compiler.warn.static.not.qualified.by.type: kindname.method, T4880220.C
T4880220.java:21:27: compiler.warn.static.not.qualified.by.type: kindname.variable, T4880220.C
T4880220.java:22:27: compiler.warn.static.not.qualified.by.type: kindname.variable, T4880220.C
T4880220.java:24:29: compiler.warn.static.not.qualified.by.type: kindname.method, T4880220.C
T4880220.java:25:29: compiler.warn.static.not.qualified.by.type: kindname.variable, T4880220.C
T4880220.java:26:29: compiler.warn.static.not.qualified.by.type: kindname.variable, T4880220.C
- compiler.err.warnings.and.werror
1 error
6 warnings
test/tools/javac/4880220/T4880220.java
0 → 100644
浏览文件 @
0a737416
/*
* @test /nodynamiccopyright/
* @bug 4880220
* @summary Add a warning when accessing a static method via an reference
*
* @compile/ref=T4880220.empty.out T4880220.java
* @compile/ref=T4880220.warn.out -XDrawDiagnostics -Xlint:static T4880220.java
* @compile/ref=T4880220.warn.out -XDrawDiagnostics -Xlint:all T4880220.java
* @compile/ref=T4880220.empty.out -XDrawDiagnostics -Xlint:all,-static T4880220.java
* @compile/ref=T4880220.error.out/fail -XDrawDiagnostics -Werror -Xlint:all T4880220.java
*/
public
class
T4880220
{
void
m1
()
{
int
good_1
=
C
.
m
();
int
good_2
=
C
.
f
;
int
good_3
=
C
.
x
;
C
c
=
new
C
();
int
bad_inst_1
=
c
.
m
();
int
bad_inst_2
=
c
.
f
;
int
bad_inst_3
=
c
.
x
;
int
bad_expr_1
=
c
().
m
();
int
bad_expr_2
=
c
().
f
;
int
bad_expr_3
=
c
().
x
;
}
void
m2
()
{
Class
<?>
good_1
=
C
.
class
;
Class
<?>
good_2
=
C
[].
class
;
}
C
c
()
{
return
new
C
();
}
static
class
C
{
static
int
m
()
{
return
0
;
}
static
int
f
;
static
final
int
x
=
3
;
}
}
test/tools/javac/4880220/T4880220.warn.out
0 → 100644
浏览文件 @
0a737416
T4880220.java:20:27: compiler.warn.static.not.qualified.by.type: kindname.method, T4880220.C
T4880220.java:21:27: compiler.warn.static.not.qualified.by.type: kindname.variable, T4880220.C
T4880220.java:22:27: compiler.warn.static.not.qualified.by.type: kindname.variable, T4880220.C
T4880220.java:24:29: compiler.warn.static.not.qualified.by.type: kindname.method, T4880220.C
T4880220.java:25:29: compiler.warn.static.not.qualified.by.type: kindname.variable, T4880220.C
T4880220.java:26:29: compiler.warn.static.not.qualified.by.type: kindname.variable, T4880220.C
6 warnings
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录