Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
464ff66e
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
464ff66e
编写于
8月 21, 2009
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6873845: refine access to symbol file
Reviewed-by: darcy
上级
8f95d350
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
179 addition
and
33 deletion
+179
-33
langtools/src/share/classes/com/sun/tools/javac/code/Lint.java
...ools/src/share/classes/com/sun/tools/javac/code/Lint.java
+12
-1
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
...ools/src/share/classes/com/sun/tools/javac/comp/Attr.java
+13
-2
langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
...ols/src/share/classes/com/sun/tools/javac/comp/Check.java
+16
-0
langtools/src/share/classes/com/sun/tools/javac/main/JavacOption.java
...c/share/classes/com/sun/tools/javac/main/JavacOption.java
+27
-16
langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
...e/classes/com/sun/tools/javac/main/RecognizedOptions.java
+8
-8
langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
...classes/com/sun/tools/javac/resources/compiler.properties
+19
-6
langtools/test/tools/javac/T6873845.java
langtools/test/tools/javac/T6873845.java
+84
-0
未找到文件。
langtools/src/share/classes/com/sun/tools/javac/code/Lint.java
浏览文件 @
464ff66e
...
...
@@ -193,10 +193,20 @@ public class Lint
/**
* Warn about unchecked operations on raw types.
*/
RAW
(
"rawtypes"
);
RAW
(
"rawtypes"
),
/**
* Warn about Sun proprietary API that may be removed in a future release.
*/
SUNAPI
(
"sunapi"
,
true
);
LintCategory
(
String
option
)
{
this
(
option
,
false
);
}
LintCategory
(
String
option
,
boolean
hidden
)
{
this
.
option
=
option
;
this
.
hidden
=
hidden
;
map
.
put
(
option
,
this
);
}
...
...
@@ -205,6 +215,7 @@ public class Lint
}
public
final
String
option
;
public
final
boolean
hidden
;
};
/**
...
...
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
464ff66e
...
...
@@ -119,6 +119,7 @@ public class Attr extends JCTree.Visitor {
options
.
get
(
"-relax"
)
!=
null
);
useBeforeDeclarationWarning
=
options
.
get
(
"useBeforeDeclarationWarning"
)
!=
null
;
allowInvokedynamic
=
options
.
get
(
"invokedynamic"
)
!=
null
;
enableSunApiLintControl
=
options
.
get
(
"enableSunApiLintControl"
)
!=
null
;
}
/** Switch: relax some constraints for retrofit mode.
...
...
@@ -160,6 +161,12 @@ public class Attr extends JCTree.Visitor {
*/
boolean
useBeforeDeclarationWarning
;
/**
* Switch: allow lint infrastructure to control Sun proprietary
* API warnings.
*/
boolean
enableSunApiLintControl
;
/** Check kind and type of given tree against protokind and prototype.
* If check succeeds, store type in tree and return it.
* If check fails, store errType in tree and return it.
...
...
@@ -2215,8 +2222,12 @@ public class Attr extends JCTree.Visitor {
sym
.
outermostClass
()
!=
env
.
info
.
scope
.
owner
.
outermostClass
())
chk
.
warnDeprecated
(
tree
.
pos
(),
sym
);
if
((
sym
.
flags
()
&
PROPRIETARY
)
!=
0
)
log
.
strictWarning
(
tree
.
pos
(),
"sun.proprietary"
,
sym
);
if
((
sym
.
flags
()
&
PROPRIETARY
)
!=
0
)
{
if
(
enableSunApiLintControl
)
chk
.
warnSunApi
(
tree
.
pos
(),
"sun.proprietary"
,
sym
);
else
log
.
strictWarning
(
tree
.
pos
(),
"sun.proprietary"
,
sym
);
}
// Test (3): if symbol is a variable, check that its type and
// kind are compatible with the prototype and protokind.
...
...
langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
464ff66e
...
...
@@ -104,12 +104,15 @@ public class Check {
boolean
verboseDeprecated
=
lint
.
isEnabled
(
LintCategory
.
DEPRECATION
);
boolean
verboseUnchecked
=
lint
.
isEnabled
(
LintCategory
.
UNCHECKED
);
boolean
verboseSunApi
=
lint
.
isEnabled
(
LintCategory
.
SUNAPI
);
boolean
enforceMandatoryWarnings
=
source
.
enforceMandatoryWarnings
();
deprecationHandler
=
new
MandatoryWarningHandler
(
log
,
verboseDeprecated
,
enforceMandatoryWarnings
,
"deprecated"
);
uncheckedHandler
=
new
MandatoryWarningHandler
(
log
,
verboseUnchecked
,
enforceMandatoryWarnings
,
"unchecked"
);
sunApiHandler
=
new
MandatoryWarningHandler
(
log
,
verboseSunApi
,
enforceMandatoryWarnings
,
"sunapi"
);
}
/** Switch: generics enabled?
...
...
@@ -137,6 +140,9 @@ public class Check {
*/
private
MandatoryWarningHandler
uncheckedHandler
;
/** A handler for messages about using Sun proprietary API.
*/
private
MandatoryWarningHandler
sunApiHandler
;
/* *************************************************************************
* Errors and Warnings
...
...
@@ -166,12 +172,22 @@ public class Check {
uncheckedHandler
.
report
(
pos
,
msg
,
args
);
}
/** Warn about using Sun proprietary API.
* @param pos Position to be used for error reporting.
* @param msg A string describing the problem.
*/
public
void
warnSunApi
(
DiagnosticPosition
pos
,
String
msg
,
Object
...
args
)
{
if
(!
lint
.
isSuppressed
(
LintCategory
.
SUNAPI
))
sunApiHandler
.
report
(
pos
,
msg
,
args
);
}
/**
* Report any deferred diagnostics.
*/
public
void
reportDeferredDiagnostics
()
{
deprecationHandler
.
reportDeferredDiagnostic
();
uncheckedHandler
.
reportDeferredDiagnostic
();
sunApiHandler
.
reportDeferredDiagnostic
();
}
...
...
langtools/src/share/classes/com/sun/tools/javac/main/JavacOption.java
浏览文件 @
464ff66e
...
...
@@ -25,11 +25,11 @@
package
com.sun.tools.javac.main
;
import
java.io.PrintWriter
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Options
;
import
java.io.PrintWriter
;
import
java.util.Arrays
;
import
java.util.Collection
;
/**
* TODO: describe com.sun.tools.javac.main.JavacOption
...
...
@@ -106,9 +106,10 @@ public interface JavacOption {
*/
ChoiceKind
choiceKind
;
/** The choices for this option, if any.
/** The choices for this option, if any, and whether or not the choices
* are hidden
*/
Collection
<
String
>
choices
;
Map
<
String
,
Boolean
>
choices
;
Option
(
OptionName
name
,
String
argsNameKey
,
String
descrKey
)
{
this
.
name
=
name
;
...
...
@@ -123,10 +124,18 @@ public interface JavacOption {
}
Option
(
OptionName
name
,
String
descrKey
,
ChoiceKind
choiceKind
,
String
...
choices
)
{
this
(
name
,
descrKey
,
choiceKind
,
Arrays
.
asList
(
choices
));
this
(
name
,
descrKey
,
choiceKind
,
createChoices
(
choices
));
}
Option
(
OptionName
name
,
String
descrKey
,
ChoiceKind
choiceKind
,
Collection
<
String
>
choices
)
{
private
static
Map
<
String
,
Boolean
>
createChoices
(
String
...
choices
)
{
Map
<
String
,
Boolean
>
map
=
new
LinkedHashMap
<
String
,
Boolean
>();
for
(
String
c:
choices
)
map
.
put
(
c
,
true
);
return
map
;
}
Option
(
OptionName
name
,
String
descrKey
,
ChoiceKind
choiceKind
,
Map
<
String
,
Boolean
>
choices
)
{
this
(
name
,
null
,
descrKey
);
if
(
choiceKind
==
null
||
choices
==
null
)
throw
new
NullPointerException
();
...
...
@@ -153,10 +162,10 @@ public interface JavacOption {
if
(
choices
!=
null
)
{
String
arg
=
option
.
substring
(
name
.
optionName
.
length
());
if
(
choiceKind
==
ChoiceKind
.
ONEOF
)
return
choices
.
contains
(
arg
);
return
choices
.
keySet
().
contains
(
arg
);
else
{
for
(
String
a:
arg
.
split
(
",+"
))
{
if
(!
choices
.
contains
(
a
))
if
(!
choices
.
keySet
().
contains
(
a
))
return
false
;
}
}
...
...
@@ -181,10 +190,12 @@ public interface JavacOption {
if
(
argsNameKey
==
null
)
{
if
(
choices
!=
null
)
{
String
sep
=
"{"
;
for
(
String
c:
choices
)
{
sb
.
append
(
sep
);
sb
.
append
(
c
);
sep
=
","
;
for
(
Map
.
Entry
<
String
,
Boolean
>
e:
choices
.
entrySet
())
{
if
(!
e
.
getValue
())
{
sb
.
append
(
sep
);
sb
.
append
(
e
.
getKey
());
sep
=
","
;
}
}
sb
.
append
(
"}"
);
}
...
...
@@ -209,8 +220,8 @@ public interface JavacOption {
if
(
choices
!=
null
)
{
if
(
choiceKind
==
ChoiceKind
.
ONEOF
)
{
// some clients like to see just one of option+choice set
for
(
String
c:
choices
)
options
.
remove
(
option
+
c
);
for
(
String
s:
choices
.
keySet
()
)
options
.
remove
(
option
+
s
);
String
opt
=
option
+
arg
;
options
.
put
(
opt
,
opt
);
// some clients like to see option (without trailing ":")
...
...
@@ -256,7 +267,7 @@ public interface JavacOption {
XOption
(
OptionName
name
,
String
descrKey
,
ChoiceKind
kind
,
String
...
choices
)
{
super
(
name
,
descrKey
,
kind
,
choices
);
}
XOption
(
OptionName
name
,
String
descrKey
,
ChoiceKind
kind
,
Collection
<
String
>
choices
)
{
XOption
(
OptionName
name
,
String
descrKey
,
ChoiceKind
kind
,
Map
<
String
,
Boolean
>
choices
)
{
super
(
name
,
descrKey
,
kind
,
choices
);
}
@Override
...
...
langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
浏览文件 @
464ff66e
...
...
@@ -38,9 +38,9 @@ import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.PrintWriter
;
import
java.util.Collection
;
import
java.util.EnumSet
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.lang.model.SourceVersion
;
...
...
@@ -598,14 +598,14 @@ public class RecognizedOptions {
};
}
private
static
Collection
<
String
>
getXLintChoices
()
{
Collection
<
String
>
choices
=
new
LinkedHashSet
<
String
>();
choices
.
add
(
"all"
);
private
static
Map
<
String
,
Boolean
>
getXLintChoices
()
{
Map
<
String
,
Boolean
>
choices
=
new
LinkedHashMap
<
String
,
Boolean
>();
choices
.
put
(
"all"
,
false
);
for
(
Lint
.
LintCategory
c
:
Lint
.
LintCategory
.
values
())
choices
.
add
(
c
.
optio
n
);
choices
.
put
(
c
.
option
,
c
.
hidde
n
);
for
(
Lint
.
LintCategory
c
:
Lint
.
LintCategory
.
values
())
choices
.
add
(
"-"
+
c
.
optio
n
);
choices
.
add
(
"none"
);
choices
.
put
(
"-"
+
c
.
option
,
c
.
hidde
n
);
choices
.
put
(
"none"
,
false
);
return
choices
;
}
...
...
langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
浏览文件 @
464ff66e
...
...
@@ -564,12 +564,6 @@ compiler.note.deprecated.filename.additional=\
compiler.note.deprecated.plural.additional
=
\
Some input files additionally use or override a deprecated API.
# Notes related to annotation processing
# Print a client-generated note; assumed to be localized, no translation required
compiler.note.proc.messager
=
\
{0}
compiler.note.unchecked.filename
=
\
{0} uses unchecked or unsafe operations.
compiler.note.unchecked.plural
=
\
...
...
@@ -584,6 +578,25 @@ compiler.note.unchecked.filename.additional=\
compiler.note.unchecked.plural.additional
=
\
Some input files additionally use unchecked or unsafe operations.
compiler.note.sunapi.filename
=
\
{0} uses Sun proprietary API that may be removed in a future release.
compiler.note.sunapi.plural
=
\
Some input files use Sun proprietary API that may be removed in a future release.
# The following string may appear after one of the above sunapi messages.
compiler.note.sunapi.recompile
=
\
Recompile with -Xlint:sunapi for details.
compiler.note.sunapi.filename.additional
=
\
{0} uses additional Sun proprietary API that may be removed in a future release.
compiler.note.sunapi.plural.additional
=
\
Some input files additionally use Sun proprietary API that may be removed in a future release.
# Notes related to annotation processing
# Print a client-generated note; assumed to be localized, no translation required
compiler.note.proc.messager
=
\
{0}
#####
compiler.misc.count.error
=
\
...
...
langtools/test/tools/javac/T6873845.java
0 → 100644
浏览文件 @
464ff66e
import
java.io.*
;
import
java.util.*
;
import
sun.misc.*
;
/*
* @test /nodynamiccopyright/
* @bug 6873845
* @summary refine access to symbol file
*/
public
class
T6873845
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
T6873845
().
run
();
}
public
void
run
()
throws
Exception
{
String
out
=
compile
(
Arrays
.
asList
(
"-XDrawDiagnostics"
,
"-X"
));
if
(
out
.
contains
(
"sunapi"
))
throw
new
Exception
(
"unexpected output for -X"
);
String
warn1
=
"T6873845.java:72:9: compiler.warn.sun.proprietary: sun.misc.Unsafe"
+
newline
;
String
warn2
=
"T6873845.java:77:9: compiler.warn.sun.proprietary: sun.misc.Unsafe"
+
newline
;
String
note1
=
"- compiler.note.sunapi.filename: T6873845.java"
+
newline
;
String
note2
=
"- compiler.note.sunapi.recompile"
+
newline
;
test
(
opts
(),
warn1
+
warn2
+
"2 warnings"
+
newline
);
test
(
opts
(
"-XDenableSunApiLintControl"
),
note1
+
note2
);
test
(
opts
(
"-XDenableSunApiLintControl"
,
"-XDsuppressNotes"
),
""
);
test
(
opts
(
"-XDenableSunApiLintControl"
,
"-Xlint:sunapi"
),
warn1
+
"1 warning"
+
newline
);
test
(
opts
(
"-XDenableSunApiLintControl"
,
"-Xlint:all"
),
warn1
+
"1 warning"
+
newline
);
test
(
opts
(
"-XDenableSunApiLintControl"
,
"-Xlint:all,-sunapi"
),
note1
+
note2
);
}
List
<
String
>
opts
(
String
...
opts
)
{
return
Arrays
.
asList
(
opts
);
}
void
test
(
List
<
String
>
opts
,
String
expect
)
throws
Exception
{
List
<
String
>
args
=
new
ArrayList
<
String
>();
args
.
addAll
(
opts
);
args
.
add
(
"-d"
);
args
.
add
(
testClasses
.
getPath
());
args
.
add
(
new
File
(
testSrc
,
"T6873845.java"
).
getPath
());
compile
(
args
);
// to verify resource strings exist
args
.
add
(
0
,
"-XDrawDiagnostics"
);
String
out
=
compile
(
args
);
if
(!
out
.
equals
(
expect
))
throw
new
Exception
(
"unexpected output from compiler"
);
}
String
compile
(
List
<
String
>
args
)
throws
Exception
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
System
.
out
.
println
(
"compile: "
+
args
);
int
rc
=
com
.
sun
.
tools
.
javac
.
Main
.
compile
(
args
.
toArray
(
new
String
[
args
.
size
()]),
pw
);
pw
.
close
();
String
out
=
sw
.
toString
();
System
.
out
.
println
(
out
);
if
(
rc
!=
0
)
throw
new
Exception
(
"compilation failed unexpectedly"
);
return
out
;
}
void
m1
()
{
Unsafe
.
getUnsafe
();
}
@SuppressWarnings
(
"sunapi"
)
void
m2
()
{
Unsafe
.
getUnsafe
();
}
private
File
testSrc
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
));
private
File
testClasses
=
new
File
(
System
.
getProperty
(
"test.classes"
,
"."
));
private
String
newline
=
System
.
getProperty
(
"line.separator"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录