Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
24549cd5
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看板
提交
24549cd5
编写于
12月 23, 2011
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
9ec97edd
e00f8408
变更
30
展开全部
隐藏空白更改
内联
并排
Showing
30 changed file
with
1232 addition
and
1245 deletion
+1232
-1245
make/jprt.properties
make/jprt.properties
+24
-9
src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
.../tools/doclets/formats/html/resources/standard.properties
+1
-0
src/share/classes/com/sun/tools/javac/api/JavacTool.java
src/share/classes/com/sun/tools/javac/api/JavacTool.java
+33
-76
src/share/classes/com/sun/tools/javac/code/Source.java
src/share/classes/com/sun/tools/javac/code/Source.java
+1
-1
src/share/classes/com/sun/tools/javac/comp/Check.java
src/share/classes/com/sun/tools/javac/comp/Check.java
+2
-3
src/share/classes/com/sun/tools/javac/comp/Enter.java
src/share/classes/com/sun/tools/javac/comp/Enter.java
+1
-1
src/share/classes/com/sun/tools/javac/comp/Lower.java
src/share/classes/com/sun/tools/javac/comp/Lower.java
+1
-1
src/share/classes/com/sun/tools/javac/file/Locations.java
src/share/classes/com/sun/tools/javac/file/Locations.java
+31
-31
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/jvm/ClassWriter.java
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
+1
-1
src/share/classes/com/sun/tools/javac/jvm/Gen.java
src/share/classes/com/sun/tools/javac/jvm/Gen.java
+1
-1
src/share/classes/com/sun/tools/javac/jvm/Target.java
src/share/classes/com/sun/tools/javac/jvm/Target.java
+1
-1
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+3
-3
src/share/classes/com/sun/tools/javac/main/JavacOption.java
src/share/classes/com/sun/tools/javac/main/JavacOption.java
+0
-299
src/share/classes/com/sun/tools/javac/main/Main.java
src/share/classes/com/sun/tools/javac/main/Main.java
+31
-45
src/share/classes/com/sun/tools/javac/main/Option.java
src/share/classes/com/sun/tools/javac/main/Option.java
+710
-0
src/share/classes/com/sun/tools/javac/main/OptionHelper.java
src/share/classes/com/sun/tools/javac/main/OptionHelper.java
+117
-0
src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
...e/classes/com/sun/tools/javac/main/RecognizedOptions.java
+0
-651
src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java
...classes/com/sun/tools/javac/nio/JavacPathFileManager.java
+1
-1
src/share/classes/com/sun/tools/javac/parser/JavacParser.java
...share/classes/com/sun/tools/javac/parser/JavacParser.java
+70
-58
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
...un/tools/javac/processing/JavacProcessingEnvironment.java
+5
-12
src/share/classes/com/sun/tools/javac/util/BaseFileManager.java
...are/classes/com/sun/tools/javac/util/BaseFileManager.java
+28
-12
src/share/classes/com/sun/tools/javac/util/Log.java
src/share/classes/com/sun/tools/javac/util/Log.java
+11
-8
src/share/classes/com/sun/tools/javac/util/Options.java
src/share/classes/com/sun/tools/javac/util/Options.java
+14
-14
test/tools/javac/4846262/Test.sh
test/tools/javac/4846262/Test.sh
+2
-2
test/tools/javac/api/T6838467.java
test/tools/javac/api/T6838467.java
+0
-1
test/tools/javac/diags/examples/UnsupportedEncoding.java
test/tools/javac/diags/examples/UnsupportedEncoding.java
+2
-1
test/tools/javac/lambda/MethodReferenceParserTest.java
test/tools/javac/lambda/MethodReferenceParserTest.java
+30
-6
test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java
...ssing/options/testPrintProcessorInfo/TestWithXstdout.java
+91
-0
test/tools/javac/util/T6597678.java
test/tools/javac/util/T6597678.java
+19
-6
未找到文件。
make/jprt.properties
浏览文件 @
24549cd5
...
...
@@ -25,23 +25,38 @@
# Properties for jprt
#
The release to build
#
Locked down to jdk8
jprt.tools.default.release
=
jdk8
# The different build flavors we want, we override here so we just get these 2
jprt.build.flavors
=
product,fastdebug
# Standard list of jprt build targets for this source tree
jprt.build.targets
=
\
solaris_sparc_5.10-{product|fastdebug},
\
solaris_sparcv9_5.10-{product|fastdebug},
\
solaris_i586_5.10-{product|fastdebug},
\
solaris_x64_5.10-{product|fastdebug},
\
linux_i586_2.6-{product|fastdebug},
\
linux_x64_2.6-{product|fastdebug},
\
windows_i586_5.1-{product|fastdebug},
\
jprt.build.targets
=
\
solaris_sparc_5.10-{product|fastdebug},
\
solaris_sparcv9_5.10-{product|fastdebug},
\
solaris_i586_5.10-{product|fastdebug},
\
solaris_x64_5.10-{product|fastdebug},
\
linux_i586_2.6-{product|fastdebug},
\
linux_x64_2.6-{product|fastdebug},
\
windows_i586_5.1-{product|fastdebug},
\
windows_x64_5.2-{product|fastdebug}
# Test target list (no fastdebug & limited c2 testing)
jprt.my.test.target.set
=
\
solaris_sparc_5.10-product-c1-TESTNAME,
\
solaris_sparcv9_5.10-product-c2-TESTNAME,
\
solaris_i586_5.10-product-c1-TESTNAME,
\
solaris_x64_5.10-product-c2-TESTNAME,
\
linux_i586_2.6-product-{c1|c2}-TESTNAME,
\
linux_x64_2.6-product-c2-TESTNAME,
\
windows_i586_5.1-product-c1-TESTNAME,
\
windows_x64_5.2-product-c2-TESTNAME
# Default test targets
jprt.make.rule.test.targets
=
\
${jprt.my.test.target.set:TESTNAME=jtreg}
# Directories to be excluded from the source bundles
jprt.bundle.exclude.src.dirs
=
build dist webrev
src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
浏览文件 @
24549cd5
...
...
@@ -216,6 +216,7 @@ doclet.Groupname_already_used=In -group option, groupname already used: {0}
doclet.Same_package_name_used
=
Package name format used twice: {0}
doclet.Serialization.Excluded_Class
=
Non-transient field {1} uses excluded class {0}.
doclet.Serialization.Nonexcluded_Class
=
Non-transient field {1} uses hidden, non-included class {0}.
doclet.exception_encountered
=
Exception encountered while processing {1}
\n
{0}
doclet.usage
=
Provided by Standard doclet:
\n\
-d <directory> Destination directory for output files
\n\
-use Create class and package usage pages
\n\
...
...
src/share/classes/com/sun/tools/javac/api/JavacTool.java
浏览文件 @
24549cd5
...
...
@@ -25,18 +25,15 @@
package
com.sun.tools.javac.api
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.io.Writer
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.EnumSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Set
;
import
javax.lang.model.SourceVersion
;
...
...
@@ -44,17 +41,15 @@ import javax.tools.*;
import
com.sun.source.util.JavacTask
;
import
com.sun.tools.javac.file.JavacFileManager
;
import
com.sun.tools.javac.main.JavacOption.OptionKind
;
import
com.sun.tools.javac.main.JavacOption
;
import
com.sun.tools.javac.main.Main
;
import
com.sun.tools.javac.main.RecognizedOptions.GrumpyHelper
;
import
com.sun.tools.javac.main.RecognizedOptions
;
import
com.sun.tools.javac.main.Option
;
import
com.sun.tools.javac.main.OptionHelper
;
import
com.sun.tools.javac.main.OptionHelper.GrumpyHelper
;
import
com.sun.tools.javac.util.ClientCodeException
;
import
com.sun.tools.javac.util.Context
;
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.Pair
;
/**
* TODO: describe com.sun.tools.javac.api.Tool
...
...
@@ -67,23 +62,10 @@ import com.sun.tools.javac.util.Pair;
* @author Peter von der Ah\u00e9
*/
public
final
class
JavacTool
implements
JavaCompiler
{
private
final
List
<
Pair
<
String
,
String
>>
options
=
new
ArrayList
<
Pair
<
String
,
String
>>();
private
final
Context
dummyContext
=
new
Context
();
private
final
PrintWriter
silent
=
new
PrintWriter
(
new
OutputStream
(){
public
void
write
(
int
b
)
{}
});
private
final
Main
sharedCompiler
=
new
Main
(
"javac"
,
silent
);
{
sharedCompiler
.
setOptions
(
Options
.
instance
(
dummyContext
));
}
/**
* Constructor used by service provider mechanism. The
correct
way to
* obtain an instance of this class is
using create or the service provider
* mechanism.
* Constructor used by service provider mechanism. The
recommended
way to
* obtain an instance of this class is
by using {@link #create} or the
*
service provider
mechanism.
* @see javax.tools.JavaCompilerTool
* @see javax.tools.ToolProvider
* @see #create
...
...
@@ -99,49 +81,6 @@ public final class JavacTool implements JavaCompiler {
return
new
JavacTool
();
}
private
String
argsToString
(
Object
...
args
)
{
String
newArgs
=
null
;
if
(
args
.
length
>
0
)
{
StringBuilder
sb
=
new
StringBuilder
();
String
separator
=
""
;
for
(
Object
arg
:
args
)
{
sb
.
append
(
separator
).
append
(
arg
.
toString
());
separator
=
File
.
pathSeparator
;
}
newArgs
=
sb
.
toString
();
}
return
newArgs
;
}
private
void
setOption1
(
String
name
,
OptionKind
kind
,
Object
...
args
)
{
String
arg
=
argsToString
(
args
);
JavacOption
option
=
sharedCompiler
.
getOption
(
name
);
if
(
option
==
null
||
!
match
(
kind
,
option
.
getKind
()))
throw
new
IllegalArgumentException
(
name
);
if
((
args
.
length
!=
0
)
!=
option
.
hasArg
())
throw
new
IllegalArgumentException
(
name
);
if
(
option
.
hasArg
())
{
if
(
option
.
process
(
null
,
name
,
arg
))
// FIXME
throw
new
IllegalArgumentException
(
name
);
}
else
{
if
(
option
.
process
(
null
,
name
))
// FIXME
throw
new
IllegalArgumentException
(
name
);
}
options
.
add
(
new
Pair
<
String
,
String
>(
name
,
arg
));
}
public
void
setOption
(
String
name
,
Object
...
args
)
{
setOption1
(
name
,
OptionKind
.
NORMAL
,
args
);
}
public
void
setExtendedOption
(
String
name
,
Object
...
args
)
{
setOption1
(
name
,
OptionKind
.
EXTENDED
,
args
);
}
private
static
boolean
match
(
OptionKind
clientKind
,
OptionKind
optionKind
)
{
return
(
clientKind
==
(
optionKind
==
OptionKind
.
HIDDEN
?
OptionKind
.
EXTENDED
:
optionKind
));
}
public
JavacFileManager
getStandardFileManager
(
DiagnosticListener
<?
super
JavaFileObject
>
diagnosticListener
,
Locale
locale
,
...
...
@@ -209,7 +148,9 @@ public final class JavacTool implements JavaCompiler {
if
(
fileManager
==
null
)
fileManager
=
getStandardFileManager
(
diagnosticListener
,
null
,
null
);
fileManager
=
ccw
.
wrap
(
fileManager
);
context
.
put
(
JavaFileManager
.
class
,
fileManager
);
processOptions
(
context
,
fileManager
,
options
);
Main
compiler
=
new
Main
(
"javacTask"
,
context
.
get
(
Log
.
outKey
));
return
new
JavacTaskImpl
(
compiler
,
options
,
context
,
classes
,
compilationUnits
);
...
...
@@ -225,11 +166,28 @@ public final class JavacTool implements JavaCompiler {
if
(
options
==
null
)
return
;
Options
optionTable
=
Options
.
instance
(
context
);
final
Options
optionTable
=
Options
.
instance
(
context
);
Log
log
=
Log
.
instance
(
context
);
JavacOption
[]
recognizedOptions
=
RecognizedOptions
.
getJavacToolOptions
(
new
GrumpyHelper
(
log
));
Option
[]
recognizedOptions
=
Option
.
getJavacToolOptions
().
toArray
(
new
Option
[
0
]);
OptionHelper
optionHelper
=
new
GrumpyHelper
(
log
)
{
@Override
public
String
get
(
Option
option
)
{
return
optionTable
.
get
(
option
.
getText
());
}
@Override
public
void
put
(
String
name
,
String
value
)
{
optionTable
.
put
(
name
,
value
);
}
@Override
public
void
remove
(
String
name
)
{
optionTable
.
remove
(
name
);
}
};
Iterator
<
String
>
flags
=
options
.
iterator
();
while
(
flags
.
hasNext
())
{
String
flag
=
flags
.
next
();
...
...
@@ -247,19 +205,19 @@ public final class JavacTool implements JavaCompiler {
}
}
Javac
Option
option
=
recognizedOptions
[
j
];
Option
option
=
recognizedOptions
[
j
];
if
(
option
.
hasArg
())
{
if
(!
flags
.
hasNext
())
{
String
msg
=
log
.
localize
(
PrefixKind
.
JAVAC
,
"err.req.arg"
,
flag
);
throw
new
IllegalArgumentException
(
msg
);
}
String
operand
=
flags
.
next
();
if
(
option
.
process
(
option
Table
,
flag
,
operand
))
if
(
option
.
process
(
option
Helper
,
flag
,
operand
))
// should not happen as the GrumpyHelper will throw exceptions
// in case of errors
throw
new
IllegalArgumentException
(
flag
+
" "
+
operand
);
}
else
{
if
(
option
.
process
(
option
Table
,
flag
))
if
(
option
.
process
(
option
Helper
,
flag
))
// should not happen as the GrumpyHelper will throw exceptions
// in case of errors
throw
new
IllegalArgumentException
(
flag
);
...
...
@@ -283,9 +241,8 @@ public final class JavacTool implements JavaCompiler {
}
public
int
isSupportedOption
(
String
option
)
{
JavacOption
[]
recognizedOptions
=
RecognizedOptions
.
getJavacToolOptions
(
new
GrumpyHelper
(
null
));
for
(
JavacOption
o
:
recognizedOptions
)
{
Set
<
Option
>
recognizedOptions
=
Option
.
getJavacToolOptions
();
for
(
Option
o
:
recognizedOptions
)
{
if
(
o
.
matches
(
option
))
return
o
.
hasArg
()
?
1
:
0
;
}
...
...
src/share/classes/com/sun/tools/javac/code/Source.java
浏览文件 @
24549cd5
...
...
@@ -32,7 +32,7 @@ import static javax.lang.model.SourceVersion.*;
import
com.sun.tools.javac.util.*
;
import
com.sun.tools.javac.jvm.Target
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
/** The source language version accepted.
*
...
...
src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
24549cd5
...
...
@@ -48,7 +48,6 @@ import static com.sun.tools.javac.code.Kinds.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.
WILDCARD
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
OptionName
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/** Type checking helper class for the attribution phase.
...
...
@@ -110,7 +109,7 @@ public class Check {
allowAnnotations
=
source
.
allowAnnotations
();
allowCovariantReturns
=
source
.
allowCovariantReturns
();
allowSimplifiedVarargs
=
source
.
allowSimplifiedVarargs
();
complexInference
=
options
.
isSet
(
COMPLEXINFERENCE
);
complexInference
=
options
.
isSet
(
"complexinference"
);
skipAnnotations
=
options
.
isSet
(
"skipAnnotations"
);
warnOnSyntheticConflicts
=
options
.
isSet
(
"warnOnSyntheticConflicts"
);
suppressAbortOnBadClassFile
=
options
.
isSet
(
"suppressAbortOnBadClassFile"
);
...
...
@@ -2482,7 +2481,7 @@ public class Check {
warnDeprecated
(
pos
,
s
);
}
});
}
;
}
}
void
checkSunAPI
(
final
DiagnosticPosition
pos
,
final
Symbol
s
)
{
...
...
src/share/classes/com/sun/tools/javac/comp/Enter.java
浏览文件 @
24549cd5
...
...
@@ -34,7 +34,7 @@ import com.sun.tools.javac.code.Scope.*;
import
com.sun.tools.javac.code.Symbol.*
;
import
com.sun.tools.javac.code.Type.*
;
import
com.sun.tools.javac.jvm.*
;
import
com.sun.tools.javac.main.
RecognizedOptions
.PkgInfo
;
import
com.sun.tools.javac.main.
Option
.PkgInfo
;
import
com.sun.tools.javac.tree.*
;
import
com.sun.tools.javac.tree.JCTree.*
;
import
com.sun.tools.javac.util.*
;
...
...
src/share/classes/com/sun/tools/javac/comp/Lower.java
浏览文件 @
24549cd5
...
...
@@ -29,7 +29,7 @@ import java.util.*;
import
com.sun.tools.javac.code.*
;
import
com.sun.tools.javac.jvm.*
;
import
com.sun.tools.javac.main.
RecognizedOptions
.PkgInfo
;
import
com.sun.tools.javac.main.
Option
.PkgInfo
;
import
com.sun.tools.javac.tree.*
;
import
com.sun.tools.javac.util.*
;
import
com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition
;
...
...
src/share/classes/com/sun/tools/javac/file/Locations.java
浏览文件 @
24549cd5
...
...
@@ -47,14 +47,14 @@ import javax.tools.JavaFileManager.Location;
import
javax.tools.StandardLocation
;
import
com.sun.tools.javac.code.Lint
;
import
com.sun.tools.javac.main.Option
Name
;
import
com.sun.tools.javac.main.Option
;
import
com.sun.tools.javac.util.ListBuffer
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Options
;
import
javax.tools.JavaFileManager
;
import
static
javax
.
tools
.
StandardLocation
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
/** This class converts command line arguments, environment variables
* and system properties (in File.pathSeparator-separated String form)
...
...
@@ -318,23 +318,23 @@ public class Locations {
*/
protected
abstract
class
LocationHandler
{
final
Location
location
;
final
Set
<
Option
Name
>
options
;
final
Set
<
Option
>
options
;
/**
* Create a handler. The location and options provide a way to map
* from a location or an option to the corresponding handler.
* @see #initHandlers
*/
protected
LocationHandler
(
Location
location
,
Option
Name
...
options
)
{
protected
LocationHandler
(
Location
location
,
Option
...
options
)
{
this
.
location
=
location
;
this
.
options
=
options
.
length
==
0
?
EnumSet
.
noneOf
(
Option
Name
.
class
):
EnumSet
.
noneOf
(
Option
.
class
):
EnumSet
.
copyOf
(
Arrays
.
asList
(
options
));
}
// TODO: TEMPORARY, while Options still used for command line options
void
update
(
Options
optionTable
)
{
for
(
Option
Name
o:
options
)
{
for
(
Option
o:
options
)
{
String
v
=
optionTable
.
get
(
o
);
if
(
v
!=
null
)
{
handleOption
(
o
,
v
);
...
...
@@ -343,7 +343,7 @@ public class Locations {
}
/** @see JavaFileManager#handleOption. */
abstract
boolean
handleOption
(
Option
Name
option
,
String
value
);
abstract
boolean
handleOption
(
Option
option
,
String
value
);
/** @see JavaFileManager#getLocation. */
abstract
Collection
<
File
>
getLocation
();
/** @see JavaFileManager#setLocation. */
...
...
@@ -359,12 +359,12 @@ public class Locations {
private
class
OutputLocationHandler
extends
LocationHandler
{
private
File
outputDir
;
OutputLocationHandler
(
Location
location
,
Option
Name
...
options
)
{
OutputLocationHandler
(
Location
location
,
Option
...
options
)
{
super
(
location
,
options
);
}
@Override
boolean
handleOption
(
Option
Name
option
,
String
value
)
{
boolean
handleOption
(
Option
option
,
String
value
)
{
if
(!
options
.
contains
(
option
))
return
false
;
...
...
@@ -410,12 +410,12 @@ public class Locations {
private
class
SimpleLocationHandler
extends
LocationHandler
{
protected
Collection
<
File
>
searchPath
;
SimpleLocationHandler
(
Location
location
,
Option
Name
...
options
)
{
SimpleLocationHandler
(
Location
location
,
Option
...
options
)
{
super
(
location
,
options
);
}
@Override
boolean
handleOption
(
Option
Name
option
,
String
value
)
{
boolean
handleOption
(
Option
option
,
String
value
)
{
if
(!
options
.
contains
(
option
))
return
false
;
searchPath
=
value
==
null
?
null
:
...
...
@@ -452,7 +452,7 @@ public class Locations {
private
class
ClassPathLocationHandler
extends
SimpleLocationHandler
{
ClassPathLocationHandler
()
{
super
(
StandardLocation
.
CLASS_PATH
,
Option
Name
.
CLASSPATH
,
OptionName
.
CP
);
Option
.
CLASSPATH
,
Option
.
CP
);
}
@Override
...
...
@@ -500,7 +500,7 @@ public class Locations {
*/
private
class
BootClassPathLocationHandler
extends
LocationHandler
{
private
Collection
<
File
>
searchPath
;
final
Map
<
Option
Name
,
String
>
optionValues
=
new
EnumMap
<
OptionName
,
String
>(
OptionName
.
class
);
final
Map
<
Option
,
String
>
optionValues
=
new
EnumMap
<
Option
,
String
>(
Option
.
class
);
/**
* rt.jar as found on the default bootclasspath.
...
...
@@ -515,11 +515,11 @@ public class Locations {
BootClassPathLocationHandler
()
{
super
(
StandardLocation
.
PLATFORM_CLASS_PATH
,
Option
Name
.
BOOTCLASSPATH
,
OptionName
.
XBOOTCLASSPATH
,
Option
Name
.
XBOOTCLASSPATH_PREPEND
,
Option
Name
.
XBOOTCLASSPATH_APPEND
,
Option
Name
.
ENDORSEDDIRS
,
OptionName
.
DJAVA_ENDORSED_DIRS
,
Option
Name
.
EXTDIRS
,
OptionName
.
DJAVA_EXT_DIRS
);
Option
.
BOOTCLASSPATH
,
Option
.
XBOOTCLASSPATH
,
Option
.
XBOOTCLASSPATH_PREPEND
,
Option
.
XBOOTCLASSPATH_APPEND
,
Option
.
ENDORSEDDIRS
,
Option
.
DJAVA_ENDORSED_DIRS
,
Option
.
EXTDIRS
,
Option
.
DJAVA_EXT_DIRS
);
}
boolean
isDefault
()
{
...
...
@@ -533,7 +533,7 @@ public class Locations {
}
@Override
boolean
handleOption
(
Option
Name
option
,
String
value
)
{
boolean
handleOption
(
Option
option
,
String
value
)
{
if
(!
options
.
contains
(
option
))
return
false
;
...
...
@@ -549,14 +549,14 @@ public class Locations {
// where
// TODO: would be better if option aliasing was handled at a higher
// level
private
Option
Name
canonicalize
(
OptionName
option
)
{
private
Option
canonicalize
(
Option
option
)
{
switch
(
option
)
{
case
XBOOTCLASSPATH:
return
Option
Name
.
BOOTCLASSPATH
;
return
Option
.
BOOTCLASSPATH
;
case
DJAVA_ENDORSED_DIRS:
return
Option
Name
.
ENDORSEDDIRS
;
return
Option
.
ENDORSEDDIRS
;
case
DJAVA_EXT_DIRS:
return
Option
Name
.
EXTDIRS
;
return
Option
.
EXTDIRS
;
default
:
return
option
;
}
...
...
@@ -636,29 +636,29 @@ public class Locations {
}
Map
<
Location
,
LocationHandler
>
handlersForLocation
;
Map
<
Option
Name
,
LocationHandler
>
handlersForOption
;
Map
<
Option
,
LocationHandler
>
handlersForOption
;
void
initHandlers
()
{
handlersForLocation
=
new
HashMap
<
Location
,
LocationHandler
>();
handlersForOption
=
new
EnumMap
<
Option
Name
,
LocationHandler
>(
OptionName
.
class
);
handlersForOption
=
new
EnumMap
<
Option
,
LocationHandler
>(
Option
.
class
);
LocationHandler
[]
handlers
=
{
new
BootClassPathLocationHandler
(),
new
ClassPathLocationHandler
(),
new
SimpleLocationHandler
(
StandardLocation
.
SOURCE_PATH
,
Option
Name
.
SOURCEPATH
),
new
SimpleLocationHandler
(
StandardLocation
.
ANNOTATION_PROCESSOR_PATH
,
Option
Name
.
PROCESSORPATH
),
new
OutputLocationHandler
((
StandardLocation
.
CLASS_OUTPUT
),
Option
Name
.
D
),
new
OutputLocationHandler
((
StandardLocation
.
SOURCE_OUTPUT
),
Option
Name
.
S
)
new
SimpleLocationHandler
(
StandardLocation
.
SOURCE_PATH
,
Option
.
SOURCEPATH
),
new
SimpleLocationHandler
(
StandardLocation
.
ANNOTATION_PROCESSOR_PATH
,
Option
.
PROCESSORPATH
),
new
OutputLocationHandler
((
StandardLocation
.
CLASS_OUTPUT
),
Option
.
D
),
new
OutputLocationHandler
((
StandardLocation
.
SOURCE_OUTPUT
),
Option
.
S
)
};
for
(
LocationHandler
h:
handlers
)
{
handlersForLocation
.
put
(
h
.
location
,
h
);
for
(
Option
Name
o:
h
.
options
)
for
(
Option
o:
h
.
options
)
handlersForOption
.
put
(
o
,
h
);
}
}
boolean
handleOption
(
Option
Name
option
,
String
value
)
{
boolean
handleOption
(
Option
option
,
String
value
)
{
LocationHandler
h
=
handlersForOption
.
get
(
option
);
return
(
h
==
null
?
false
:
h
.
handleOption
(
option
,
value
));
}
...
...
src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
浏览文件 @
24549cd5
...
...
@@ -59,7 +59,7 @@ import static com.sun.tools.javac.code.TypeTags.*;
import
static
com
.
sun
.
tools
.
javac
.
jvm
.
ClassFile
.*;
import
static
com
.
sun
.
tools
.
javac
.
jvm
.
ClassFile
.
Version
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
/** This class provides operations to read a classfile into an internal
* representation. The internal representation is anchored in a
...
...
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
浏览文件 @
24549cd5
...
...
@@ -45,7 +45,7 @@ import static com.sun.tools.javac.code.Flags.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Kinds
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.*;
import
static
com
.
sun
.
tools
.
javac
.
jvm
.
UninitializedType
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
import
static
javax
.
tools
.
StandardLocation
.
CLASS_OUTPUT
;
...
...
src/share/classes/com/sun/tools/javac/jvm/Gen.java
浏览文件 @
24549cd5
...
...
@@ -45,7 +45,7 @@ import static com.sun.tools.javac.code.Kinds.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.*;
import
static
com
.
sun
.
tools
.
javac
.
jvm
.
ByteCodes
.*;
import
static
com
.
sun
.
tools
.
javac
.
jvm
.
CRTFlags
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.
BLOCK
;
...
...
src/share/classes/com/sun/tools/javac/jvm/Target.java
浏览文件 @
24549cd5
...
...
@@ -31,7 +31,7 @@ import com.sun.tools.javac.code.Flags;
import
com.sun.tools.javac.code.Symbol
;
import
com.sun.tools.javac.util.*
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
/** The classfile version target.
*
...
...
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
浏览文件 @
24549cd5
...
...
@@ -62,7 +62,7 @@ import com.sun.tools.javac.util.*;
import
com.sun.tools.javac.util.Log.WriterKind
;
import
static
javax
.
tools
.
StandardLocation
.
CLASS_OUTPUT
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
import
static
com
.
sun
.
tools
.
javac
.
util
.
JCDiagnostic
.
DiagnosticFlag
.*;
import
static
com
.
sun
.
tools
.
javac
.
util
.
ListBuffer
.
lb
;
...
...
@@ -817,8 +817,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
// forcibly set the equivalent of -Xlint:-options, so that no further
// warnings about command line options are generated from this point on
options
.
put
(
XLINT_CUSTOM
+
"-"
+
LintCategory
.
OPTIONS
.
option
,
"true"
);
options
.
remove
(
XLINT_CUSTOM
+
LintCategory
.
OPTIONS
.
option
);
options
.
put
(
XLINT_CUSTOM
.
text
+
"-"
+
LintCategory
.
OPTIONS
.
option
,
"true"
);
options
.
remove
(
XLINT_CUSTOM
.
text
+
LintCategory
.
OPTIONS
.
option
);
start_msec
=
now
();
...
...
src/share/classes/com/sun/tools/javac/main/JavacOption.java
已删除
100644 → 0
浏览文件 @
9ec97edd
/*
* Copyright (c) 2006, 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
com.sun.tools.javac.main
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
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
;
/**
* TODO: describe com.sun.tools.javac.main.JavacOption
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
public
interface
JavacOption
{
OptionKind
getKind
();
/** Does this option take a (separate) operand?
* @return true if this option takes a separate operand
*/
boolean
hasArg
();
/** Does argument string match option pattern?
* @param arg the command line argument string
* @return true if {@code arg} matches this option
*/
boolean
matches
(
String
arg
);
/** Process an option with an argument.
* @param options the accumulated set of analyzed options
* @param option the option to be processed
* @param arg the arg for the option to be processed
* @return true if an error was detected
*/
boolean
process
(
Options
options
,
String
option
,
String
arg
);
/** Process the option with no argument.
* @param options the accumulated set of analyzed options
* @param option the option to be processed
* @return true if an error was detected
*/
boolean
process
(
Options
options
,
String
option
);
OptionName
getName
();
enum
OptionKind
{
NORMAL
,
EXTENDED
,
HIDDEN
,
}
enum
ChoiceKind
{
ONEOF
,
ANYOF
}
/** This class represents an option recognized by the main program
*/
static
class
Option
implements
JavacOption
{
/** Option string.
*/
OptionName
name
;
/** Documentation key for arguments.
*/
String
argsNameKey
;
/** Documentation key for description.
*/
String
descrKey
;
/** Suffix option (-foo=bar or -foo:bar)
*/
boolean
hasSuffix
;
/** The kind of choices for this option, if any.
*/
ChoiceKind
choiceKind
;
/** The choices for this option, if any, and whether or not the choices
* are hidden
*/
Map
<
String
,
Boolean
>
choices
;
Option
(
OptionName
name
,
String
argsNameKey
,
String
descrKey
)
{
this
.
name
=
name
;
this
.
argsNameKey
=
argsNameKey
;
this
.
descrKey
=
descrKey
;
char
lastChar
=
name
.
optionName
.
charAt
(
name
.
optionName
.
length
()-
1
);
hasSuffix
=
lastChar
==
':'
||
lastChar
==
'='
;
}
Option
(
OptionName
name
,
String
descrKey
)
{
this
(
name
,
null
,
descrKey
);
}
Option
(
OptionName
name
,
String
descrKey
,
ChoiceKind
choiceKind
,
String
...
choices
)
{
this
(
name
,
descrKey
,
choiceKind
,
createChoices
(
choices
));
}
private
static
Map
<
String
,
Boolean
>
createChoices
(
String
...
choices
)
{
Map
<
String
,
Boolean
>
map
=
new
LinkedHashMap
<
String
,
Boolean
>();
for
(
String
c:
choices
)
map
.
put
(
c
,
false
);
return
map
;
}
Option
(
OptionName
name
,
String
descrKey
,
ChoiceKind
choiceKind
,
Map
<
String
,
Boolean
>
choices
)
{
this
(
name
,
null
,
descrKey
);
if
(
choiceKind
==
null
||
choices
==
null
)
throw
new
NullPointerException
();
this
.
choiceKind
=
choiceKind
;
this
.
choices
=
choices
;
}
@Override
public
String
toString
()
{
return
name
.
optionName
;
}
public
boolean
hasArg
()
{
return
argsNameKey
!=
null
&&
!
hasSuffix
;
}
public
boolean
matches
(
String
option
)
{
if
(!
hasSuffix
)
return
option
.
equals
(
name
.
optionName
);
if
(!
option
.
startsWith
(
name
.
optionName
))
return
false
;
if
(
choices
!=
null
)
{
String
arg
=
option
.
substring
(
name
.
optionName
.
length
());
if
(
choiceKind
==
ChoiceKind
.
ONEOF
)
return
choices
.
keySet
().
contains
(
arg
);
else
{
for
(
String
a:
arg
.
split
(
",+"
))
{
if
(!
choices
.
keySet
().
contains
(
a
))
return
false
;
}
}
}
return
true
;
}
/** Print a line of documentation describing this option, if standard.
* @param out the stream to which to write the documentation
*/
void
help
(
Log
log
)
{
log
.
printRawLines
(
WriterKind
.
NOTICE
,
String
.
format
(
" %-26s %s"
,
helpSynopsis
(
log
),
log
.
localize
(
PrefixKind
.
JAVAC
,
descrKey
)));
}
String
helpSynopsis
(
Log
log
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
name
);
if
(
argsNameKey
==
null
)
{
if
(
choices
!=
null
)
{
String
sep
=
"{"
;
for
(
Map
.
Entry
<
String
,
Boolean
>
e:
choices
.
entrySet
())
{
if
(!
e
.
getValue
())
{
sb
.
append
(
sep
);
sb
.
append
(
e
.
getKey
());
sep
=
","
;
}
}
sb
.
append
(
"}"
);
}
}
else
{
if
(!
hasSuffix
)
sb
.
append
(
" "
);
sb
.
append
(
log
.
localize
(
PrefixKind
.
JAVAC
,
argsNameKey
));
}
return
sb
.
toString
();
}
/** Print a line of documentation describing this option, if non-standard.
* @param out the stream to which to write the documentation
*/
void
xhelp
(
Log
log
)
{}
/** Process the option (with arg). Return true if error detected.
*/
public
boolean
process
(
Options
options
,
String
option
,
String
arg
)
{
if
(
options
!=
null
)
{
if
(
choices
!=
null
)
{
if
(
choiceKind
==
ChoiceKind
.
ONEOF
)
{
// some clients like to see just one of option+choice set
for
(
String
s:
choices
.
keySet
())
options
.
remove
(
option
+
s
);
String
opt
=
option
+
arg
;
options
.
put
(
opt
,
opt
);
// some clients like to see option (without trailing ":")
// set to arg
String
nm
=
option
.
substring
(
0
,
option
.
length
()
-
1
);
options
.
put
(
nm
,
arg
);
}
else
{
// set option+word for each word in arg
for
(
String
a:
arg
.
split
(
",+"
))
{
String
opt
=
option
+
a
;
options
.
put
(
opt
,
opt
);
}
}
}
options
.
put
(
option
,
arg
);
}
return
false
;
}
/** Process the option (without arg). Return true if error detected.
*/
public
boolean
process
(
Options
options
,
String
option
)
{
if
(
hasSuffix
)
return
process
(
options
,
name
.
optionName
,
option
.
substring
(
name
.
optionName
.
length
()));
else
return
process
(
options
,
option
,
option
);
}
public
OptionKind
getKind
()
{
return
OptionKind
.
NORMAL
;
}
public
OptionName
getName
()
{
return
name
;
}
};
/** A nonstandard or extended (-X) option
*/
static
class
XOption
extends
Option
{
XOption
(
OptionName
name
,
String
argsNameKey
,
String
descrKey
)
{
super
(
name
,
argsNameKey
,
descrKey
);
}
XOption
(
OptionName
name
,
String
descrKey
)
{
this
(
name
,
null
,
descrKey
);
}
XOption
(
OptionName
name
,
String
descrKey
,
ChoiceKind
kind
,
String
...
choices
)
{
super
(
name
,
descrKey
,
kind
,
choices
);
}
XOption
(
OptionName
name
,
String
descrKey
,
ChoiceKind
kind
,
Map
<
String
,
Boolean
>
choices
)
{
super
(
name
,
descrKey
,
kind
,
choices
);
}
@Override
void
help
(
Log
log
)
{}
@Override
void
xhelp
(
Log
log
)
{
super
.
help
(
log
);
}
@Override
public
OptionKind
getKind
()
{
return
OptionKind
.
EXTENDED
;
}
};
/** A hidden (implementor) option
*/
static
class
HiddenOption
extends
Option
{
HiddenOption
(
OptionName
name
)
{
super
(
name
,
null
,
null
);
}
HiddenOption
(
OptionName
name
,
String
argsNameKey
)
{
super
(
name
,
argsNameKey
,
null
);
}
@Override
void
help
(
Log
log
)
{}
@Override
void
xhelp
(
Log
log
)
{}
@Override
public
OptionKind
getKind
()
{
return
OptionKind
.
HIDDEN
;
}
};
}
src/share/classes/com/sun/tools/javac/main/Main.java
浏览文件 @
24549cd5
...
...
@@ -42,14 +42,12 @@ import com.sun.tools.javac.code.Source;
import
com.sun.tools.javac.file.CacheFSInfo
;
import
com.sun.tools.javac.file.JavacFileManager
;
import
com.sun.tools.javac.jvm.Target
;
import
com.sun.tools.javac.main.JavacOption.Option
;
import
com.sun.tools.javac.main.RecognizedOptions.OptionHelper
;
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
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
/** This class provides a commandline interface to the GJC compiler.
*
...
...
@@ -99,42 +97,51 @@ public class Main {
public
final
int
exitCode
;
}
private
Option
[]
recognizedOptions
=
RecognizedOptions
.
getJavaCompilerOptions
(
new
OptionHelper
()
{
private
Option
[]
recognizedOptions
=
Option
.
getJavaCompilerOptions
().
toArray
(
new
Option
[
0
]);
public
void
setOut
(
PrintWriter
out
)
{
Main
.
this
.
out
=
out
;
Main
.
this
.
log
.
setWriters
(
out
);
private
OptionHelper
optionHelper
=
new
OptionHelper
()
{
@Override
public
String
get
(
Option
option
)
{
return
options
.
get
(
option
);
}
public
void
error
(
String
key
,
Object
...
args
)
{
Main
.
this
.
error
(
key
,
args
);
@Override
public
void
put
(
String
name
,
String
value
)
{
options
.
put
(
name
,
value
);
}
public
void
printVersion
()
{
log
.
printLines
(
PrefixKind
.
JAVAC
,
"version"
,
ownName
,
JavaCompiler
.
version
());
@Override
public
void
remove
(
String
name
)
{
options
.
remove
(
name
);
}
public
void
printFullVersion
()
{
log
.
printLines
(
PrefixKind
.
JAVAC
,
"fullVersion"
,
ownName
,
JavaCompiler
.
fullVersion
());
@Override
public
Log
getLog
()
{
return
log
;
}
public
void
printHelp
()
{
help
();
@Override
public
String
getOwnName
()
{
return
ownName
;
}
public
void
printXhelp
()
{
xhelp
();
@Override
public
void
error
(
String
key
,
Object
...
args
)
{
Main
.
this
.
error
(
key
,
args
);
}
@Override
public
void
addFile
(
File
f
)
{
filenames
.
add
(
f
);
}
@Override
public
void
addClassName
(
String
s
)
{
classnames
.
append
(
s
);
}
}
)
;
};
/**
* Construct a compiler instance.
...
...
@@ -161,26 +168,6 @@ public class Main {
*/
public
ListBuffer
<
String
>
classnames
=
null
;
// XXX sb protected
/** Print a string that explains usage.
*/
void
help
()
{
log
.
printLines
(
PrefixKind
.
JAVAC
,
"msg.usage.header"
,
ownName
);
for
(
int
i
=
0
;
i
<
recognizedOptions
.
length
;
i
++)
{
recognizedOptions
[
i
].
help
(
log
);
}
log
.
printNewline
();
}
/** Print a string that explains usage for X options.
*/
void
xhelp
()
{
for
(
int
i
=
0
;
i
<
recognizedOptions
.
length
;
i
++)
{
recognizedOptions
[
i
].
xhelp
(
log
);
}
log
.
printNewline
();
log
.
printLines
(
PrefixKind
.
JAVAC
,
"msg.usage.nonstandard.footer"
);
}
/** Report a usage error.
*/
void
error
(
String
key
,
Object
...
args
)
{
...
...
@@ -253,10 +240,10 @@ public class Main {
}
String
operand
=
flags
[
ac
];
ac
++;
if
(
option
.
process
(
option
s
,
flag
,
operand
))
if
(
option
.
process
(
option
Helper
,
flag
,
operand
))
return
null
;
}
else
{
if
(
option
.
process
(
option
s
,
flag
))
if
(
option
.
process
(
option
Helper
,
flag
))
return
null
;
}
}
...
...
@@ -317,8 +304,8 @@ public class Main {
return
filenames
;
}
// where
private
boolean
checkDirectory
(
Option
Name
optName
)
{
String
value
=
options
.
get
(
opt
Name
);
private
boolean
checkDirectory
(
Option
option
)
{
String
value
=
options
.
get
(
opt
ion
);
if
(
value
==
null
)
return
true
;
File
file
=
new
File
(
value
);
...
...
@@ -375,7 +362,7 @@ public class Main {
*/
try
{
if
(
args
.
length
==
0
&&
fileObjects
.
isEmpty
())
{
help
(
);
Option
.
HELP
.
process
(
optionHelper
,
"-help"
);
return
Result
.
CMDERR
;
}
...
...
@@ -407,8 +394,7 @@ public class Main {
boolean
forceStdOut
=
options
.
isSet
(
"stdout"
);
if
(
forceStdOut
)
{
log
.
flush
();
out
=
new
PrintWriter
(
System
.
out
,
true
);
log
.
setWriters
(
out
);
log
.
setWriters
(
new
PrintWriter
(
System
.
out
,
true
));
}
// allow System property in following line as a Mustang legacy
...
...
src/share/classes/com/sun/tools/javac/main/Option.java
0 → 100644
浏览文件 @
24549cd5
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/main/Option
Name
.java
→
src/share/classes/com/sun/tools/javac/main/Option
Helper
.java
浏览文件 @
24549cd5
...
...
@@ -25,81 +25,93 @@
package
com.sun.tools.javac.main
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Log.PrefixKind
;
import
java.io.File
;
/**
* TODO: describe com.sun.tools.javac.main.OptionName
* Helper object to be used by {@link Option#process}, providing access to
* the compilation environment.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
public
enum
OptionName
{
G
(
"-g"
),
G_NONE
(
"-g:none"
),
G_CUSTOM
(
"-g:"
),
XLINT
(
"-Xlint"
),
XLINT_CUSTOM
(
"-Xlint:"
),
DIAGS
(
"-XDdiags="
),
NOWARN
(
"-nowarn"
),
VERBOSE
(
"-verbose"
),
DEPRECATION
(
"-deprecation"
),
CLASSPATH
(
"-classpath"
),
CP
(
"-cp"
),
SOURCEPATH
(
"-sourcepath"
),
BOOTCLASSPATH
(
"-bootclasspath"
),
XBOOTCLASSPATH_PREPEND
(
"-Xbootclasspath/p:"
),
XBOOTCLASSPATH_APPEND
(
"-Xbootclasspath/a:"
),
XBOOTCLASSPATH
(
"-Xbootclasspath:"
),
EXTDIRS
(
"-extdirs"
),
DJAVA_EXT_DIRS
(
"-Djava.ext.dirs="
),
ENDORSEDDIRS
(
"-endorseddirs"
),
DJAVA_ENDORSED_DIRS
(
"-Djava.endorsed.dirs="
),
PROC
(
"-proc:"
),
PROCESSOR
(
"-processor"
),
PROCESSORPATH
(
"-processorpath"
),
D
(
"-d"
),
S
(
"-s"
),
IMPLICIT
(
"-implicit:"
),
ENCODING
(
"-encoding"
),
SOURCE
(
"-source"
),
TARGET
(
"-target"
),
VERSION
(
"-version"
),
FULLVERSION
(
"-fullversion"
),
HELP
(
"-help"
),
A
(
"-A"
),
X
(
"-X"
),
J
(
"-J"
),
MOREINFO
(
"-moreinfo"
),
WERROR
(
"-Werror"
),
COMPLEXINFERENCE
(
"-complexinference"
),
PROMPT
(
"-prompt"
),
DOE
(
"-doe"
),
PRINTSOURCE
(
"-printsource"
),
WARNUNCHECKED
(
"-warnunchecked"
),
XMAXERRS
(
"-Xmaxerrs"
),
XMAXWARNS
(
"-Xmaxwarns"
),
XSTDOUT
(
"-Xstdout"
),
XPKGINFO
(
"-Xpkginfo:"
),
XPRINT
(
"-Xprint"
),
XPRINTROUNDS
(
"-XprintRounds"
),
XPRINTPROCESSORINFO
(
"-XprintProcessorInfo"
),
XPREFER
(
"-Xprefer:"
),
O
(
"-O"
),
XJCOV
(
"-Xjcov"
),
XD
(
"-XD"
),
AT
(
"@"
),
SOURCEFILE
(
"sourcefile"
);
public
final
String
optionName
;
OptionName
(
String
optionName
)
{
this
.
optionName
=
optionName
;
}
@Override
public
String
toString
()
{
return
optionName
;
public
abstract
class
OptionHelper
{
/** Get the current value of an option. */
public
abstract
String
get
(
Option
option
);
/** Set the value of an option. */
public
abstract
void
put
(
String
name
,
String
value
);
/** Remove any prior value for an option. */
public
abstract
void
remove
(
String
name
);
/** Get access to the Log for the compilation. */
public
abstract
Log
getLog
();
/** Get the name of the tool, such as "javac", to be used in info like -help. */
public
abstract
String
getOwnName
();
/** Report an error. */
abstract
void
error
(
String
key
,
Object
...
args
);
/** Record a file to be compiled. */
abstract
void
addFile
(
File
f
);
/** Record the name of a class for annotation processing. */
abstract
void
addClassName
(
String
s
);
/** An implementation of OptionHelper that mostly throws exceptions. */
public
static
class
GrumpyHelper
extends
OptionHelper
{
private
final
Log
log
;
public
GrumpyHelper
(
Log
log
)
{
this
.
log
=
log
;
}
@Override
public
Log
getLog
()
{
return
log
;
}
@Override
public
String
getOwnName
()
{
throw
new
IllegalStateException
();
}
@Override
public
String
get
(
Option
option
)
{
throw
new
IllegalArgumentException
();
}
@Override
public
void
put
(
String
name
,
String
value
)
{
throw
new
IllegalArgumentException
();
}
@Override
public
void
remove
(
String
name
)
{
throw
new
IllegalArgumentException
();
}
@Override
void
error
(
String
key
,
Object
...
args
)
{
throw
new
IllegalArgumentException
(
log
.
localize
(
PrefixKind
.
JAVAC
,
key
,
args
));
}
@Override
public
void
addFile
(
File
f
)
{
throw
new
IllegalArgumentException
(
f
.
getPath
());
}
@Override
public
void
addClassName
(
String
s
)
{
throw
new
IllegalArgumentException
(
s
);
}
}
}
src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
已删除
100644 → 0
浏览文件 @
9ec97edd
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java
浏览文件 @
24549cd5
...
...
@@ -63,7 +63,7 @@ import com.sun.tools.javac.util.Context;
import
com.sun.tools.javac.util.List
;
import
com.sun.tools.javac.util.ListBuffer
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
// NOTE the imports carefully for this compilation unit.
...
...
src/share/classes/com/sun/tools/javac/parser/JavacParser.java
浏览文件 @
24549cd5
...
...
@@ -787,7 +787,7 @@ public class JavacParser implements Parser {
top
++;
topOp
=
token
;
nextToken
();
odStack
[
top
]
=
(
topOp
.
kind
==
INSTANCEOF
)
?
parseType
()
:
term3
NoParams
();
odStack
[
top
]
=
(
topOp
.
kind
==
INSTANCEOF
)
?
parseType
()
:
term3
();
while
(
top
>
0
&&
prec
(
topOp
.
kind
)
>=
prec
(
token
.
kind
))
{
odStack
[
top
-
1
]
=
makeOp
(
topOp
.
pos
,
topOp
.
kind
,
odStack
[
top
-
1
],
odStack
[
top
]);
...
...
@@ -931,7 +931,7 @@ public class JavacParser implements Parser {
mode
=
EXPR
;
t
=
literal
(
names
.
hyphen
,
pos
);
}
else
{
t
=
term3
NoParams
();
t
=
term3
();
return
F
.
at
(
pos
).
Unary
(
unoptag
(
tk
),
t
);
}
}
else
return
illegal
();
...
...
@@ -947,8 +947,8 @@ public class JavacParser implements Parser {
break
;
}
else
{
nextToken
();
mode
=
EXPR
|
TYPE
;
t
=
term3
NoParams
();
mode
=
EXPR
|
TYPE
|
NOPARAMS
;
t
=
term3
();
if
((
mode
&
TYPE
)
!=
0
&&
token
.
kind
==
LT
)
{
// Could be a cast to a parameterized type
JCTree
.
Tag
op
=
JCTree
.
Tag
.
LT
;
...
...
@@ -1011,7 +1011,7 @@ public class JavacParser implements Parser {
lastmode
=
mode
;
mode
=
EXPR
;
if
((
lastmode
&
EXPR
)
==
0
)
{
JCExpression
t1
=
term3
NoParams
();
JCExpression
t1
=
term3
();
return
F
.
at
(
pos
).
TypeCast
(
t
,
t1
);
}
else
if
((
lastmode
&
TYPE
)
!=
0
)
{
switch
(
token
.
kind
)
{
...
...
@@ -1024,7 +1024,7 @@ public class JavacParser implements Parser {
case
NEW:
case
IDENTIFIER:
case
ASSERT:
case
ENUM:
case
BYTE:
case
SHORT:
case
CHAR:
case
INT:
case
LONG:
case
FLOAT:
case
DOUBLE:
case
BOOLEAN:
case
VOID:
JCExpression
t1
=
term3
NoParams
();
JCExpression
t1
=
term3
();
return
F
.
at
(
pos
).
TypeCast
(
t
,
t1
);
}
}
...
...
@@ -1143,49 +1143,35 @@ public class JavacParser implements Parser {
// typeArgs saved for next loop iteration.
t
=
toP
(
F
.
at
(
pos
).
Select
(
t
,
ident
()));
break
;
// case LT:
// if ((mode & (TYPE | NOPARAMS)) == 0) {
// //could be an unbound method reference whose qualifier
// //is a generic type i.e. A<S>#m
// mode = EXPR | TYPE;
// JCTree.Tag op = JCTree.Tag.LT;
// int pos1 = token.pos;
// nextToken();
// mode |= EXPR | TYPE | TYPEARG;
// JCExpression t1 = term3();
// if ((mode & TYPE) != 0 &&
// (token.kind == COMMA || token.kind == GT)) {
// mode = TYPE;
// ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
// args.append(t1);
// while (token.kind == COMMA) {
// nextToken();
// args.append(typeArgument());
// }
// accept(GT);
// t = toP(F.at(pos1).TypeApply(t, args.toList()));
// checkGenerics();
// while (token.kind == DOT) {
// nextToken();
// mode = TYPE;
// t = toP(F.at(token.pos).Select(t, ident()));
// t = typeArgumentsOpt(t);
// }
// if (token.kind != HASH) {
// //method reference expected here
// t = illegal();
// }
// mode = EXPR;
// break;
// } else if ((mode & EXPR) != 0) {
// //rollback - it was a binary expression
// mode = EXPR;
// JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
// t = F.at(pos1).Binary(op, t, e);
// t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
// }
// }
// break loop;
case
LT:
if
((
mode
&
TYPE
)
==
0
&&
isUnboundMemberRef
())
{
//this is an unbound method reference whose qualifier
//is a generic type i.e. A<S>#m
int
pos1
=
token
.
pos
;
accept
(
LT
);
ListBuffer
<
JCExpression
>
args
=
new
ListBuffer
<
JCExpression
>();
args
.
append
(
typeArgument
());
while
(
token
.
kind
==
COMMA
)
{
nextToken
();
args
.
append
(
typeArgument
());
}
accept
(
GT
);
t
=
toP
(
F
.
at
(
pos1
).
TypeApply
(
t
,
args
.
toList
()));
checkGenerics
();
while
(
token
.
kind
==
DOT
)
{
nextToken
();
mode
=
TYPE
;
t
=
toP
(
F
.
at
(
token
.
pos
).
Select
(
t
,
ident
()));
t
=
typeArgumentsOpt
(
t
);
}
if
(
token
.
kind
!=
HASH
)
{
//method reference expected here
t
=
illegal
();
}
mode
=
EXPR
;
return
term3Rest
(
t
,
typeArgs
);
}
break
loop
;
default
:
break
loop
;
}
...
...
@@ -1225,15 +1211,6 @@ public class JavacParser implements Parser {
return
term3Rest
(
t
,
typeArgs
);
}
JCExpression
term3NoParams
()
{
try
{
mode
|=
NOPARAMS
;
return
term3
();
}
finally
{
mode
&=
~
NOPARAMS
;
}
}
JCExpression
term3Rest
(
JCExpression
t
,
List
<
JCExpression
>
typeArgs
)
{
if
(
typeArgs
!=
null
)
illegal
();
while
(
true
)
{
...
...
@@ -1297,6 +1274,41 @@ public class JavacParser implements Parser {
return
toP
(
t
);
}
/**
* If we see an identifier followed by a '<' it could be an unbound
* method reference or a binary expression. To disambiguate, look for a
* matching '>' and see if the subsequent terminal is either '.' or '#'.
*/
@SuppressWarnings
(
"fallthrough"
)
boolean
isUnboundMemberRef
()
{
int
pos
=
0
,
depth
=
0
;
for
(
Token
t
=
S
.
token
(
pos
)
;
;
t
=
S
.
token
(++
pos
))
{
switch
(
t
.
kind
)
{
case
IDENTIFIER:
case
QUES:
case
EXTENDS:
case
SUPER:
case
DOT:
case
RBRACKET:
case
LBRACKET:
case
COMMA:
case
BYTE:
case
SHORT:
case
INT:
case
LONG:
case
FLOAT:
case
DOUBLE:
case
BOOLEAN:
case
CHAR:
break
;
case
LT:
depth
++;
break
;
case
GTGTGT:
depth
--;
case
GTGT:
depth
--;
case
GT:
depth
--;
if
(
depth
==
0
)
{
return
S
.
token
(
pos
+
1
).
kind
==
TokenKind
.
DOT
||
S
.
token
(
pos
+
1
).
kind
==
TokenKind
.
HASH
;
}
break
;
default
:
return
false
;
}
}
}
JCExpression
lambdaExpressionOrStatement
(
JCVariableDecl
firstParam
,
int
pos
)
{
ListBuffer
<
JCVariableDecl
>
params
=
new
ListBuffer
<
JCVariableDecl
>();
params
.
append
(
firstParam
);
...
...
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
浏览文件 @
24549cd5
...
...
@@ -82,7 +82,7 @@ import com.sun.tools.javac.util.Options;
import
static
javax
.
tools
.
StandardLocation
.*;
import
static
com
.
sun
.
tools
.
javac
.
util
.
JCDiagnostic
.
DiagnosticFlag
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Lint
.
LintCategory
.
PROCESSING
;
/**
...
...
@@ -1033,12 +1033,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
Assert
.
checkNonNull
(
options
);
next
.
put
(
Options
.
optionsKey
,
options
);
PrintWriter
out
=
context
.
get
(
Log
.
outKey
);
Assert
.
checkNonNull
(
out
);
next
.
put
(
Log
.
outKey
,
out
);
Locale
locale
=
context
.
get
(
Locale
.
class
);
if
(
locale
!=
null
)
next
.
put
(
Locale
.
class
,
locale
);
Assert
.
checkNonNull
(
messages
);
next
.
put
(
JavacMessages
.
messagesKey
,
messages
);
...
...
@@ -1076,6 +1074,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
Assert
.
checkNonNull
(
tokens
);
next
.
put
(
Tokens
.
tokensKey
,
tokens
);
// propogate the log's writers directly, instead of going through context
Log
.
instance
(
next
).
setWriters
(
log
);
JavaCompiler
oldCompiler
=
JavaCompiler
.
instance
(
context
);
JavaCompiler
nextCompiler
=
JavaCompiler
.
instance
(
next
);
nextCompiler
.
initRound
(
oldCompiler
);
...
...
@@ -1472,14 +1473,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
return
context
;
}
/**
* Internal use method to return the writer being used by the
* processing environment.
*/
public
PrintWriter
getWriter
()
{
return
context
.
get
(
Log
.
outKey
);
}
public
String
toString
()
{
return
"javac ProcessingEnvironment"
;
}
...
...
src/share/classes/com/sun/tools/javac/util/BaseFileManager.java
浏览文件 @
24549cd5
...
...
@@ -46,6 +46,7 @@ import java.util.Collection;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.tools.JavaFileObject
;
import
javax.tools.JavaFileObject.Kind
;
...
...
@@ -53,9 +54,9 @@ import com.sun.tools.javac.code.Lint;
import
com.sun.tools.javac.code.Source
;
import
com.sun.tools.javac.file.FSInfo
;
import
com.sun.tools.javac.file.Locations
;
import
com.sun.tools.javac.main.
Javac
Option
;
import
com.sun.tools.javac.main.Option
Name
;
import
com.sun.tools.javac.main.
RecognizedOptions
;
import
com.sun.tools.javac.main.Option
;
import
com.sun.tools.javac.main.Option
Helper
;
import
com.sun.tools.javac.main.
OptionHelper.GrumpyHelper
;
import
com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition
;
/**
...
...
@@ -101,7 +102,7 @@ public abstract class BaseFileManager {
protected
Locations
locations
;
protected
Source
getSource
()
{
String
sourceName
=
options
.
get
(
Option
Name
.
SOURCE
);
String
sourceName
=
options
.
get
(
Option
.
SOURCE
);
Source
source
=
null
;
if
(
sourceName
!=
null
)
source
=
Source
.
lookup
(
sourceName
);
...
...
@@ -145,15 +146,31 @@ public abstract class BaseFileManager {
// <editor-fold defaultstate="collapsed" desc="Option handling">
public
boolean
handleOption
(
String
current
,
Iterator
<
String
>
remaining
)
{
for
(
JavacOption
o:
javacFileManagerOptions
)
{
OptionHelper
helper
=
new
GrumpyHelper
(
log
)
{
@Override
public
String
get
(
Option
option
)
{
return
options
.
get
(
option
.
getText
());
}
@Override
public
void
put
(
String
name
,
String
value
)
{
options
.
put
(
name
,
value
);
}
@Override
public
void
remove
(
String
name
)
{
options
.
remove
(
name
);
}
};
for
(
Option
o:
javacFileManagerOptions
)
{
if
(
o
.
matches
(
current
))
{
if
(
o
.
hasArg
())
{
if
(
remaining
.
hasNext
())
{
if
(!
o
.
process
(
options
,
current
,
remaining
.
next
()))
if
(!
o
.
process
(
helper
,
current
,
remaining
.
next
()))
return
true
;
}
}
else
{
if
(!
o
.
process
(
options
,
current
))
if
(!
o
.
process
(
helper
,
current
))
return
true
;
}
// operand missing, or process returned false
...
...
@@ -164,12 +181,11 @@ public abstract class BaseFileManager {
return
false
;
}
// where
private
static
JavacOption
[]
javacFileManagerOptions
=
RecognizedOptions
.
getJavacFileManagerOptions
(
new
RecognizedOptions
.
GrumpyHelper
(
Log
.
instance
(
new
Context
())));
private
static
Set
<
Option
>
javacFileManagerOptions
=
Option
.
getJavacFileManagerOptions
();
public
int
isSupportedOption
(
String
option
)
{
for
(
Javac
Option
o
:
javacFileManagerOptions
)
{
for
(
Option
o
:
javacFileManagerOptions
)
{
if
(
o
.
matches
(
option
))
return
o
.
hasArg
()
?
1
:
0
;
}
...
...
@@ -191,7 +207,7 @@ public abstract class BaseFileManager {
}
public
String
getEncodingName
()
{
String
encName
=
options
.
get
(
Option
Name
.
ENCODING
);
String
encName
=
options
.
get
(
Option
.
ENCODING
);
if
(
encName
==
null
)
return
getDefaultEncodingName
();
else
...
...
src/share/classes/com/sun/tools/javac/util/Log.java
浏览文件 @
24549cd5
...
...
@@ -25,25 +25,23 @@
package
com.sun.tools.javac.util
;
import
com.sun.tools.javac.main.Main
;
import
java.io.*
;
import
java.util.Arrays
;
import
java.util.EnumSet
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Queue
;
import
java.util.Set
;
import
javax.tools.DiagnosticListener
;
import
javax.tools.JavaFileObject
;
import
com.sun.tools.javac.api.DiagnosticFormatter
;
import
com.sun.tools.javac.main.OptionName
;
import
com.sun.tools.javac.main.Main
;
import
com.sun.tools.javac.main.Option
;
import
com.sun.tools.javac.parser.EndPosTable
;
import
com.sun.tools.javac.tree.JCTree
;
import
com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition
;
import
com.sun.tools.javac.util.JCDiagnostic.DiagnosticType
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
/** A class for error logs. Reports errors and warnings, and
* keeps track of error numbers and positions.
...
...
@@ -137,7 +135,6 @@ public class Log extends AbstractLog {
/** Construct a log with given I/O redirections.
*/
@Deprecated
protected
Log
(
Context
context
,
PrintWriter
errWriter
,
PrintWriter
warnWriter
,
PrintWriter
noticeWriter
)
{
super
(
JCDiagnostic
.
Factory
.
instance
(
context
));
context
.
put
(
logKey
,
this
);
...
...
@@ -179,8 +176,8 @@ public class Log extends AbstractLog {
expectDiagKeys
=
new
HashSet
<
String
>(
Arrays
.
asList
(
ek
.
split
(
", *"
)));
}
private
int
getIntOption
(
Options
options
,
Option
Name
optionName
,
int
defaultValue
)
{
String
s
=
options
.
get
(
option
Name
);
private
int
getIntOption
(
Options
options
,
Option
option
,
int
defaultValue
)
{
String
s
=
options
.
get
(
option
);
try
{
if
(
s
!=
null
)
{
int
n
=
Integer
.
parseInt
(
s
);
...
...
@@ -298,6 +295,12 @@ public class Log extends AbstractLog {
noticeWriter
=
warnWriter
=
errWriter
=
pw
;
}
public
void
setWriters
(
Log
other
)
{
this
.
noticeWriter
=
other
.
noticeWriter
;
this
.
warnWriter
=
other
.
warnWriter
;
this
.
errWriter
=
other
.
errWriter
;
}
/** Flush the logs
*/
public
void
flush
()
{
...
...
src/share/classes/com/sun/tools/javac/util/Options.java
浏览文件 @
24549cd5
...
...
@@ -26,8 +26,8 @@
package
com.sun.tools.javac.util
;
import
java.util.*
;
import
com.sun.tools.javac.main.Option
Name
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
Name
.*;
import
com.sun.tools.javac.main.Option
;
import
static
com
.
sun
.
tools
.
javac
.
main
.
Option
.*;
/** A table of all command-line options.
* If an option has an argument, the option name is mapped to the argument.
...
...
@@ -71,8 +71,8 @@ public class Options {
/**
* Get the value for an option.
*/
public
String
get
(
Option
Name
name
)
{
return
values
.
get
(
name
.
optionName
);
public
String
get
(
Option
option
)
{
return
values
.
get
(
option
.
text
);
}
/**
...
...
@@ -101,15 +101,15 @@ public class Options {
/**
* Check if the value for an option has been set.
*/
public
boolean
isSet
(
Option
Name
name
)
{
return
(
values
.
get
(
name
.
optionName
)
!=
null
);
public
boolean
isSet
(
Option
option
)
{
return
(
values
.
get
(
option
.
text
)
!=
null
);
}
/**
* Check if the value for a choice option has been set to a specific value.
*/
public
boolean
isSet
(
Option
Name
name
,
String
value
)
{
return
(
values
.
get
(
name
.
optionName
+
value
)
!=
null
);
public
boolean
isSet
(
Option
option
,
String
value
)
{
return
(
values
.
get
(
option
.
text
+
value
)
!=
null
);
}
/**
...
...
@@ -122,23 +122,23 @@ public class Options {
/**
* Check if the value for an option has not been set.
*/
public
boolean
isUnset
(
Option
Name
name
)
{
return
(
values
.
get
(
name
.
optionName
)
==
null
);
public
boolean
isUnset
(
Option
option
)
{
return
(
values
.
get
(
option
.
text
)
==
null
);
}
/**
* Check if the value for a choice option has not been set to a specific value.
*/
public
boolean
isUnset
(
Option
Name
name
,
String
value
)
{
return
(
values
.
get
(
name
.
optionName
+
value
)
==
null
);
public
boolean
isUnset
(
Option
option
,
String
value
)
{
return
(
values
.
get
(
option
.
text
+
value
)
==
null
);
}
public
void
put
(
String
name
,
String
value
)
{
values
.
put
(
name
,
value
);
}
public
void
put
(
Option
Name
name
,
String
value
)
{
values
.
put
(
name
.
optionName
,
value
);
public
void
put
(
Option
option
,
String
value
)
{
values
.
put
(
option
.
text
,
value
);
}
public
void
putAll
(
Options
options
)
{
...
...
test/tools/javac/4846262/Test.sh
浏览文件 @
24549cd5
#!/bin/sh -f
#
# Copyright (c) 2005, 20
09
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2005, 20
11
, 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
...
...
@@ -71,7 +71,7 @@ rm -f Test.java Test.out
diff
${
DIFFOPTS
}
-c
"
${
TESTSRC
}${
FS
}
Test.out"
Test.out
result
=
$?
if
[
$result
-eq
o
]
if
[
$result
-eq
0
]
then
echo
"Passed"
else
...
...
test/tools/javac/api/T6838467.java
浏览文件 @
24549cd5
...
...
@@ -32,7 +32,6 @@ import java.util.*;
import
java.util.zip.*
;
import
javax.tools.*
;
import
com.sun.tools.javac.file.JavacFileManager
;
import
com.sun.tools.javac.main.OptionName
;
import
com.sun.tools.javac.util.Context
;
import
com.sun.tools.javac.util.Options
;
...
...
test/tools/javac/diags/examples/UnsupportedEncoding.java
浏览文件 @
24549cd5
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
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
...
...
@@ -23,5 +23,6 @@
// key: compiler.err.unsupported.encoding
// options: -encoding UNSUPPORTED -doe
// run: simple
class
UnsupportedEncoding
{
}
test/tools/javac/lambda/MethodReferenceParserTest.java
浏览文件 @
24549cd5
...
...
@@ -24,7 +24,6 @@
/*
* @test
* @bug 7115052
* @ignore 7120266
* @summary Add parser support for method references
*/
...
...
@@ -45,6 +44,7 @@ public class MethodReferenceParserTest {
enum
ReferenceKind
{
METHOD_REF
(
"#Q##Gm"
),
CONSTRUCTOR_REF
(
"#Q##Gnew"
),
FALSE_REF
(
"min < max"
),
ERR_SUPER
(
"#Q##Gsuper"
),
ERR_METH0
(
"#Q##Gm()"
),
ERR_METH1
(
"#Q##Gm(X)"
),
...
...
@@ -76,6 +76,21 @@ public class MethodReferenceParserTest {
}
}
enum
ContextKind
{
ASSIGN
(
"SAM s = #E;"
),
METHOD
(
"m(#E, i);"
);
String
contextTemplate
;
ContextKind
(
String
contextTemplate
)
{
this
.
contextTemplate
=
contextTemplate
;
}
String
contextString
(
ExprKind
ek
,
ReferenceKind
rk
,
QualifierKind
qk
,
GenericKind
gk
,
SubExprKind
sk
)
{
return
contextTemplate
.
replaceAll
(
"#E"
,
ek
.
expressionString
(
rk
,
qk
,
gk
,
sk
));
}
}
enum
GenericKind
{
NONE
(
""
),
ONE
(
"<X>"
),
...
...
@@ -97,7 +112,10 @@ public class MethodReferenceParserTest {
UBOUND_SIMPLE
(
"A"
),
UNBOUND_GENERIC1
(
"A<X>"
),
UNBOUND_GENERIC2
(
"A<X, Y>"
),
UNBOUND_GENERIC3
(
"A<? extends X, ? super Y>"
);
UNBOUND_GENERIC3
(
"A<? extends X, ? super Y>"
),
UNBOUND_GENERIC4
(
"A<int[], short[][]>"
),
NESTED_GENERIC1
(
"A<A<X,Y>, A<X,Y>>"
),
NESTED_GENERIC2
(
"A<A<A<X,Y>,A<X,Y>>, A<A<X,Y>,A<X,Y>>>"
);
String
qualifier
;
...
...
@@ -153,7 +171,9 @@ public class MethodReferenceParserTest {
for
(
GenericKind
gk
:
GenericKind
.
values
())
{
for
(
SubExprKind
sk
:
SubExprKind
.
values
())
{
for
(
ExprKind
ek
:
ExprKind
.
values
())
{
new
MethodReferenceParserTest
(
rk
,
qk
,
gk
,
sk
,
ek
).
run
(
comp
,
fm
);
for
(
ContextKind
ck
:
ContextKind
.
values
())
{
new
MethodReferenceParserTest
(
rk
,
qk
,
gk
,
sk
,
ek
,
ck
).
run
(
comp
,
fm
);
}
}
}
}
...
...
@@ -167,15 +187,17 @@ public class MethodReferenceParserTest {
GenericKind
gk
;
SubExprKind
sk
;
ExprKind
ek
;
ContextKind
ck
;
JavaSource
source
;
DiagnosticChecker
diagChecker
;
MethodReferenceParserTest
(
ReferenceKind
rk
,
QualifierKind
qk
,
GenericKind
gk
,
SubExprKind
sk
,
ExprKind
ek
)
{
MethodReferenceParserTest
(
ReferenceKind
rk
,
QualifierKind
qk
,
GenericKind
gk
,
SubExprKind
sk
,
ExprKind
ek
,
ContextKind
ck
)
{
this
.
rk
=
rk
;
this
.
qk
=
qk
;
this
.
gk
=
gk
;
this
.
sk
=
sk
;
this
.
ek
=
ek
;
this
.
ck
=
ck
;
this
.
source
=
new
JavaSource
();
this
.
diagChecker
=
new
DiagnosticChecker
();
}
...
...
@@ -183,14 +205,16 @@ public class MethodReferenceParserTest {
class
JavaSource
extends
SimpleJavaFileObject
{
String
template
=
"class Test {\n"
+
" SAM s = #E;\n"
+
" void test() {\n"
+
" #C\n"
+
" }"
+
"}"
;
String
source
;
public
JavaSource
()
{
super
(
URI
.
create
(
"myfo:/Test.java"
),
JavaFileObject
.
Kind
.
SOURCE
);
source
=
template
.
replaceAll
(
"#
E"
,
ek
.
expressionString
(
rk
,
qk
,
gk
,
sk
));
source
=
template
.
replaceAll
(
"#
C"
,
ck
.
contextString
(
ek
,
rk
,
qk
,
gk
,
sk
));
}
@Override
...
...
test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java
0 → 100644
浏览文件 @
24549cd5
/*
* Copyright (c) 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6987384
* @summary -XprintProcessorRoundsInfo message printed with different timing than previous
* @library ../../../lib
* @build JavacTestingAbstractProcessor Test TestWithXstdout
* @run main TestWithXstdout
*/
import
java.io.*
;
import
java.nio.charset.*
;
import
java.nio.file.*
;
import
java.util.*
;
public
class
TestWithXstdout
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
File
testSrc
=
new
File
(
System
.
getProperty
(
"test.src"
));
File
testClasses
=
new
File
(
System
.
getProperty
(
"test.classes"
));
File
stdout
=
new
File
(
"stdout.out"
);
run_javac
(
"-XDrawDiagnostics"
,
"-XprintProcessorInfo"
,
"-Werror"
,
"-proc:only"
,
"-processor"
,
"Test"
,
"-Xstdout"
,
stdout
.
getPath
(),
"-classpath"
,
testClasses
.
getPath
(),
new
File
(
testSrc
,
"Test.java"
).
getPath
());
boolean
ok
=
compare
(
stdout
,
new
File
(
testSrc
,
"Test.out"
));
if
(!
ok
)
throw
new
Exception
(
"differences found"
);
}
static
void
run_javac
(
String
...
args
)
throws
IOException
,
InterruptedException
{
File
javaHome
=
new
File
(
System
.
getProperty
(
"java.home"
));
if
(
javaHome
.
getName
().
equals
(
"jre"
))
javaHome
=
javaHome
.
getParentFile
();
File
javac
=
new
File
(
new
File
(
javaHome
,
"bin"
),
"javac"
);
List
<
String
>
opts
=
new
ArrayList
<>();
opts
.
add
(
javac
.
getPath
());
String
toolOpts
=
System
.
getProperty
(
"test.tool.vm.opts"
);
if
(
toolOpts
!=
null
&&
!
""
.
equals
(
toolOpts
.
trim
()))
{
opts
.
addAll
(
Arrays
.
asList
(
toolOpts
.
trim
().
split
(
"[\\s]+"
)));
}
opts
.
addAll
(
Arrays
.
asList
(
args
));
System
.
out
.
println
(
"exec: "
+
opts
);
ProcessBuilder
pb
=
new
ProcessBuilder
(
opts
);
pb
.
redirectErrorStream
();
Process
p
=
pb
.
start
();
try
(
BufferedReader
r
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
())))
{
String
line
;
while
((
line
=
r
.
readLine
())
!=
null
)
System
.
out
.
println
();
}
int
rc
=
p
.
waitFor
();
if
(
rc
!=
0
)
System
.
out
.
println
(
"javac exited, rc="
+
rc
);
}
static
boolean
compare
(
File
a
,
File
b
)
throws
IOException
{
List
<
String
>
aLines
=
Files
.
readAllLines
(
a
.
toPath
(),
Charset
.
defaultCharset
());
List
<
String
>
bLines
=
Files
.
readAllLines
(
b
.
toPath
(),
Charset
.
defaultCharset
());
System
.
out
.
println
(
a
+
": "
+
aLines
.
size
()
+
" lines"
);
System
.
out
.
println
(
b
+
": "
+
bLines
.
size
()
+
" lines"
);
return
aLines
.
equals
(
bLines
);
}
}
test/tools/javac/util/T6597678.java
浏览文件 @
24549cd5
...
...
@@ -41,6 +41,7 @@ import javax.tools.Diagnostic;
import
com.sun.tools.javac.processing.JavacProcessingEnvironment
;
import
com.sun.tools.javac.util.Context
;
import
com.sun.tools.javac.util.JavacMessages
;
import
com.sun.tools.javac.util.Log
;
@SupportedOptions
(
"WriterString"
)
public
class
T6597678
extends
JavacTestingAbstractProcessor
{
...
...
@@ -78,7 +79,10 @@ public class T6597678 extends JavacTestingAbstractProcessor {
@Override
public
boolean
process
(
Set
<?
extends
TypeElement
>
annotations
,
RoundEnvironment
roundEnv
)
{
Context
context
=
((
JavacProcessingEnvironment
)
processingEnv
).
getContext
();
PrintWriter
out
=
((
JavacProcessingEnvironment
)
processingEnv
).
getWriter
();
Log
log
=
Log
.
instance
(
context
);
PrintWriter
noteOut
=
log
.
getWriter
(
Log
.
WriterKind
.
NOTICE
);
PrintWriter
warnOut
=
log
.
getWriter
(
Log
.
WriterKind
.
WARNING
);
PrintWriter
errOut
=
log
.
getWriter
(
Log
.
WriterKind
.
ERROR
);
Locale
locale
=
context
.
get
(
Locale
.
class
);
JavacMessages
messages
=
context
.
get
(
JavacMessages
.
messagesKey
);
...
...
@@ -86,13 +90,20 @@ public class T6597678 extends JavacTestingAbstractProcessor {
if
(
round
==
1
)
{
initialLocale
=
locale
;
initialMessages
=
messages
;
initialWriter
=
out
;
checkEqual
(
"writerString"
,
out
.
toString
().
intern
(),
options
.
get
(
"WriterString"
).
intern
());
initialNoteWriter
=
noteOut
;
initialWarnWriter
=
warnOut
;
initialErrWriter
=
errOut
;
String
writerStringOpt
=
options
.
get
(
"WriterString"
).
intern
();
checkEqual
(
"noteWriterString"
,
noteOut
.
toString
().
intern
(),
writerStringOpt
);
checkEqual
(
"warnWriterString"
,
warnOut
.
toString
().
intern
(),
writerStringOpt
);
checkEqual
(
"errWriterString"
,
errOut
.
toString
().
intern
(),
writerStringOpt
);
}
else
{
checkEqual
(
"locale"
,
locale
,
initialLocale
);
checkEqual
(
"messages"
,
messages
,
initialMessages
);
checkEqual
(
"writer"
,
out
,
initialWriter
);
checkEqual
(
"noteWriter"
,
noteOut
,
initialNoteWriter
);
checkEqual
(
"warnWriter"
,
warnOut
,
initialWarnWriter
);
checkEqual
(
"errWriter"
,
errOut
,
initialErrWriter
);
}
return
true
;
...
...
@@ -109,5 +120,7 @@ public class T6597678 extends JavacTestingAbstractProcessor {
int
round
=
0
;
Locale
initialLocale
;
JavacMessages
initialMessages
;
PrintWriter
initialWriter
;
PrintWriter
initialNoteWriter
;
PrintWriter
initialWarnWriter
;
PrintWriter
initialErrWriter
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录