Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
bf0d054e
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看板
提交
bf0d054e
编写于
11月 08, 2011
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7108669: cleanup Log methods for direct printing to streams
Reviewed-by: mcimadamore
上级
ecb72958
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
236 addition
and
169 deletion
+236
-169
src/share/classes/com/sun/tools/apt/main/Main.java
src/share/classes/com/sun/tools/apt/main/Main.java
+16
-16
src/share/classes/com/sun/tools/javac/api/JavacTool.java
src/share/classes/com/sun/tools/javac/api/JavacTool.java
+21
-6
src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
+1
-1
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+8
-7
src/share/classes/com/sun/tools/javac/main/JavacOption.java
src/share/classes/com/sun/tools/javac/main/JavacOption.java
+15
-14
src/share/classes/com/sun/tools/javac/main/Main.java
src/share/classes/com/sun/tools/javac/main/Main.java
+62
-66
src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
...e/classes/com/sun/tools/javac/main/RecognizedOptions.java
+24
-16
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
...un/tools/javac/processing/JavacProcessingEnvironment.java
+2
-2
src/share/classes/com/sun/tools/javac/resources/compiler.properties
...classes/com/sun/tools/javac/resources/compiler.properties
+5
-3
src/share/classes/com/sun/tools/javac/util/BaseFileManager.java
...are/classes/com/sun/tools/javac/util/BaseFileManager.java
+1
-1
src/share/classes/com/sun/tools/javac/util/Log.java
src/share/classes/com/sun/tools/javac/util/Log.java
+71
-26
test/tools/javac/6410653/T6410653.java
test/tools/javac/6410653/T6410653.java
+7
-6
test/tools/javac/diags/ArgTypeCompilerFactory.java
test/tools/javac/diags/ArgTypeCompilerFactory.java
+3
-5
未找到文件。
src/share/classes/com/sun/tools/apt/main/Main.java
浏览文件 @
bf0d054e
...
@@ -205,7 +205,7 @@ public class Main {
...
@@ -205,7 +205,7 @@ public class Main {
String
s
=
" "
+
helpSynopsis
();
String
s
=
" "
+
helpSynopsis
();
out
.
print
(
s
);
out
.
print
(
s
);
for
(
int
j
=
s
.
length
();
j
<
29
;
j
++)
out
.
print
(
" "
);
for
(
int
j
=
s
.
length
();
j
<
29
;
j
++)
out
.
print
(
" "
);
Bark
.
printLines
(
out
,
getLocalizedString
(
descrKey
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
descrKey
));
}
}
}
}
...
@@ -227,7 +227,7 @@ public class Main {
...
@@ -227,7 +227,7 @@ public class Main {
String
s
=
" "
+
helpSynopsis
();
String
s
=
" "
+
helpSynopsis
();
out
.
print
(
s
);
out
.
print
(
s
);
for
(
int
j
=
s
.
length
();
j
<
29
;
j
++)
out
.
print
(
" "
);
for
(
int
j
=
s
.
length
();
j
<
29
;
j
++)
out
.
print
(
" "
);
Bark
.
printLines
(
out
,
getLocalizedString
(
descrKey
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
descrKey
));
}
}
}
}
...
@@ -259,7 +259,7 @@ public class Main {
...
@@ -259,7 +259,7 @@ public class Main {
String
s
=
" "
+
helpSynopsis
();
String
s
=
" "
+
helpSynopsis
();
out
.
print
(
s
);
out
.
print
(
s
);
for
(
int
j
=
s
.
length
();
j
<
29
;
j
++)
out
.
print
(
" "
);
for
(
int
j
=
s
.
length
();
j
<
29
;
j
++)
out
.
print
(
" "
);
Log
.
printLines
(
out
,
getLocalizedString
(
descrKey
));
Log
.
print
Raw
Lines
(
out
,
getLocalizedString
(
descrKey
));
}
}
};
};
...
@@ -421,7 +421,7 @@ public class Main {
...
@@ -421,7 +421,7 @@ public class Main {
},
},
new
AptOption
(
"-version"
,
"opt.version"
)
{
new
AptOption
(
"-version"
,
"opt.version"
)
{
boolean
process
(
String
option
)
{
boolean
process
(
String
option
)
{
Bark
.
printLines
(
out
,
ownName
+
" "
+
AptJavaCompiler
.
version
());
Bark
.
print
Raw
Lines
(
out
,
ownName
+
" "
+
AptJavaCompiler
.
version
());
return
super
.
process
(
option
);
return
super
.
process
(
option
);
}
}
},
},
...
@@ -660,11 +660,11 @@ public class Main {
...
@@ -660,11 +660,11 @@ public class Main {
/** Print a string that explains usage.
/** Print a string that explains usage.
*/
*/
void
help
()
{
void
help
()
{
Bark
.
printLines
(
out
,
getLocalizedString
(
"msg.usage.header"
,
ownName
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"msg.usage.header"
,
ownName
));
for
(
int
i
=
0
;
i
<
recognizedOptions
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
recognizedOptions
.
length
;
i
++)
{
recognizedOptions
[
i
].
help
();
recognizedOptions
[
i
].
help
();
}
}
Bark
.
printLines
(
out
,
getLocalizedString
(
"msg.usage.footer"
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"msg.usage.footer"
));
out
.
println
();
out
.
println
();
}
}
...
@@ -675,7 +675,7 @@ public class Main {
...
@@ -675,7 +675,7 @@ public class Main {
recognizedOptions
[
i
].
xhelp
();
recognizedOptions
[
i
].
xhelp
();
}
}
out
.
println
();
out
.
println
();
Bark
.
printLines
(
out
,
getLocalizedString
(
"msg.usage.nonstandard.footer"
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"msg.usage.nonstandard.footer"
));
}
}
/** Report a usage error.
/** Report a usage error.
...
@@ -688,7 +688,7 @@ public class Main {
...
@@ -688,7 +688,7 @@ public class Main {
/** Report a warning.
/** Report a warning.
*/
*/
void
warning
(
String
key
,
Object
...
args
)
{
void
warning
(
String
key
,
Object
...
args
)
{
Bark
.
printLines
(
out
,
ownName
+
": "
Bark
.
print
Raw
Lines
(
out
,
ownName
+
": "
+
getLocalizedString
(
key
,
args
));
+
getLocalizedString
(
key
,
args
));
}
}
...
@@ -796,7 +796,7 @@ public class Main {
...
@@ -796,7 +796,7 @@ public class Main {
origFilenames
=
processArgs
((
args
=
CommandLine
.
parse
(
args
)));
origFilenames
=
processArgs
((
args
=
CommandLine
.
parse
(
args
)));
if
(
options
.
get
(
"suppress-tool-api-removal-message"
)
==
null
)
{
if
(
options
.
get
(
"suppress-tool-api-removal-message"
)
==
null
)
{
Bark
.
printLines
(
out
,
getLocalizedString
(
"misc.Deprecation"
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"misc.Deprecation"
));
}
}
if
(
origFilenames
==
null
)
{
if
(
origFilenames
==
null
)
{
...
@@ -808,7 +808,7 @@ public class Main {
...
@@ -808,7 +808,7 @@ public class Main {
return
EXIT_OK
;
return
EXIT_OK
;
}
}
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
Bark
.
printLines
(
out
,
ownName
+
": "
+
Bark
.
print
Raw
Lines
(
out
,
ownName
+
": "
+
getLocalizedString
(
"err.file.not.found"
,
getLocalizedString
(
"err.file.not.found"
,
e
.
getMessage
()));
e
.
getMessage
()));
return
EXIT_SYSERR
;
return
EXIT_SYSERR
;
...
@@ -1183,7 +1183,7 @@ public class Main {
...
@@ -1183,7 +1183,7 @@ public class Main {
/** Print a message reporting an internal error.
/** Print a message reporting an internal error.
*/
*/
void
bugMessage
(
Throwable
ex
)
{
void
bugMessage
(
Throwable
ex
)
{
Bark
.
printLines
(
out
,
getLocalizedString
(
"msg.bug"
,
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"msg.bug"
,
AptJavaCompiler
.
version
()));
AptJavaCompiler
.
version
()));
ex
.
printStackTrace
(
out
);
ex
.
printStackTrace
(
out
);
}
}
...
@@ -1191,34 +1191,34 @@ public class Main {
...
@@ -1191,34 +1191,34 @@ public class Main {
/** Print a message reporting an fatal error.
/** Print a message reporting an fatal error.
*/
*/
void
apMessage
(
AnnotationProcessingError
ex
)
{
void
apMessage
(
AnnotationProcessingError
ex
)
{
Bark
.
printLines
(
out
,
getLocalizedString
(
"misc.Problem"
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"misc.Problem"
));
ex
.
getCause
().
printStackTrace
(
out
);
ex
.
getCause
().
printStackTrace
(
out
);
}
}
/** Print a message about sun.misc.Service problem.
/** Print a message about sun.misc.Service problem.
*/
*/
void
sceMessage
(
sun
.
misc
.
ServiceConfigurationError
ex
)
{
void
sceMessage
(
sun
.
misc
.
ServiceConfigurationError
ex
)
{
Bark
.
printLines
(
out
,
getLocalizedString
(
"misc.SunMiscService"
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"misc.SunMiscService"
));
ex
.
printStackTrace
(
out
);
ex
.
printStackTrace
(
out
);
}
}
/** Print a message reporting an fatal error.
/** Print a message reporting an fatal error.
*/
*/
void
feMessage
(
Throwable
ex
)
{
void
feMessage
(
Throwable
ex
)
{
Bark
.
printLines
(
out
,
ex
.
toString
());
Bark
.
print
Raw
Lines
(
out
,
ex
.
toString
());
}
}
/** Print a message reporting an input/output error.
/** Print a message reporting an input/output error.
*/
*/
void
ioMessage
(
Throwable
ex
)
{
void
ioMessage
(
Throwable
ex
)
{
Bark
.
printLines
(
out
,
getLocalizedString
(
"msg.io"
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"msg.io"
));
ex
.
printStackTrace
(
out
);
ex
.
printStackTrace
(
out
);
}
}
/** Print a message reporting an out-of-resources error.
/** Print a message reporting an out-of-resources error.
*/
*/
void
resourceMessage
(
Throwable
ex
)
{
void
resourceMessage
(
Throwable
ex
)
{
Bark
.
printLines
(
out
,
getLocalizedString
(
"msg.resource"
));
Bark
.
print
Raw
Lines
(
out
,
getLocalizedString
(
"msg.resource"
));
ex
.
printStackTrace
(
out
);
ex
.
printStackTrace
(
out
);
}
}
...
...
src/share/classes/com/sun/tools/javac/api/JavacTool.java
浏览文件 @
bf0d054e
...
@@ -52,6 +52,7 @@ import com.sun.tools.javac.main.RecognizedOptions;
...
@@ -52,6 +52,7 @@ import com.sun.tools.javac.main.RecognizedOptions;
import
com.sun.tools.javac.util.ClientCodeException
;
import
com.sun.tools.javac.util.ClientCodeException
;
import
com.sun.tools.javac.util.Context
;
import
com.sun.tools.javac.util.Context
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Log.PrefixKind
;
import
com.sun.tools.javac.util.Options
;
import
com.sun.tools.javac.util.Options
;
import
com.sun.tools.javac.util.Pair
;
import
com.sun.tools.javac.util.Pair
;
...
@@ -156,15 +157,28 @@ public final class JavacTool implements JavaCompiler {
...
@@ -156,15 +157,28 @@ public final class JavacTool implements JavaCompiler {
return
new
JavacFileManager
(
context
,
true
,
charset
);
return
new
JavacFileManager
(
context
,
true
,
charset
);
}
}
@Override
public
JavacTask
getTask
(
Writer
out
,
public
JavacTask
getTask
(
Writer
out
,
JavaFileManager
fileManager
,
JavaFileManager
fileManager
,
DiagnosticListener
<?
super
JavaFileObject
>
diagnosticListener
,
DiagnosticListener
<?
super
JavaFileObject
>
diagnosticListener
,
Iterable
<
String
>
options
,
Iterable
<
String
>
options
,
Iterable
<
String
>
classes
,
Iterable
<
String
>
classes
,
Iterable
<?
extends
JavaFileObject
>
compilationUnits
)
Iterable
<?
extends
JavaFileObject
>
compilationUnits
)
{
Context
context
=
new
Context
();
return
getTask
(
out
,
fileManager
,
diagnosticListener
,
options
,
classes
,
compilationUnits
,
context
);
}
public
JavacTask
getTask
(
Writer
out
,
JavaFileManager
fileManager
,
DiagnosticListener
<?
super
JavaFileObject
>
diagnosticListener
,
Iterable
<
String
>
options
,
Iterable
<
String
>
classes
,
Iterable
<?
extends
JavaFileObject
>
compilationUnits
,
Context
context
)
{
{
try
{
try
{
Context
context
=
new
Context
();
ClientCodeWrapper
ccw
=
ClientCodeWrapper
.
instance
(
context
);
ClientCodeWrapper
ccw
=
ClientCodeWrapper
.
instance
(
context
);
final
String
kindMsg
=
"All compilation units must be of SOURCE kind"
;
final
String
kindMsg
=
"All compilation units must be of SOURCE kind"
;
...
@@ -212,9 +226,10 @@ public final class JavacTool implements JavaCompiler {
...
@@ -212,9 +226,10 @@ public final class JavacTool implements JavaCompiler {
return
;
return
;
Options
optionTable
=
Options
.
instance
(
context
);
Options
optionTable
=
Options
.
instance
(
context
);
Log
log
=
Log
.
instance
(
context
);
JavacOption
[]
recognizedOptions
=
JavacOption
[]
recognizedOptions
=
RecognizedOptions
.
getJavacToolOptions
(
new
GrumpyHelper
());
RecognizedOptions
.
getJavacToolOptions
(
new
GrumpyHelper
(
log
));
Iterator
<
String
>
flags
=
options
.
iterator
();
Iterator
<
String
>
flags
=
options
.
iterator
();
while
(
flags
.
hasNext
())
{
while
(
flags
.
hasNext
())
{
String
flag
=
flags
.
next
();
String
flag
=
flags
.
next
();
...
@@ -227,7 +242,7 @@ public final class JavacTool implements JavaCompiler {
...
@@ -227,7 +242,7 @@ public final class JavacTool implements JavaCompiler {
if
(
fileManager
.
handleOption
(
flag
,
flags
))
{
if
(
fileManager
.
handleOption
(
flag
,
flags
))
{
continue
;
continue
;
}
else
{
}
else
{
String
msg
=
Main
.
getLocalizedString
(
"err.invalid.flag"
,
flag
);
String
msg
=
log
.
localize
(
PrefixKind
.
JAVAC
,
"err.invalid.flag"
,
flag
);
throw
new
IllegalArgumentException
(
msg
);
throw
new
IllegalArgumentException
(
msg
);
}
}
}
}
...
@@ -235,7 +250,7 @@ public final class JavacTool implements JavaCompiler {
...
@@ -235,7 +250,7 @@ public final class JavacTool implements JavaCompiler {
JavacOption
option
=
recognizedOptions
[
j
];
JavacOption
option
=
recognizedOptions
[
j
];
if
(
option
.
hasArg
())
{
if
(
option
.
hasArg
())
{
if
(!
flags
.
hasNext
())
{
if
(!
flags
.
hasNext
())
{
String
msg
=
Main
.
getLocalizedString
(
"err.req.arg"
,
flag
);
String
msg
=
log
.
localize
(
PrefixKind
.
JAVAC
,
"err.req.arg"
,
flag
);
throw
new
IllegalArgumentException
(
msg
);
throw
new
IllegalArgumentException
(
msg
);
}
}
String
operand
=
flags
.
next
();
String
operand
=
flags
.
next
();
...
@@ -269,7 +284,7 @@ public final class JavacTool implements JavaCompiler {
...
@@ -269,7 +284,7 @@ public final class JavacTool implements JavaCompiler {
public
int
isSupportedOption
(
String
option
)
{
public
int
isSupportedOption
(
String
option
)
{
JavacOption
[]
recognizedOptions
=
JavacOption
[]
recognizedOptions
=
RecognizedOptions
.
getJavacToolOptions
(
new
GrumpyHelper
());
RecognizedOptions
.
getJavacToolOptions
(
new
GrumpyHelper
(
null
));
for
(
JavacOption
o
:
recognizedOptions
)
{
for
(
JavacOption
o
:
recognizedOptions
)
{
if
(
o
.
matches
(
option
))
if
(
o
.
matches
(
option
))
return
o
.
hasArg
()
?
1
:
0
;
return
o
.
hasArg
()
?
1
:
0
;
...
...
src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
浏览文件 @
bf0d054e
...
@@ -2539,7 +2539,7 @@ public class ClassReader implements Completer {
...
@@ -2539,7 +2539,7 @@ public class ClassReader implements Completer {
* @param arg An argument for substitution into the output string.
* @param arg An argument for substitution into the output string.
*/
*/
private
void
printCCF
(
String
key
,
Object
arg
)
{
private
void
printCCF
(
String
key
,
Object
arg
)
{
log
.
print
Note
Lines
(
key
,
arg
);
log
.
printLines
(
key
,
arg
);
}
}
...
...
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
浏览文件 @
bf0d054e
...
@@ -48,17 +48,18 @@ import javax.tools.DiagnosticListener;
...
@@ -48,17 +48,18 @@ import javax.tools.DiagnosticListener;
import
com.sun.source.util.TaskEvent
;
import
com.sun.source.util.TaskEvent
;
import
com.sun.source.util.TaskListener
;
import
com.sun.source.util.TaskListener
;
import
com.sun.tools.javac.file.JavacFileManager
;
import
com.sun.tools.javac.util.*
;
import
com.sun.tools.javac.code.*
;
import
com.sun.tools.javac.code.*
;
import
com.sun.tools.javac.code.Lint.LintCategory
;
import
com.sun.tools.javac.code.Lint.LintCategory
;
import
com.sun.tools.javac.code.Symbol.*
;
import
com.sun.tools.javac.code.Symbol.*
;
import
com.sun.tools.javac.tree.*
;
import
com.sun.tools.javac.tree.JCTree.*
;
import
com.sun.tools.javac.parser.*
;
import
com.sun.tools.javac.comp.*
;
import
com.sun.tools.javac.comp.*
;
import
com.sun.tools.javac.file.JavacFileManager
;
import
com.sun.tools.javac.jvm.*
;
import
com.sun.tools.javac.jvm.*
;
import
com.sun.tools.javac.parser.*
;
import
com.sun.tools.javac.processing.*
;
import
com.sun.tools.javac.processing.*
;
import
com.sun.tools.javac.tree.*
;
import
com.sun.tools.javac.tree.JCTree.*
;
import
com.sun.tools.javac.util.*
;
import
com.sun.tools.javac.util.Log.WriterKind
;
import
static
javax
.
tools
.
StandardLocation
.
CLASS_OUTPUT
;
import
static
javax
.
tools
.
StandardLocation
.
CLASS_OUTPUT
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
OptionName
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
OptionName
.*;
...
@@ -1602,7 +1603,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
...
@@ -1602,7 +1603,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
}
}
protected
void
printNote
(
String
lines
)
{
protected
void
printNote
(
String
lines
)
{
log
.
printLines
(
Log
.
WriterKind
.
NOTICE
,
lines
);
log
.
print
Raw
Lines
(
Log
.
WriterKind
.
NOTICE
,
lines
);
}
}
/** Print numbers of errors and warnings.
/** Print numbers of errors and warnings.
...
@@ -1614,7 +1615,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
...
@@ -1614,7 +1615,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
key
=
"count."
+
kind
;
key
=
"count."
+
kind
;
else
else
key
=
"count."
+
kind
+
".plural"
;
key
=
"count."
+
kind
+
".plural"
;
log
.
print
ErrLines
(
key
,
String
.
valueOf
(
count
));
log
.
print
Lines
(
WriterKind
.
ERROR
,
key
,
String
.
valueOf
(
count
));
log
.
flush
(
Log
.
WriterKind
.
ERROR
);
log
.
flush
(
Log
.
WriterKind
.
ERROR
);
}
}
}
}
...
...
src/share/classes/com/sun/tools/javac/main/JavacOption.java
浏览文件 @
bf0d054e
/*
/*
* Copyright (c) 2006, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 20
11
, 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,10 +25,11 @@
...
@@ -25,10 +25,11 @@
package
com.sun.tools.javac.main
;
package
com.sun.tools.javac.main
;
import
java.io.PrintWriter
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Log.PrefixKind
;
import
com.sun.tools.javac.util.Log.WriterKind
;
import
com.sun.tools.javac.util.Options
;
import
com.sun.tools.javac.util.Options
;
/**
/**
...
@@ -177,14 +178,14 @@ public interface JavacOption {
...
@@ -177,14 +178,14 @@ public interface JavacOption {
/** Print a line of documentation describing this option, if standard.
/** Print a line of documentation describing this option, if standard.
* @param out the stream to which to write the documentation
* @param out the stream to which to write the documentation
*/
*/
void
help
(
PrintWriter
out
)
{
void
help
(
Log
log
)
{
String
s
=
" "
+
helpSynopsis
();
log
.
printRawLines
(
WriterKind
.
NOTICE
,
out
.
print
(
s
);
String
.
format
(
" %-26s %s"
,
for
(
int
j
=
Math
.
min
(
s
.
length
(),
28
);
j
<
29
;
j
++)
out
.
print
(
" "
);
helpSynopsis
(
log
),
Log
.
printLines
(
out
,
Main
.
getLocalizedString
(
descrKey
));
log
.
localize
(
PrefixKind
.
JAVAC
,
descrKey
)
));
}
}
String
helpSynopsis
()
{
String
helpSynopsis
(
Log
log
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
name
);
sb
.
append
(
name
);
if
(
argsNameKey
==
null
)
{
if
(
argsNameKey
==
null
)
{
...
@@ -202,7 +203,7 @@ public interface JavacOption {
...
@@ -202,7 +203,7 @@ public interface JavacOption {
}
else
{
}
else
{
if
(!
hasSuffix
)
if
(!
hasSuffix
)
sb
.
append
(
" "
);
sb
.
append
(
" "
);
sb
.
append
(
Main
.
getLocalizedString
(
argsNameKey
));
sb
.
append
(
log
.
localize
(
PrefixKind
.
JAVAC
,
argsNameKey
));
}
}
return
sb
.
toString
();
return
sb
.
toString
();
...
@@ -211,7 +212,7 @@ public interface JavacOption {
...
@@ -211,7 +212,7 @@ public interface JavacOption {
/** Print a line of documentation describing this option, if non-standard.
/** Print a line of documentation describing this option, if non-standard.
* @param out the stream to which to write the documentation
* @param out the stream to which to write the documentation
*/
*/
void
xhelp
(
PrintWriter
out
)
{}
void
xhelp
(
Log
log
)
{}
/** Process the option (with arg). Return true if error detected.
/** Process the option (with arg). Return true if error detected.
*/
*/
...
@@ -271,9 +272,9 @@ public interface JavacOption {
...
@@ -271,9 +272,9 @@ public interface JavacOption {
super
(
name
,
descrKey
,
kind
,
choices
);
super
(
name
,
descrKey
,
kind
,
choices
);
}
}
@Override
@Override
void
help
(
PrintWriter
out
)
{}
void
help
(
Log
log
)
{}
@Override
@Override
void
xhelp
(
PrintWriter
out
)
{
super
.
help
(
out
);
}
void
xhelp
(
Log
log
)
{
super
.
help
(
log
);
}
@Override
@Override
public
OptionKind
getKind
()
{
return
OptionKind
.
EXTENDED
;
}
public
OptionKind
getKind
()
{
return
OptionKind
.
EXTENDED
;
}
};
};
...
@@ -288,9 +289,9 @@ public interface JavacOption {
...
@@ -288,9 +289,9 @@ public interface JavacOption {
super
(
name
,
argsNameKey
,
null
);
super
(
name
,
argsNameKey
,
null
);
}
}
@Override
@Override
void
help
(
PrintWriter
out
)
{}
void
help
(
Log
log
)
{}
@Override
@Override
void
xhelp
(
PrintWriter
out
)
{}
void
xhelp
(
Log
log
)
{}
@Override
@Override
public
OptionKind
getKind
()
{
return
OptionKind
.
HIDDEN
;
}
public
OptionKind
getKind
()
{
return
OptionKind
.
HIDDEN
;
}
};
};
...
...
src/share/classes/com/sun/tools/javac/main/Main.java
浏览文件 @
bf0d054e
...
@@ -33,7 +33,6 @@ import java.security.DigestInputStream;
...
@@ -33,7 +33,6 @@ import java.security.DigestInputStream;
import
java.security.MessageDigest
;
import
java.security.MessageDigest
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.MissingResourceException
;
import
java.util.Set
;
import
java.util.Set
;
import
javax.tools.JavaFileManager
;
import
javax.tools.JavaFileManager
;
import
javax.tools.JavaFileObject
;
import
javax.tools.JavaFileObject
;
...
@@ -46,6 +45,8 @@ import com.sun.tools.javac.jvm.Target;
...
@@ -46,6 +45,8 @@ import com.sun.tools.javac.jvm.Target;
import
com.sun.tools.javac.main.JavacOption.Option
;
import
com.sun.tools.javac.main.JavacOption.Option
;
import
com.sun.tools.javac.main.RecognizedOptions.OptionHelper
;
import
com.sun.tools.javac.main.RecognizedOptions.OptionHelper
;
import
com.sun.tools.javac.util.*
;
import
com.sun.tools.javac.util.*
;
import
com.sun.tools.javac.util.Log.WriterKind
;
import
com.sun.tools.javac.util.Log.PrefixKind
;
import
com.sun.tools.javac.processing.AnnotationProcessingError
;
import
com.sun.tools.javac.processing.AnnotationProcessingError
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
OptionName
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
OptionName
.*;
...
@@ -110,11 +111,11 @@ public class Main {
...
@@ -110,11 +111,11 @@ public class Main {
}
}
public
void
printVersion
()
{
public
void
printVersion
()
{
Log
.
printLines
(
out
,
getLocalizedString
(
"version"
,
ownName
,
JavaCompiler
.
version
()
));
log
.
printLines
(
PrefixKind
.
JAVAC
,
"version"
,
ownName
,
JavaCompiler
.
version
(
));
}
}
public
void
printFullVersion
()
{
public
void
printFullVersion
()
{
Log
.
printLines
(
out
,
getLocalizedString
(
"fullVersion"
,
ownName
,
JavaCompiler
.
fullVersion
()
));
log
.
printLines
(
PrefixKind
.
JAVAC
,
"fullversion"
,
ownName
,
JavaCompiler
.
fullVersion
(
));
}
}
public
void
printHelp
()
{
public
void
printHelp
()
{
...
@@ -163,39 +164,38 @@ public class Main {
...
@@ -163,39 +164,38 @@ public class Main {
/** Print a string that explains usage.
/** Print a string that explains usage.
*/
*/
void
help
()
{
void
help
()
{
Log
.
printLines
(
out
,
getLocalizedString
(
"msg.usage.header"
,
ownName
)
);
log
.
printLines
(
PrefixKind
.
JAVAC
,
"msg.usage.header"
,
ownName
);
for
(
int
i
=
0
;
i
<
recognizedOptions
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
recognizedOptions
.
length
;
i
++)
{
recognizedOptions
[
i
].
help
(
out
);
recognizedOptions
[
i
].
help
(
log
);
}
}
out
.
println
();
log
.
printNewline
();
}
}
/** Print a string that explains usage for X options.
/** Print a string that explains usage for X options.
*/
*/
void
xhelp
()
{
void
xhelp
()
{
for
(
int
i
=
0
;
i
<
recognizedOptions
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
recognizedOptions
.
length
;
i
++)
{
recognizedOptions
[
i
].
xhelp
(
out
);
recognizedOptions
[
i
].
xhelp
(
log
);
}
}
out
.
println
();
log
.
printNewline
();
Log
.
printLines
(
out
,
getLocalizedString
(
"msg.usage.nonstandard.footer"
)
);
log
.
printLines
(
PrefixKind
.
JAVAC
,
"msg.usage.nonstandard.footer"
);
}
}
/** Report a usage error.
/** Report a usage error.
*/
*/
void
error
(
String
key
,
Object
...
args
)
{
void
error
(
String
key
,
Object
...
args
)
{
if
(
apiMode
)
{
if
(
apiMode
)
{
String
msg
=
getLocalizedString
(
key
,
args
);
String
msg
=
log
.
localize
(
PrefixKind
.
JAVAC
,
key
,
args
);
throw
new
PropagatedException
(
new
IllegalStateException
(
msg
));
throw
new
PropagatedException
(
new
IllegalStateException
(
msg
));
}
}
warning
(
key
,
args
);
warning
(
key
,
args
);
Log
.
printLines
(
out
,
getLocalizedString
(
"msg.usage"
,
ownName
)
);
log
.
printLines
(
PrefixKind
.
JAVAC
,
"msg.usage"
,
ownName
);
}
}
/** Report a warning.
/** Report a warning.
*/
*/
void
warning
(
String
key
,
Object
...
args
)
{
void
warning
(
String
key
,
Object
...
args
)
{
Log
.
printLines
(
out
,
ownName
+
": "
log
.
printRawLines
(
ownName
+
": "
+
log
.
localize
(
PrefixKind
.
JAVAC
,
key
,
args
));
+
getLocalizedString
(
key
,
args
));
}
}
public
Option
getOption
(
String
flag
)
{
public
Option
getOption
(
String
flag
)
{
...
@@ -400,9 +400,7 @@ public class Main {
...
@@ -400,9 +400,7 @@ public class Main {
return
Result
.
CMDERR
;
return
Result
.
CMDERR
;
}
}
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
Log
.
printLines
(
out
,
ownName
+
": "
+
warning
(
"err.file.not.found"
,
e
.
getMessage
());
getLocalizedString
(
"err.file.not.found"
,
e
.
getMessage
()));
return
Result
.
SYSERR
;
return
Result
.
SYSERR
;
}
}
...
@@ -440,10 +438,10 @@ public class Main {
...
@@ -440,10 +438,10 @@ public class Main {
if
(
log
.
expectDiagKeys
!=
null
)
{
if
(
log
.
expectDiagKeys
!=
null
)
{
if
(
log
.
expectDiagKeys
.
isEmpty
())
{
if
(
log
.
expectDiagKeys
.
isEmpty
())
{
log
.
print
Lines
(
Log
.
WriterKind
.
NOTICE
,
"all expected diagnostics found"
);
log
.
print
RawLines
(
"all expected diagnostics found"
);
return
Result
.
OK
;
return
Result
.
OK
;
}
else
{
}
else
{
log
.
print
Lines
(
Log
.
WriterKind
.
NOTICE
,
"expected diagnostic keys not found: "
+
log
.
expectDiagKeys
);
log
.
print
RawLines
(
"expected diagnostic keys not found: "
+
log
.
expectDiagKeys
);
return
Result
.
ERROR
;
return
Result
.
ERROR
;
}
}
}
}
...
@@ -498,52 +496,50 @@ public class Main {
...
@@ -498,52 +496,50 @@ public class Main {
/** Print a message reporting an internal error.
/** Print a message reporting an internal error.
*/
*/
void
bugMessage
(
Throwable
ex
)
{
void
bugMessage
(
Throwable
ex
)
{
Log
.
printLines
(
out
,
getLocalizedString
(
"msg.bug"
,
log
.
printLines
(
PrefixKind
.
JAVAC
,
"msg.bug"
,
JavaCompiler
.
version
());
JavaCompiler
.
version
()));
ex
.
printStackTrace
(
log
.
getWriter
(
WriterKind
.
NOTICE
));
ex
.
printStackTrace
(
out
);
}
}
/** Print a message reporting a fatal error.
/** Print a message reporting a fatal error.
*/
*/
void
feMessage
(
Throwable
ex
)
{
void
feMessage
(
Throwable
ex
)
{
Log
.
printLines
(
out
,
ex
.
getMessage
());
log
.
printRawLines
(
ex
.
getMessage
());
if
(
ex
.
getCause
()
!=
null
&&
options
.
isSet
(
"dev"
))
{
if
(
ex
.
getCause
()
!=
null
&&
options
.
isSet
(
"dev"
))
{
ex
.
getCause
().
printStackTrace
(
out
);
ex
.
getCause
().
printStackTrace
(
log
.
getWriter
(
WriterKind
.
NOTICE
)
);
}
}
}
}
/** Print a message reporting an input/output error.
/** Print a message reporting an input/output error.
*/
*/
void
ioMessage
(
Throwable
ex
)
{
void
ioMessage
(
Throwable
ex
)
{
Log
.
printLines
(
out
,
getLocalizedString
(
"msg.io"
)
);
log
.
printLines
(
PrefixKind
.
JAVAC
,
"msg.io"
);
ex
.
printStackTrace
(
out
);
ex
.
printStackTrace
(
log
.
getWriter
(
WriterKind
.
NOTICE
)
);
}
}
/** Print a message reporting an out-of-resources error.
/** Print a message reporting an out-of-resources error.
*/
*/
void
resourceMessage
(
Throwable
ex
)
{
void
resourceMessage
(
Throwable
ex
)
{
Log
.
printLines
(
out
,
getLocalizedString
(
"msg.resource"
));
log
.
printLines
(
PrefixKind
.
JAVAC
,
"msg.resource"
);
// System.out.println("(name buffer len = " + Name.names.length + " " + Name.nc);//DEBUG
ex
.
printStackTrace
(
log
.
getWriter
(
WriterKind
.
NOTICE
));
ex
.
printStackTrace
(
out
);
}
}
/** Print a message reporting an uncaught exception from an
/** Print a message reporting an uncaught exception from an
* annotation processor.
* annotation processor.
*/
*/
void
apMessage
(
AnnotationProcessingError
ex
)
{
void
apMessage
(
AnnotationProcessingError
ex
)
{
Log
.
printLines
(
out
,
log
.
printLines
(
"msg.proc.annotation.uncaught.exception"
);
getLocalizedString
(
"msg.proc.annotation.uncaught.exception"
));
ex
.
getCause
().
printStackTrace
(
log
.
getWriter
(
WriterKind
.
NOTICE
));
ex
.
getCause
().
printStackTrace
(
out
);
}
}
/** Display the location and checksum of a class. */
/** Display the location and checksum of a class. */
void
showClass
(
String
className
)
{
void
showClass
(
String
className
)
{
out
.
println
(
"javac: show class: "
+
className
);
PrintWriter
pw
=
log
.
getWriter
(
WriterKind
.
NOTICE
);
pw
.
println
(
"javac: show class: "
+
className
);
URL
url
=
getClass
().
getResource
(
'/'
+
className
.
replace
(
'.'
,
'/'
)
+
".class"
);
URL
url
=
getClass
().
getResource
(
'/'
+
className
.
replace
(
'.'
,
'/'
)
+
".class"
);
if
(
url
==
null
)
if
(
url
==
null
)
out
.
println
(
" class not found"
);
pw
.
println
(
" class not found"
);
else
{
else
{
out
.
println
(
" "
+
url
);
pw
.
println
(
" "
+
url
);
try
{
try
{
final
String
algorithm
=
"MD5"
;
final
String
algorithm
=
"MD5"
;
byte
[]
digest
;
byte
[]
digest
;
...
@@ -560,9 +556,9 @@ public class Main {
...
@@ -560,9 +556,9 @@ public class Main {
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
byte
b:
digest
)
for
(
byte
b:
digest
)
sb
.
append
(
String
.
format
(
"%02x"
,
b
));
sb
.
append
(
String
.
format
(
"%02x"
,
b
));
out
.
println
(
" "
+
algorithm
+
" checksum: "
+
sb
);
pw
.
println
(
" "
+
algorithm
+
" checksum: "
+
sb
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
out
.
println
(
" cannot compute digest: "
+
e
);
pw
.
println
(
" cannot compute digest: "
+
e
);
}
}
}
}
}
}
...
@@ -573,35 +569,35 @@ public class Main {
...
@@ -573,35 +569,35 @@ public class Main {
* Internationalization
* Internationalization
*************************************************************************/
*************************************************************************/
/** Find a localized string in the resource bundle.
//
/** Find a localized string in the resource bundle.
* @param key The key for the localized string.
//
* @param key The key for the localized string.
*/
//
*/
public
static
String
getLocalizedString
(
String
key
,
Object
...
args
)
{
// FIXME sb private
//
public static String getLocalizedString(String key, Object... args) { // FIXME sb private
try
{
//
try {
if
(
messages
==
null
)
//
if (messages == null)
messages
=
new
JavacMessages
(
javacBundleName
);
//
messages = new JavacMessages(javacBundleName);
return
messages
.
getLocalizedString
(
"javac."
+
key
,
args
);
//
return messages.getLocalizedString("javac." + key, args);
}
//
}
catch
(
MissingResourceException
e
)
{
//
catch (MissingResourceException e) {
throw
new
Error
(
"Fatal Error: Resource for javac is missing"
,
e
);
//
throw new Error("Fatal Error: Resource for javac is missing", e);
}
//
}
}
//
}
//
public
static
void
useRawMessages
(
boolean
enable
)
{
//
public static void useRawMessages(boolean enable) {
if
(
enable
)
{
//
if (enable) {
messages
=
new
JavacMessages
(
javacBundleName
)
{
//
messages = new JavacMessages(javacBundleName) {
@Override
//
@Override
public
String
getLocalizedString
(
String
key
,
Object
...
args
)
{
//
public String getLocalizedString(String key, Object... args) {
return
key
;
//
return key;
}
//
}
};
//
};
}
else
{
//
} else {
messages
=
new
JavacMessages
(
javacBundleName
);
//
messages = new JavacMessages(javacBundleName);
}
//
}
}
//
}
p
rivate
static
final
String
javacBundleName
=
p
ublic
static
final
String
javacBundleName
=
"com.sun.tools.javac.resources.javac"
;
"com.sun.tools.javac.resources.javac"
;
//
private
static
JavacMessages
messages
;
//
private static JavacMessages messages;
}
}
src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
浏览文件 @
bf0d054e
...
@@ -25,6 +25,15 @@
...
@@ -25,6 +25,15 @@
package
com.sun.tools.javac.main
;
package
com.sun.tools.javac.main
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.PrintWriter
;
import
java.util.EnumSet
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.lang.model.SourceVersion
;
import
com.sun.tools.javac.code.Lint
;
import
com.sun.tools.javac.code.Lint
;
import
com.sun.tools.javac.code.Source
;
import
com.sun.tools.javac.code.Source
;
import
com.sun.tools.javac.code.Type
;
import
com.sun.tools.javac.code.Type
;
...
@@ -32,17 +41,11 @@ import com.sun.tools.javac.jvm.Target;
...
@@ -32,17 +41,11 @@ import com.sun.tools.javac.jvm.Target;
import
com.sun.tools.javac.main.JavacOption.HiddenOption
;
import
com.sun.tools.javac.main.JavacOption.HiddenOption
;
import
com.sun.tools.javac.main.JavacOption.Option
;
import
com.sun.tools.javac.main.JavacOption.Option
;
import
com.sun.tools.javac.main.JavacOption.XOption
;
import
com.sun.tools.javac.main.JavacOption.XOption
;
import
com.sun.tools.javac.processing.JavacProcessingEnvironment
;
import
com.sun.tools.javac.util.ListBuffer
;
import
com.sun.tools.javac.util.ListBuffer
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Log.PrefixKind
;
import
com.sun.tools.javac.util.Options
;
import
com.sun.tools.javac.util.Options
;
import
com.sun.tools.javac.processing.JavacProcessingEnvironment
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.PrintWriter
;
import
java.util.EnumSet
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.lang.model.SourceVersion
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
OptionName
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
OptionName
.*;
...
@@ -79,13 +82,18 @@ public class RecognizedOptions {
...
@@ -79,13 +82,18 @@ public class RecognizedOptions {
}
}
public
static
class
GrumpyHelper
implements
OptionHelper
{
public
static
class
GrumpyHelper
implements
OptionHelper
{
private
Log
log
;
public
GrumpyHelper
(
Log
log
)
{
this
.
log
=
log
;
}
public
void
setOut
(
PrintWriter
out
)
{
public
void
setOut
(
PrintWriter
out
)
{
throw
new
IllegalArgumentException
();
throw
new
IllegalArgumentException
();
}
}
public
void
error
(
String
key
,
Object
...
args
)
{
public
void
error
(
String
key
,
Object
...
args
)
{
throw
new
IllegalArgumentException
(
Main
.
getLocalizedString
(
key
,
args
));
throw
new
IllegalArgumentException
(
log
.
localize
(
PrefixKind
.
JAVAC
,
key
,
args
));
}
}
public
void
printVersion
()
{
public
void
printVersion
()
{
...
@@ -400,9 +408,9 @@ public class RecognizedOptions {
...
@@ -400,9 +408,9 @@ public class RecognizedOptions {
},
},
new
Option
(
A
,
"opt.arg.key.equals.value"
,
"opt.A"
)
{
new
Option
(
A
,
"opt.arg.key.equals.value"
,
"opt.A"
)
{
@Override
@Override
String
helpSynopsis
()
{
String
helpSynopsis
(
Log
log
)
{
hasSuffix
=
true
;
hasSuffix
=
true
;
return
super
.
helpSynopsis
();
return
super
.
helpSynopsis
(
log
);
}
}
@Override
@Override
...
@@ -444,9 +452,9 @@ public class RecognizedOptions {
...
@@ -444,9 +452,9 @@ public class RecognizedOptions {
// It's actually implemented by the launcher.
// It's actually implemented by the launcher.
new
Option
(
J
,
"opt.arg.flag"
,
"opt.J"
)
{
new
Option
(
J
,
"opt.arg.flag"
,
"opt.J"
)
{
@Override
@Override
String
helpSynopsis
()
{
String
helpSynopsis
(
Log
log
)
{
hasSuffix
=
true
;
hasSuffix
=
true
;
return
super
.
helpSynopsis
();
return
super
.
helpSynopsis
(
log
);
}
}
@Override
@Override
public
boolean
process
(
Options
options
,
String
option
)
{
public
boolean
process
(
Options
options
,
String
option
)
{
...
@@ -570,9 +578,9 @@ public class RecognizedOptions {
...
@@ -570,9 +578,9 @@ public class RecognizedOptions {
// It's actually implemented by the CommandLine class.
// It's actually implemented by the CommandLine class.
new
Option
(
AT
,
"opt.arg.file"
,
"opt.AT"
)
{
new
Option
(
AT
,
"opt.arg.file"
,
"opt.AT"
)
{
@Override
@Override
String
helpSynopsis
()
{
String
helpSynopsis
(
Log
log
)
{
hasSuffix
=
true
;
hasSuffix
=
true
;
return
super
.
helpSynopsis
();
return
super
.
helpSynopsis
(
log
);
}
}
@Override
@Override
public
boolean
process
(
Options
options
,
String
option
)
{
public
boolean
process
(
Options
options
,
String
option
)
{
...
...
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
浏览文件 @
bf0d054e
...
@@ -688,7 +688,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
...
@@ -688,7 +688,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
ps
.
removeSupportedOptions
(
unmatchedProcessorOptions
);
ps
.
removeSupportedOptions
(
unmatchedProcessorOptions
);
if
(
printProcessorInfo
||
verbose
)
{
if
(
printProcessorInfo
||
verbose
)
{
log
.
print
Note
Lines
(
"x.print.processor.info"
,
log
.
printLines
(
"x.print.processor.info"
,
ps
.
processor
.
getClass
().
getName
(),
ps
.
processor
.
getClass
().
getName
(),
matchedNames
.
toString
(),
matchedNames
.
toString
(),
processingResult
);
processingResult
);
...
@@ -1014,7 +1014,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
...
@@ -1014,7 +1014,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
if
(
printRounds
||
verbose
)
{
if
(
printRounds
||
verbose
)
{
List
<
ClassSymbol
>
tlc
=
lastRound
?
List
.<
ClassSymbol
>
nil
()
:
topLevelClasses
;
List
<
ClassSymbol
>
tlc
=
lastRound
?
List
.<
ClassSymbol
>
nil
()
:
topLevelClasses
;
Set
<
TypeElement
>
ap
=
lastRound
?
Collections
.<
TypeElement
>
emptySet
()
:
annotationsPresent
;
Set
<
TypeElement
>
ap
=
lastRound
?
Collections
.<
TypeElement
>
emptySet
()
:
annotationsPresent
;
log
.
print
Note
Lines
(
"x.print.rounds"
,
log
.
printLines
(
"x.print.rounds"
,
number
,
number
,
"{"
+
tlc
.
toString
(
", "
)
+
"}"
,
"{"
+
tlc
.
toString
(
", "
)
+
"}"
,
ap
,
ap
,
...
...
src/share/classes/com/sun/tools/javac/resources/compiler.properties
浏览文件 @
bf0d054e
...
@@ -792,7 +792,7 @@ compiler.err.invalid.inferred.types=\
...
@@ -792,7 +792,7 @@ compiler.err.invalid.inferred.types=\
compiler.err.cant.apply.diamond
=
\
compiler.err.cant.apply.diamond
=
\
cannot infer type arguments for {0}
cannot infer type arguments for {0}
# 0: message segment, 1: message segment
# 0: message segment
or type
, 1: message segment
compiler.err.cant.apply.diamond.1
=
\
compiler.err.cant.apply.diamond.1
=
\
cannot infer type arguments for {0};
\n\
cannot infer type arguments for {0};
\n\
reason: {1}
reason: {1}
...
@@ -854,7 +854,7 @@ compiler.misc.varargs.trustme.on.non.varargs.meth=\
...
@@ -854,7 +854,7 @@ compiler.misc.varargs.trustme.on.non.varargs.meth=\
compiler.misc.varargs.trustme.on.virtual.varargs
=
\
compiler.misc.varargs.trustme.on.virtual.varargs
=
\
Instance method {0} is not final.
Instance method {0} is not final.
# 0: type, 1: kind, 2: symbol
# 0: type, 1:
symbol
kind, 2: symbol
compiler.misc.inaccessible.varargs.type
=
\
compiler.misc.inaccessible.varargs.type
=
\
formal varargs element type {0} is not accessible from {1} {2}
formal varargs element type {0} is not accessible from {1} {2}
...
@@ -1631,6 +1631,7 @@ compiler.misc.diamond=\
...
@@ -1631,6 +1631,7 @@ compiler.misc.diamond=\
compiler.misc.diamond.non.generic
=
\
compiler.misc.diamond.non.generic
=
\
cannot use ''<>'' with non-generic class {0}
cannot use ''<>'' with non-generic class {0}
# 0: unused
compiler.misc.diamond.and.explicit.params
=
\
compiler.misc.diamond.and.explicit.params
=
\
cannot use ''<>'' with explicit type parameters for constructor
cannot use ''<>'' with explicit type parameters for constructor
...
@@ -1712,7 +1713,7 @@ compiler.err.cant.resolve.location.args.params=\
...
@@ -1712,7 +1713,7 @@ compiler.err.cant.resolve.location.args.params=\
## The second argument {1} is the location name
## The second argument {1} is the location name
## The third argument {2} is the location type (only when {1} is a variable name)
## The third argument {2} is the location type (only when {1} is a variable name)
# 0: symbol kind, 1: symbol, 2: unused
# 0: symbol kind, 1:
type or
symbol, 2: unused
compiler.misc.location
=
\
compiler.misc.location
=
\
{0} {1}
{0} {1}
...
@@ -1847,6 +1848,7 @@ compiler.misc.varargs.implement=\
...
@@ -1847,6 +1848,7 @@ compiler.misc.varargs.implement=\
compiler.misc.varargs.clash.with
=
\
compiler.misc.varargs.clash.with
=
\
{0} in {1} overrides {2} in {3}
{0} in {1} overrides {2} in {3}
# 0: unused
compiler.misc.diamond.and.anon.class
=
\
compiler.misc.diamond.and.anon.class
=
\
cannot use ''<>'' with anonymous inner classes
cannot use ''<>'' with anonymous inner classes
...
...
src/share/classes/com/sun/tools/javac/util/BaseFileManager.java
浏览文件 @
bf0d054e
...
@@ -166,7 +166,7 @@ public abstract class BaseFileManager {
...
@@ -166,7 +166,7 @@ public abstract class BaseFileManager {
// where
// where
private
static
JavacOption
[]
javacFileManagerOptions
=
private
static
JavacOption
[]
javacFileManagerOptions
=
RecognizedOptions
.
getJavacFileManagerOptions
(
RecognizedOptions
.
getJavacFileManagerOptions
(
new
RecognizedOptions
.
GrumpyHelper
());
new
RecognizedOptions
.
GrumpyHelper
(
Log
.
instance
(
new
Context
())
));
public
int
isSupportedOption
(
String
option
)
{
public
int
isSupportedOption
(
String
option
)
{
for
(
JavacOption
o
:
javacFileManagerOptions
)
{
for
(
JavacOption
o
:
javacFileManagerOptions
)
{
...
...
src/share/classes/com/sun/tools/javac/util/Log.java
浏览文件 @
bf0d054e
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
package
com.sun.tools.javac.util
;
package
com.sun.tools.javac.util
;
import
com.sun.tools.javac.main.Main
;
import
java.io.*
;
import
java.io.*
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.EnumSet
;
import
java.util.EnumSet
;
...
@@ -60,6 +61,19 @@ public class Log extends AbstractLog {
...
@@ -60,6 +61,19 @@ public class Log extends AbstractLog {
public
static
final
Context
.
Key
<
PrintWriter
>
outKey
=
public
static
final
Context
.
Key
<
PrintWriter
>
outKey
=
new
Context
.
Key
<
PrintWriter
>();
new
Context
.
Key
<
PrintWriter
>();
/* TODO: Should unify this with prefix handling in JCDiagnostic.Factory. */
public
enum
PrefixKind
{
JAVAC
(
"javac."
),
COMPILER_MISC
(
"compiler.misc."
);
PrefixKind
(
String
v
)
{
value
=
v
;
}
public
String
key
(
String
k
)
{
return
value
+
k
;
}
final
String
value
;
}
public
enum
WriterKind
{
NOTICE
,
WARNING
,
ERROR
};
public
enum
WriterKind
{
NOTICE
,
WARNING
,
ERROR
};
protected
PrintWriter
errWriter
;
protected
PrintWriter
errWriter
;
...
@@ -136,6 +150,7 @@ public class Log extends AbstractLog {
...
@@ -136,6 +150,7 @@ public class Log extends AbstractLog {
this
.
diagListener
=
dl
;
this
.
diagListener
=
dl
;
messages
=
JavacMessages
.
instance
(
context
);
messages
=
JavacMessages
.
instance
(
context
);
messages
.
add
(
Main
.
javacBundleName
);
final
Options
options
=
Options
.
instance
(
context
);
final
Options
options
=
Options
.
instance
(
context
);
initOptions
(
options
);
initOptions
(
options
);
...
@@ -313,7 +328,6 @@ public class Log extends AbstractLog {
...
@@ -313,7 +328,6 @@ public class Log extends AbstractLog {
public
void
prompt
()
{
public
void
prompt
()
{
if
(
promptOnError
)
{
if
(
promptOnError
)
{
System
.
err
.
println
(
localize
(
"resume.abort"
));
System
.
err
.
println
(
localize
(
"resume.abort"
));
char
ch
;
try
{
try
{
while
(
true
)
{
while
(
true
)
{
switch
(
System
.
in
.
read
())
{
switch
(
System
.
in
.
read
())
{
...
@@ -340,7 +354,7 @@ public class Log extends AbstractLog {
...
@@ -340,7 +354,7 @@ public class Log extends AbstractLog {
return
;
return
;
int
col
=
source
.
getColumnNumber
(
pos
,
false
);
int
col
=
source
.
getColumnNumber
(
pos
,
false
);
printLines
(
writer
,
line
);
print
Raw
Lines
(
writer
,
line
);
for
(
int
i
=
0
;
i
<
col
-
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
col
-
1
;
i
++)
{
writer
.
print
((
line
.
charAt
(
i
)
==
'\t'
)
?
"\t"
:
" "
);
writer
.
print
((
line
.
charAt
(
i
)
==
'\t'
)
?
"\t"
:
" "
);
}
}
...
@@ -348,17 +362,48 @@ public class Log extends AbstractLog {
...
@@ -348,17 +362,48 @@ public class Log extends AbstractLog {
writer
.
flush
();
writer
.
flush
();
}
}
public
void
printNewline
()
{
noticeWriter
.
println
();
}
public
void
printNewline
(
WriterKind
wk
)
{
getWriter
(
wk
).
println
();
}
public
void
printLines
(
String
key
,
Object
...
args
)
{
printRawLines
(
noticeWriter
,
localize
(
key
,
args
));
}
public
void
printLines
(
PrefixKind
pk
,
String
key
,
Object
...
args
)
{
printRawLines
(
noticeWriter
,
localize
(
pk
,
key
,
args
));
}
public
void
printLines
(
WriterKind
wk
,
String
key
,
Object
...
args
)
{
printRawLines
(
getWriter
(
wk
),
localize
(
key
,
args
));
}
public
void
printLines
(
WriterKind
wk
,
PrefixKind
pk
,
String
key
,
Object
...
args
)
{
printRawLines
(
getWriter
(
wk
),
localize
(
pk
,
key
,
args
));
}
/** Print the text of a message, translating newlines appropriately
* for the platform.
*/
public
void
printRawLines
(
String
msg
)
{
printRawLines
(
noticeWriter
,
msg
);
}
/** Print the text of a message, translating newlines appropriately
/** Print the text of a message, translating newlines appropriately
* for the platform.
* for the platform.
*/
*/
public
void
printLines
(
WriterKind
kind
,
String
msg
)
{
public
void
print
Raw
Lines
(
WriterKind
kind
,
String
msg
)
{
printLines
(
getWriter
(
kind
),
msg
);
print
Raw
Lines
(
getWriter
(
kind
),
msg
);
}
}
/** Print the text of a message, translating newlines appropriately
/** Print the text of a message, translating newlines appropriately
* for the platform.
* for the platform.
*/
*/
public
static
void
printLines
(
PrintWriter
writer
,
String
msg
)
{
public
static
void
print
Raw
Lines
(
PrintWriter
writer
,
String
msg
)
{
int
nl
;
int
nl
;
while
((
nl
=
msg
.
indexOf
(
'\n'
))
!=
-
1
)
{
while
((
nl
=
msg
.
indexOf
(
'\n'
))
!=
-
1
)
{
writer
.
println
(
msg
.
substring
(
0
,
nl
));
writer
.
println
(
msg
.
substring
(
0
,
nl
));
...
@@ -367,30 +412,16 @@ public class Log extends AbstractLog {
...
@@ -367,30 +412,16 @@ public class Log extends AbstractLog {
if
(
msg
.
length
()
!=
0
)
writer
.
println
(
msg
);
if
(
msg
.
length
()
!=
0
)
writer
.
println
(
msg
);
}
}
/** Print the text of a message to the errWriter stream,
* translating newlines appropriately for the platform.
*/
public
void
printErrLines
(
String
key
,
Object
...
args
)
{
printLines
(
errWriter
,
localize
(
key
,
args
));
}
/** Print the text of a message to the noticeWriter stream,
* translating newlines appropriately for the platform.
*/
public
void
printNoteLines
(
String
key
,
Object
...
args
)
{
printLines
(
noticeWriter
,
localize
(
key
,
args
));
}
/**
/**
* Print the localized text of a "verbose" message to the
* Print the localized text of a "verbose" message to the
* noticeWriter stream.
* noticeWriter stream.
*/
*/
public
void
printVerbose
(
String
key
,
Object
...
args
)
{
public
void
printVerbose
(
String
key
,
Object
...
args
)
{
printLines
(
noticeWriter
,
localize
(
"verbose."
+
key
,
args
));
print
Raw
Lines
(
noticeWriter
,
localize
(
"verbose."
+
key
,
args
));
}
}
protected
void
directError
(
String
key
,
Object
...
args
)
{
protected
void
directError
(
String
key
,
Object
...
args
)
{
print
ErrLines
(
key
,
args
);
print
RawLines
(
errWriter
,
localize
(
key
,
args
)
);
errWriter
.
flush
();
errWriter
.
flush
();
}
}
...
@@ -476,7 +507,7 @@ public class Log extends AbstractLog {
...
@@ -476,7 +507,7 @@ public class Log extends AbstractLog {
PrintWriter
writer
=
getWriterForDiagnosticType
(
diag
.
getType
());
PrintWriter
writer
=
getWriterForDiagnosticType
(
diag
.
getType
());
printLines
(
writer
,
diagFormatter
.
format
(
diag
,
messages
.
getCurrentLocale
()));
print
Raw
Lines
(
writer
,
diagFormatter
.
format
(
diag
,
messages
.
getCurrentLocale
()));
if
(
promptOnError
)
{
if
(
promptOnError
)
{
switch
(
diag
.
getType
())
{
switch
(
diag
.
getType
())
{
...
@@ -519,7 +550,7 @@ public class Log extends AbstractLog {
...
@@ -519,7 +550,7 @@ public class Log extends AbstractLog {
* @param args Fields to substitute into the string.
* @param args Fields to substitute into the string.
*/
*/
public
static
String
getLocalizedString
(
String
key
,
Object
...
args
)
{
public
static
String
getLocalizedString
(
String
key
,
Object
...
args
)
{
return
JavacMessages
.
getDefaultLocalizedString
(
"compiler.misc."
+
key
,
args
);
return
JavacMessages
.
getDefaultLocalizedString
(
PrefixKind
.
COMPILER_MISC
.
key
(
key
)
,
args
);
}
}
/** Find a localized string in the resource bundle.
/** Find a localized string in the resource bundle.
...
@@ -527,8 +558,22 @@ public class Log extends AbstractLog {
...
@@ -527,8 +558,22 @@ public class Log extends AbstractLog {
* @param args Fields to substitute into the string.
* @param args Fields to substitute into the string.
*/
*/
public
String
localize
(
String
key
,
Object
...
args
)
{
public
String
localize
(
String
key
,
Object
...
args
)
{
return
messages
.
getLocalizedString
(
"compiler.misc."
+
key
,
args
);
return
localize
(
PrefixKind
.
COMPILER_MISC
,
key
,
args
);
}
/** Find a localized string in the resource bundle.
* @param key The key for the localized string.
* @param args Fields to substitute into the string.
*/
public
String
localize
(
PrefixKind
pk
,
String
key
,
Object
...
args
)
{
if
(
useRawMessages
)
return
pk
.
key
(
key
);
else
return
messages
.
getLocalizedString
(
pk
.
key
(
key
),
args
);
}
}
// where
// backdoor hook for testing, should transition to use -XDrawDiagnostics
private
static
boolean
useRawMessages
=
false
;
/***************************************************************************
/***************************************************************************
* raw error messages without internationalization; used for experimentation
* raw error messages without internationalization; used for experimentation
...
@@ -539,12 +584,12 @@ public class Log extends AbstractLog {
...
@@ -539,12 +584,12 @@ public class Log extends AbstractLog {
*/
*/
private
void
printRawError
(
int
pos
,
String
msg
)
{
private
void
printRawError
(
int
pos
,
String
msg
)
{
if
(
source
==
null
||
pos
==
Position
.
NOPOS
)
{
if
(
source
==
null
||
pos
==
Position
.
NOPOS
)
{
printLines
(
errWriter
,
"error: "
+
msg
);
print
Raw
Lines
(
errWriter
,
"error: "
+
msg
);
}
else
{
}
else
{
int
line
=
source
.
getLineNumber
(
pos
);
int
line
=
source
.
getLineNumber
(
pos
);
JavaFileObject
file
=
source
.
getFile
();
JavaFileObject
file
=
source
.
getFile
();
if
(
file
!=
null
)
if
(
file
!=
null
)
printLines
(
errWriter
,
print
Raw
Lines
(
errWriter
,
file
.
getName
()
+
":"
+
file
.
getName
()
+
":"
+
line
+
": "
+
msg
);
line
+
": "
+
msg
);
printErrLine
(
pos
,
errWriter
);
printErrLine
(
pos
,
errWriter
);
...
...
test/tools/javac/6410653/T6410653.java
浏览文件 @
bf0d054e
/*
/*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006,
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,7 +28,7 @@
...
@@ -28,7 +28,7 @@
* @author Peter von der Ah\u00e9
* @author Peter von der Ah\u00e9
*/
*/
import
java.lang.reflect.
Metho
d
;
import
java.lang.reflect.
Fiel
d
;
import
java.io.File
;
import
java.io.File
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
javax.tools.*
;
import
javax.tools.*
;
...
@@ -39,12 +39,13 @@ public class T6410653 {
...
@@ -39,12 +39,13 @@ public class T6410653 {
String
source
=
new
File
(
testSrc
,
"T6410653.java"
).
getPath
();
String
source
=
new
File
(
testSrc
,
"T6410653.java"
).
getPath
();
ClassLoader
cl
=
ToolProvider
.
getSystemToolClassLoader
();
ClassLoader
cl
=
ToolProvider
.
getSystemToolClassLoader
();
Tool
compiler
=
ToolProvider
.
getSystemJavaCompiler
();
Tool
compiler
=
ToolProvider
.
getSystemJavaCompiler
();
Class
<?>
main
=
Class
.
forName
(
"com.sun.tools.javac.main.Main"
,
true
,
cl
);
Class
<?>
log
=
Class
.
forName
(
"com.sun.tools.javac.util.Log"
,
true
,
cl
);
Method
useRawMessages
=
main
.
getMethod
(
"useRawMessages"
,
boolean
.
class
);
Field
useRawMessages
=
log
.
getDeclaredField
(
"useRawMessages"
);
useRawMessages
.
invoke
(
null
,
true
);
useRawMessages
.
setAccessible
(
true
);
useRawMessages
.
setBoolean
(
null
,
true
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
compiler
.
run
(
null
,
null
,
out
,
"-d"
,
source
,
source
);
compiler
.
run
(
null
,
null
,
out
,
"-d"
,
source
,
source
);
useRawMessages
.
invoke
(
null
,
false
);
useRawMessages
.
setBoolean
(
null
,
false
);
if
(!
out
.
toString
().
equals
(
String
.
format
(
"%s%n%s%n"
,
if
(!
out
.
toString
().
equals
(
String
.
format
(
"%s%n%s%n"
,
"javac: javac.err.file.not.directory"
,
"javac: javac.err.file.not.directory"
,
"javac.msg.usage"
)))
{
"javac.msg.usage"
)))
{
...
...
test/tools/javac/diags/ArgTypeCompilerFactory.java
浏览文件 @
bf0d054e
...
@@ -105,13 +105,11 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
...
@@ -105,13 +105,11 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
Iterable
<?
extends
JavaFileObject
>
fos
=
fm
.
getJavaFileObjectsFromFiles
(
files
);
Iterable
<?
extends
JavaFileObject
>
fos
=
fm
.
getJavaFileObjectsFromFiles
(
files
);
JavacTaskImpl
t
=
(
JavacTaskImpl
)
tool
.
getTask
(
out
,
fm
,
null
,
opts
,
null
,
fos
);
Context
c
=
new
Context
();
Context
c
=
t
.
getContext
();
ArgTypeMessages
.
preRegister
(
c
);
ArgTypeMessages
.
preRegister
(
c
);
ArgTypeJavaCompiler
.
preRegister
(
c
);
ArgTypeJavaCompiler
.
preRegister
(
c
);
Boolean
ok
=
t
.
call
();
JavacTaskImpl
t
=
(
JavacTaskImpl
)
tool
.
getTask
(
out
,
fm
,
null
,
opts
,
null
,
fos
,
c
);
return
t
.
call
();
return
ok
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录