Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
ecb72958
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看板
提交
ecb72958
编写于
11月 08, 2011
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7108668: allow Log to be initialized and used earlier
Reviewed-by: mcimadamore
上级
b0ad1aa2
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
135 addition
and
55 deletion
+135
-55
src/share/classes/com/sun/tools/apt/comp/Apt.java
src/share/classes/com/sun/tools/apt/comp/Apt.java
+2
-2
src/share/classes/com/sun/tools/javac/api/JavacTool.java
src/share/classes/com/sun/tools/javac/api/JavacTool.java
+2
-0
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
+13
-9
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+2
-2
src/share/classes/com/sun/tools/javac/main/Main.java
src/share/classes/com/sun/tools/javac/main/Main.java
+14
-7
src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java
src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java
+11
-2
src/share/classes/com/sun/tools/javac/util/JavacMessages.java
...share/classes/com/sun/tools/javac/util/JavacMessages.java
+2
-2
src/share/classes/com/sun/tools/javac/util/Log.java
src/share/classes/com/sun/tools/javac/util/Log.java
+69
-24
src/share/classes/com/sun/tools/javac/util/Options.java
src/share/classes/com/sun/tools/javac/util/Options.java
+13
-0
src/share/classes/com/sun/tools/javadoc/Start.java
src/share/classes/com/sun/tools/javadoc/Start.java
+7
-7
未找到文件。
src/share/classes/com/sun/tools/apt/comp/Apt.java
浏览文件 @
ecb72958
/*
* Copyright (c) 2004, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 201
1
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -214,7 +214,7 @@ public class Apt extends ListBuffer<Env<AttrContext>> {
AnnotationProcessorFactory
providedFactory
,
java
.
util
.
Set
<
Class
<?
extends
AnnotationProcessorFactory
>
>
productiveFactories
)
{
Bark
bark
=
Bark
.
instance
(
context
);
java
.
io
.
PrintWriter
out
=
bark
.
warnWriter
;
java
.
io
.
PrintWriter
out
=
bark
.
getWriter
(
Log
.
WriterKind
.
WARNING
)
;
Options
options
=
Options
.
instance
(
context
);
Collection
<
TypeDeclaration
>
spectypedecls
=
new
LinkedHashSet
<
TypeDeclaration
>();
...
...
src/share/classes/com/sun/tools/javac/api/JavacTool.java
浏览文件 @
ecb72958
...
...
@@ -250,6 +250,8 @@ public final class JavacTool implements JavaCompiler {
throw
new
IllegalArgumentException
(
flag
);
}
}
optionTable
.
notifyListeners
();
}
public
int
run
(
InputStream
in
,
OutputStream
out
,
OutputStream
err
,
String
...
arguments
)
{
...
...
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
浏览文件 @
ecb72958
...
...
@@ -892,8 +892,9 @@ public class ClassWriter extends ClassFile {
if
((
flags
&
INTERFACE
)
!=
0
)
flags
|=
ABSTRACT
;
// Interfaces are always ABSTRACT
if
(
inner
.
name
.
isEmpty
())
flags
&=
~
FINAL
;
// Anonymous class: unset FINAL flag
if
(
dumpInnerClassModifiers
)
{
log
.
errWriter
.
println
(
"INNERCLASS "
+
inner
.
name
);
log
.
errWriter
.
println
(
"---"
+
flagNames
(
flags
));
PrintWriter
pw
=
log
.
getWriter
(
Log
.
WriterKind
.
ERROR
);
pw
.
println
(
"INNERCLASS "
+
inner
.
name
);
pw
.
println
(
"---"
+
flagNames
(
flags
));
}
databuf
.
appendChar
(
pool
.
get
(
inner
));
databuf
.
appendChar
(
...
...
@@ -911,8 +912,9 @@ public class ClassWriter extends ClassFile {
int
flags
=
adjustFlags
(
v
.
flags
());
databuf
.
appendChar
(
flags
);
if
(
dumpFieldModifiers
)
{
log
.
errWriter
.
println
(
"FIELD "
+
fieldName
(
v
));
log
.
errWriter
.
println
(
"---"
+
flagNames
(
v
.
flags
()));
PrintWriter
pw
=
log
.
getWriter
(
Log
.
WriterKind
.
ERROR
);
pw
.
println
(
"FIELD "
+
fieldName
(
v
));
pw
.
println
(
"---"
+
flagNames
(
v
.
flags
()));
}
databuf
.
appendChar
(
pool
.
put
(
fieldName
(
v
)));
databuf
.
appendChar
(
pool
.
put
(
typeSig
(
v
.
erasure
(
types
))));
...
...
@@ -934,8 +936,9 @@ public class ClassWriter extends ClassFile {
int
flags
=
adjustFlags
(
m
.
flags
());
databuf
.
appendChar
(
flags
);
if
(
dumpMethodModifiers
)
{
log
.
errWriter
.
println
(
"METHOD "
+
fieldName
(
m
));
log
.
errWriter
.
println
(
"---"
+
flagNames
(
m
.
flags
()));
PrintWriter
pw
=
log
.
getWriter
(
Log
.
WriterKind
.
ERROR
);
pw
.
println
(
"METHOD "
+
fieldName
(
m
));
pw
.
println
(
"---"
+
flagNames
(
m
.
flags
()));
}
databuf
.
appendChar
(
pool
.
put
(
fieldName
(
m
)));
databuf
.
appendChar
(
pool
.
put
(
typeSig
(
m
.
externalType
(
types
))));
...
...
@@ -1483,9 +1486,10 @@ public class ClassWriter extends ClassFile {
if
((
flags
&
INTERFACE
)
==
0
)
flags
|=
ACC_SUPER
;
if
(
c
.
isInner
()
&&
c
.
name
.
isEmpty
())
flags
&=
~
FINAL
;
if
(
dumpClassModifiers
)
{
log
.
errWriter
.
println
();
log
.
errWriter
.
println
(
"CLASSFILE "
+
c
.
getQualifiedName
());
log
.
errWriter
.
println
(
"---"
+
flagNames
(
flags
));
PrintWriter
pw
=
log
.
getWriter
(
Log
.
WriterKind
.
ERROR
);
pw
.
println
();
pw
.
println
(
"CLASSFILE "
+
c
.
getQualifiedName
());
pw
.
println
(
"---"
+
flagNames
(
flags
));
}
databuf
.
appendChar
(
flags
);
...
...
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
浏览文件 @
ecb72958
...
...
@@ -1602,7 +1602,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
}
protected
void
printNote
(
String
lines
)
{
Log
.
printLines
(
log
.
noticeWriter
,
lines
);
log
.
printLines
(
Log
.
WriterKind
.
NOTICE
,
lines
);
}
/** Print numbers of errors and warnings.
...
...
@@ -1615,7 +1615,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
else
key
=
"count."
+
kind
+
".plural"
;
log
.
printErrLines
(
key
,
String
.
valueOf
(
count
));
log
.
errWriter
.
flush
(
);
log
.
flush
(
Log
.
WriterKind
.
ERROR
);
}
}
...
...
src/share/classes/com/sun/tools/javac/main/Main.java
浏览文件 @
ecb72958
...
...
@@ -67,6 +67,10 @@ public class Main {
*/
PrintWriter
out
;
/** The log to use for diagnostic output.
*/
Log
log
;
/**
* If true, certain errors will cause an exception, such as command line
* arg errors, or exceptions in user provided code.
...
...
@@ -98,6 +102,7 @@ public class Main {
public
void
setOut
(
PrintWriter
out
)
{
Main
.
this
.
out
=
out
;
Main
.
this
.
log
.
setWriters
(
out
);
}
public
void
error
(
String
key
,
Object
...
args
)
{
...
...
@@ -307,6 +312,8 @@ public class Main {
showClass
(
showClass
);
}
options
.
notifyListeners
();
return
filenames
;
}
// where
...
...
@@ -352,6 +359,9 @@ public class Main {
List
<
JavaFileObject
>
fileObjects
,
Iterable
<?
extends
Processor
>
processors
)
{
context
.
put
(
Log
.
outKey
,
out
);
log
=
Log
.
instance
(
context
);
if
(
options
==
null
)
options
=
Options
.
instance
(
context
);
// creates a new one
...
...
@@ -398,12 +408,11 @@ public class Main {
boolean
forceStdOut
=
options
.
isSet
(
"stdout"
);
if
(
forceStdOut
)
{
out
.
flush
();
log
.
flush
();
out
=
new
PrintWriter
(
System
.
out
,
true
);
log
.
setWriters
(
out
);
}
context
.
put
(
Log
.
outKey
,
out
);
// allow System property in following line as a Mustang legacy
boolean
batchMode
=
(
options
.
isUnset
(
"nonBatchMode"
)
&&
System
.
getProperty
(
"nonBatchMode"
)
==
null
);
...
...
@@ -415,8 +424,6 @@ public class Main {
comp
=
JavaCompiler
.
instance
(
context
);
if
(
comp
==
null
)
return
Result
.
SYSERR
;
Log
log
=
Log
.
instance
(
context
);
if
(!
files
.
isEmpty
())
{
// add filenames to fileObjects
comp
=
JavaCompiler
.
instance
(
context
);
...
...
@@ -433,10 +440,10 @@ public class Main {
if
(
log
.
expectDiagKeys
!=
null
)
{
if
(
log
.
expectDiagKeys
.
isEmpty
())
{
Log
.
printLines
(
log
.
noticeWriter
,
"all expected diagnostics found"
);
log
.
printLines
(
Log
.
WriterKind
.
NOTICE
,
"all expected diagnostics found"
);
return
Result
.
OK
;
}
else
{
Log
.
printLines
(
log
.
noticeWriter
,
"expected diagnostic keys not found: "
+
log
.
expectDiagKeys
);
log
.
printLines
(
Log
.
WriterKind
.
NOTICE
,
"expected diagnostic keys not found: "
+
log
.
expectDiagKeys
);
return
Result
.
ERROR
;
}
}
...
...
src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java
浏览文件 @
ecb72958
/*
* Copyright (c) 2003, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
1
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -70,7 +70,16 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
this
(
JavacMessages
.
instance
(
context
),
"compiler"
);
context
.
put
(
diagnosticFactoryKey
,
this
);
Options
options
=
Options
.
instance
(
context
);
final
Options
options
=
Options
.
instance
(
context
);
initOptions
(
options
);
options
.
addListener
(
new
Runnable
()
{
public
void
run
()
{
initOptions
(
options
);
}
});
}
private
void
initOptions
(
Options
options
)
{
if
(
options
.
isSet
(
"onlySyntaxErrorsUnrecoverable"
))
defaultErrorFlags
.
add
(
DiagnosticFlag
.
RECOVERABLE
);
}
...
...
src/share/classes/com/sun/tools/javac/util/JavacMessages.java
浏览文件 @
ecb72958
...
...
@@ -82,14 +82,14 @@ public class JavacMessages implements Messages {
}
/** Creates a JavacMessages object.
* @param bundleName the name to identify the resource bu
u
ndle of localized messages.
* @param bundleName the name to identify the resource bundle of localized messages.
*/
public
JavacMessages
(
String
bundleName
)
throws
MissingResourceException
{
this
(
bundleName
,
null
);
}
/** Creates a JavacMessages object.
* @param bundleName the name to identify the resource bu
u
ndle of localized messages.
* @param bundleName the name to identify the resource bundle of localized messages.
*/
public
JavacMessages
(
String
bundleName
,
Locale
locale
)
throws
MissingResourceException
{
bundleNames
=
List
.
nil
();
...
...
src/share/classes/com/sun/tools/javac/util/Log.java
浏览文件 @
ecb72958
...
...
@@ -60,19 +60,18 @@ public class Log extends AbstractLog {
public
static
final
Context
.
Key
<
PrintWriter
>
outKey
=
new
Context
.
Key
<
PrintWriter
>();
//@Deprecated
public
final
PrintWriter
errWriter
;
public
enum
WriterKind
{
NOTICE
,
WARNING
,
ERROR
};
//@Deprecated
public
final
PrintWriter
warnWriter
;
protected
PrintWriter
errWriter
;
//@Deprecated
public
final
PrintWriter
noticeWriter
;
protected
PrintWriter
warnWriter
;
protected
PrintWriter
noticeWriter
;
/** The maximum number of errors/warnings that are reported.
*/
p
ublic
final
int
MaxErrors
;
p
ublic
final
int
MaxWarnings
;
p
rotected
int
MaxErrors
;
p
rotected
int
MaxWarnings
;
/** Switch: prompt user on each error.
*/
...
...
@@ -131,28 +130,39 @@ public class Log extends AbstractLog {
this
.
warnWriter
=
warnWriter
;
this
.
noticeWriter
=
noticeWriter
;
Options
options
=
Options
.
instance
(
context
);
this
.
dumpOnError
=
options
.
isSet
(
DOE
);
this
.
promptOnError
=
options
.
isSet
(
PROMPT
);
this
.
emitWarnings
=
options
.
isUnset
(
XLINT_CUSTOM
,
"none"
);
this
.
suppressNotes
=
options
.
isSet
(
"suppressNotes"
);
this
.
MaxErrors
=
getIntOption
(
options
,
XMAXERRS
,
getDefaultMaxErrors
());
this
.
MaxWarnings
=
getIntOption
(
options
,
XMAXWARNS
,
getDefaultMaxWarnings
());
boolean
rawDiagnostics
=
options
.
isSet
(
"rawDiagnostics"
);
messages
=
JavacMessages
.
instance
(
context
);
this
.
diagFormatter
=
rawDiagnostics
?
new
RawDiagnosticFormatter
(
options
)
:
new
BasicDiagnosticFormatter
(
options
,
messages
);
@SuppressWarnings
(
"unchecked"
)
// FIXME
DiagnosticListener
<?
super
JavaFileObject
>
dl
=
context
.
get
(
DiagnosticListener
.
class
);
this
.
diagListener
=
dl
;
String
ek
=
options
.
get
(
"expectKeys"
);
if
(
ek
!=
null
)
expectDiagKeys
=
new
HashSet
<
String
>(
Arrays
.
asList
(
ek
.
split
(
", *"
)));
messages
=
JavacMessages
.
instance
(
context
);
final
Options
options
=
Options
.
instance
(
context
);
initOptions
(
options
);
options
.
addListener
(
new
Runnable
()
{
public
void
run
()
{
initOptions
(
options
);
}
});
}
// where
private
void
initOptions
(
Options
options
)
{
this
.
dumpOnError
=
options
.
isSet
(
DOE
);
this
.
promptOnError
=
options
.
isSet
(
PROMPT
);
this
.
emitWarnings
=
options
.
isUnset
(
XLINT_CUSTOM
,
"none"
);
this
.
suppressNotes
=
options
.
isSet
(
"suppressNotes"
);
this
.
MaxErrors
=
getIntOption
(
options
,
XMAXERRS
,
getDefaultMaxErrors
());
this
.
MaxWarnings
=
getIntOption
(
options
,
XMAXWARNS
,
getDefaultMaxWarnings
());
boolean
rawDiagnostics
=
options
.
isSet
(
"rawDiagnostics"
);
this
.
diagFormatter
=
rawDiagnostics
?
new
RawDiagnosticFormatter
(
options
)
:
new
BasicDiagnosticFormatter
(
options
,
messages
);
String
ek
=
options
.
get
(
"expectKeys"
);
if
(
ek
!=
null
)
expectDiagKeys
=
new
HashSet
<
String
>(
Arrays
.
asList
(
ek
.
split
(
", *"
)));
}
private
int
getIntOption
(
Options
options
,
OptionName
optionName
,
int
defaultValue
)
{
String
s
=
options
.
get
(
optionName
);
try
{
...
...
@@ -180,7 +190,7 @@ public class Log extends AbstractLog {
/** The default writer for diagnostics
*/
static
final
PrintWriter
defaultWriter
(
Context
context
)
{
static
PrintWriter
defaultWriter
(
Context
context
)
{
PrintWriter
result
=
context
.
get
(
outKey
);
if
(
result
==
null
)
context
.
put
(
outKey
,
result
=
new
PrintWriter
(
System
.
err
));
...
...
@@ -248,6 +258,30 @@ public class Log extends AbstractLog {
this
.
diagFormatter
=
diagFormatter
;
}
public
PrintWriter
getWriter
(
WriterKind
kind
)
{
switch
(
kind
)
{
case
NOTICE:
return
noticeWriter
;
case
WARNING:
return
warnWriter
;
case
ERROR:
return
errWriter
;
default
:
throw
new
IllegalArgumentException
();
}
}
public
void
setWriter
(
WriterKind
kind
,
PrintWriter
pw
)
{
pw
.
getClass
();
switch
(
kind
)
{
case
NOTICE:
noticeWriter
=
pw
;
break
;
case
WARNING:
warnWriter
=
pw
;
break
;
case
ERROR:
errWriter
=
pw
;
break
;
default
:
throw
new
IllegalArgumentException
();
}
}
public
void
setWriters
(
PrintWriter
pw
)
{
pw
.
getClass
();
noticeWriter
=
warnWriter
=
errWriter
=
pw
;
}
/** Flush the logs
*/
public
void
flush
()
{
...
...
@@ -256,6 +290,10 @@ public class Log extends AbstractLog {
noticeWriter
.
flush
();
}
public
void
flush
(
WriterKind
kind
)
{
getWriter
(
kind
).
flush
();
}
/** Returns true if an error needs to be reported for a given
* source name and pos.
*/
...
...
@@ -310,6 +348,13 @@ public class Log extends AbstractLog {
writer
.
flush
();
}
/** Print the text of a message, translating newlines appropriately
* for the platform.
*/
public
void
printLines
(
WriterKind
kind
,
String
msg
)
{
printLines
(
getWriter
(
kind
),
msg
);
}
/** Print the text of a message, translating newlines appropriately
* for the platform.
*/
...
...
src/share/classes/com/sun/tools/javac/util/Options.java
浏览文件 @
ecb72958
...
...
@@ -157,6 +157,19 @@ public class Options {
return
values
.
size
();
}
// light-weight notification mechanism
private
List
<
Runnable
>
listeners
=
List
.
nil
();
public
void
addListener
(
Runnable
listener
)
{
listeners
=
listeners
.
prepend
(
listener
);
}
public
void
notifyListeners
()
{
for
(
Runnable
r:
listeners
)
r
.
run
();
}
/** Check for a lint suboption. */
public
boolean
lint
(
String
s
)
{
// return true if either the specific option is enabled, or
...
...
src/share/classes/com/sun/tools/javadoc/Start.java
浏览文件 @
ecb72958
...
...
@@ -31,6 +31,7 @@ import com.sun.tools.javac.main.CommandLine;
import
com.sun.tools.javac.util.Context
;
import
com.sun.tools.javac.util.List
;
import
com.sun.tools.javac.util.ListBuffer
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Options
;
import
java.io.IOException
;
...
...
@@ -76,9 +77,6 @@ class Start {
private
DocletInvoker
docletInvoker
;
private
static
final
int
F_VERBOSE
=
1
<<
0
;
private
static
final
int
F_WARNINGS
=
1
<<
2
;
/* Treat warnings as errors. */
private
boolean
rejectWarnings
=
false
;
...
...
@@ -171,11 +169,11 @@ class Start {
messager
.
error
(
null
,
"main.out.of.memory"
);
failed
=
true
;
}
catch
(
Error
ee
)
{
ee
.
printStackTrace
();
ee
.
printStackTrace
(
System
.
err
);
messager
.
error
(
null
,
"main.fatal.error"
);
failed
=
true
;
}
catch
(
Exception
ee
)
{
ee
.
printStackTrace
();
ee
.
printStackTrace
(
System
.
err
);
messager
.
error
(
null
,
"main.fatal.exception"
);
failed
=
true
;
}
finally
{
...
...
@@ -211,7 +209,7 @@ class Start {
messager
.
error
(
null
,
"main.cant.read"
,
e
.
getMessage
());
exit
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
(
System
.
err
);
exit
();
}
...
...
@@ -225,7 +223,9 @@ class Start {
// options that may be set up below.
Messager
.
preRegister
(
context
,
messager
.
programName
,
messager
.
errWriter
,
messager
.
warnWriter
,
messager
.
noticeWriter
);
messager
.
getWriter
(
Log
.
WriterKind
.
ERROR
),
messager
.
getWriter
(
Log
.
WriterKind
.
WARNING
),
messager
.
getWriter
(
Log
.
WriterKind
.
NOTICE
));
Options
compOpts
=
Options
.
instance
(
context
);
boolean
docClasses
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录