Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
71cc3199
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看板
提交
71cc3199
编写于
3月 03, 2011
作者:
M
mcimadamore
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7023703: Valid code doesn't compile
Summary: leftovers cause problems when analyzing loops in Flow.java Reviewed-by: jjg
上级
e7767409
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
164 addition
and
9 deletion
+164
-9
src/share/classes/com/sun/tools/javac/comp/Flow.java
src/share/classes/com/sun/tools/javac/comp/Flow.java
+15
-9
test/tools/javac/7023703/T7023703neg.java
test/tools/javac/7023703/T7023703neg.java
+71
-0
test/tools/javac/7023703/T7023703neg.out
test/tools/javac/7023703/T7023703neg.out
+5
-0
test/tools/javac/7023703/T7023703pos.java
test/tools/javac/7023703/T7023703pos.java
+73
-0
未找到文件。
src/share/classes/com/sun/tools/javac/comp/Flow.java
浏览文件 @
71cc3199
...
@@ -804,14 +804,16 @@ public class Flow extends TreeScanner {
...
@@ -804,14 +804,16 @@ public class Flow extends TreeScanner {
ListBuffer
<
PendingExit
>
prevPendingExits
=
pendingExits
;
ListBuffer
<
PendingExit
>
prevPendingExits
=
pendingExits
;
boolean
prevLoopPassTwo
=
loopPassTwo
;
boolean
prevLoopPassTwo
=
loopPassTwo
;
pendingExits
=
new
ListBuffer
<
PendingExit
>();
pendingExits
=
new
ListBuffer
<
PendingExit
>();
int
prevErrors
=
log
.
nerrors
;
do
{
do
{
Bits
uninitsEntry
=
uninits
.
dup
();
Bits
uninitsEntry
=
uninits
.
dup
();
uninitsEntry
.
excludeFrom
(
nextadr
);
scanStat
(
tree
.
body
);
scanStat
(
tree
.
body
);
alive
|=
resolveContinues
(
tree
);
alive
|=
resolveContinues
(
tree
);
scanCond
(
tree
.
cond
);
scanCond
(
tree
.
cond
);
if
(
log
.
nerrors
!=
0
||
if
(
log
.
nerrors
!=
prevErrors
||
loopPassTwo
||
loopPassTwo
||
uninitsEntry
.
diffSet
(
uninitsWhenTrue
).
nextBit
(
firstadr
)==-
1
)
uninitsEntry
.
d
up
().
d
iffSet
(
uninitsWhenTrue
).
nextBit
(
firstadr
)==-
1
)
break
;
break
;
inits
=
initsWhenTrue
;
inits
=
initsWhenTrue
;
uninits
=
uninitsEntry
.
andSet
(
uninitsWhenTrue
);
uninits
=
uninitsEntry
.
andSet
(
uninitsWhenTrue
);
...
@@ -831,8 +833,10 @@ public class Flow extends TreeScanner {
...
@@ -831,8 +833,10 @@ public class Flow extends TreeScanner {
Bits
initsCond
;
Bits
initsCond
;
Bits
uninitsCond
;
Bits
uninitsCond
;
pendingExits
=
new
ListBuffer
<
PendingExit
>();
pendingExits
=
new
ListBuffer
<
PendingExit
>();
int
prevErrors
=
log
.
nerrors
;
do
{
do
{
Bits
uninitsEntry
=
uninits
.
dup
();
Bits
uninitsEntry
=
uninits
.
dup
();
uninitsEntry
.
excludeFrom
(
nextadr
);
scanCond
(
tree
.
cond
);
scanCond
(
tree
.
cond
);
initsCond
=
initsWhenFalse
;
initsCond
=
initsWhenFalse
;
uninitsCond
=
uninitsWhenFalse
;
uninitsCond
=
uninitsWhenFalse
;
...
@@ -841,9 +845,9 @@ public class Flow extends TreeScanner {
...
@@ -841,9 +845,9 @@ public class Flow extends TreeScanner {
alive
=
!
tree
.
cond
.
type
.
isFalse
();
alive
=
!
tree
.
cond
.
type
.
isFalse
();
scanStat
(
tree
.
body
);
scanStat
(
tree
.
body
);
alive
|=
resolveContinues
(
tree
);
alive
|=
resolveContinues
(
tree
);
if
(
log
.
nerrors
!=
0
||
if
(
log
.
nerrors
!=
prevErrors
||
loopPassTwo
||
loopPassTwo
||
uninitsEntry
.
diffSet
(
uninits
).
nextBit
(
firstadr
)
==
-
1
)
uninitsEntry
.
d
up
().
d
iffSet
(
uninits
).
nextBit
(
firstadr
)
==
-
1
)
break
;
break
;
uninits
=
uninitsEntry
.
andSet
(
uninits
);
uninits
=
uninitsEntry
.
andSet
(
uninits
);
loopPassTwo
=
true
;
loopPassTwo
=
true
;
...
@@ -864,8 +868,10 @@ public class Flow extends TreeScanner {
...
@@ -864,8 +868,10 @@ public class Flow extends TreeScanner {
Bits
initsCond
;
Bits
initsCond
;
Bits
uninitsCond
;
Bits
uninitsCond
;
pendingExits
=
new
ListBuffer
<
PendingExit
>();
pendingExits
=
new
ListBuffer
<
PendingExit
>();
int
prevErrors
=
log
.
nerrors
;
do
{
do
{
Bits
uninitsEntry
=
uninits
.
dup
();
Bits
uninitsEntry
=
uninits
.
dup
();
uninitsEntry
.
excludeFrom
(
nextadr
);
if
(
tree
.
cond
!=
null
)
{
if
(
tree
.
cond
!=
null
)
{
scanCond
(
tree
.
cond
);
scanCond
(
tree
.
cond
);
initsCond
=
initsWhenFalse
;
initsCond
=
initsWhenFalse
;
...
@@ -883,7 +889,7 @@ public class Flow extends TreeScanner {
...
@@ -883,7 +889,7 @@ public class Flow extends TreeScanner {
scanStat
(
tree
.
body
);
scanStat
(
tree
.
body
);
alive
|=
resolveContinues
(
tree
);
alive
|=
resolveContinues
(
tree
);
scan
(
tree
.
step
);
scan
(
tree
.
step
);
if
(
log
.
nerrors
!=
0
||
if
(
log
.
nerrors
!=
prevErrors
||
loopPassTwo
||
loopPassTwo
||
uninitsEntry
.
dup
().
diffSet
(
uninits
).
nextBit
(
firstadr
)
==
-
1
)
uninitsEntry
.
dup
().
diffSet
(
uninits
).
nextBit
(
firstadr
)
==
-
1
)
break
;
break
;
...
@@ -897,8 +903,6 @@ public class Flow extends TreeScanner {
...
@@ -897,8 +903,6 @@ public class Flow extends TreeScanner {
alive
=
resolveBreaks
(
tree
,
prevPendingExits
)
||
alive
=
resolveBreaks
(
tree
,
prevPendingExits
)
||
tree
.
cond
!=
null
&&
!
tree
.
cond
.
type
.
isTrue
();
tree
.
cond
!=
null
&&
!
tree
.
cond
.
type
.
isTrue
();
nextadr
=
nextadrPrev
;
nextadr
=
nextadrPrev
;
inits
.
excludeFrom
(
nextadr
);
uninits
.
excludeFrom
(
nextadr
);
}
}
public
void
visitForeachLoop
(
JCEnhancedForLoop
tree
)
{
public
void
visitForeachLoop
(
JCEnhancedForLoop
tree
)
{
...
@@ -913,13 +917,15 @@ public class Flow extends TreeScanner {
...
@@ -913,13 +917,15 @@ public class Flow extends TreeScanner {
letInit
(
tree
.
pos
(),
tree
.
var
.
sym
);
letInit
(
tree
.
pos
(),
tree
.
var
.
sym
);
pendingExits
=
new
ListBuffer
<
PendingExit
>();
pendingExits
=
new
ListBuffer
<
PendingExit
>();
int
prevErrors
=
log
.
nerrors
;
do
{
do
{
Bits
uninitsEntry
=
uninits
.
dup
();
Bits
uninitsEntry
=
uninits
.
dup
();
uninitsEntry
.
excludeFrom
(
nextadr
);
scanStat
(
tree
.
body
);
scanStat
(
tree
.
body
);
alive
|=
resolveContinues
(
tree
);
alive
|=
resolveContinues
(
tree
);
if
(
log
.
nerrors
!=
0
||
if
(
log
.
nerrors
!=
prevErrors
||
loopPassTwo
||
loopPassTwo
||
uninitsEntry
.
diffSet
(
uninits
).
nextBit
(
firstadr
)
==
-
1
)
uninitsEntry
.
d
up
().
d
iffSet
(
uninits
).
nextBit
(
firstadr
)
==
-
1
)
break
;
break
;
uninits
=
uninitsEntry
.
andSet
(
uninits
);
uninits
=
uninitsEntry
.
andSet
(
uninits
);
loopPassTwo
=
true
;
loopPassTwo
=
true
;
...
...
test/tools/javac/7023703/T7023703neg.java
0 → 100644
浏览文件 @
71cc3199
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 7023703
* @summary Valid code doesn't compile
* @compile/fail/ref=T7023703neg.out -XDrawDiagnostics T7023703neg.java
*/
class
T7023703neg
{
void
testForLoop
(
boolean
cond
)
{
final
int
bug
;
final
int
bug2
;
for
(;
cond
;)
{
final
int
item
=
0
;
bug2
=
1
;
//error
}
bug
=
0
;
//ok
}
void
testForEachLoop
(
java
.
util
.
Collection
<
Integer
>
c
)
{
final
int
bug
;
final
int
bug2
;
for
(
Integer
i
:
c
)
{
final
int
item
=
0
;
bug2
=
1
;
//error
}
bug
=
0
;
//ok
}
void
testWhileLoop
(
boolean
cond
)
{
final
int
bug
;
final
int
bug2
;
while
(
cond
)
{
final
int
item
=
0
;
bug2
=
1
;
//error
}
bug
=
0
;
//ok
}
void
testDoWhileLoop
(
boolean
cond
)
{
final
int
bug
;
final
int
bug2
;
do
{
final
int
item
=
0
;
bug2
=
1
;
//error
}
while
(
cond
);
bug
=
0
;
//ok
}
}
test/tools/javac/7023703/T7023703neg.out
0 → 100644
浏览文件 @
71cc3199
T7023703neg.java:37:13: compiler.err.var.might.be.assigned.in.loop: bug2
T7023703neg.java:47:13: compiler.err.var.might.be.assigned.in.loop: bug2
T7023703neg.java:57:13: compiler.err.var.might.be.assigned.in.loop: bug2
T7023703neg.java:67:13: compiler.err.var.might.be.assigned.in.loop: bug2
4 errors
test/tools/javac/7023703/T7023703pos.java
0 → 100644
浏览文件 @
71cc3199
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 7023703
* @summary Valid code doesn't compile
* @compile T7023703pos.java
*/
class
T7023703pos
{
void
testForLoop
()
{
final
int
bug
;
for
(;
"a"
.
equals
(
"b"
);)
{
final
int
item
=
0
;
}
bug
=
0
;
//ok
}
void
testForEachLoop
(
boolean
cond
,
java
.
util
.
Collection
<
Integer
>
c
)
{
final
int
bug
;
for
(
Integer
i
:
c
)
{
if
(
cond
)
{
final
int
item
=
0
;
}
}
bug
=
0
;
//ok
}
void
testWhileLoop
()
{
final
int
bug
;
while
(
"a"
.
equals
(
"b"
))
{
final
int
item
=
0
;
}
bug
=
0
;
//ok
}
void
testDoWhileLoop
()
{
final
int
bug
;
do
{
final
int
item
=
0
;
}
while
(
"a"
.
equals
(
"b"
));
bug
=
0
;
//ok
}
private
static
class
Inner
{
private
final
int
a
,
b
,
c
,
d
,
e
;
public
Inner
()
{
a
=
b
=
c
=
d
=
e
=
0
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录