Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
acc5bf50
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看板
提交
acc5bf50
编写于
9月 22, 2011
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7075721: javac should have public enum for exit codes
Reviewed-by: mcimadamore
上级
2e2265fa
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
55 addition
and
67 deletion
+55
-67
src/share/classes/com/sun/tools/javac/Main.java
src/share/classes/com/sun/tools/javac/Main.java
+2
-2
src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
+2
-2
src/share/classes/com/sun/tools/javac/main/Main.java
src/share/classes/com/sun/tools/javac/main/Main.java
+37
-26
test/tools/javac/diags/ArgTypeCompilerFactory.java
test/tools/javac/diags/ArgTypeCompilerFactory.java
+5
-5
test/tools/javac/diags/Example.java
test/tools/javac/diags/Example.java
+4
-3
test/tools/javac/lib/CompileFail.java
test/tools/javac/lib/CompileFail.java
+2
-26
test/tools/javac/util/context/T7021650.java
test/tools/javac/util/context/T7021650.java
+3
-3
未找到文件。
src/share/classes/com/sun/tools/javac/Main.java
浏览文件 @
acc5bf50
...
...
@@ -73,7 +73,7 @@ public class Main {
public
static
int
compile
(
String
[]
args
)
{
com
.
sun
.
tools
.
javac
.
main
.
Main
compiler
=
new
com
.
sun
.
tools
.
javac
.
main
.
Main
(
"javac"
);
return
compiler
.
compile
(
args
);
return
compiler
.
compile
(
args
)
.
exitCode
;
}
...
...
@@ -91,6 +91,6 @@ public class Main {
public
static
int
compile
(
String
[]
args
,
PrintWriter
out
)
{
com
.
sun
.
tools
.
javac
.
main
.
Main
compiler
=
new
com
.
sun
.
tools
.
javac
.
main
.
Main
(
"javac"
,
out
);
return
compiler
.
compile
(
args
);
return
compiler
.
compile
(
args
)
.
exitCode
;
}
}
src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
浏览文件 @
acc5bf50
...
...
@@ -78,7 +78,7 @@ public class JavacTaskImpl extends JavacTask {
private
AtomicBoolean
used
=
new
AtomicBoolean
();
private
Iterable
<?
extends
Processor
>
processors
;
private
Integer
result
=
null
;
private
Main
.
Result
result
=
null
;
JavacTaskImpl
(
Main
compilerMain
,
String
[]
args
,
...
...
@@ -131,7 +131,7 @@ public class JavacTaskImpl extends JavacTask {
compilerMain
.
setAPIMode
(
true
);
result
=
compilerMain
.
compile
(
args
,
context
,
fileObjects
,
processors
);
cleanup
();
return
result
==
0
;
return
result
.
isOK
()
;
}
else
{
throw
new
IllegalStateException
(
"multiple calls to method 'call'"
);
}
...
...
src/share/classes/com/sun/tools/javac/main/Main.java
浏览文件 @
acc5bf50
...
...
@@ -76,12 +76,23 @@ public class Main {
/** Result codes.
*/
static
final
int
EXIT_OK
=
0
,
// Compilation completed with no errors.
EXIT_ERROR
=
1
,
// Completed but reported errors.
EXIT_CMDERR
=
2
,
// Bad command-line arguments
EXIT_SYSERR
=
3
,
// System error or resource exhaustion.
EXIT_ABNORMAL
=
4
;
// Compiler terminated abnormally
public
enum
Result
{
OK
(
0
),
// Compilation completed with no errors.
ERROR
(
1
),
// Completed but reported errors.
CMDERR
(
2
),
// Bad command-line arguments
SYSERR
(
3
),
// System error or resource exhaustion.
ABNORMAL
(
4
);
// Compiler terminated abnormally
Result
(
int
exitCode
)
{
this
.
exitCode
=
exitCode
;
}
public
boolean
isOK
()
{
return
(
exitCode
==
0
);
}
public
final
int
exitCode
;
}
private
Option
[]
recognizedOptions
=
RecognizedOptions
.
getJavaCompilerOptions
(
new
OptionHelper
()
{
...
...
@@ -318,10 +329,10 @@ public class Main {
/** Programmatic interface for main function.
* @param args The command line parameters.
*/
public
in
t
compile
(
String
[]
args
)
{
public
Resul
t
compile
(
String
[]
args
)
{
Context
context
=
new
Context
();
JavacFileManager
.
preRegister
(
context
);
// can't create it until Log has been set up
in
t
result
=
compile
(
args
,
context
);
Resul
t
result
=
compile
(
args
,
context
);
if
(
fileManager
instanceof
JavacFileManager
)
{
// A fresh context was created above, so jfm must be a JavacFileManager
((
JavacFileManager
)
fileManager
).
close
();
...
...
@@ -329,14 +340,14 @@ public class Main {
return
result
;
}
public
in
t
compile
(
String
[]
args
,
Context
context
)
{
public
Resul
t
compile
(
String
[]
args
,
Context
context
)
{
return
compile
(
args
,
context
,
List
.<
JavaFileObject
>
nil
(),
null
);
}
/** Programmatic interface for main function.
* @param args The command line parameters.
*/
public
in
t
compile
(
String
[]
args
,
public
Resul
t
compile
(
String
[]
args
,
Context
context
,
List
<
JavaFileObject
>
fileObjects
,
Iterable
<?
extends
Processor
>
processors
)
...
...
@@ -355,7 +366,7 @@ public class Main {
try
{
if
(
args
.
length
==
0
&&
fileObjects
.
isEmpty
())
{
help
();
return
EXIT_
CMDERR
;
return
Result
.
CMDERR
;
}
Collection
<
File
>
files
;
...
...
@@ -363,26 +374,26 @@ public class Main {
files
=
processArgs
(
CommandLine
.
parse
(
args
));
if
(
files
==
null
)
{
// null signals an error in options, abort
return
EXIT_
CMDERR
;
return
Result
.
CMDERR
;
}
else
if
(
files
.
isEmpty
()
&&
fileObjects
.
isEmpty
()
&&
classnames
.
isEmpty
())
{
// it is allowed to compile nothing if just asking for help or version info
if
(
options
.
isSet
(
HELP
)
||
options
.
isSet
(
X
)
||
options
.
isSet
(
VERSION
)
||
options
.
isSet
(
FULLVERSION
))
return
EXIT_
OK
;
return
Result
.
OK
;
if
(
JavaCompiler
.
explicitAnnotationProcessingRequested
(
options
))
{
error
(
"err.no.source.files.classes"
);
}
else
{
error
(
"err.no.source.files"
);
}
return
EXIT_
CMDERR
;
return
Result
.
CMDERR
;
}
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
Log
.
printLines
(
out
,
ownName
+
": "
+
getLocalizedString
(
"err.file.not.found"
,
e
.
getMessage
()));
return
EXIT_
SYSERR
;
return
Result
.
SYSERR
;
}
boolean
forceStdOut
=
options
.
isSet
(
"stdout"
);
...
...
@@ -402,7 +413,7 @@ public class Main {
fileManager
=
context
.
get
(
JavaFileManager
.
class
);
comp
=
JavaCompiler
.
instance
(
context
);
if
(
comp
==
null
)
return
EXIT_
SYSERR
;
if
(
comp
==
null
)
return
Result
.
SYSERR
;
Log
log
=
Log
.
instance
(
context
);
...
...
@@ -423,32 +434,32 @@ public class Main {
if
(
log
.
expectDiagKeys
!=
null
)
{
if
(
log
.
expectDiagKeys
.
isEmpty
())
{
Log
.
printLines
(
log
.
noticeWriter
,
"all expected diagnostics found"
);
return
EXIT_
OK
;
return
Result
.
OK
;
}
else
{
Log
.
printLines
(
log
.
noticeWriter
,
"expected diagnostic keys not found: "
+
log
.
expectDiagKeys
);
return
EXIT_
ERROR
;
return
Result
.
ERROR
;
}
}
if
(
comp
.
errorCount
()
!=
0
)
return
EXIT_
ERROR
;
return
Result
.
ERROR
;
}
catch
(
IOException
ex
)
{
ioMessage
(
ex
);
return
EXIT_
SYSERR
;
return
Result
.
SYSERR
;
}
catch
(
OutOfMemoryError
ex
)
{
resourceMessage
(
ex
);
return
EXIT_
SYSERR
;
return
Result
.
SYSERR
;
}
catch
(
StackOverflowError
ex
)
{
resourceMessage
(
ex
);
return
EXIT_
SYSERR
;
return
Result
.
SYSERR
;
}
catch
(
FatalError
ex
)
{
feMessage
(
ex
);
return
EXIT_
SYSERR
;
return
Result
.
SYSERR
;
}
catch
(
AnnotationProcessingError
ex
)
{
if
(
apiMode
)
throw
new
RuntimeException
(
ex
.
getCause
());
apMessage
(
ex
);
return
EXIT_
SYSERR
;
return
Result
.
SYSERR
;
}
catch
(
ClientCodeException
ex
)
{
// as specified by javax.tools.JavaCompiler#getTask
// and javax.tools.JavaCompiler.CompilationTask#call
...
...
@@ -462,7 +473,7 @@ public class Main {
if
(
comp
==
null
||
comp
.
errorCount
()
==
0
||
options
==
null
||
options
.
isSet
(
"dev"
))
bugMessage
(
ex
);
return
EXIT_
ABNORMAL
;
return
Result
.
ABNORMAL
;
}
finally
{
if
(
comp
!=
null
)
{
try
{
...
...
@@ -474,7 +485,7 @@ public class Main {
filenames
=
null
;
options
=
null
;
}
return
EXIT_
OK
;
return
Result
.
OK
;
}
/** Print a message reporting an internal error.
...
...
test/tools/javac/diags/ArgTypeCompilerFactory.java
浏览文件 @
acc5bf50
...
...
@@ -146,9 +146,9 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
JavacFileManager
.
preRegister
(
c
);
// can't create it until Log has been set up
ArgTypeJavaCompiler
.
preRegister
(
c
);
ArgTypeMessages
.
preRegister
(
c
);
in
t
result
=
main
.
compile
(
args
.
toArray
(
new
String
[
args
.
size
()]),
c
);
Main
.
Resul
t
result
=
main
.
compile
(
args
.
toArray
(
new
String
[
args
.
size
()]),
c
);
return
(
result
==
0
);
return
result
.
isOK
(
);
}
}
...
...
@@ -172,10 +172,10 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
JavacFileManager
.
preRegister
(
c
);
// can't create it until Log has been set up
ArgTypeJavaCompiler
.
preRegister
(
c
);
ArgTypeMessages
.
preRegister
(
c
);
com
.
sun
.
tools
.
javac
.
main
.
Main
m
=
new
com
.
sun
.
tools
.
javac
.
main
.
Main
(
"javac"
,
out
);
int
rc
=
m
.
compile
(
args
.
toArray
(
new
String
[
args
.
size
()]),
c
);
Main
m
=
new
Main
(
"javac"
,
out
);
Main
.
Result
result
=
m
.
compile
(
args
.
toArray
(
new
String
[
args
.
size
()]),
c
);
return
(
rc
==
0
);
return
result
.
isOK
(
);
}
}
...
...
test/tools/javac/diags/Example.java
浏览文件 @
acc5bf50
...
...
@@ -41,6 +41,7 @@ import javax.tools.ToolProvider;
import
com.sun.tools.javac.api.ClientCodeWrapper
;
import
com.sun.tools.javac.file.JavacFileManager
;
import
com.sun.tools.javac.main.Main
;
import
com.sun.tools.javac.util.Context
;
import
com.sun.tools.javac.util.JavacMessages
;
import
com.sun.tools.javac.util.JCDiagnostic
;
...
...
@@ -515,14 +516,14 @@ class Example implements Comparable<Example> {
Context
c
=
new
Context
();
JavacFileManager
.
preRegister
(
c
);
// can't create it until Log has been set up
MessageTracker
.
preRegister
(
c
,
keys
);
com
.
sun
.
tools
.
javac
.
main
.
Main
m
=
new
com
.
sun
.
tools
.
javac
.
main
.
Main
(
"javac"
,
pw
);
in
t
rc
=
m
.
compile
(
args
.
toArray
(
new
String
[
args
.
size
()]),
c
);
Main
m
=
new
Main
(
"javac"
,
pw
);
Main
.
Resul
t
rc
=
m
.
compile
(
args
.
toArray
(
new
String
[
args
.
size
()]),
c
);
if
(
keys
!=
null
)
{
pw
.
close
();
}
return
(
rc
==
0
);
return
rc
.
isOK
(
);
}
static
class
MessageTracker
extends
JavacMessages
{
...
...
test/tools/javac/lib/CompileFail.java
浏览文件 @
acc5bf50
...
...
@@ -23,6 +23,7 @@
import
java.io.*
;
import
java.util.*
;
import
com.sun.tools.javac.main.Main
;
/*
* Utility class to emulate jtreg @compile/fail, but also checking the specific
...
...
@@ -58,32 +59,7 @@ public class CompileFail {
}
static
int
getReturnCode
(
String
name
)
{
switch
(
name
)
{
case
"OK"
:
return
EXIT_OK
;
case
"ERROR"
:
return
EXIT_ERROR
;
case
"CMDERR"
:
return
EXIT_CMDERR
;
case
"SYSERR"
:
return
EXIT_SYSERR
;
case
"ABNORMAL"
:
return
EXIT_ABNORMAL
;
default
:
throw
new
IllegalArgumentException
(
name
);
}
return
Main
.
Result
.
valueOf
(
name
).
exitCode
;
}
// The following is cut-n-paste from com.sun.tools.javac.main.Main
static
final
int
EXIT_OK
=
0
,
// Compilation completed with no errors.
EXIT_ERROR
=
1
,
// Completed but reported errors.
EXIT_CMDERR
=
2
,
// Bad command-line arguments
EXIT_SYSERR
=
3
,
// System error or resource exhaustion.
EXIT_ABNORMAL
=
4
;
// Compiler terminated abnormally
}
test/tools/javac/util/context/T7021650.java
浏览文件 @
acc5bf50
...
...
@@ -101,13 +101,13 @@ public class T7021650 extends JavacTestingAbstractProcessor {
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
Main
m
=
new
Main
(
"javac"
,
pw
);
int
rc
=
m
.
compile
(
args
,
context
);
Main
.
Result
res
=
m
.
compile
(
args
,
context
);
pw
.
close
();
String
out
=
sw
.
toString
();
if
(!
out
.
isEmpty
())
System
.
err
.
println
(
out
);
if
(
rc
!=
0
)
throw
new
Exception
(
"compilation failed unexpectedly: r
c="
+
rc
);
if
(
!
res
.
isOK
()
)
throw
new
Exception
(
"compilation failed unexpectedly: r
esult="
+
res
);
}
void
checkEqual
(
String
label
,
int
found
,
int
expect
)
throws
Exception
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录