Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
54641c7a
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看板
提交
54641c7a
编写于
9月 25, 2012
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7196464: upgrade JavaCompiler.shouldStopPolicy to accomodate policies in face of error and no error
Reviewed-by: mcimadamore
上级
7a8667bf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
29 deletion
+57
-29
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+47
-14
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
...un/tools/javac/processing/JavacProcessingEnvironment.java
+10
-15
未找到文件。
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
浏览文件 @
54641c7a
...
...
@@ -406,10 +406,17 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
?
names
.
fromString
(
options
.
get
(
"failcomplete"
))
:
null
;
shouldStopPolicy
=
options
.
isSet
(
"shouldStopPolicy"
)
shouldStopPolicy
IfError
=
options
.
isSet
(
"shouldStopPolicy"
)
// backwards compatible
?
CompileState
.
valueOf
(
options
.
get
(
"shouldStopPolicy"
))
:
null
;
:
options
.
isSet
(
"shouldStopPolicyIfError"
)
?
CompileState
.
valueOf
(
options
.
get
(
"shouldStopPolicyIfError"
))
:
CompileState
.
INIT
;
shouldStopPolicyIfNoError
=
options
.
isSet
(
"shouldStopPolicyIfNoError"
)
?
CompileState
.
valueOf
(
options
.
get
(
"shouldStopPolicyIfNoError"
))
:
CompileState
.
GENERATE
;
if
(
options
.
isUnset
(
"oldDiags"
))
log
.
setDiagnosticFormatter
(
RichDiagnosticFormatter
.
instance
(
context
));
}
...
...
@@ -486,12 +493,20 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
public
boolean
verboseCompilePolicy
;
/**
* Policy of how far to continue processing. null means until first
* error.
* Policy of how far to continue compilation after errors have occurred.
* Set this to minimum CompileState (INIT) to stop as soon as possible
* after errors.
*/
public
CompileState
shouldStopPolicy
;
public
CompileState
shouldStopPolicy
IfError
;
/** A queue of all as yet unattributed classes.
/**
* Policy of how far to continue compilation when no errors have occurred.
* Set this to maximum CompileState (GENERATE) to perform full compilation.
* Set this lower to perform partial compilation, such as -proc:only.
*/
public
CompileState
shouldStopPolicyIfNoError
;
/** A queue of all as yet unattributed classes.oLo
*/
public
Todo
todo
;
...
...
@@ -501,6 +516,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
/** Ordered list of compiler phases for each compilation unit. */
public
enum
CompileState
{
INIT
(
0
),
PARSE
(
1
),
ENTER
(
2
),
PROCESS
(
3
),
...
...
@@ -512,8 +528,11 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
CompileState
(
int
value
)
{
this
.
value
=
value
;
}
boolean
isDone
(
CompileState
other
)
{
return
value
>=
other
.
value
;
boolean
isAfter
(
CompileState
other
)
{
return
value
>
other
.
value
;
}
public
static
CompileState
max
(
CompileState
a
,
CompileState
b
)
{
return
a
.
value
>
b
.
value
?
a
:
b
;
}
private
int
value
;
};
...
...
@@ -524,7 +543,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
private
static
final
long
serialVersionUID
=
1812267524140424433L
;
boolean
isDone
(
Env
<
AttrContext
>
env
,
CompileState
cs
)
{
CompileState
ecs
=
get
(
env
);
return
ecs
!=
null
&&
ecs
.
isDone
(
cs
);
return
(
ecs
!=
null
)
&&
!
cs
.
isAfter
(
e
cs
);
}
}
private
CompileStates
compileStates
=
new
CompileStates
();
...
...
@@ -536,10 +555,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
protected
Set
<
JavaFileObject
>
inputFiles
=
new
HashSet
<
JavaFileObject
>();
protected
boolean
shouldStop
(
CompileState
cs
)
{
if
(
shouldStopPolicy
==
null
)
return
(
errorCount
()
>
0
||
unrecoverableError
());
else
return
cs
.
ordinal
()
>
shouldStopPolicy
.
ordinal
(
);
CompileState
shouldStopPolicy
=
(
errorCount
()
>
0
||
unrecoverableError
()
)
?
shouldStopPolicyIfError
:
shouldStopPolicyIfNoError
;
return
cs
.
isAfter
(
shouldStopPolicy
);
}
/** The number of errors reported so far.
...
...
@@ -923,6 +942,18 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
return
trees
.
toList
();
}
/**
* Enter the symbols found in a list of parse trees if the compilation
* is expected to proceed beyond anno processing into attr.
* As a side-effect, this puts elements on the "todo" list.
* Also stores a list of all top level classes in rootClasses.
*/
public
List
<
JCCompilationUnit
>
enterTreesIfNeeded
(
List
<
JCCompilationUnit
>
roots
)
{
if
(
shouldStop
(
CompileState
.
ATTR
))
return
List
.
nil
();
return
enterTrees
(
roots
);
}
/**
* Enter the symbols found in a list of parse trees.
* As a side-effect, this puts elements on the "todo" list.
...
...
@@ -1648,6 +1679,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
hasBeenUsed
=
true
;
closeables
=
prev
.
closeables
;
prev
.
closeables
=
List
.
nil
();
shouldStopPolicyIfError
=
prev
.
shouldStopPolicyIfError
;
shouldStopPolicyIfNoError
=
prev
.
shouldStopPolicyIfNoError
;
}
public
static
void
enableLogging
()
{
...
...
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
浏览文件 @
54641c7a
...
...
@@ -97,11 +97,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
private
final
boolean
printRounds
;
private
final
boolean
verbose
;
private
final
boolean
lint
;
private
final
boolean
procOnly
;
private
final
boolean
fatalErrors
;
private
final
boolean
werror
;
private
final
boolean
showResolveErrors
;
private
boolean
foundTypeProcessors
;
private
final
JavacFiler
filer
;
private
final
JavacMessager
messager
;
...
...
@@ -167,12 +165,14 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
printRounds
=
options
.
isSet
(
XPRINTROUNDS
);
verbose
=
options
.
isSet
(
VERBOSE
);
lint
=
Lint
.
instance
(
context
).
isEnabled
(
PROCESSING
);
procOnly
=
options
.
isSet
(
PROC
,
"only"
)
||
options
.
isSet
(
XPRINT
);
if
(
options
.
isSet
(
PROC
,
"only"
)
||
options
.
isSet
(
XPRINT
))
{
JavaCompiler
compiler
=
JavaCompiler
.
instance
(
context
);
compiler
.
shouldStopPolicyIfNoError
=
CompileState
.
PROCESS
;
}
fatalErrors
=
options
.
isSet
(
"fatalEnterError"
);
showResolveErrors
=
options
.
isSet
(
"showResolveErrors"
);
werror
=
options
.
isSet
(
WERROR
);
platformAnnotations
=
initPlatformAnnotations
();
foundTypeProcessors
=
false
;
// Initialize services before any processors are initialized
// in case processors use them.
...
...
@@ -462,7 +462,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
* State about how a processor has been used by the tool. If a
* processor has been used on a prior round, its process method is
* called on all subsequent rounds, perhaps with an empty set of
* annotations to process. The {@code annotat
ed
Supported} method
* annotations to process. The {@code annotat
ion
Supported} method
* caches the supported annotation information from the first (and
* only) getSupportedAnnotationTypes call to the processor.
*/
...
...
@@ -882,7 +882,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
/** Create the compiler to be used for the final compilation. */
JavaCompiler
finalCompiler
(
boolean
errorStatus
)
{
try
{
JavaCompiler
c
=
JavaCompiler
.
instance
(
nextContext
());
Context
nextCtx
=
nextContext
();
JavacProcessingEnvironment
.
this
.
context
=
nextCtx
;
JavaCompiler
c
=
JavaCompiler
.
instance
(
nextCtx
);
c
.
log
.
nwarnings
+=
compiler
.
log
.
nwarnings
;
if
(
errorStatus
)
{
c
.
log
.
nerrors
+=
compiler
.
log
.
nerrors
;
...
...
@@ -1021,7 +1023,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
}
/** Get the context for the next round of processing.
* Important values are prop
o
gated from round to round;
* Important values are prop
a
gated from round to round;
* other values are implicitly reset.
*/
private
Context
nextContext
()
{
...
...
@@ -1190,14 +1192,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
return
compiler
;
}
if
(
procOnly
&&
!
foundTypeProcessors
)
{
compiler
.
todo
.
clear
();
}
else
{
if
(
procOnly
&&
foundTypeProcessors
)
compiler
.
shouldStopPolicy
=
CompileState
.
FLOW
;
compiler
.
enterTrees
(
roots
);
}
compiler
.
enterTreesIfNeeded
(
roots
);
return
compiler
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录