Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
b46865f7
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看板
提交
b46865f7
编写于
11月 14, 2011
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
8b1a957b
b0ad1aa2
变更
35
展开全部
隐藏空白更改
内联
并排
Showing
35 changed file
with
1698 addition
and
1552 deletion
+1698
-1552
src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
+3
-3
src/share/classes/com/sun/tools/javac/api/JavacTrees.java
src/share/classes/com/sun/tools/javac/api/JavacTrees.java
+1
-1
src/share/classes/com/sun/tools/javac/comp/Annotate.java
src/share/classes/com/sun/tools/javac/comp/Annotate.java
+8
-6
src/share/classes/com/sun/tools/javac/comp/Attr.java
src/share/classes/com/sun/tools/javac/comp/Attr.java
+50
-45
src/share/classes/com/sun/tools/javac/comp/Check.java
src/share/classes/com/sun/tools/javac/comp/Check.java
+14
-9
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/Env.java
src/share/classes/com/sun/tools/javac/comp/Env.java
+3
-3
src/share/classes/com/sun/tools/javac/comp/Flow.java
src/share/classes/com/sun/tools/javac/comp/Flow.java
+21
-19
src/share/classes/com/sun/tools/javac/comp/Infer.java
src/share/classes/com/sun/tools/javac/comp/Infer.java
+2
-2
src/share/classes/com/sun/tools/javac/comp/Lower.java
src/share/classes/com/sun/tools/javac/comp/Lower.java
+104
-68
src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
+4
-2
src/share/classes/com/sun/tools/javac/comp/Resolve.java
src/share/classes/com/sun/tools/javac/comp/Resolve.java
+7
-4
src/share/classes/com/sun/tools/javac/jvm/CRTable.java
src/share/classes/com/sun/tools/javac/jvm/CRTable.java
+1
-1
src/share/classes/com/sun/tools/javac/jvm/Gen.java
src/share/classes/com/sun/tools/javac/jvm/Gen.java
+29
-27
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/model/JavacElements.java
...hare/classes/com/sun/tools/javac/model/JavacElements.java
+4
-3
src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
...are/classes/com/sun/tools/javac/parser/JavaTokenizer.java
+200
-222
src/share/classes/com/sun/tools/javac/parser/JavacParser.java
...share/classes/com/sun/tools/javac/parser/JavacParser.java
+86
-77
src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java
.../classes/com/sun/tools/javac/parser/JavadocTokenizer.java
+275
-332
src/share/classes/com/sun/tools/javac/parser/Tokens.java
src/share/classes/com/sun/tools/javac/parser/Tokens.java
+66
-17
src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java
...are/classes/com/sun/tools/javac/parser/UnicodeReader.java
+54
-1
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
...un/tools/javac/processing/JavacProcessingEnvironment.java
+1
-1
src/share/classes/com/sun/tools/javac/tree/JCTree.java
src/share/classes/com/sun/tools/javac/tree/JCTree.java
+313
-270
src/share/classes/com/sun/tools/javac/tree/Pretty.java
src/share/classes/com/sun/tools/javac/tree/Pretty.java
+46
-44
src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
+1
-1
src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
+309
-299
src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
+3
-3
src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
+3
-2
src/share/classes/com/sun/tools/javadoc/JavadocTool.java
src/share/classes/com/sun/tools/javadoc/JavadocTool.java
+1
-1
test/Makefile
test/Makefile
+22
-9
test/tools/javac/depDocComment/DeprecatedDocComment4.java
test/tools/javac/depDocComment/DeprecatedDocComment4.java
+20
-0
test/tools/javac/depDocComment/DeprecatedDocComment4.out
test/tools/javac/depDocComment/DeprecatedDocComment4.out
+6
-0
test/tools/javac/failover/CheckAttributedTree.java
test/tools/javac/failover/CheckAttributedTree.java
+11
-28
test/tools/javac/tree/AbstractTreeScannerTest.java
test/tools/javac/tree/AbstractTreeScannerTest.java
+2
-2
test/tools/javac/tree/TreePosTest.java
test/tools/javac/tree/TreePosTest.java
+24
-46
未找到文件。
src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
浏览文件 @
b46865f7
...
...
@@ -325,7 +325,7 @@ public class JavacTaskImpl extends JavacTask {
ListBuffer
<
TypeElement
>
elements
=
new
ListBuffer
<
TypeElement
>();
for
(
JCCompilationUnit
unit
:
units
)
{
for
(
JCTree
node
:
unit
.
defs
)
{
if
(
node
.
getTag
()
==
JCTree
.
CLASSDEF
)
{
if
(
node
.
hasTag
(
JCTree
.
Tag
.
CLASSDEF
)
)
{
JCClassDecl
cdef
=
(
JCClassDecl
)
node
;
if
(
cdef
.
sym
!=
null
)
// maybe null if errors in anno processing
elements
.
append
(
cdef
.
sym
);
...
...
@@ -383,12 +383,12 @@ public class JavacTaskImpl extends JavacTask {
private
void
handleFlowResults
(
Queue
<
Env
<
AttrContext
>>
queue
,
ListBuffer
<
Element
>
elems
)
{
for
(
Env
<
AttrContext
>
env:
queue
)
{
switch
(
env
.
tree
.
getTag
())
{
case
JCTree
.
CLASSDEF
:
case
CLASSDEF:
JCClassDecl
cdef
=
(
JCClassDecl
)
env
.
tree
;
if
(
cdef
.
sym
!=
null
)
elems
.
append
(
cdef
.
sym
);
break
;
case
JCTree
.
TOPLEVEL
:
case
TOPLEVEL:
JCCompilationUnit
unit
=
(
JCCompilationUnit
)
env
.
tree
;
if
(
unit
.
packge
!=
null
)
elems
.
append
(
unit
.
packge
);
...
...
src/share/classes/com/sun/tools/javac/api/JavacTrees.java
浏览文件 @
b46865f7
...
...
@@ -207,7 +207,7 @@ public class JavacTrees extends Trees {
if
(
sym
==
null
&&
TreeInfo
.
isDeclaration
(
tree
))
{
for
(
TreePath
p
=
path
;
p
!=
null
;
p
=
p
.
getParentPath
())
{
JCTree
t
=
(
JCTree
)
p
.
getLeaf
();
if
(
t
.
getTag
()
==
JCTree
.
CLASSDEF
)
{
if
(
t
.
hasTag
(
JCTree
.
Tag
.
CLASSDEF
)
)
{
JCClassDecl
ct
=
(
JCClassDecl
)
t
;
if
(
ct
.
sym
!=
null
)
{
if
((
ct
.
sym
.
flags_field
&
Flags
.
UNATTRIBUTED
)
!=
0
)
{
...
...
src/share/classes/com/sun/tools/javac/comp/Annotate.java
浏览文件 @
b46865f7
/*
* 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
...
...
@@ -31,6 +31,8 @@ import com.sun.tools.javac.code.Symbol.*;
import
com.sun.tools.javac.tree.*
;
import
com.sun.tools.javac.tree.JCTree.*
;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/** Enter annotations on symbols. Annotations accumulate in a queue,
* which is processed at the top level of any set of recursive calls
* requesting it be processed.
...
...
@@ -148,7 +150,7 @@ public class Annotate {
return
new
Attribute
.
Compound
(
a
.
type
,
List
.<
Pair
<
MethodSymbol
,
Attribute
>>
nil
());
}
List
<
JCExpression
>
args
=
a
.
args
;
if
(
args
.
length
()
==
1
&&
args
.
head
.
getTag
()
!=
JCTree
.
ASSIGN
)
{
if
(
args
.
length
()
==
1
&&
!
args
.
head
.
hasTag
(
ASSIGN
)
)
{
// special case: elided "value=" assumed
args
.
head
=
make
.
at
(
args
.
head
.
pos
).
Assign
(
make
.
Ident
(
names
.
value
),
args
.
head
);
...
...
@@ -157,12 +159,12 @@ public class Annotate {
new
ListBuffer
<
Pair
<
MethodSymbol
,
Attribute
>>();
for
(
List
<
JCExpression
>
tl
=
args
;
tl
.
nonEmpty
();
tl
=
tl
.
tail
)
{
JCExpression
t
=
tl
.
head
;
if
(
t
.
getTag
()
!=
JCTree
.
ASSIGN
)
{
if
(
!
t
.
hasTag
(
ASSIGN
)
)
{
log
.
error
(
t
.
pos
(),
"annotation.value.must.be.name.value"
);
continue
;
}
JCAssign
assign
=
(
JCAssign
)
t
;
if
(
assign
.
lhs
.
getTag
()
!=
JCTree
.
IDENT
)
{
if
(
!
assign
.
lhs
.
hasTag
(
IDENT
)
)
{
log
.
error
(
t
.
pos
(),
"annotation.value.must.be.name.value"
);
continue
;
}
...
...
@@ -222,14 +224,14 @@ public class Annotate {
(((
JCFieldAccess
)
tree
).
selected
).
type
);
}
if
((
expected
.
tsym
.
flags
()
&
Flags
.
ANNOTATION
)
!=
0
)
{
if
(
tree
.
getTag
()
!=
JCTree
.
ANNOTATION
)
{
if
(
!
tree
.
hasTag
(
ANNOTATION
)
)
{
log
.
error
(
tree
.
pos
(),
"annotation.value.must.be.annotation"
);
expected
=
syms
.
errorType
;
}
return
enterAnnotation
((
JCAnnotation
)
tree
,
expected
,
env
);
}
if
(
expected
.
tag
==
TypeTags
.
ARRAY
)
{
// should really be isArray()
if
(
tree
.
getTag
()
!=
JCTree
.
NEWARRAY
)
{
if
(
!
tree
.
hasTag
(
NEWARRAY
)
)
{
tree
=
make
.
at
(
tree
.
pos
).
NewArray
(
null
,
List
.<
JCExpression
>
nil
(),
List
.
of
(
tree
));
}
...
...
src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
b46865f7
...
...
@@ -49,8 +49,13 @@ import com.sun.source.tree.TreeVisitor;
import
com.sun.source.util.SimpleTreeVisitor
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.
ANNOTATION
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.
BLOCK
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Kinds
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Kinds
.
ERRONEOUS
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.
WILDCARD
;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/** This is the main context-dependent analysis phase in GJC. It
* encompasses name resolution, type checking and constant folding as
...
...
@@ -245,7 +250,7 @@ public class Attr extends JCTree.Visitor {
((
v
.
flags
()
&
HASINIT
)
!=
0
||
!((
base
==
null
||
(
base
.
getTag
()
==
JCTree
.
IDENT
&&
TreeInfo
.
name
(
base
)
==
names
.
_this
))
&&
(
base
.
hasTag
(
IDENT
)
&&
TreeInfo
.
name
(
base
)
==
names
.
_this
))
&&
isAssignableAsBlankFinal
(
v
,
env
))))
{
if
(
v
.
isResourceVariable
())
{
//TWR resource
log
.
error
(
pos
,
"try.resource.may.not.be.assigned"
,
v
);
...
...
@@ -263,7 +268,7 @@ public class Attr extends JCTree.Visitor {
* @param tree The candidate tree.
*/
boolean
isStaticReference
(
JCTree
tree
)
{
if
(
tree
.
getTag
()
==
JCTree
.
SELECT
)
{
if
(
tree
.
hasTag
(
SELECT
)
)
{
Symbol
lsym
=
TreeInfo
.
symbol
(((
JCFieldAccess
)
tree
).
selected
);
if
(
lsym
==
null
||
lsym
.
kind
!=
TYP
)
{
return
false
;
...
...
@@ -693,7 +698,7 @@ public class Attr extends JCTree.Visitor {
// disable implicit outer instance from being passed.
// (This would be an illegal access to "this before super").
if
(
env
.
info
.
isSelfCall
&&
env
.
tree
.
getTag
()
==
JCTree
.
NEWCLASS
&&
env
.
tree
.
hasTag
(
NEWCLASS
)
&&
((
JCNewClass
)
env
.
tree
).
encl
==
null
)
{
c
.
flags_field
|=
NOOUTERTHIS
;
...
...
@@ -863,7 +868,7 @@ public class Attr extends JCTree.Visitor {
chk
.
checkDeprecatedAnnotation
(
tree
.
pos
(),
v
);
if
(
tree
.
init
!=
null
)
{
if
((
v
.
flags_field
&
FINAL
)
!=
0
&&
tree
.
init
.
getTag
()
!=
JCTree
.
NEWCLASS
)
{
if
((
v
.
flags_field
&
FINAL
)
!=
0
&&
!
tree
.
init
.
hasTag
(
NEWCLASS
)
)
{
// In this case, `v' is final. Ensure that it's initializer is
// evaluated.
v
.
getConstValue
();
// ensure initializer is evaluated
...
...
@@ -971,8 +976,8 @@ public class Attr extends JCTree.Visitor {
public
void
visitLabelled
(
JCLabeledStatement
tree
)
{
// Check that label is not used in an enclosing statement
Env
<
AttrContext
>
env1
=
env
;
while
(
env1
!=
null
&&
env1
.
tree
.
getTag
()
!=
JCTree
.
CLASSDEF
)
{
if
(
env1
.
tree
.
getTag
()
==
JCTree
.
LABELLED
&&
while
(
env1
!=
null
&&
!
env1
.
tree
.
hasTag
(
CLASSDEF
)
)
{
if
(
env1
.
tree
.
hasTag
(
LABELLED
)
&&
((
JCLabeledStatement
)
env1
.
tree
).
label
==
tree
.
label
)
{
log
.
error
(
tree
.
pos
(),
"label.already.in.use"
,
tree
.
label
);
...
...
@@ -1052,14 +1057,14 @@ public class Attr extends JCTree.Visitor {
private
static
void
addVars
(
List
<
JCStatement
>
stats
,
Scope
switchScope
)
{
for
(;
stats
.
nonEmpty
();
stats
=
stats
.
tail
)
{
JCTree
stat
=
stats
.
head
;
if
(
stat
.
getTag
()
==
JCTree
.
VARDEF
)
if
(
stat
.
hasTag
(
VARDEF
)
)
switchScope
.
enter
(((
JCVariableDecl
)
stat
).
sym
);
}
}
// where
/** Return the selected enumeration constant symbol, or null. */
private
Symbol
enumConstant
(
JCTree
tree
,
Type
enumType
)
{
if
(
tree
.
getTag
()
!=
JCTree
.
IDENT
)
{
if
(
!
tree
.
hasTag
(
IDENT
)
)
{
log
.
error
(
tree
.
pos
(),
"enum.label.must.be.unqualified.enum"
);
return
syms
.
errSymbol
;
}
...
...
@@ -1094,7 +1099,7 @@ public class Attr extends JCTree.Visitor {
localEnv
;
// Attribute resource declarations
for
(
JCTree
resource
:
tree
.
resources
)
{
if
(
resource
.
getTag
()
==
JCTree
.
VARDEF
)
{
if
(
resource
.
hasTag
(
VARDEF
)
)
{
attribStat
(
resource
,
tryEnv
);
chk
.
checkType
(
resource
,
resource
.
type
,
syms
.
autoCloseableType
,
"try.not.applicable.to.type"
);
...
...
@@ -1312,7 +1317,7 @@ public class Attr extends JCTree.Visitor {
* @param env The environment current at the jump statement.
*/
private
JCTree
findJumpTarget
(
DiagnosticPosition
pos
,
int
tag
,
JCTree
.
Tag
tag
,
Name
label
,
Env
<
AttrContext
>
env
)
{
// Search environments outwards from the point of jump.
...
...
@@ -1320,15 +1325,15 @@ public class Attr extends JCTree.Visitor {
LOOP:
while
(
env1
!=
null
)
{
switch
(
env1
.
tree
.
getTag
())
{
case
JCTree
.
LABELLED
:
case
LABELLED:
JCLabeledStatement
labelled
=
(
JCLabeledStatement
)
env1
.
tree
;
if
(
label
==
labelled
.
label
)
{
// If jump is a continue, check that target is a loop.
if
(
tag
==
JCTree
.
CONTINUE
)
{
if
(
labelled
.
body
.
getTag
()
!=
JCTree
.
DOLOOP
&&
labelled
.
body
.
getTag
()
!=
JCTree
.
WHILELOOP
&&
labelled
.
body
.
getTag
()
!=
JCTree
.
FORLOOP
&&
labelled
.
body
.
getTag
()
!=
JCTree
.
FOREACHLOOP
)
if
(
tag
==
CONTINUE
)
{
if
(
!
labelled
.
body
.
hasTag
(
DOLOOP
)
&&
!
labelled
.
body
.
hasTag
(
WHILELOOP
)
&&
!
labelled
.
body
.
hasTag
(
FORLOOP
)
&&
!
labelled
.
body
.
hasTag
(
FOREACHLOOP
)
)
log
.
error
(
pos
,
"not.loop.label"
,
label
);
// Found labelled statement target, now go inwards
// to next non-labelled tree.
...
...
@@ -1338,17 +1343,17 @@ public class Attr extends JCTree.Visitor {
}
}
break
;
case
JCTree
.
DOLOOP
:
case
JCTree
.
WHILELOOP
:
case
JCTree
.
FORLOOP
:
case
JCTree
.
FOREACHLOOP
:
case
DOLOOP:
case
WHILELOOP:
case
FORLOOP:
case
FOREACHLOOP:
if
(
label
==
null
)
return
env1
.
tree
;
break
;
case
JCTree
.
SWITCH
:
if
(
label
==
null
&&
tag
==
JCTree
.
BREAK
)
return
env1
.
tree
;
case
SWITCH:
if
(
label
==
null
&&
tag
==
BREAK
)
return
env1
.
tree
;
break
;
case
JCTree
.
METHODDEF
:
case
JCTree
.
CLASSDEF
:
case
METHODDEF:
case
CLASSDEF:
break
LOOP
;
default
:
}
...
...
@@ -1356,7 +1361,7 @@ public class Attr extends JCTree.Visitor {
}
if
(
label
!=
null
)
log
.
error
(
pos
,
"undef.label"
,
label
);
else
if
(
tag
==
JCTree
.
CONTINUE
)
else
if
(
tag
==
CONTINUE
)
log
.
error
(
pos
,
"cont.outside.loop"
);
else
log
.
error
(
pos
,
"break.outside.switch.loop"
);
...
...
@@ -1452,7 +1457,7 @@ public class Attr extends JCTree.Visitor {
if
(
encl
.
tag
==
CLASS
)
{
// we are calling a nested class
if
(
tree
.
meth
.
getTag
()
==
JCTree
.
SELECT
)
{
if
(
tree
.
meth
.
hasTag
(
SELECT
)
)
{
JCTree
qualifier
=
((
JCFieldAccess
)
tree
.
meth
).
selected
;
// We are seeing a prefixed call, of the form
...
...
@@ -1468,7 +1473,7 @@ public class Attr extends JCTree.Visitor {
rs
.
resolveImplicitThis
(
tree
.
meth
.
pos
(),
localEnv
,
site
,
true
);
}
}
else
if
(
tree
.
meth
.
getTag
()
==
JCTree
.
SELECT
)
{
}
else
if
(
tree
.
meth
.
hasTag
(
SELECT
)
)
{
log
.
error
(
tree
.
meth
.
pos
(),
"illegal.qual.not.icls"
,
site
.
tsym
);
}
...
...
@@ -1522,7 +1527,7 @@ public class Attr extends JCTree.Visitor {
// as a special case, array.clone() has a result that is
// the same as static type of the array being cloned
if
(
tree
.
meth
.
getTag
()
==
JCTree
.
SELECT
&&
if
(
tree
.
meth
.
hasTag
(
SELECT
)
&&
allowCovariantReturns
&&
methName
==
names
.
clone
&&
types
.
isArray
(((
JCFieldAccess
)
tree
.
meth
).
selected
.
type
))
...
...
@@ -1531,7 +1536,7 @@ public class Attr extends JCTree.Visitor {
// as a special case, x.getClass() has type Class<? extends |X|>
if
(
allowGenerics
&&
methName
==
names
.
getClass
&&
tree
.
args
.
isEmpty
())
{
Type
qualifier
=
(
tree
.
meth
.
getTag
()
==
JCTree
.
SELECT
)
Type
qualifier
=
(
tree
.
meth
.
hasTag
(
SELECT
)
)
?
((
JCFieldAccess
)
tree
.
meth
).
selected
.
type
:
env
.
enclClass
.
sym
.
type
;
restype
=
new
...
...
@@ -1560,7 +1565,7 @@ public class Attr extends JCTree.Visitor {
JCMethodDecl
enclMethod
=
env
.
enclMethod
;
if
(
enclMethod
!=
null
&&
enclMethod
.
name
==
names
.
init
)
{
JCBlock
body
=
enclMethod
.
body
;
if
(
body
.
stats
.
head
.
getTag
()
==
JCTree
.
EXEC
&&
if
(
body
.
stats
.
head
.
hasTag
(
EXEC
)
&&
((
JCExpressionStatement
)
body
.
stats
.
head
).
expr
==
tree
)
return
true
;
}
...
...
@@ -1591,7 +1596,7 @@ public class Attr extends JCTree.Visitor {
// complete class name to be fully qualified
JCExpression
clazz
=
tree
.
clazz
;
// Class field following new
JCExpression
clazzid
=
// Identifier in class field
(
clazz
.
getTag
()
==
JCTree
.
TYPEAPPLY
)
(
clazz
.
hasTag
(
TYPEAPPLY
)
)
?
((
JCTypeApply
)
clazz
).
clazz
:
clazz
;
...
...
@@ -1610,7 +1615,7 @@ public class Attr extends JCTree.Visitor {
attribExpr
(
tree
.
encl
,
env
));
clazzid1
=
make
.
at
(
clazz
.
pos
).
Select
(
make
.
Type
(
encltype
),
((
JCIdent
)
clazzid
).
name
);
if
(
clazz
.
getTag
()
==
JCTree
.
TYPEAPPLY
)
if
(
clazz
.
hasTag
(
TYPEAPPLY
)
)
clazz
=
make
.
at
(
tree
.
pos
).
TypeApply
(
clazzid1
,
((
JCTypeApply
)
clazz
).
arguments
);
...
...
@@ -1689,7 +1694,7 @@ public class Attr extends JCTree.Visitor {
// Enums may not be instantiated except implicitly
if
(
allowEnums
&&
(
clazztype
.
tsym
.
flags_field
&
Flags
.
ENUM
)
!=
0
&&
(
env
.
tree
.
getTag
()
!=
JCTree
.
VARDEF
||
(
!
env
.
tree
.
hasTag
(
VARDEF
)
||
(((
JCVariableDecl
)
env
.
tree
).
mods
.
flags
&
Flags
.
ENUM
)
==
0
||
((
JCVariableDecl
)
env
.
tree
).
init
!=
tree
))
log
.
error
(
tree
.
pos
(),
"enum.cant.be.instantiated"
);
...
...
@@ -1930,7 +1935,7 @@ public class Attr extends JCTree.Visitor {
Name
name
=
TreeInfo
.
name
(
arg
);
if
(
name
==
names
.
_this
||
name
==
names
.
_super
)
return
arg
;
int
optag
=
JCTree
.
NULLCHK
;
JCTree
.
Tag
optag
=
NULLCHK
;
JCUnary
tree
=
make
.
at
(
arg
.
pos
).
Unary
(
optag
,
arg
);
tree
.
operator
=
syms
.
nullcheck
;
tree
.
type
=
arg
.
type
;
...
...
@@ -1991,7 +1996,7 @@ public class Attr extends JCTree.Visitor {
Type
operand
=
attribExpr
(
tree
.
rhs
,
env
);
// Find operator.
Symbol
operator
=
tree
.
operator
=
rs
.
resolveBinaryOperator
(
tree
.
pos
(),
tree
.
getTag
()
-
JCTree
.
ASGOffset
,
env
,
tree
.
pos
(),
tree
.
getTag
()
.
noAssignOp
()
,
env
,
owntype
,
operand
);
if
(
operator
.
kind
==
MTH
&&
...
...
@@ -1999,7 +2004,7 @@ public class Attr extends JCTree.Visitor {
!
operand
.
isErroneous
())
{
chk
.
checkOperator
(
tree
.
pos
(),
(
OperatorSymbol
)
operator
,
tree
.
getTag
()
-
JCTree
.
ASGOffset
,
tree
.
getTag
()
.
noAssignOp
()
,
owntype
,
operand
);
chk
.
checkDivZero
(
tree
.
rhs
.
pos
(),
operator
,
operand
);
...
...
@@ -2012,7 +2017,7 @@ public class Attr extends JCTree.Visitor {
public
void
visitUnary
(
JCUnary
tree
)
{
// Attribute arguments.
Type
argtype
=
(
JCTree
.
PREINC
<=
tree
.
getTag
()
&&
tree
.
getTag
()
<=
JCTree
.
POSTDEC
)
Type
argtype
=
(
tree
.
getTag
().
isIncOrDecUnaryOp
()
)
?
attribTree
(
tree
.
arg
,
env
,
VAR
,
Type
.
noType
)
:
chk
.
checkNonVoid
(
tree
.
arg
.
pos
(),
attribExpr
(
tree
.
arg
,
env
));
...
...
@@ -2023,7 +2028,7 @@ public class Attr extends JCTree.Visitor {
Type
owntype
=
types
.
createErrorType
(
tree
.
type
);
if
(
operator
.
kind
==
MTH
&&
!
argtype
.
isErroneous
())
{
owntype
=
(
JCTree
.
PREINC
<=
tree
.
getTag
()
&&
tree
.
getTag
()
<=
JCTree
.
POSTDEC
)
owntype
=
(
tree
.
getTag
().
isIncOrDecUnaryOp
()
)
?
tree
.
arg
.
type
:
operator
.
type
.
getReturnType
();
int
opc
=
((
OperatorSymbol
)
operator
).
opcode
;
...
...
@@ -2621,7 +2626,7 @@ public class Attr extends JCTree.Visitor {
canOwnInitializer
(
env
.
info
.
scope
.
owner
)
&&
v
.
owner
==
env
.
info
.
scope
.
owner
.
enclClass
()
&&
((
v
.
flags
()
&
STATIC
)
!=
0
)
==
Resolve
.
isStatic
(
env
)
&&
(
env
.
tree
.
getTag
()
!=
JCTree
.
ASSIGN
||
(
!
env
.
tree
.
hasTag
(
ASSIGN
)
||
TreeInfo
.
skipParens
(((
JCAssign
)
env
.
tree
).
lhs
)
!=
tree
))
{
String
suffix
=
(
env
.
info
.
enclVar
==
v
)
?
"self.ref"
:
"forward.ref"
;
...
...
@@ -2812,10 +2817,10 @@ public class Attr extends JCTree.Visitor {
}
Type
elemtype
=
types
.
elemtype
(
argtype
);
switch
(
tree
.
getTag
())
{
case
JCTree
.
APPLY
:
case
APPLY:
((
JCMethodInvocation
)
tree
).
varargsElement
=
elemtype
;
break
;
case
JCTree
.
NEWCLASS
:
case
NEWCLASS:
((
JCNewClass
)
tree
).
varargsElement
=
elemtype
;
break
;
default
:
...
...
@@ -2896,9 +2901,9 @@ public class Attr extends JCTree.Visitor {
if
(
clazzOuter
.
tag
==
CLASS
)
{
Type
site
;
JCExpression
clazz
=
TreeInfo
.
typeIn
(
tree
.
clazz
);
if
(
clazz
.
getTag
()
==
JCTree
.
IDENT
)
{
if
(
clazz
.
hasTag
(
IDENT
)
)
{
site
=
env
.
enclClass
.
sym
.
type
;
}
else
if
(
clazz
.
getTag
()
==
JCTree
.
SELECT
)
{
}
else
if
(
clazz
.
hasTag
(
SELECT
)
)
{
site
=
((
JCFieldAccess
)
clazz
).
selected
.
type
;
}
else
throw
new
AssertionError
(
""
+
tree
);
if
(
clazzOuter
.
tag
==
CLASS
&&
site
!=
clazzOuter
)
{
...
...
@@ -3068,7 +3073,7 @@ public class Attr extends JCTree.Visitor {
* Attribute an env for either a top level tree or class declaration.
*/
public
void
attrib
(
Env
<
AttrContext
>
env
)
{
if
(
env
.
tree
.
getTag
()
==
JCTree
.
TOPLEVEL
)
if
(
env
.
tree
.
hasTag
(
TOPLEVEL
)
)
attribTopLevel
(
env
);
else
attribClass
(
env
.
tree
.
pos
(),
env
.
enclClass
.
sym
);
...
...
@@ -3245,7 +3250,7 @@ public class Attr extends JCTree.Visitor {
((
c
.
flags
()
&
STATIC
)
==
0
||
c
.
name
==
names
.
empty
)
&&
(
TreeInfo
.
flags
(
l
.
head
)
&
(
STATIC
|
INTERFACE
))
!=
0
)
{
Symbol
sym
=
null
;
if
(
l
.
head
.
getTag
()
==
JCTree
.
VARDEF
)
sym
=
((
JCVariableDecl
)
l
.
head
).
sym
;
if
(
l
.
head
.
hasTag
(
VARDEF
)
)
sym
=
((
JCVariableDecl
)
l
.
head
).
sym
;
if
(
sym
==
null
||
sym
.
kind
!=
VAR
||
((
VarSymbol
)
sym
).
getConstValue
()
==
null
)
...
...
src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
b46865f7
...
...
@@ -42,10 +42,14 @@ import com.sun.tools.javac.code.Type.*;
import
com.sun.tools.javac.code.Symbol.*
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.
ANNOTATION
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.
SYNCHRONIZED
;
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.
*
...
...
@@ -987,7 +991,7 @@ public class Check {
* <i>not</i> final.
*/
private
long
implicitEnumFinalFlag
(
JCTree
tree
)
{
if
(
tree
.
getTag
()
!=
JCTree
.
CLASSDEF
)
return
0
;
if
(
!
tree
.
hasTag
(
CLASSDEF
)
)
return
0
;
class
SpecialTreeVisitor
extends
JCTree
.
Visitor
{
boolean
specialized
;
SpecialTreeVisitor
()
{
...
...
@@ -1099,7 +1103,7 @@ public class Check {
// not parameterized at all.
if
(
tree
.
type
.
getEnclosingType
().
isRaw
())
log
.
error
(
tree
.
pos
(),
"improperly.formed.type.inner.raw.param"
);
if
(
tree
.
clazz
.
getTag
()
==
JCTree
.
SELECT
)
if
(
tree
.
clazz
.
hasTag
(
SELECT
)
)
visitSelectInternal
((
JCFieldAccess
)
tree
.
clazz
);
}
}
...
...
@@ -2413,7 +2417,7 @@ public class Check {
// count them off as they're annotated
for
(
JCTree
arg
:
a
.
args
)
{
if
(
arg
.
getTag
()
!=
JCTree
.
ASSIGN
)
continue
;
// recovery
if
(
!
arg
.
hasTag
(
ASSIGN
)
)
continue
;
// recovery
JCAssign
assign
=
(
JCAssign
)
arg
;
Symbol
m
=
TreeInfo
.
symbol
(
assign
.
lhs
);
if
(
m
==
null
||
m
.
type
.
isErroneous
())
continue
;
...
...
@@ -2442,12 +2446,12 @@ public class Check {
a
.
args
.
tail
==
null
)
return
;
if
(
a
.
args
.
head
.
getTag
()
!=
JCTree
.
ASSIGN
)
return
;
// error recovery
if
(
!
a
.
args
.
head
.
hasTag
(
ASSIGN
)
)
return
;
// error recovery
JCAssign
assign
=
(
JCAssign
)
a
.
args
.
head
;
Symbol
m
=
TreeInfo
.
symbol
(
assign
.
lhs
);
if
(
m
.
name
!=
names
.
value
)
return
;
JCTree
rhs
=
assign
.
rhs
;
if
(
rhs
.
getTag
()
!=
JCTree
.
NEWARRAY
)
return
;
if
(
!
rhs
.
hasTag
(
NEWARRAY
)
)
return
;
JCNewArray
na
=
(
JCNewArray
)
rhs
;
Set
<
Symbol
>
targets
=
new
HashSet
<
Symbol
>();
for
(
JCTree
elem
:
na
.
elems
)
{
...
...
@@ -2506,7 +2510,7 @@ public class Check {
try
{
tree
.
sym
.
flags_field
|=
LOCKED
;
for
(
JCTree
def
:
tree
.
defs
)
{
if
(
def
.
getTag
()
!=
JCTree
.
METHODDEF
)
continue
;
if
(
!
def
.
hasTag
(
METHODDEF
)
)
continue
;
JCMethodDecl
meth
=
(
JCMethodDecl
)
def
;
checkAnnotationResType
(
meth
.
pos
(),
meth
.
restype
.
type
);
}
...
...
@@ -2614,7 +2618,7 @@ public class Check {
*/
int
checkOperator
(
DiagnosticPosition
pos
,
OperatorSymbol
operator
,
int
tag
,
JCTree
.
Tag
tag
,
Type
left
,
Type
right
)
{
if
(
operator
.
opcode
==
ByteCodes
.
error
)
{
...
...
@@ -2650,7 +2654,8 @@ public class Check {
* Check for empty statements after if
*/
void
checkEmptyIf
(
JCIf
tree
)
{
if
(
tree
.
thenpart
.
getTag
()
==
JCTree
.
SKIP
&&
tree
.
elsepart
==
null
&&
lint
.
isEnabled
(
LintCategory
.
EMPTY
))
if
(
tree
.
thenpart
.
hasTag
(
SKIP
)
&&
tree
.
elsepart
==
null
&&
lint
.
isEnabled
(
LintCategory
.
EMPTY
))
log
.
warning
(
LintCategory
.
EMPTY
,
tree
.
thenpart
.
pos
(),
"empty.if"
);
}
...
...
@@ -2754,7 +2759,7 @@ public class Check {
}
// where
private
boolean
isCanonical
(
JCTree
tree
)
{
while
(
tree
.
getTag
()
==
JCTree
.
SELECT
)
{
while
(
tree
.
hasTag
(
SELECT
)
)
{
JCFieldAccess
s
=
(
JCFieldAccess
)
tree
;
if
(
s
.
sym
.
owner
!=
TreeInfo
.
symbol
(
s
.
selected
))
return
false
;
...
...
src/share/classes/com/sun/tools/javac/comp/Enter.java
浏览文件 @
b46865f7
...
...
@@ -228,7 +228,7 @@ public class Enter extends JCTree.Visitor {
* only, and members go into the class member scope.
*/
Scope
enterScope
(
Env
<
AttrContext
>
env
)
{
return
(
env
.
tree
.
getTag
()
==
JCTree
.
CLASSDEF
)
return
(
env
.
tree
.
hasTag
(
JCTree
.
Tag
.
CLASSDEF
)
)
?
((
JCClassDecl
)
env
.
tree
).
sym
.
members_field
:
env
.
info
.
scope
;
}
...
...
src/share/classes/com/sun/tools/javac/comp/Env.java
浏览文件 @
b46865f7
/*
* Copyright (c) 1999, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
...
...
@@ -116,9 +116,9 @@ public class Env<A> implements Iterable<Env<A>> {
/** Return closest enclosing environment which points to a tree with given tag.
*/
public
Env
<
A
>
enclosing
(
int
tag
)
{
public
Env
<
A
>
enclosing
(
JCTree
.
Tag
tag
)
{
Env
<
A
>
env1
=
this
;
while
(
env1
!=
null
&&
env1
.
tree
.
getTag
()
!=
tag
)
env1
=
env1
.
next
;
while
(
env1
!=
null
&&
!
env1
.
tree
.
hasTag
(
tag
)
)
env1
=
env1
.
next
;
return
env1
;
}
...
...
src/share/classes/com/sun/tools/javac/comp/Flow.java
浏览文件 @
b46865f7
...
...
@@ -40,8 +40,10 @@ import com.sun.tools.javac.code.Symbol.*;
import
com.sun.tools.javac.tree.JCTree.*
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.
BLOCK
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Kinds
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/** This pass implements dataflow analysis for Java programs.
* Liveness analysis checks that every statement is reachable.
...
...
@@ -321,7 +323,7 @@ public class Flow extends TreeScanner {
log
.
error
(
exit
.
tree
.
pos
(),
"unreported.exception.default.constructor"
,
exit
.
thrown
);
}
else
if
(
exit
.
tree
.
getTag
()
==
JCTree
.
VARDEF
&&
}
else
if
(
exit
.
tree
.
hasTag
(
VARDEF
)
&&
((
JCVariableDecl
)
exit
.
tree
).
sym
.
isResourceVariable
())
{
log
.
error
(
exit
.
tree
.
pos
(),
"unreported.exception.implicit.close"
,
...
...
@@ -416,7 +418,7 @@ public class Flow extends TreeScanner {
*/
void
letInit
(
JCTree
tree
)
{
tree
=
TreeInfo
.
skipParens
(
tree
);
if
(
tree
.
getTag
()
==
JCTree
.
IDENT
||
tree
.
getTag
()
==
JCTree
.
SELECT
)
{
if
(
tree
.
hasTag
(
IDENT
)
||
tree
.
hasTag
(
SELECT
)
)
{
Symbol
sym
=
TreeInfo
.
symbol
(
tree
);
if
(
sym
.
kind
==
VAR
)
{
letInit
(
tree
.
pos
(),
(
VarSymbol
)
sym
);
...
...
@@ -452,7 +454,7 @@ public class Flow extends TreeScanner {
pendingExits
=
oldPendingExits
;
for
(;
exits
.
nonEmpty
();
exits
=
exits
.
tail
)
{
PendingExit
exit
=
exits
.
head
;
if
(
exit
.
tree
.
getTag
()
==
JCTree
.
BREAK
&&
if
(
exit
.
tree
.
hasTag
(
BREAK
)
&&
((
JCBreak
)
exit
.
tree
).
target
==
tree
)
{
inits
.
andSet
(
exit
.
inits
);
uninits
.
andSet
(
exit
.
uninits
);
...
...
@@ -471,7 +473,7 @@ public class Flow extends TreeScanner {
pendingExits
=
new
ListBuffer
<
PendingExit
>();
for
(;
exits
.
nonEmpty
();
exits
=
exits
.
tail
)
{
PendingExit
exit
=
exits
.
head
;
if
(
exit
.
tree
.
getTag
()
==
JCTree
.
CONTINUE
&&
if
(
exit
.
tree
.
hasTag
(
CONTINUE
)
&&
((
JCContinue
)
exit
.
tree
).
target
==
tree
)
{
inits
.
andSet
(
exit
.
inits
);
uninits
.
andSet
(
exit
.
uninits
);
...
...
@@ -517,7 +519,7 @@ public class Flow extends TreeScanner {
*/
void
scanDef
(
JCTree
tree
)
{
scanStat
(
tree
);
if
(
tree
!=
null
&&
tree
.
getTag
()
==
JCTree
.
BLOCK
&&
!
alive
)
{
if
(
tree
!=
null
&&
tree
.
hasTag
(
JCTree
.
Tag
.
BLOCK
)
&&
!
alive
)
{
log
.
error
(
tree
.
pos
(),
"initializer.must.be.able.to.complete.normally"
);
}
...
...
@@ -528,7 +530,7 @@ public class Flow extends TreeScanner {
void
scanStat
(
JCTree
tree
)
{
if
(!
alive
&&
tree
!=
null
)
{
log
.
error
(
tree
.
pos
(),
"unreachable.stmt"
);
if
(
tree
.
getTag
()
!=
JCTree
.
SKIP
)
alive
=
true
;
if
(
!
tree
.
hasTag
(
SKIP
)
)
alive
=
true
;
}
scan
(
tree
);
}
...
...
@@ -614,7 +616,7 @@ public class Flow extends TreeScanner {
try
{
// define all the static fields
for
(
List
<
JCTree
>
l
=
tree
.
defs
;
l
.
nonEmpty
();
l
=
l
.
tail
)
{
if
(
l
.
head
.
getTag
()
==
JCTree
.
VARDEF
)
{
if
(
l
.
head
.
hasTag
(
VARDEF
)
)
{
JCVariableDecl
def
=
(
JCVariableDecl
)
l
.
head
;
if
((
def
.
mods
.
flags
&
STATIC
)
!=
0
)
{
VarSymbol
sym
=
def
.
sym
;
...
...
@@ -626,7 +628,7 @@ public class Flow extends TreeScanner {
// process all the static initializers
for
(
List
<
JCTree
>
l
=
tree
.
defs
;
l
.
nonEmpty
();
l
=
l
.
tail
)
{
if
(
l
.
head
.
getTag
()
!=
JCTree
.
METHODDEF
&&
if
(
!
l
.
head
.
hasTag
(
METHODDEF
)
&&
(
TreeInfo
.
flags
(
l
.
head
)
&
STATIC
)
!=
0
)
{
scanDef
(
l
.
head
);
errorUncaught
();
...
...
@@ -653,7 +655,7 @@ public class Flow extends TreeScanner {
// define all the instance fields
for
(
List
<
JCTree
>
l
=
tree
.
defs
;
l
.
nonEmpty
();
l
=
l
.
tail
)
{
if
(
l
.
head
.
getTag
()
==
JCTree
.
VARDEF
)
{
if
(
l
.
head
.
hasTag
(
VARDEF
)
)
{
JCVariableDecl
def
=
(
JCVariableDecl
)
l
.
head
;
if
((
def
.
mods
.
flags
&
STATIC
)
==
0
)
{
VarSymbol
sym
=
def
.
sym
;
...
...
@@ -665,7 +667,7 @@ public class Flow extends TreeScanner {
// process all the instance initializers
for
(
List
<
JCTree
>
l
=
tree
.
defs
;
l
.
nonEmpty
();
l
=
l
.
tail
)
{
if
(
l
.
head
.
getTag
()
!=
JCTree
.
METHODDEF
&&
if
(
!
l
.
head
.
hasTag
(
METHODDEF
)
&&
(
TreeInfo
.
flags
(
l
.
head
)
&
STATIC
)
==
0
)
{
scanDef
(
l
.
head
);
errorUncaught
();
...
...
@@ -691,7 +693,7 @@ public class Flow extends TreeScanner {
// process all the methods
for
(
List
<
JCTree
>
l
=
tree
.
defs
;
l
.
nonEmpty
();
l
=
l
.
tail
)
{
if
(
l
.
head
.
getTag
()
==
JCTree
.
METHODDEF
)
{
if
(
l
.
head
.
hasTag
(
METHODDEF
)
)
{
scan
(
l
.
head
);
errorUncaught
();
}
...
...
@@ -760,7 +762,7 @@ public class Flow extends TreeScanner {
PendingExit
exit
=
exits
.
head
;
exits
=
exits
.
tail
;
if
(
exit
.
thrown
==
null
)
{
Assert
.
check
(
exit
.
tree
.
getTag
()
==
JCTree
.
RETURN
);
Assert
.
check
(
exit
.
tree
.
hasTag
(
RETURN
)
);
if
(
isInitialConstructor
)
{
inits
=
exit
.
inits
;
for
(
int
i
=
firstadr
;
i
<
nextadr
;
i
++)
...
...
@@ -989,7 +991,7 @@ public class Flow extends TreeScanner {
Bits
uninits
)
{
for
(;
stats
.
nonEmpty
();
stats
=
stats
.
tail
)
{
JCTree
stat
=
stats
.
head
;
if
(
stat
.
getTag
()
==
JCTree
.
VARDEF
)
{
if
(
stat
.
hasTag
(
VARDEF
)
)
{
int
adr
=
((
JCVariableDecl
)
stat
).
sym
.
adr
;
inits
.
excl
(
adr
);
uninits
.
incl
(
adr
);
...
...
@@ -1346,7 +1348,7 @@ public class Flow extends TreeScanner {
public
void
visitUnary
(
JCUnary
tree
)
{
switch
(
tree
.
getTag
())
{
case
JCTree
.
NOT
:
case
NOT:
scanCond
(
tree
.
arg
);
Bits
t
=
initsWhenFalse
;
initsWhenFalse
=
initsWhenTrue
;
...
...
@@ -1355,8 +1357,8 @@ public class Flow extends TreeScanner {
uninitsWhenFalse
=
uninitsWhenTrue
;
uninitsWhenTrue
=
t
;
break
;
case
JCTree
.
PREINC
:
case
JCTree
.
POSTINC
:
case
JCTree
.
PREDEC
:
case
JCTree
.
POSTDEC
:
case
PREINC:
case
POSTINC:
case
PREDEC:
case
POSTDEC:
scanExpr
(
tree
.
arg
);
letInit
(
tree
.
arg
);
break
;
...
...
@@ -1367,7 +1369,7 @@ public class Flow extends TreeScanner {
public
void
visitBinary
(
JCBinary
tree
)
{
switch
(
tree
.
getTag
())
{
case
JCTree
.
AND
:
case
AND:
scanCond
(
tree
.
lhs
);
Bits
initsWhenFalseLeft
=
initsWhenFalse
;
Bits
uninitsWhenFalseLeft
=
uninitsWhenFalse
;
...
...
@@ -1377,7 +1379,7 @@ public class Flow extends TreeScanner {
initsWhenFalse
.
andSet
(
initsWhenFalseLeft
);
uninitsWhenFalse
.
andSet
(
uninitsWhenFalseLeft
);
break
;
case
JCTree
.
OR
:
case
OR:
scanCond
(
tree
.
lhs
);
Bits
initsWhenTrueLeft
=
initsWhenTrue
;
Bits
uninitsWhenTrueLeft
=
uninitsWhenTrue
;
...
...
@@ -1418,7 +1420,7 @@ public class Flow extends TreeScanner {
private
boolean
is292targetTypeCast
(
JCTypeCast
tree
)
{
boolean
is292targetTypeCast
=
false
;
JCExpression
expr
=
TreeInfo
.
skipParens
(
tree
.
expr
);
if
(
expr
.
getTag
()
==
JCTree
.
APPLY
)
{
if
(
expr
.
hasTag
(
APPLY
)
)
{
JCMethodInvocation
apply
=
(
JCMethodInvocation
)
expr
;
Symbol
sym
=
TreeInfo
.
symbol
(
apply
.
meth
);
is292targetTypeCast
=
sym
!=
null
&&
...
...
src/share/classes/com/sun/tools/javac/comp/Infer.java
浏览文件 @
b46865f7
...
...
@@ -633,13 +633,13 @@ public class Infer {
//the polymorphic signature call environment is nested.
switch
(
env
.
next
.
tree
.
getTag
())
{
case
JCTree
.
TYPECAST
:
case
TYPECAST:
JCTypeCast
castTree
=
(
JCTypeCast
)
env
.
next
.
tree
;
restype
=
(
TreeInfo
.
skipParens
(
castTree
.
expr
)
==
env
.
tree
)
?
castTree
.
clazz
.
type
:
syms
.
objectType
;
break
;
case
JCTree
.
EXEC
:
case
EXEC:
JCTree
.
JCExpressionStatement
execTree
=
(
JCTree
.
JCExpressionStatement
)
env
.
next
.
tree
;
restype
=
(
TreeInfo
.
skipParens
(
execTree
.
expr
)
==
env
.
tree
)
?
...
...
src/share/classes/com/sun/tools/javac/comp/Lower.java
浏览文件 @
b46865f7
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
浏览文件 @
b46865f7
...
...
@@ -40,8 +40,10 @@ import com.sun.tools.javac.code.Symbol.*;
import
com.sun.tools.javac.tree.JCTree.*
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.
ANNOTATION
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Kinds
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
import
com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition
;
/** This is the second phase of Enter, in which classes are completed
...
...
@@ -644,7 +646,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
tree
.
sym
=
v
;
if
(
tree
.
init
!=
null
)
{
v
.
flags_field
|=
HASINIT
;
if
((
v
.
flags_field
&
FINAL
)
!=
0
&&
tree
.
init
.
getTag
()
!=
JCTree
.
NEWCLASS
)
{
if
((
v
.
flags_field
&
FINAL
)
!=
0
&&
!
tree
.
init
.
hasTag
(
NEWCLASS
)
)
{
Env
<
AttrContext
>
initEnv
=
getInitEnv
(
tree
,
env
);
initEnv
.
info
.
enclVar
=
v
;
v
.
setLazyConstValue
(
initEnv
(
tree
,
initEnv
),
attr
,
tree
.
init
);
...
...
@@ -868,7 +870,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
// If this is a toplevel-class, make sure any preceding import
// clauses have been seen.
if
(
c
.
owner
.
kind
==
PCK
)
{
memberEnter
(
env
.
toplevel
,
env
.
enclosing
(
JCTree
.
TOPLEVEL
));
memberEnter
(
env
.
toplevel
,
env
.
enclosing
(
TOPLEVEL
));
todo
.
append
(
env
);
}
...
...
src/share/classes/com/sun/tools/javac/comp/Resolve.java
浏览文件 @
b46865f7
...
...
@@ -49,9 +49,12 @@ import java.util.Set;
import
javax.lang.model.element.ElementVisitor
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.
BLOCK
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Kinds
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Kinds
.
ERRONEOUS
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.*;
import
static
com
.
sun
.
tools
.
javac
.
comp
.
Resolve
.
MethodResolutionPhase
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/** Helper class for name resolution, used mostly by the attribution phase.
*
...
...
@@ -1269,7 +1272,7 @@ public class Resolve {
staticOnly
=
true
;
}
if
(
env
.
tree
.
getTag
()
!=
JCTree
.
IMPORT
)
{
if
(
!
env
.
tree
.
hasTag
(
IMPORT
)
)
{
sym
=
findGlobalType
(
env
,
env
.
toplevel
.
namedImportScope
,
name
);
if
(
sym
.
exists
())
return
sym
;
else
if
(
sym
.
kind
<
bestSoFar
.
kind
)
bestSoFar
=
sym
;
...
...
@@ -1796,7 +1799,7 @@ public class Resolve {
* @param env The environment current at the operation.
* @param argtypes The types of the operands.
*/
Symbol
resolveOperator
(
DiagnosticPosition
pos
,
int
optag
,
Symbol
resolveOperator
(
DiagnosticPosition
pos
,
JCTree
.
Tag
optag
,
Env
<
AttrContext
>
env
,
List
<
Type
>
argtypes
)
{
startResolution
();
Name
name
=
treeinfo
.
operatorName
(
optag
);
...
...
@@ -1815,7 +1818,7 @@ public class Resolve {
* @param env The environment current at the operation.
* @param arg The type of the operand.
*/
Symbol
resolveUnaryOperator
(
DiagnosticPosition
pos
,
int
optag
,
Env
<
AttrContext
>
env
,
Type
arg
)
{
Symbol
resolveUnaryOperator
(
DiagnosticPosition
pos
,
JCTree
.
Tag
optag
,
Env
<
AttrContext
>
env
,
Type
arg
)
{
return
resolveOperator
(
pos
,
optag
,
env
,
List
.
of
(
arg
));
}
...
...
@@ -1827,7 +1830,7 @@ public class Resolve {
* @param right The types of the right operand.
*/
Symbol
resolveBinaryOperator
(
DiagnosticPosition
pos
,
int
optag
,
JCTree
.
Tag
optag
,
Env
<
AttrContext
>
env
,
Type
left
,
Type
right
)
{
...
...
src/share/classes/com/sun/tools/javac/jvm/CRTable.java
浏览文件 @
b46865f7
...
...
@@ -532,7 +532,7 @@ implements CRTFlags {
*/
public
int
endPos
(
JCTree
tree
)
{
if
(
tree
==
null
)
return
Position
.
NOPOS
;
if
(
tree
.
getTag
()
==
JCTree
.
BLOCK
)
if
(
tree
.
hasTag
(
JCTree
.
Tag
.
BLOCK
)
)
return
((
JCBlock
)
tree
).
endpos
;
Integer
endpos
=
endPositions
.
get
(
tree
);
if
(
endpos
!=
null
)
...
...
src/share/classes/com/sun/tools/javac/jvm/Gen.java
浏览文件 @
b46865f7
...
...
@@ -47,6 +47,8 @@ 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
.
OptionName
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.
BLOCK
;
/** This pass maps flat Java (i.e. without inner classes) to bytecodes.
*
...
...
@@ -433,7 +435,7 @@ public class Gen extends JCTree.Visitor {
*/
boolean
hasFinally
(
JCTree
target
,
Env
<
GenContext
>
env
)
{
while
(
env
.
tree
!=
target
)
{
if
(
env
.
tree
.
getTag
()
==
JCTree
.
TRY
&&
env
.
info
.
finalize
.
hasFinalizer
())
if
(
env
.
tree
.
hasTag
(
TRY
)
&&
env
.
info
.
finalize
.
hasFinalizer
())
return
true
;
env
=
env
.
next
;
}
...
...
@@ -460,17 +462,17 @@ public class Gen extends JCTree.Visitor {
for
(
List
<
JCTree
>
l
=
defs
;
l
.
nonEmpty
();
l
=
l
.
tail
)
{
JCTree
def
=
l
.
head
;
switch
(
def
.
getTag
())
{
case
JCTree
.
BLOCK
:
case
BLOCK:
JCBlock
block
=
(
JCBlock
)
def
;
if
((
block
.
flags
&
STATIC
)
!=
0
)
clinitCode
.
append
(
block
);
else
initCode
.
append
(
block
);
break
;
case
JCTree
.
METHODDEF
:
case
METHODDEF:
methodDefs
.
append
(
def
);
break
;
case
JCTree
.
VARDEF
:
case
VARDEF:
JCVariableDecl
vdef
=
(
JCVariableDecl
)
def
;
VarSymbol
sym
=
vdef
.
sym
;
checkDimension
(
vdef
.
pos
(),
sym
.
type
);
...
...
@@ -707,7 +709,7 @@ public class Gen extends JCTree.Visitor {
}
int
startpc
=
code
.
curPc
();
genStat
(
tree
,
env
);
if
(
tree
.
getTag
()
==
JCTree
.
BLOCK
)
crtFlags
|=
CRT_BLOCK
;
if
(
tree
.
hasTag
(
BLOCK
)
)
crtFlags
|=
CRT_BLOCK
;
code
.
crt
.
put
(
tree
,
crtFlags
,
startpc
,
code
.
curPc
());
}
...
...
@@ -717,7 +719,7 @@ public class Gen extends JCTree.Visitor {
if
(
code
.
isAlive
())
{
code
.
statBegin
(
tree
.
pos
);
genDef
(
tree
,
env
);
}
else
if
(
env
.
info
.
isSwitch
&&
tree
.
getTag
()
==
JCTree
.
VARDEF
)
{
}
else
if
(
env
.
info
.
isSwitch
&&
tree
.
hasTag
(
VARDEF
)
)
{
// variables whose declarations are in a switch
// can be used even if the decl is unreachable.
code
.
newLocal
(((
JCVariableDecl
)
tree
).
sym
);
...
...
@@ -784,7 +786,7 @@ public class Gen extends JCTree.Visitor {
*/
public
CondItem
genCond
(
JCTree
_tree
,
boolean
markBranches
)
{
JCTree
inner_tree
=
TreeInfo
.
skipParens
(
_tree
);
if
(
inner_tree
.
getTag
()
==
JCTree
.
CONDEXPR
)
{
if
(
inner_tree
.
hasTag
(
CONDEXPR
)
)
{
JCConditional
tree
=
(
JCConditional
)
inner_tree
;
CondItem
cond
=
genCond
(
tree
.
cond
,
CRT_FLOW_CONTROLLER
);
if
(
cond
.
isTrue
())
{
...
...
@@ -1033,7 +1035,7 @@ public class Gen extends JCTree.Visitor {
Env
<
GenContext
>
localEnv
=
env
.
dup
(
tree
,
new
GenContext
());
genStats
(
tree
.
stats
,
localEnv
);
// End the scope of all block-local variables in variable info.
if
(
env
.
tree
.
getTag
()
!=
JCTree
.
METHODDEF
)
{
if
(
!
env
.
tree
.
hasTag
(
METHODDEF
)
)
{
code
.
statBegin
(
tree
.
endpos
);
code
.
endScopes
(
limit
);
code
.
pendingStatPos
=
Position
.
NOPOS
;
...
...
@@ -1628,11 +1630,11 @@ public class Gen extends JCTree.Visitor {
// Optimize x++ to ++x and x-- to --x.
JCExpression
e
=
tree
.
expr
;
switch
(
e
.
getTag
())
{
case
JCTree
.
POSTINC
:
((
JCUnary
)
e
).
setTag
(
JCTree
.
PREINC
);
case
POSTINC:
((
JCUnary
)
e
).
setTag
(
PREINC
);
break
;
case
JCTree
.
POSTDEC
:
((
JCUnary
)
e
).
setTag
(
JCTree
.
PREDEC
);
case
POSTDEC:
((
JCUnary
)
e
).
setTag
(
PREDEC
);
break
;
}
genExpr
(
tree
.
expr
,
tree
.
expr
.
type
).
drop
();
...
...
@@ -1819,13 +1821,13 @@ public class Gen extends JCTree.Visitor {
// If we have an increment of -32768 to +32767 of a local
// int variable we can use an incr instruction instead of
// proceeding further.
if
((
tree
.
getTag
()
==
JCTree
.
PLUS_ASG
||
tree
.
getTag
()
==
JCTree
.
MINUS_ASG
)
&&
if
((
tree
.
hasTag
(
PLUS_ASG
)
||
tree
.
hasTag
(
MINUS_ASG
)
)
&&
l
instanceof
LocalItem
&&
tree
.
lhs
.
type
.
tag
<=
INT
&&
tree
.
rhs
.
type
.
tag
<=
INT
&&
tree
.
rhs
.
type
.
constValue
()
!=
null
)
{
int
ival
=
((
Number
)
tree
.
rhs
.
type
.
constValue
()).
intValue
();
if
(
tree
.
getTag
()
==
JCTree
.
MINUS_ASG
)
ival
=
-
ival
;
if
(
tree
.
hasTag
(
MINUS_ASG
)
)
ival
=
-
ival
;
((
LocalItem
)
l
).
incr
(
ival
);
result
=
l
;
return
;
...
...
@@ -1841,29 +1843,29 @@ public class Gen extends JCTree.Visitor {
public
void
visitUnary
(
JCUnary
tree
)
{
OperatorSymbol
operator
=
(
OperatorSymbol
)
tree
.
operator
;
if
(
tree
.
getTag
()
==
JCTree
.
NOT
)
{
if
(
tree
.
hasTag
(
NOT
)
)
{
CondItem
od
=
genCond
(
tree
.
arg
,
false
);
result
=
od
.
negate
();
}
else
{
Item
od
=
genExpr
(
tree
.
arg
,
operator
.
type
.
getParameterTypes
().
head
);
switch
(
tree
.
getTag
())
{
case
JCTree
.
POS
:
case
POS:
result
=
od
.
load
();
break
;
case
JCTree
.
NEG
:
case
NEG:
result
=
od
.
load
();
code
.
emitop0
(
operator
.
opcode
);
break
;
case
JCTree
.
COMPL
:
case
COMPL:
result
=
od
.
load
();
emitMinusOne
(
od
.
typecode
);
code
.
emitop0
(
operator
.
opcode
);
break
;
case
JCTree
.
PREINC
:
case
JCTree
.
PREDEC
:
case
PREINC:
case
PREDEC:
od
.
duplicate
();
if
(
od
instanceof
LocalItem
&&
(
operator
.
opcode
==
iadd
||
operator
.
opcode
==
isub
))
{
((
LocalItem
)
od
).
incr
(
tree
.
getTag
()
==
JCTree
.
PREINC
?
1
:
-
1
);
((
LocalItem
)
od
).
incr
(
tree
.
hasTag
(
PREINC
)
?
1
:
-
1
);
result
=
od
;
}
else
{
od
.
load
();
...
...
@@ -1877,12 +1879,12 @@ public class Gen extends JCTree.Visitor {
result
=
items
.
makeAssignItem
(
od
);
}
break
;
case
JCTree
.
POSTINC
:
case
JCTree
.
POSTDEC
:
case
POSTINC:
case
POSTDEC:
od
.
duplicate
();
if
(
od
instanceof
LocalItem
&&
(
operator
.
opcode
==
iadd
||
operator
.
opcode
==
isub
))
{
Item
res
=
od
.
load
();
((
LocalItem
)
od
).
incr
(
tree
.
getTag
()
==
JCTree
.
POSTINC
?
1
:
-
1
);
((
LocalItem
)
od
).
incr
(
tree
.
hasTag
(
POSTINC
)
?
1
:
-
1
);
result
=
res
;
}
else
{
Item
res
=
od
.
load
();
...
...
@@ -1898,7 +1900,7 @@ public class Gen extends JCTree.Visitor {
result
=
res
;
}
break
;
case
JCTree
.
NULLCHK
:
case
NULLCHK:
result
=
od
.
load
();
code
.
emitop0
(
dup
);
genNullCheck
(
tree
.
pos
());
...
...
@@ -1926,7 +1928,7 @@ public class Gen extends JCTree.Visitor {
// Convert buffer to string.
bufferToString
(
tree
.
pos
());
result
=
items
.
makeStackItem
(
syms
.
stringType
);
}
else
if
(
tree
.
getTag
()
==
JCTree
.
AND
)
{
}
else
if
(
tree
.
hasTag
(
AND
)
)
{
CondItem
lcond
=
genCond
(
tree
.
lhs
,
CRT_FLOW_CONTROLLER
);
if
(!
lcond
.
isFalse
())
{
Chain
falseJumps
=
lcond
.
jumpFalse
();
...
...
@@ -1940,7 +1942,7 @@ public class Gen extends JCTree.Visitor {
}
else
{
result
=
lcond
;
}
}
else
if
(
tree
.
getTag
()
==
JCTree
.
OR
)
{
}
else
if
(
tree
.
hasTag
(
OR
)
)
{
CondItem
lcond
=
genCond
(
tree
.
lhs
,
CRT_FLOW_CONTROLLER
);
if
(!
lcond
.
isTrue
())
{
Chain
trueJumps
=
lcond
.
jumpTrue
();
...
...
@@ -1997,7 +1999,7 @@ public class Gen extends JCTree.Visitor {
*/
void
appendStrings
(
JCTree
tree
)
{
tree
=
TreeInfo
.
skipParens
(
tree
);
if
(
tree
.
getTag
()
==
JCTree
.
PLUS
&&
tree
.
type
.
constValue
()
==
null
)
{
if
(
tree
.
hasTag
(
PLUS
)
&&
tree
.
type
.
constValue
()
==
null
)
{
JCBinary
op
=
(
JCBinary
)
tree
;
if
(
op
.
operator
.
kind
==
MTH
&&
((
OperatorSymbol
)
op
.
operator
).
opcode
==
string_add
)
{
...
...
@@ -2240,7 +2242,7 @@ public class Gen extends JCTree.Visitor {
if
(
nerrs
!=
0
)
{
// if errors, discard code
for
(
List
<
JCTree
>
l
=
cdef
.
defs
;
l
.
nonEmpty
();
l
=
l
.
tail
)
{
if
(
l
.
head
.
getTag
()
==
JCTree
.
METHODDEF
)
if
(
l
.
head
.
hasTag
(
METHODDEF
)
)
((
JCMethodDecl
)
l
.
head
).
sym
.
code
=
null
;
}
}
...
...
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
浏览文件 @
b46865f7
...
...
@@ -1506,20 +1506,20 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
for
(
List
<
JCTree
>
it
=
tree
.
defs
;
it
.
tail
!=
null
;
it
=
it
.
tail
)
{
JCTree
t
=
it
.
head
;
switch
(
t
.
getTag
())
{
case
JCTree
.
CLASSDEF
:
case
CLASSDEF:
if
(
isInterface
||
(((
JCClassDecl
)
t
).
mods
.
flags
&
(
Flags
.
PROTECTED
|
Flags
.
PUBLIC
))
!=
0
||
(((
JCClassDecl
)
t
).
mods
.
flags
&
(
Flags
.
PRIVATE
))
==
0
&&
((
JCClassDecl
)
t
).
sym
.
packge
().
getQualifiedName
()
==
names
.
java_lang
)
newdefs
.
append
(
t
);
break
;
case
JCTree
.
METHODDEF
:
case
METHODDEF:
if
(
isInterface
||
(((
JCMethodDecl
)
t
).
mods
.
flags
&
(
Flags
.
PROTECTED
|
Flags
.
PUBLIC
))
!=
0
||
((
JCMethodDecl
)
t
).
sym
.
name
==
names
.
init
||
(((
JCMethodDecl
)
t
).
mods
.
flags
&
(
Flags
.
PRIVATE
))
==
0
&&
((
JCMethodDecl
)
t
).
sym
.
packge
().
getQualifiedName
()
==
names
.
java_lang
)
newdefs
.
append
(
t
);
break
;
case
JCTree
.
VARDEF
:
case
VARDEF:
if
(
isInterface
||
(((
JCVariableDecl
)
t
).
mods
.
flags
&
(
Flags
.
PROTECTED
|
Flags
.
PUBLIC
))
!=
0
||
(((
JCVariableDecl
)
t
).
mods
.
flags
&
(
Flags
.
PRIVATE
))
==
0
&&
((
JCVariableDecl
)
t
).
sym
.
packge
().
getQualifiedName
()
==
names
.
java_lang
)
newdefs
.
append
(
t
);
...
...
src/share/classes/com/sun/tools/javac/model/JavacElements.java
浏览文件 @
b46865f7
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
...
...
@@ -48,6 +48,7 @@ import com.sun.tools.javac.tree.TreeScanner;
import
com.sun.tools.javac.util.*
;
import
com.sun.tools.javac.util.Name
;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
import
static
javax
.
lang
.
model
.
util
.
ElementFilter
.
methodsIn
;
/**
...
...
@@ -288,7 +289,7 @@ public class JavacElements implements Elements {
}
}
public
void
visitArray
(
Attribute
.
Array
array
)
{
if
(
tree
.
getTag
()
==
JCTree
.
NEWARRAY
&&
if
(
tree
.
hasTag
(
NEWARRAY
)
&&
types
.
elemtype
(
array
.
type
).
tsym
==
findme
.
type
.
tsym
)
{
List
<
JCExpression
>
elems
=
((
JCNewArray
)
tree
).
elems
;
for
(
Attribute
value
:
array
.
values
)
{
...
...
@@ -327,7 +328,7 @@ public class JavacElements implements Elements {
scan
(
t
.
args
);
}
public
void
visitAssign
(
JCAssign
t
)
{
if
(
t
.
lhs
.
getTag
()
==
JCTree
.
IDENT
)
{
if
(
t
.
lhs
.
hasTag
(
IDENT
)
)
{
JCIdent
ident
=
(
JCIdent
)
t
.
lhs
;
if
(
ident
.
sym
==
sym
)
result
=
t
.
rhs
;
...
...
src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
浏览文件 @
b46865f7
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/parser/JavacParser.java
浏览文件 @
b46865f7
...
...
@@ -29,6 +29,7 @@ import java.util.*;
import
com.sun.tools.javac.code.*
;
import
com.sun.tools.javac.parser.Tokens.*
;
import
com.sun.tools.javac.parser.Tokens.Comment.CommentStyle
;
import
com.sun.tools.javac.tree.*
;
import
com.sun.tools.javac.tree.JCTree.*
;
import
com.sun.tools.javac.util.*
;
...
...
@@ -36,8 +37,16 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
import
com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition
;
import
com.sun.tools.javac.util.List
;
import
static
com
.
sun
.
tools
.
javac
.
util
.
ListBuffer
.
lb
;
import
static
com
.
sun
.
tools
.
javac
.
parser
.
Tokens
.
TokenKind
.*;
import
static
com
.
sun
.
tools
.
javac
.
parser
.
Tokens
.
TokenKind
.
ASSERT
;
import
static
com
.
sun
.
tools
.
javac
.
parser
.
Tokens
.
TokenKind
.
CASE
;
import
static
com
.
sun
.
tools
.
javac
.
parser
.
Tokens
.
TokenKind
.
CATCH
;
import
static
com
.
sun
.
tools
.
javac
.
parser
.
Tokens
.
TokenKind
.
EQ
;
import
static
com
.
sun
.
tools
.
javac
.
parser
.
Tokens
.
TokenKind
.
GT
;
import
static
com
.
sun
.
tools
.
javac
.
parser
.
Tokens
.
TokenKind
.
IMPORT
;
import
static
com
.
sun
.
tools
.
javac
.
parser
.
Tokens
.
TokenKind
.
LT
;
import
static
com
.
sun
.
tools
.
javac
.
util
.
ListBuffer
.
lb
;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/** The parser maps a token sequence into an abstract syntax
* tree. It operates by recursive descent, with code derived
...
...
@@ -757,7 +766,7 @@ public class JavacParser implements Parser {
Assert
.
check
(
top
==
0
);
t
=
odStack
[
0
];
if
(
t
.
getTag
()
==
JCTree
.
PLUS
)
{
if
(
t
.
hasTag
(
JCTree
.
Tag
.
PLUS
)
)
{
StringBuffer
buf
=
foldStrings
(
t
);
if
(
buf
!=
null
)
{
t
=
toP
(
F
.
at
(
startPos
).
Literal
(
TypeTags
.
CLASS
,
buf
.
toString
()));
...
...
@@ -790,7 +799,7 @@ public class JavacParser implements Parser {
return
null
;
List
<
String
>
buf
=
List
.
nil
();
while
(
true
)
{
if
(
tree
.
getTag
()
==
JCTree
.
LITERAL
)
{
if
(
tree
.
hasTag
(
LITERAL
)
)
{
JCLiteral
lit
=
(
JCLiteral
)
tree
;
if
(
lit
.
typetag
==
TypeTags
.
CLASS
)
{
StringBuffer
sbuf
=
...
...
@@ -801,9 +810,9 @@ public class JavacParser implements Parser {
}
return
sbuf
;
}
}
else
if
(
tree
.
getTag
()
==
JCTree
.
PLUS
)
{
}
else
if
(
tree
.
hasTag
(
JCTree
.
Tag
.
PLUS
)
)
{
JCBinary
op
=
(
JCBinary
)
tree
;
if
(
op
.
rhs
.
getTag
()
==
JCTree
.
LITERAL
)
{
if
(
op
.
rhs
.
hasTag
(
LITERAL
)
)
{
JCLiteral
lit
=
(
JCLiteral
)
op
.
rhs
;
if
(
lit
.
typetag
==
TypeTags
.
CLASS
)
{
buf
=
buf
.
prepend
((
String
)
lit
.
value
);
...
...
@@ -899,7 +908,7 @@ public class JavacParser implements Parser {
t
=
term3
();
if
((
mode
&
TYPE
)
!=
0
&&
token
.
kind
==
LT
)
{
// Could be a cast to a parameterized type
int
op
=
JCTree
.
LT
;
JCTree
.
Tag
op
=
JCTree
.
Tag
.
LT
;
int
pos1
=
token
.
pos
;
nextToken
();
mode
&=
(
EXPR
|
TYPE
);
...
...
@@ -1153,7 +1162,7 @@ public class JavacParser implements Parser {
while
((
token
.
kind
==
PLUSPLUS
||
token
.
kind
==
SUBSUB
)
&&
(
mode
&
EXPR
)
!=
0
)
{
mode
=
EXPR
;
t
=
to
(
F
.
at
(
token
.
pos
).
Unary
(
token
.
kind
==
PLUSPLUS
?
JCTree
.
POSTINC
:
JCTree
.
POSTDEC
,
t
));
token
.
kind
==
PLUSPLUS
?
POSTINC
:
POSTDEC
,
t
));
nextToken
();
}
return
toP
(
t
);
...
...
@@ -1584,7 +1593,7 @@ public class JavacParser implements Parser {
break
;
case
MONKEYS_AT:
case
FINAL:
{
String
dc
=
token
.
docComment
;
String
dc
=
token
.
comment
(
CommentStyle
.
JAVADOC
)
;
JCModifiers
mods
=
modifiersOpt
();
if
(
token
.
kind
==
INTERFACE
||
token
.
kind
==
CLASS
||
...
...
@@ -1601,21 +1610,21 @@ public class JavacParser implements Parser {
break
;
}
case
ABSTRACT:
case
STRICTFP:
{
String
dc
=
token
.
docComment
;
String
dc
=
token
.
comment
(
CommentStyle
.
JAVADOC
)
;
JCModifiers
mods
=
modifiersOpt
();
stats
.
append
(
classOrInterfaceOrEnumDeclaration
(
mods
,
dc
));
break
;
}
case
INTERFACE:
case
CLASS:
String
dc
=
token
.
docComment
;
String
dc
=
token
.
comment
(
CommentStyle
.
JAVADOC
)
;
stats
.
append
(
classOrInterfaceOrEnumDeclaration
(
modifiersOpt
(),
dc
));
break
;
case
ENUM:
case
ASSERT:
if
(
allowEnums
&&
token
.
kind
==
ENUM
)
{
error
(
token
.
pos
,
"local.enum"
);
dc
=
token
.
docComment
;
dc
=
token
.
comment
(
CommentStyle
.
JAVADOC
)
;
stats
.
append
(
classOrInterfaceOrEnumDeclaration
(
modifiersOpt
(),
dc
));
break
;
}
else
if
(
allowAsserts
&&
token
.
kind
==
ASSERT
)
{
...
...
@@ -1626,7 +1635,7 @@ public class JavacParser implements Parser {
default
:
Token
prevToken
=
token
;
JCExpression
t
=
term
(
EXPR
|
TYPE
);
if
(
token
.
kind
==
COLON
&&
t
.
getTag
()
==
JCTree
.
IDENT
)
{
if
(
token
.
kind
==
COLON
&&
t
.
hasTag
(
IDENT
)
)
{
nextToken
();
JCStatement
stat
=
parseStatement
();
stats
.
append
(
F
.
at
(
pos
).
Labelled
(
prevToken
.
name
(),
stat
));
...
...
@@ -1701,7 +1710,7 @@ public class JavacParser implements Parser {
accept
(
LPAREN
);
List
<
JCStatement
>
inits
=
token
.
kind
==
SEMI
?
List
.<
JCStatement
>
nil
()
:
forInit
();
if
(
inits
.
length
()
==
1
&&
inits
.
head
.
getTag
()
==
JCTree
.
VARDEF
&&
inits
.
head
.
hasTag
(
VARDEF
)
&&
((
JCVariableDecl
)
inits
.
head
).
init
==
null
&&
token
.
kind
==
COLON
)
{
checkForeach
();
...
...
@@ -1834,7 +1843,7 @@ public class JavacParser implements Parser {
default
:
Token
prevToken
=
token
;
JCExpression
expr
=
parseExpression
();
if
(
token
.
kind
==
COLON
&&
expr
.
getTag
()
==
JCTree
.
IDENT
)
{
if
(
token
.
kind
==
COLON
&&
expr
.
hasTag
(
IDENT
)
)
{
nextToken
();
JCStatement
stat
=
parseStatement
();
return
F
.
at
(
pos
).
Labelled
(
prevToken
.
name
(),
stat
);
...
...
@@ -1991,7 +2000,7 @@ public class JavacParser implements Parser {
annotations
.
appendList
(
partial
.
annotations
);
pos
=
partial
.
pos
;
}
if
(
token
.
deprecatedFlag
)
{
if
(
token
.
deprecatedFlag
()
)
{
flags
|=
Flags
.
DEPRECATED
;
}
int
lastPos
=
Position
.
NOPOS
;
...
...
@@ -2087,7 +2096,7 @@ public class JavacParser implements Parser {
if
(
token
.
kind
==
IDENTIFIER
)
{
mode
=
EXPR
;
JCExpression
t1
=
term1
();
if
(
t1
.
getTag
()
==
JCTree
.
IDENT
&&
token
.
kind
==
EQ
)
{
if
(
t1
.
hasTag
(
IDENT
)
&&
token
.
kind
==
EQ
)
{
int
pos
=
token
.
pos
;
accept
(
EQ
);
JCExpression
v
=
annotationValue
();
...
...
@@ -2271,9 +2280,9 @@ public class JavacParser implements Parser {
seenImport
=
true
;
defs
.
append
(
importDeclaration
());
}
else
{
String
docComment
=
token
.
docComment
;
String
docComment
=
token
.
comment
(
CommentStyle
.
JAVADOC
)
;
if
(
firstTypeDecl
&&
!
seenImport
&&
!
seenPackage
)
{
docComment
=
firstToken
.
docComment
;
docComment
=
firstToken
.
comment
(
CommentStyle
.
JAVADOC
)
;
consumedToplevelDoc
=
true
;
}
JCTree
def
=
typeDeclaration
(
mods
,
docComment
);
...
...
@@ -2288,7 +2297,7 @@ public class JavacParser implements Parser {
}
JCTree
.
JCCompilationUnit
toplevel
=
F
.
at
(
firstToken
.
pos
).
TopLevel
(
packageAnnotations
,
pid
,
defs
.
toList
());
if
(!
consumedToplevelDoc
)
attach
(
toplevel
,
firstToken
.
docComment
);
attach
(
toplevel
,
firstToken
.
comment
(
CommentStyle
.
JAVADOC
)
);
if
(
defs
.
elems
.
isEmpty
())
storeEnd
(
toplevel
,
S
.
prevToken
().
endPos
);
if
(
keepDocComments
)
...
...
@@ -2498,9 +2507,9 @@ public class JavacParser implements Parser {
/** EnumeratorDeclaration = AnnotationsOpt [TypeArguments] IDENTIFIER [ Arguments ] [ "{" ClassBody "}" ]
*/
JCTree
enumeratorDeclaration
(
Name
enumName
)
{
String
dc
=
token
.
docComment
;
String
dc
=
token
.
comment
(
CommentStyle
.
JAVADOC
)
;
int
flags
=
Flags
.
PUBLIC
|
Flags
.
STATIC
|
Flags
.
FINAL
|
Flags
.
ENUM
;
if
(
token
.
deprecatedFlag
)
{
if
(
token
.
deprecatedFlag
()
)
{
flags
|=
Flags
.
DEPRECATED
;
}
int
pos
=
token
.
pos
;
...
...
@@ -2587,7 +2596,7 @@ public class JavacParser implements Parser {
nextToken
();
return
List
.<
JCTree
>
nil
();
}
else
{
String
dc
=
token
.
docComment
;
String
dc
=
token
.
comment
(
CommentStyle
.
JAVADOC
)
;
int
pos
=
token
.
pos
;
JCModifiers
mods
=
modifiersOpt
();
if
(
token
.
kind
==
CLASS
||
...
...
@@ -2617,7 +2626,7 @@ public class JavacParser implements Parser {
}
else
{
type
=
parseType
();
}
if
(
token
.
kind
==
LPAREN
&&
!
isInterface
&&
type
.
getTag
()
==
JCTree
.
IDENT
)
{
if
(
token
.
kind
==
LPAREN
&&
!
isInterface
&&
type
.
hasTag
(
IDENT
)
)
{
if
(
isInterface
||
tk
.
name
()
!=
className
)
error
(
pos
,
"invalid.meth.decl.ret.type.req"
);
return
List
.
of
(
methodDeclaratorRest
(
...
...
@@ -2814,15 +2823,15 @@ public class JavacParser implements Parser {
*/
protected
JCExpression
checkExprStat
(
JCExpression
t
)
{
switch
(
t
.
getTag
())
{
case
JCTree
.
PREINC
:
case
JCTree
.
PREDEC
:
case
JCTree
.
POSTINC
:
case
JCTree
.
POSTDEC
:
case
JCTree
.
ASSIGN
:
case
JCTree
.
BITOR_ASG
:
case
JCTree
.
BITXOR_ASG
:
case
JCTree
.
BITAND_ASG
:
case
JCTree
.
SL_ASG
:
case
JCTree
.
SR_ASG
:
case
JCTree
.
USR_ASG
:
case
JCTree
.
PLUS_ASG
:
case
JCTree
.
MINUS_ASG
:
case
JCTree
.
MUL_ASG
:
case
JCTree
.
DIV_ASG
:
case
JCTree
.
MOD_ASG
:
case
JCTree
.
APPLY
:
case
JCTree
.
NEWCLASS
:
case
JCTree
.
ERRONEOUS
:
case
PREINC:
case
PREDEC:
case
POSTINC:
case
POSTDEC:
case
ASSIGN:
case
BITOR_ASG:
case
BITXOR_ASG:
case
BITAND_ASG:
case
SL_ASG:
case
SR_ASG:
case
USR_ASG:
case
PLUS_ASG:
case
MINUS_ASG:
case
MUL_ASG:
case
DIV_ASG:
case
MOD_ASG:
case
APPLY:
case
NEWCLASS:
case
ERRONEOUS:
return
t
;
default
:
JCExpression
ret
=
F
.
at
(
t
.
pos
).
Erroneous
(
List
.<
JCTree
>
of
(
t
));
...
...
@@ -2835,8 +2844,8 @@ public class JavacParser implements Parser {
* -1 if token is not a binary operator. @see TreeInfo.opPrec
*/
static
int
prec
(
TokenKind
token
)
{
int
oc
=
optag
(
token
);
return
(
oc
>=
0
)
?
TreeInfo
.
opPrec
(
oc
)
:
-
1
;
JCTree
.
Tag
oc
=
optag
(
token
);
return
(
oc
!=
NO_TAG
)
?
TreeInfo
.
opPrec
(
oc
)
:
-
1
;
}
/**
...
...
@@ -2852,96 +2861,96 @@ public class JavacParser implements Parser {
}
/** Return operation tag of binary operator represented by token,
*
-1
if token is not a binary operator.
*
No_TAG
if token is not a binary operator.
*/
static
int
optag
(
TokenKind
token
)
{
static
JCTree
.
Tag
optag
(
TokenKind
token
)
{
switch
(
token
)
{
case
BARBAR:
return
JCTree
.
OR
;
return
OR
;
case
AMPAMP:
return
JCTree
.
AND
;
return
AND
;
case
BAR:
return
JCTree
.
BITOR
;
return
BITOR
;
case
BAREQ:
return
JCTree
.
BITOR_ASG
;
return
BITOR_ASG
;
case
CARET:
return
JCTree
.
BITXOR
;
return
BITXOR
;
case
CARETEQ:
return
JCTree
.
BITXOR_ASG
;
return
BITXOR_ASG
;
case
AMP:
return
JCTree
.
BITAND
;
return
BITAND
;
case
AMPEQ:
return
JCTree
.
BITAND_ASG
;
return
BITAND_ASG
;
case
EQEQ:
return
JCTree
.
EQ
;
return
JCTree
.
Tag
.
EQ
;
case
BANGEQ:
return
JCTree
.
NE
;
return
NE
;
case
LT:
return
JCTree
.
LT
;
return
JCTree
.
Tag
.
LT
;
case
GT:
return
JCTree
.
GT
;
return
JCTree
.
Tag
.
GT
;
case
LTEQ:
return
JCTree
.
LE
;
return
LE
;
case
GTEQ:
return
JCTree
.
GE
;
return
GE
;
case
LTLT:
return
JCTree
.
SL
;
return
SL
;
case
LTLTEQ:
return
JCTree
.
SL_ASG
;
return
SL_ASG
;
case
GTGT:
return
JCTree
.
SR
;
return
SR
;
case
GTGTEQ:
return
JCTree
.
SR_ASG
;
return
SR_ASG
;
case
GTGTGT:
return
JCTree
.
USR
;
return
USR
;
case
GTGTGTEQ:
return
JCTree
.
USR_ASG
;
return
USR_ASG
;
case
PLUS:
return
JCTree
.
PLUS
;
return
JCTree
.
Tag
.
PLUS
;
case
PLUSEQ:
return
JCTree
.
PLUS_ASG
;
return
PLUS_ASG
;
case
SUB:
return
JCTree
.
MINUS
;
return
MINUS
;
case
SUBEQ:
return
JCTree
.
MINUS_ASG
;
return
MINUS_ASG
;
case
STAR:
return
JCTree
.
MUL
;
return
MUL
;
case
STAREQ:
return
JCTree
.
MUL_ASG
;
return
MUL_ASG
;
case
SLASH:
return
JCTree
.
DIV
;
return
DIV
;
case
SLASHEQ:
return
JCTree
.
DIV_ASG
;
return
DIV_ASG
;
case
PERCENT:
return
JCTree
.
MOD
;
return
MOD
;
case
PERCENTEQ:
return
JCTree
.
MOD_ASG
;
return
MOD_ASG
;
case
INSTANCEOF:
return
JCTree
.
TYPETEST
;
return
TYPETEST
;
default
:
return
-
1
;
return
NO_TAG
;
}
}
/** Return operation tag of unary operator represented by token,
*
-1
if token is not a binary operator.
*
No_TAG
if token is not a binary operator.
*/
static
int
unoptag
(
TokenKind
token
)
{
static
JCTree
.
Tag
unoptag
(
TokenKind
token
)
{
switch
(
token
)
{
case
PLUS:
return
JCTree
.
POS
;
return
POS
;
case
SUB:
return
JCTree
.
NEG
;
return
NEG
;
case
BANG:
return
JCTree
.
NOT
;
return
NOT
;
case
TILDE:
return
JCTree
.
COMPL
;
return
COMPL
;
case
PLUSPLUS:
return
JCTree
.
PREINC
;
return
PREINC
;
case
SUBSUB:
return
JCTree
.
PREDEC
;
return
PREDEC
;
default
:
return
-
1
;
return
NO_TAG
;
}
}
...
...
src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java
浏览文件 @
b46865f7
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/parser/Tokens.java
浏览文件 @
b46865f7
...
...
@@ -30,8 +30,10 @@ import java.util.Locale;
import
com.sun.tools.javac.api.Formattable
;
import
com.sun.tools.javac.api.Messages
;
import
com.sun.tools.javac.parser.Tokens.Token.Tag
;
import
com.sun.tools.javac.util.List
;
import
com.sun.tools.javac.util.Name
;
import
com.sun.tools.javac.util.Context
;
import
com.sun.tools.javac.util.ListBuffer
;
import
com.sun.tools.javac.util.Names
;
/** A class that defines codes/utilities for Java source tokens
...
...
@@ -281,6 +283,19 @@ public class Tokens {
}
}
public
interface
Comment
{
enum
CommentStyle
{
LINE
,
BLOCK
,
JAVADOC
,
}
String
getText
();
CommentStyle
getStyle
();
boolean
isDeprecated
();
}
/**
* This is the class representing a javac token. Each token has several fields
* that are set by the javac lexer (i.e. start/end position, string value, etc).
...
...
@@ -304,18 +319,14 @@ public class Tokens {
/** The end position of this token */
public
final
int
endPos
;
/** Is this token preceeded by a deprecated comment? */
public
final
boolean
deprecatedFlag
;
/** Is this token preceeded by a deprecated comment? */
public
String
docComment
;
/** Comment reader associated with this token */
public
final
List
<
Comment
>
comments
;
Token
(
TokenKind
kind
,
int
pos
,
int
endPos
,
boolean
deprecatedFlag
)
{
Token
(
TokenKind
kind
,
int
pos
,
int
endPos
,
List
<
Comment
>
comments
)
{
this
.
kind
=
kind
;
this
.
pos
=
pos
;
this
.
endPos
=
endPos
;
this
.
deprecatedFlag
=
deprecatedFlag
;
this
.
comments
=
comments
;
checkKind
();
}
...
...
@@ -331,8 +342,8 @@ public class Tokens {
throw
new
AssertionError
(
"Cant split - bad subtokens"
);
}
return
new
Token
[]
{
new
Token
(
t1
,
pos
,
pos
+
t1
.
name
.
length
(),
deprecatedFlag
),
new
Token
(
t2
,
pos
+
t1
.
name
.
length
(),
endPos
,
false
)
new
Token
(
t1
,
pos
,
pos
+
t1
.
name
.
length
(),
comments
),
new
Token
(
t2
,
pos
+
t1
.
name
.
length
(),
endPos
,
null
)
};
}
...
...
@@ -353,14 +364,52 @@ public class Tokens {
public
int
radix
()
{
throw
new
UnsupportedOperationException
();
}
/**
* Preserve classic semantics - if multiple javadocs are found on the token
* the last one is returned
*/
public
String
comment
(
Comment
.
CommentStyle
style
)
{
List
<
Comment
>
readers
=
getReaders
(
Comment
.
CommentStyle
.
JAVADOC
);
return
readers
.
isEmpty
()
?
null
:
readers
.
head
.
getText
();
}
/**
* Preserve classic semantics - deprecated should be set if at least one
* javadoc comment attached to this token contains the '@deprecated' string
*/
public
boolean
deprecatedFlag
()
{
for
(
Comment
r
:
getReaders
(
Comment
.
CommentStyle
.
JAVADOC
))
{
if
(
r
.
isDeprecated
())
{
return
true
;
}
}
return
false
;
}
private
List
<
Comment
>
getReaders
(
Comment
.
CommentStyle
style
)
{
if
(
comments
==
null
)
{
return
List
.
nil
();
}
else
{
ListBuffer
<
Comment
>
buf
=
ListBuffer
.
lb
();
for
(
Comment
r
:
comments
)
{
if
(
r
.
getStyle
()
==
style
)
{
buf
.
add
(
r
);
}
}
return
buf
.
toList
();
}
}
}
final
static
class
NamedToken
extends
Token
{
/** The name of this token */
public
final
Name
name
;
public
NamedToken
(
TokenKind
kind
,
int
pos
,
int
endPos
,
Name
name
,
boolean
deprecatedFlag
)
{
super
(
kind
,
pos
,
endPos
,
deprecatedFlag
);
public
NamedToken
(
TokenKind
kind
,
int
pos
,
int
endPos
,
Name
name
,
List
<
Comment
>
comments
)
{
super
(
kind
,
pos
,
endPos
,
comments
);
this
.
name
=
name
;
}
...
...
@@ -380,8 +429,8 @@ public class Tokens {
/** The string value of this token */
public
final
String
stringVal
;
public
StringToken
(
TokenKind
kind
,
int
pos
,
int
endPos
,
String
stringVal
,
boolean
deprecatedFlag
)
{
super
(
kind
,
pos
,
endPos
,
deprecatedFlag
);
public
StringToken
(
TokenKind
kind
,
int
pos
,
int
endPos
,
String
stringVal
,
List
<
Comment
>
comments
)
{
super
(
kind
,
pos
,
endPos
,
comments
);
this
.
stringVal
=
stringVal
;
}
...
...
@@ -401,8 +450,8 @@ public class Tokens {
/** The 'radix' value of this token */
public
final
int
radix
;
public
NumericToken
(
TokenKind
kind
,
int
pos
,
int
endPos
,
String
stringVal
,
int
radix
,
boolean
deprecatedFlag
)
{
super
(
kind
,
pos
,
endPos
,
stringVal
,
deprecatedFlag
);
public
NumericToken
(
TokenKind
kind
,
int
pos
,
int
endPos
,
String
stringVal
,
int
radix
,
List
<
Comment
>
comments
)
{
super
(
kind
,
pos
,
endPos
,
stringVal
,
comments
);
this
.
radix
=
radix
;
}
...
...
@@ -419,5 +468,5 @@ public class Tokens {
}
public
static
final
Token
DUMMY
=
new
Token
(
TokenKind
.
ERROR
,
0
,
0
,
false
);
new
Token
(
TokenKind
.
ERROR
,
0
,
0
,
null
);
}
src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java
浏览文件 @
b46865f7
...
...
@@ -26,8 +26,12 @@
package
com.sun.tools.javac.parser
;
import
com.sun.tools.javac.file.JavacFileManager
;
import
java.nio.CharBuffer
;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Name
;
import
com.sun.tools.javac.util.Names
;
import
java.nio.CharBuffer
;
import
static
com
.
sun
.
tools
.
javac
.
util
.
LayoutCharacters
.*;
/** The char reader used by the javac lexer/tokenizer. Returns the sequence of
...
...
@@ -58,6 +62,12 @@ public class UnicodeReader {
protected
int
unicodeConversionBp
=
-
1
;
protected
Log
log
;
protected
Names
names
;
/** A character buffer for saved chars.
*/
protected
char
[]
sbuf
=
new
char
[
128
];
protected
int
sp
;
/**
* Create a scanner from the input array. This method might
...
...
@@ -76,6 +86,7 @@ public class UnicodeReader {
protected
UnicodeReader
(
ScannerFactory
sf
,
char
[]
input
,
int
inputLength
)
{
log
=
sf
.
log
;
names
=
sf
.
names
;
if
(
inputLength
==
input
.
length
)
{
if
(
input
.
length
>
0
&&
Character
.
isWhitespace
(
input
[
input
.
length
-
1
]))
{
inputLength
--;
...
...
@@ -103,6 +114,48 @@ public class UnicodeReader {
}
}
/** Read next character in comment, skipping over double '\' characters.
*/
protected
void
scanCommentChar
()
{
scanChar
();
if
(
ch
==
'\\'
)
{
if
(
peekChar
()
==
'\\'
&&
!
isUnicode
())
{
skipChar
();
}
else
{
convertUnicode
();
}
}
}
/** Append a character to sbuf.
*/
protected
void
putChar
(
char
ch
,
boolean
scan
)
{
if
(
sp
==
sbuf
.
length
)
{
char
[]
newsbuf
=
new
char
[
sbuf
.
length
*
2
];
System
.
arraycopy
(
sbuf
,
0
,
newsbuf
,
0
,
sbuf
.
length
);
sbuf
=
newsbuf
;
}
sbuf
[
sp
++]
=
ch
;
if
(
scan
)
scanChar
();
}
protected
void
putChar
(
char
ch
)
{
putChar
(
ch
,
false
);
}
protected
void
putChar
(
boolean
scan
)
{
putChar
(
ch
,
scan
);
}
Name
name
()
{
return
names
.
fromChars
(
sbuf
,
0
,
sp
);
}
String
chars
()
{
return
new
String
(
sbuf
,
0
,
sp
);
}
/** Convert unicode escape; bp points to initial '\' character
* (Spec 3.3).
*/
...
...
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
浏览文件 @
b46865f7
...
...
@@ -1222,7 +1222,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
List
<
ClassSymbol
>
classes
=
List
.
nil
();
for
(
JCCompilationUnit
unit
:
units
)
{
for
(
JCTree
node
:
unit
.
defs
)
{
if
(
node
.
getTag
()
==
JCTree
.
CLASSDEF
)
{
if
(
node
.
hasTag
(
JCTree
.
Tag
.
CLASSDEF
)
)
{
ClassSymbol
sym
=
((
JCClassDecl
)
node
).
sym
;
Assert
.
checkNonNull
(
sym
);
classes
=
classes
.
prepend
(
sym
);
...
...
src/share/classes/com/sun/tools/javac/tree/JCTree.java
浏览文件 @
b46865f7
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/tree/Pretty.java
浏览文件 @
b46865f7
...
...
@@ -36,6 +36,8 @@ import com.sun.tools.javac.code.Symbol.*;
import
com.sun.tools.javac.tree.JCTree.*
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.
ANNOTATION
;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/** Prints out a tree as an indented Java source program.
*
...
...
@@ -310,7 +312,7 @@ public class Pretty extends JCTree.Visitor {
/** Is the given tree an enumerator definition? */
boolean
isEnumerator
(
JCTree
t
)
{
return
t
.
getTag
()
==
JCTree
.
VARDEF
&&
(((
JCVariableDecl
)
t
).
mods
.
flags
&
ENUM
)
!=
0
;
return
t
.
hasTag
(
VARDEF
)
&&
(((
JCVariableDecl
)
t
).
mods
.
flags
&
ENUM
)
!=
0
;
}
/** Print unit consisting of package clause and import statements in toplevel,
...
...
@@ -331,9 +333,9 @@ public class Pretty extends JCTree.Visitor {
}
boolean
firstImport
=
true
;
for
(
List
<
JCTree
>
l
=
tree
.
defs
;
l
.
nonEmpty
()
&&
(
cdef
==
null
||
l
.
head
.
getTag
()
==
JCTree
.
IMPORT
);
l
.
nonEmpty
()
&&
(
cdef
==
null
||
l
.
head
.
hasTag
(
IMPORT
)
);
l
=
l
.
tail
)
{
if
(
l
.
head
.
getTag
()
==
JCTree
.
IMPORT
)
{
if
(
l
.
head
.
hasTag
(
IMPORT
)
)
{
JCImport
imp
=
(
JCImport
)
l
.
head
;
Name
name
=
TreeInfo
.
name
(
imp
.
qualid
);
if
(
name
==
name
.
table
.
names
.
asterisk
||
...
...
@@ -484,7 +486,7 @@ public class Pretty extends JCTree.Visitor {
print
(
"/*public static final*/ "
);
print
(
tree
.
name
);
if
(
tree
.
init
!=
null
)
{
if
(
sourceOutput
&&
tree
.
init
.
getTag
()
==
JCTree
.
NEWCLASS
)
{
if
(
sourceOutput
&&
tree
.
init
.
hasTag
(
NEWCLASS
)
)
{
print
(
" /*enum*/ "
);
JCNewClass
init
=
(
JCNewClass
)
tree
.
init
;
if
(
init
.
args
!=
null
&&
init
.
args
.
nonEmpty
())
{
...
...
@@ -545,7 +547,7 @@ public class Pretty extends JCTree.Visitor {
printStat
(
tree
.
body
);
align
();
print
(
" while "
);
if
(
tree
.
cond
.
getTag
()
==
JCTree
.
PARENS
)
{
if
(
tree
.
cond
.
hasTag
(
PARENS
)
)
{
printExpr
(
tree
.
cond
);
}
else
{
print
(
"("
);
...
...
@@ -561,7 +563,7 @@ public class Pretty extends JCTree.Visitor {
public
void
visitWhileLoop
(
JCWhileLoop
tree
)
{
try
{
print
(
"while "
);
if
(
tree
.
cond
.
getTag
()
==
JCTree
.
PARENS
)
{
if
(
tree
.
cond
.
hasTag
(
PARENS
)
)
{
printExpr
(
tree
.
cond
);
}
else
{
print
(
"("
);
...
...
@@ -579,7 +581,7 @@ public class Pretty extends JCTree.Visitor {
try
{
print
(
"for ("
);
if
(
tree
.
init
.
nonEmpty
())
{
if
(
tree
.
init
.
head
.
getTag
()
==
JCTree
.
VARDEF
)
{
if
(
tree
.
init
.
head
.
hasTag
(
VARDEF
)
)
{
printExpr
(
tree
.
init
.
head
);
for
(
List
<
JCStatement
>
l
=
tree
.
init
.
tail
;
l
.
nonEmpty
();
l
=
l
.
tail
)
{
JCVariableDecl
vdef
=
(
JCVariableDecl
)
l
.
head
;
...
...
@@ -626,7 +628,7 @@ public class Pretty extends JCTree.Visitor {
public
void
visitSwitch
(
JCSwitch
tree
)
{
try
{
print
(
"switch "
);
if
(
tree
.
selector
.
getTag
()
==
JCTree
.
PARENS
)
{
if
(
tree
.
selector
.
hasTag
(
PARENS
)
)
{
printExpr
(
tree
.
selector
);
}
else
{
print
(
"("
);
...
...
@@ -665,7 +667,7 @@ public class Pretty extends JCTree.Visitor {
public
void
visitSynchronized
(
JCSynchronized
tree
)
{
try
{
print
(
"synchronized "
);
if
(
tree
.
lock
.
getTag
()
==
JCTree
.
PARENS
)
{
if
(
tree
.
lock
.
hasTag
(
PARENS
)
)
{
printExpr
(
tree
.
lock
);
}
else
{
print
(
"("
);
...
...
@@ -736,7 +738,7 @@ public class Pretty extends JCTree.Visitor {
public
void
visitIf
(
JCIf
tree
)
{
try
{
print
(
"if "
);
if
(
tree
.
cond
.
getTag
()
==
JCTree
.
PARENS
)
{
if
(
tree
.
cond
.
hasTag
(
PARENS
)
)
{
printExpr
(
tree
.
cond
);
}
else
{
print
(
"("
);
...
...
@@ -823,7 +825,7 @@ public class Pretty extends JCTree.Visitor {
public
void
visitApply
(
JCMethodInvocation
tree
)
{
try
{
if
(!
tree
.
typeargs
.
isEmpty
())
{
if
(
tree
.
meth
.
getTag
()
==
JCTree
.
SELECT
)
{
if
(
tree
.
meth
.
hasTag
(
SELECT
)
)
{
JCFieldAccess
left
=
(
JCFieldAccess
)
tree
.
meth
;
printExpr
(
left
.
selected
);
print
(
".<"
);
...
...
@@ -882,7 +884,7 @@ public class Pretty extends JCTree.Visitor {
if
(
tree
.
elemtype
!=
null
)
{
print
(
"new "
);
JCTree
elem
=
tree
.
elemtype
;
if
(
elem
.
getTag
()
==
JCTree
.
TYPEARRAY
)
if
(
elem
.
hasTag
(
TYPEARRAY
)
)
printBaseElementType
((
JCArrayTypeTree
)
elem
);
else
printExpr
(
elem
);
...
...
@@ -927,36 +929,36 @@ public class Pretty extends JCTree.Visitor {
}
}
public
String
operatorName
(
int
tag
)
{
public
String
operatorName
(
JCTree
.
Tag
tag
)
{
switch
(
tag
)
{
case
JCTree
.
POS
:
return
"+"
;
case
JCTree
.
NEG
:
return
"-"
;
case
JCTree
.
NOT
:
return
"!"
;
case
JCTree
.
COMPL
:
return
"~"
;
case
JCTree
.
PREINC
:
return
"++"
;
case
JCTree
.
PREDEC
:
return
"--"
;
case
JCTree
.
POSTINC
:
return
"++"
;
case
JCTree
.
POSTDEC
:
return
"--"
;
case
JCTree
.
NULLCHK
:
return
"<*nullchk*>"
;
case
JCTree
.
OR
:
return
"||"
;
case
JCTree
.
AND
:
return
"&&"
;
case
JCTree
.
EQ
:
return
"=="
;
case
JCTree
.
NE
:
return
"!="
;
case
JCTree
.
LT
:
return
"<"
;
case
JCTree
.
GT
:
return
">"
;
case
JCTree
.
LE
:
return
"<="
;
case
JCTree
.
GE
:
return
">="
;
case
JCTree
.
BITOR
:
return
"|"
;
case
JCTree
.
BITXOR
:
return
"^"
;
case
JCTree
.
BITAND
:
return
"&"
;
case
JCTree
.
SL
:
return
"<<"
;
case
JCTree
.
SR
:
return
">>"
;
case
JCTree
.
USR
:
return
">>>"
;
case
JCTree
.
PLUS
:
return
"+"
;
case
JCTree
.
MINUS
:
return
"-"
;
case
JCTree
.
MUL
:
return
"*"
;
case
JCTree
.
DIV
:
return
"/"
;
case
JCTree
.
MOD
:
return
"%"
;
case
POS:
return
"+"
;
case
NEG:
return
"-"
;
case
NOT:
return
"!"
;
case
COMPL:
return
"~"
;
case
PREINC:
return
"++"
;
case
PREDEC:
return
"--"
;
case
POSTINC:
return
"++"
;
case
POSTDEC:
return
"--"
;
case
NULLCHK:
return
"<*nullchk*>"
;
case
OR:
return
"||"
;
case
AND:
return
"&&"
;
case
EQ:
return
"=="
;
case
NE:
return
"!="
;
case
LT:
return
"<"
;
case
GT:
return
">"
;
case
LE:
return
"<="
;
case
GE:
return
">="
;
case
BITOR:
return
"|"
;
case
BITXOR:
return
"^"
;
case
BITAND:
return
"&"
;
case
SL:
return
"<<"
;
case
SR:
return
">>"
;
case
USR:
return
">>>"
;
case
PLUS:
return
"+"
;
case
MINUS:
return
"-"
;
case
MUL:
return
"*"
;
case
DIV:
return
"/"
;
case
MOD:
return
"%"
;
default
:
throw
new
Error
();
}
}
...
...
@@ -965,7 +967,7 @@ public class Pretty extends JCTree.Visitor {
try
{
open
(
prec
,
TreeInfo
.
assignopPrec
);
printExpr
(
tree
.
lhs
,
TreeInfo
.
assignopPrec
+
1
);
print
(
" "
+
operatorName
(
tree
.
getTag
()
-
JCTree
.
ASGOffset
)
+
"= "
);
print
(
" "
+
operatorName
(
tree
.
getTag
()
.
noAssignOp
()
)
+
"= "
);
printExpr
(
tree
.
rhs
,
TreeInfo
.
assignopPrec
);
close
(
prec
,
TreeInfo
.
assignopPrec
);
}
catch
(
IOException
e
)
{
...
...
@@ -978,7 +980,7 @@ public class Pretty extends JCTree.Visitor {
int
ownprec
=
TreeInfo
.
opPrec
(
tree
.
getTag
());
String
opname
=
operatorName
(
tree
.
getTag
());
open
(
prec
,
ownprec
);
if
(
tree
.
getTag
()
<=
JCTree
.
PREDEC
)
{
if
(
!
tree
.
getTag
().
isPostUnaryOp
()
)
{
print
(
opname
);
printExpr
(
tree
.
arg
,
ownprec
);
}
else
{
...
...
@@ -1153,7 +1155,7 @@ public class Pretty extends JCTree.Visitor {
while
(
true
)
{
elem
=
tree
.
elemtype
;
print
(
"[]"
);
if
(
elem
.
getTag
()
!=
JCTree
.
TYPEARRAY
)
break
;
if
(
!
elem
.
hasTag
(
TYPEARRAY
)
)
break
;
tree
=
(
JCArrayTypeTree
)
elem
;
}
}
...
...
src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
浏览文件 @
b46865f7
...
...
@@ -406,7 +406,7 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
public
JCTree
visitOther
(
Tree
node
,
P
p
)
{
JCTree
tree
=
(
JCTree
)
node
;
switch
(
tree
.
getTag
())
{
case
JCTree
.
LETEXPR
:
{
case
LETEXPR:
{
LetExpr
t
=
(
LetExpr
)
node
;
List
<
JCVariableDecl
>
defs
=
copy
(
t
.
defs
,
p
);
JCTree
expr
=
copy
(
t
.
expr
,
p
);
...
...
src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
浏览文件 @
b46865f7
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
浏览文件 @
b46865f7
...
...
@@ -363,19 +363,19 @@ public class TreeMaker implements JCTree.Factory {
return
tree
;
}
public
JCAssignOp
Assignop
(
int
opcode
,
JCTree
lhs
,
JCTree
rhs
)
{
public
JCAssignOp
Assignop
(
JCTree
.
Tag
opcode
,
JCTree
lhs
,
JCTree
rhs
)
{
JCAssignOp
tree
=
new
JCAssignOp
(
opcode
,
lhs
,
rhs
,
null
);
tree
.
pos
=
pos
;
return
tree
;
}
public
JCUnary
Unary
(
int
opcode
,
JCExpression
arg
)
{
public
JCUnary
Unary
(
JCTree
.
Tag
opcode
,
JCExpression
arg
)
{
JCUnary
tree
=
new
JCUnary
(
opcode
,
arg
);
tree
.
pos
=
pos
;
return
tree
;
}
public
JCBinary
Binary
(
int
opcode
,
JCExpression
lhs
,
JCExpression
rhs
)
{
public
JCBinary
Binary
(
JCTree
.
Tag
opcode
,
JCExpression
lhs
,
JCExpression
rhs
)
{
JCBinary
tree
=
new
JCBinary
(
opcode
,
lhs
,
rhs
,
null
);
tree
.
pos
=
pos
;
return
tree
;
...
...
src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
浏览文件 @
b46865f7
...
...
@@ -65,6 +65,7 @@ import com.sun.tools.javac.util.Names;
import
com.sun.tools.javac.util.Position
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Kinds
.*;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/**
* Represents a java class and provides access to information
...
...
@@ -1083,7 +1084,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
Name
asterisk
=
tsym
.
name
.
table
.
names
.
asterisk
;
for
(
JCTree
t
:
compenv
.
toplevel
.
defs
)
{
if
(
t
.
getTag
()
==
JCTree
.
IMPORT
)
{
if
(
t
.
hasTag
(
IMPORT
)
)
{
JCTree
imp
=
((
JCImport
)
t
).
qualid
;
if
((
TreeInfo
.
name
(
imp
)
!=
asterisk
)
&&
(
imp
.
type
.
tsym
.
kind
&
Kinds
.
TYP
)
!=
0
)
{
...
...
@@ -1124,7 +1125,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
if
(
compenv
==
null
)
return
new
PackageDocImpl
[
0
];
for
(
JCTree
t
:
compenv
.
toplevel
.
defs
)
{
if
(
t
.
getTag
()
==
JCTree
.
IMPORT
)
{
if
(
t
.
hasTag
(
IMPORT
)
)
{
JCTree
imp
=
((
JCImport
)
t
).
qualid
;
if
(
TreeInfo
.
name
(
imp
)
==
names
.
asterisk
)
{
JCFieldAccess
sel
=
(
JCFieldAccess
)
imp
;
...
...
src/share/classes/com/sun/tools/javadoc/JavadocTool.java
浏览文件 @
b46865f7
...
...
@@ -419,7 +419,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
ListBuffer
<
JCClassDecl
>
result
=
new
ListBuffer
<
JCClassDecl
>();
for
(
JCCompilationUnit
t
:
trees
)
{
for
(
JCTree
def
:
t
.
defs
)
{
if
(
def
.
getTag
()
==
JCTree
.
CLASSDEF
)
if
(
def
.
hasTag
(
JCTree
.
Tag
.
CLASSDEF
)
)
result
.
append
((
JCClassDecl
)
def
);
}
}
...
...
test/Makefile
浏览文件 @
b46865f7
...
...
@@ -19,6 +19,7 @@
# Get OS/ARCH specifics
OSNAME
=
$(
shell
uname
-s
)
ifeq
($(OSNAME), SunOS)
SLASH_JAVA
=
/java
PLATFORM
=
solaris
JT_PLATFORM
=
solaris
ARCH
=
$(
shell
uname
-p
)
...
...
@@ -27,6 +28,7 @@ ifeq ($(OSNAME), SunOS)
endif
endif
ifeq
($(OSNAME), Linux)
SLASH_JAVA
=
/java
PLATFORM
=
linux
JT_PLATFORM
=
linux
ARCH
=
$(
shell
uname
-m
)
...
...
@@ -35,7 +37,16 @@ ifeq ($(OSNAME), Linux)
endif
endif
ifeq
($(OSNAME), Windows_NT)
# MKS
PLATFORM
=
windows
endif
ifeq
($(PLATFORM),)
PLATFORM
=
windows
CYGPATH
=
| cygpath
-m
-s
-f
-
endif
ifeq
($(PLATFORM), windows)
SLASH_JAVA
=
J:
JT_PLATFORM
=
win32
ifeq
($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
ARCH
=
ia64
...
...
@@ -54,7 +65,7 @@ ifeq ($(OSNAME), Windows_NT)
endif
# Root of this test area (important to use full paths in some places)
TEST_ROOT
:=
$(
shell
pwd
)
TEST_ROOT
:=
$(
shell
pwd
$(CYGPATH)
)
# Default bundle of all test results (passed or not) (JPRT only)
ifdef
JPRT_JOB_ID
...
...
@@ -72,7 +83,7 @@ endif
ifdef
JPRT_JTREG_HOME
JTREG_HOME
=
$(JPRT_JTREG_HOME)
else
JTREG_HOME
=
$(SLASH_JAVA)
/re/jtreg/4.
0
/promoted/latest/binaries/jtreg
JTREG_HOME
=
$(SLASH_JAVA)
/re/jtreg/4.
1
/promoted/latest/binaries/jtreg
endif
JTREG
=
$(JTREG_HOME)
/
$(JT_PLATFORM)
/bin/jtreg
JTDIFF
=
$(JTREG_HOME)
/
$(JT_PLATFORM)
/bin/jtdiff
...
...
@@ -81,7 +92,7 @@ JTDIFF = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtdiff
ifdef
JPRT_JCK_HOME
JCK_HOME
=
$(JPRT_JCK_HOME)
else
JCK_HOME
=
$(SLASH_JAVA)
/re/jck/
7
/promoted/latest/binaries
JCK_HOME
=
$(SLASH_JAVA)
/re/jck/
8
/promoted/latest/binaries
endif
# Default JDK for JTREG and JCK
...
...
@@ -93,7 +104,7 @@ endif
ifdef
JPRT_JAVA_HOME
JT_JAVA
=
$(JPRT_JAVA_HOME)
else
JT_JAVA
=
$(SLASH_JAVA)
/re/jdk/1.
6
.0/archive/fcs/binaries/
$(PLATFORM)
-
$(ARCH)
JT_JAVA
=
$(SLASH_JAVA)
/re/jdk/1.
7
.0/archive/fcs/binaries/
$(PLATFORM)
-
$(ARCH)
endif
# Default JDK to test
...
...
@@ -195,7 +206,7 @@ TEST_OUTPUT_DIR = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools
ABS_TEST_OUTPUT_DIR
:=
\
$(
shell
mkdir
-p
$(TEST_ROOT)
/../build/
$(PLATFORM)
-
$(ARCH)
/test/langtools
;
\
cd
$(TEST_ROOT)
/../build/
$(PLATFORM)
-
$(ARCH)
/test/langtools
;
\
pwd
)
pwd
$(CYGPATH)
)
# Subdirectories for different test runs
JTREG_OUTPUT_DIR
=
$(ABS_TEST_OUTPUT_DIR)
/jtreg
JCK_COMPILER_OUTPUT_DIR
=
$(ABS_TEST_OUTPUT_DIR)
/jck-compiler
...
...
@@ -272,15 +283,17 @@ jtreg-summary: FRC
fi
# Check to make sure these directories exist
check-jtreg
:
$(
JT_HOME) $(
PRODUCT_HOME) $(JTREG)
check-jtreg
:
$(PRODUCT_HOME) $(JTREG)
# Run JCK-compiler tests
#
# JCK_HOME
# Installed location of JCK: should include JCK-compiler, and JCK-extras
# Default is JCK 8.
# JT_JAVA
# Version of java used to run JCK. Should normally be the same as TESTJAVA
# Default is JDK 7
# TESTJAVA
# Version of java to be tested.
# JCK_COMPILER_OPTIONS
...
...
@@ -297,7 +310,7 @@ jck-compiler-tests: check-jck FRC
$(JCK_COMPILER_OUTPUT_DIR)
/diff.html
$(JCK_COMPILER_OUTPUT_DIR)
/status.txt
@
mkdir
-p
$(JCK_COMPILER_OUTPUT_DIR)
$(JT_JAVA)
/bin/java
-XX
:MaxPermSize
=
256m
-Xmx512m
\
-jar
$(JCK_HOME)
/JCK-compiler-
7
/lib/jtjck.jar
\
-jar
$(JCK_HOME)
/JCK-compiler-
8
/lib/jtjck.jar
\
-v
:non-pass
\
-r
:
$(JCK_COMPILER_OUTPUT_DIR)
/report
\
-w
:
$(JCK_COMPILER_OUTPUT_DIR)
/work
\
...
...
@@ -346,7 +359,7 @@ jck-runtime-tests: check-jck FRC
$(JCK_RUNTIME_OUTPUT_DIR)
/diff.html
$(JCK_RUNTIME_OUTPUT_DIR)
/status.txt
@
mkdir
-p
$(JCK_RUNTIME_OUTPUT_DIR)
$(JT_JAVA)
/bin/java
-XX
:MaxPermSize
=
256m
-Xmx512m
\
-jar
$(JCK_HOME)
/JCK-runtime-
7
/lib/jtjck.jar
\
-jar
$(JCK_HOME)
/JCK-runtime-
8
/lib/jtjck.jar
\
-v
:non-pass
\
-r
:
$(JCK_RUNTIME_OUTPUT_DIR)
/report
\
-w
:
$(JCK_RUNTIME_OUTPUT_DIR)
/work
\
...
...
@@ -373,7 +386,7 @@ jck-runtime-summary: FRC
fi
# Check to make sure these directories exist
check-jck
:
$(J
T_HOME) $(J
CK_HOME) $(PRODUCT_HOME)
check-jck
:
$(JCK_HOME) $(PRODUCT_HOME)
all-summary
:
FRC
if
[
-n
"
`
find
$(TEST_OUTPUT_DIR)
-name
status.txt
`
"
]
;
then
...
...
test/tools/javac/depDocComment/DeprecatedDocComment4.java
0 → 100644
浏览文件 @
b46865f7
/**
* @test /nodynamiccopyright/
* @bug 7104201
* @summary Refactor DocCommentScanner
* @compile/fail/ref=DeprecatedDocComment4.out -XDrawDiagnostics -Werror -Xlint:dep-ann DeprecatedDocComment4.java
*/
class
DeprecatedDocComment4
{
/** @deprecated **/
/* block */
void
test1
()
{};
/** @deprecated **/
/** double javadoc */
void
test2
()
{};
/** @deprecated **/
//line comment
void
test3
()
{};
}
test/tools/javac/depDocComment/DeprecatedDocComment4.out
0 → 100644
浏览文件 @
b46865f7
DeprecatedDocComment4.java:11:10: compiler.warn.missing.deprecated.annotation
DeprecatedDocComment4.java:15:10: compiler.warn.missing.deprecated.annotation
DeprecatedDocComment4.java:19:10: compiler.warn.missing.deprecated.annotation
- compiler.err.warnings.and.werror
1 error
3 warnings
test/tools/javac/failover/CheckAttributedTree.java
浏览文件 @
b46865f7
/*
* 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
...
...
@@ -85,6 +85,8 @@ import java.util.HashSet;
import
java.util.Set
;
import
javax.lang.model.element.Element
;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
/**
* Utility and test program to check validity of tree positions for tree nodes.
* The program can be run standalone, or as a jtreg test. In standalone mode,
...
...
@@ -289,7 +291,7 @@ public class CheckAttributedTree {
for
(
CompilationUnitTree
t
:
trees
)
{
JCCompilationUnit
cu
=
(
JCCompilationUnit
)
t
;
for
(
JCTree
def
:
cu
.
defs
)
{
if
(
def
.
getTag
()
==
JCTree
.
CLASSDEF
&&
if
(
def
.
hasTag
(
CLASSDEF
)
&&
analyzedElems
.
contains
(((
JCTree
.
JCClassDecl
)
def
).
sym
))
{
//System.out.println("Adding pair...");
res
.
add
(
new
Pair
<>(
cu
,
def
));
...
...
@@ -373,9 +375,9 @@ public class CheckAttributedTree {
private
boolean
mandatoryType
(
JCTree
that
)
{
return
that
instanceof
JCTree
.
JCExpression
||
that
.
getTag
()
==
JCTree
.
VARDEF
||
that
.
getTag
()
==
JCTree
.
METHODDEF
||
that
.
getTag
()
==
JCTree
.
CLASSDEF
;
that
.
hasTag
(
VARDEF
)
||
that
.
hasTag
(
METHODDEF
)
||
that
.
hasTag
(
CLASSDEF
)
;
}
private
final
List
<
String
>
excludedFields
=
Arrays
.
asList
(
"varargsElement"
);
...
...
@@ -429,7 +431,7 @@ public class CheckAttributedTree {
private
class
Info
{
Info
()
{
tree
=
null
;
tag
=
JCTree
.
ERRONEOUS
;
tag
=
ERRONEOUS
;
start
=
0
;
pos
=
0
;
end
=
Integer
.
MAX_VALUE
;
...
...
@@ -449,7 +451,7 @@ public class CheckAttributedTree {
}
final
JCTree
tree
;
final
int
tag
;
final
JCTree
.
Tag
tag
;
final
int
start
;
final
int
pos
;
final
int
end
;
...
...
@@ -457,27 +459,10 @@ public class CheckAttributedTree {
/**
* Names for tree tags.
* javac does not provide an API to convert tag values to strings, so this class uses
* reflection to determine names of public static final int values in JCTree.
*/
private
static
class
TreeUtil
{
String
nameFromTag
(
int
tag
)
{
if
(
names
==
null
)
{
names
=
new
HashMap
<
Integer
,
String
>();
Class
c
=
JCTree
.
class
;
for
(
Field
f
:
c
.
getDeclaredFields
())
{
if
(
f
.
getType
().
equals
(
int
.
class
))
{
int
mods
=
f
.
getModifiers
();
if
(
Modifier
.
isPublic
(
mods
)
&&
Modifier
.
isStatic
(
mods
)
&&
Modifier
.
isFinal
(
mods
))
{
try
{
names
.
put
(
f
.
getInt
(
null
),
f
.
getName
());
}
catch
(
IllegalAccessException
e
)
{
}
}
}
}
}
String
name
=
names
.
get
(
tag
);
String
nameFromTag
(
JCTree
.
Tag
tag
)
{
String
name
=
tag
.
name
();
return
(
name
==
null
)
?
"??"
:
name
;
}
...
...
@@ -496,8 +481,6 @@ public class CheckAttributedTree {
}
return
buf
;
}
private
Map
<
Integer
,
String
>
names
;
}
/**
...
...
test/tools/javac/tree/AbstractTreeScannerTest.java
浏览文件 @
b46865f7
/*
* 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
...
...
@@ -274,7 +274,7 @@ public abstract class AbstractTreeScannerTest {
return
fields
;
}
// where
Map
<
Integer
,
Set
<
Field
>>
map
=
new
HashMap
<
Integer
,
Set
<
Field
>>();
Map
<
JCTree
.
Tag
,
Set
<
Field
>>
map
=
new
HashMap
<
JCTree
.
Tag
,
Set
<
Field
>>();
/** Get the line number for the primary position for a tree.
* The code is intended to be simple, although not necessarily efficient.
...
...
test/tools/javac/tree/TreePosTest.java
浏览文件 @
b46865f7
/*
* 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
...
...
@@ -80,6 +80,7 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import
com.sun.tools.javac.tree.TreeInfo
;
import
com.sun.tools.javac.tree.TreeScanner
;
import
static
com
.
sun
.
tools
.
javac
.
tree
.
JCTree
.
Tag
.*;
import
static
com
.
sun
.
tools
.
javac
.
util
.
Position
.
NOPOS
;
/**
...
...
@@ -291,6 +292,14 @@ public class TreePosTest {
errors
++;
}
/**
* Names for tree tags.
*/
private
static
String
getTagName
(
JCTree
.
Tag
tag
)
{
String
name
=
tag
.
name
();
return
(
name
==
null
)
?
"??"
:
name
;
}
/** Number of files that have been analyzed. */
int
fileCount
;
/** Number of errors reported. */
...
...
@@ -312,8 +321,6 @@ public class TreePosTest {
Set
<
File
>
excludeFiles
=
new
HashSet
<
File
>();
/** Set of tag names to be excluded from analysis. */
Set
<
String
>
excludeTags
=
new
HashSet
<
String
>();
/** Table of printable names for tree tag values. */
TagNames
tagNames
=
new
TagNames
();
/**
* Main class for testing assertions concerning tree positions for tree nodes.
...
...
@@ -337,7 +344,7 @@ public class TreePosTest {
// there is no corresponding source text.
// Redundant semicolons in a class definition can cause empty
// initializer blocks with no positions.
if
((
self
.
tag
==
JCTree
.
MODIFIERS
||
self
.
tag
==
JCTree
.
BLOCK
)
if
((
self
.
tag
==
MODIFIERS
||
self
.
tag
==
BLOCK
)
&&
self
.
pos
==
NOPOS
)
{
// If pos is NOPOS, so should be the start and end positions
check
(
"start == NOPOS"
,
encl
,
self
,
self
.
start
==
NOPOS
);
...
...
@@ -359,15 +366,15 @@ public class TreePosTest {
// e.g. int[][] a = new int[2][];
check
(
"encl.start <= start"
,
encl
,
self
,
encl
.
start
<=
self
.
start
);
check
(
"start <= pos"
,
encl
,
self
,
self
.
start
<=
self
.
pos
);
if
(!(
self
.
tag
==
JCTree
.
TYPEARRAY
&&
(
encl
.
tag
==
JCTree
.
VARDEF
||
encl
.
tag
==
JCTree
.
METHODDEF
||
encl
.
tag
==
JCTree
.
TYPEARRAY
)))
{
if
(!(
self
.
tag
==
TYPEARRAY
&&
(
encl
.
tag
==
VARDEF
||
encl
.
tag
==
METHODDEF
||
encl
.
tag
==
TYPEARRAY
)))
{
check
(
"encl.pos <= start || end <= encl.pos"
,
encl
,
self
,
encl
.
pos
<=
self
.
start
||
self
.
end
<=
encl
.
pos
);
}
check
(
"pos <= end"
,
encl
,
self
,
self
.
pos
<=
self
.
end
);
if
(!(
self
.
tag
==
JCTree
.
TYPEARRAY
&&
encl
.
tag
==
JCTree
.
TYPEARRAY
))
{
if
(!(
self
.
tag
==
TYPEARRAY
&&
encl
.
tag
==
TYPEARRAY
))
{
check
(
"end <= encl.end"
,
encl
,
self
,
self
.
end
<=
encl
.
end
);
}
}
...
...
@@ -388,7 +395,7 @@ public class TreePosTest {
if
((
tree
.
mods
.
flags
&
Flags
.
ENUM
)
!=
0
)
{
scan
(
tree
.
mods
);
if
(
tree
.
init
!=
null
)
{
if
(
tree
.
init
.
getTag
()
==
JCTree
.
NEWCLASS
)
{
if
(
tree
.
init
.
hasTag
(
NEWCLASS
)
)
{
JCNewClass
init
=
(
JCNewClass
)
tree
.
init
;
if
(
init
.
args
!=
null
&&
init
.
args
.
nonEmpty
())
{
scan
(
init
.
args
);
...
...
@@ -404,11 +411,11 @@ public class TreePosTest {
boolean
check
(
Info
encl
,
Info
self
)
{
if
(
excludeTags
.
size
()
>
0
)
{
if
(
encl
!=
null
&&
excludeTags
.
contains
(
tagNames
.
get
(
encl
.
tag
))
||
excludeTags
.
contains
(
tagNames
.
get
(
self
.
tag
)))
if
(
encl
!=
null
&&
excludeTags
.
contains
(
getTagName
(
encl
.
tag
))
||
excludeTags
.
contains
(
getTagName
(
self
.
tag
)))
return
false
;
}
return
tags
.
size
()
==
0
||
tags
.
contains
(
tagNames
.
get
(
self
.
tag
));
return
tags
.
size
()
==
0
||
tags
.
contains
(
getTagName
(
self
.
tag
));
}
void
check
(
String
label
,
Info
encl
,
Info
self
,
boolean
ok
)
{
...
...
@@ -439,7 +446,7 @@ public class TreePosTest {
private
class
Info
{
Info
()
{
tree
=
null
;
tag
=
JCTree
.
ERRONEOUS
;
tag
=
ERRONEOUS
;
start
=
0
;
pos
=
0
;
end
=
Integer
.
MAX_VALUE
;
...
...
@@ -455,45 +462,16 @@ public class TreePosTest {
@Override
public
String
toString
()
{
return
tagNames
.
get
(
tree
.
getTag
())
+
"[start:"
+
start
+
",pos:"
+
pos
+
",end:"
+
end
+
"]"
;
return
getTagName
(
tree
.
getTag
())
+
"[start:"
+
start
+
",pos:"
+
pos
+
",end:"
+
end
+
"]"
;
}
final
JCTree
tree
;
final
int
tag
;
final
JCTree
.
Tag
tag
;
final
int
start
;
final
int
pos
;
final
int
end
;
}
/**
* Names for tree tags.
* javac does not provide an API to convert tag values to strings, so this class uses
* reflection to determine names of public static final int values in JCTree.
*/
private
static
class
TagNames
{
String
get
(
int
tag
)
{
if
(
map
==
null
)
{
map
=
new
HashMap
<
Integer
,
String
>();
Class
c
=
JCTree
.
class
;
for
(
Field
f
:
c
.
getDeclaredFields
())
{
if
(
f
.
getType
().
equals
(
int
.
class
))
{
int
mods
=
f
.
getModifiers
();
if
(
Modifier
.
isPublic
(
mods
)
&&
Modifier
.
isStatic
(
mods
)
&&
Modifier
.
isFinal
(
mods
))
{
try
{
map
.
put
(
f
.
getInt
(
null
),
f
.
getName
());
}
catch
(
IllegalAccessException
e
)
{
}
}
}
}
}
String
name
=
map
.
get
(
tag
);
return
(
name
==
null
)
?
"??"
:
name
;
}
private
Map
<
Integer
,
String
>
map
;
}
/**
* Thrown when errors are found parsing a java file.
*/
...
...
@@ -719,7 +697,7 @@ public class TreePosTest {
void
setInfo
(
Info
info
)
{
this
.
info
=
info
;
tagName
.
setText
(
tagNames
.
get
(
info
.
tag
));
tagName
.
setText
(
getTagName
(
info
.
tag
));
start
.
setText
(
String
.
valueOf
(
info
.
start
));
pos
.
setText
(
String
.
valueOf
(
info
.
pos
));
end
.
setText
(
String
.
valueOf
(
info
.
end
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录