Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
44225572
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看板
提交
44225572
编写于
2月 05, 2016
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
3907acf9
7082f467
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
171 addition
and
24 deletion
+171
-24
src/share/classes/com/sun/tools/javac/util/GraphUtils.java
src/share/classes/com/sun/tools/javac/util/GraphUtils.java
+49
-24
test/tools/javac/generics/inference/8130304/T8130304.java
test/tools/javac/generics/inference/8130304/T8130304.java
+74
-0
test/tools/javac/generics/inference/8130304/T8130304b.java
test/tools/javac/generics/inference/8130304/T8130304b.java
+48
-0
未找到文件。
src/share/classes/com/sun/tools/javac/util/GraphUtils.java
浏览文件 @
44225572
...
...
@@ -103,34 +103,60 @@ public class GraphUtils {
* directed graph in linear time. Works on TarjanNode.
*/
public
static
<
D
,
N
extends
TarjanNode
<
D
>>
List
<?
extends
List
<?
extends
N
>>
tarjan
(
Iterable
<?
extends
N
>
nodes
)
{
ListBuffer
<
List
<
N
>>
cycles
=
new
ListBuffer
<>();
ListBuffer
<
N
>
stack
=
new
ListBuffer
<>();
Tarjan
<
D
,
N
>
tarjan
=
new
Tarjan
<>();
return
tarjan
.
findSCC
(
nodes
);
}
//where
private
static
class
Tarjan
<
D
,
N
extends
TarjanNode
<
D
>>
{
/** Unique node identifier. */
int
index
=
0
;
for
(
N
node:
nodes
)
{
if
(
node
.
index
==
-
1
)
{
index
+=
tarjan
(
node
,
index
,
stack
,
cycles
);
/** List of SCCs found so far. */
ListBuffer
<
List
<
N
>>
sccs
=
new
ListBuffer
<>();
/** Stack of all reacheable nodes from given root. */
ListBuffer
<
N
>
stack
=
new
ListBuffer
<>();
private
List
<?
extends
List
<?
extends
N
>>
findSCC
(
Iterable
<?
extends
N
>
nodes
)
{
for
(
N
node
:
nodes
)
{
if
(
node
.
index
==
-
1
)
{
findSCC
(
node
);
}
}
return
sccs
.
toList
();
}
return
cycles
.
toList
();
}
private
static
<
D
,
N
extends
TarjanNode
<
D
>>
int
tarjan
(
N
v
,
int
index
,
ListBuffer
<
N
>
stack
,
ListBuffer
<
List
<
N
>>
cycles
)
{
v
.
index
=
index
;
v
.
lowlink
=
index
;
index
++;
stack
.
prepend
(
v
);
v
.
active
=
true
;
for
(
TarjanNode
<
D
>
nd:
v
.
getAllDependencies
())
{
@SuppressWarnings
(
"unchecked"
)
N
n
=
(
N
)
nd
;
if
(
n
.
index
==
-
1
)
{
tarjan
(
n
,
index
,
stack
,
cycles
);
v
.
lowlink
=
Math
.
min
(
v
.
lowlink
,
n
.
lowlink
);
}
else
if
(
stack
.
contains
(
n
))
{
v
.
lowlink
=
Math
.
min
(
v
.
lowlink
,
n
.
index
);
private
void
findSCC
(
N
v
)
{
visitNode
(
v
);
for
(
TarjanNode
<
D
>
tn
:
v
.
getAllDependencies
())
{
@SuppressWarnings
(
"unchecked"
)
N
n
=
(
N
)
tn
;
if
(
n
.
index
==
-
1
)
{
//it's the first time we see this node
findSCC
(
n
);
v
.
lowlink
=
Math
.
min
(
v
.
lowlink
,
n
.
lowlink
);
}
else
if
(
stack
.
contains
(
n
))
{
//this node is already reachable from current root
v
.
lowlink
=
Math
.
min
(
v
.
lowlink
,
n
.
index
);
}
}
if
(
v
.
lowlink
==
v
.
index
)
{
//v is the root of a SCC
addSCC
(
v
);
}
}
if
(
v
.
lowlink
==
v
.
index
)
{
private
void
visitNode
(
N
n
)
{
n
.
index
=
index
;
n
.
lowlink
=
index
;
index
++;
stack
.
prepend
(
n
);
n
.
active
=
true
;
}
private
void
addSCC
(
N
v
)
{
N
n
;
ListBuffer
<
N
>
cycle
=
new
ListBuffer
<>();
do
{
...
...
@@ -138,9 +164,8 @@ public class GraphUtils {
n
.
active
=
false
;
cycle
.
add
(
n
);
}
while
(
n
!=
v
);
cycle
s
.
add
(
cycle
.
toList
());
scc
s
.
add
(
cycle
.
toList
());
}
return
index
;
}
/**
...
...
test/tools/javac/generics/inference/8130304/T8130304.java
0 → 100644
浏览文件 @
44225572
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8130304
* @summary Inference: NodeNotFoundException thrown with deep generic method call chain
* @compile T8130304.java
*/
class
T8130304
{
void
test
()
{
outer
(
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
(),
inner
());
}
<
T
>
void
outer
(
T
...
ts
)
{
}
<
T
,
V
,
W
extends
V
>
T
inner
()
{
return
null
;
}
}
test/tools/javac/generics/inference/8130304/T8130304b.java
0 → 100644
浏览文件 @
44225572
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8130304
* @summary Inference: NodeNotFoundException thrown with deep generic method call chain
* @compile T8130304b.java
*/
class
T8130304b
{
void
test
()
{
TestZ
r
=
null
;
Crazy
<
String
,
String
>
x
=
r
.
m3
(
"X"
);
r
.
m1
(
r
.
m4
(
r
.
m2
(
x
,
r
.
m3
(
"a"
)),
t
->
"x"
),
r
.
m3
(
"a"
));
}
interface
Crazy
<
A
,
B
>
{
}
interface
TestZ
{
public
<
A
,
B
>
Crazy
<
A
,
B
>
m1
(
Crazy
<
A
,
?
extends
B
>...
d
);
public
<
A
,
B
,
C
>
Crazy
<
A
,
Crazy
<
B
,
C
>>
m2
(
Crazy
<
A
,
B
>
e
,
Crazy
<
A
,
C
>
f
);
public
<
A
>
Crazy
<
A
,
A
>
m3
(
A
g
);
public
<
A
,
B
,
C
>
Crazy
<
A
,
C
>
m4
(
Crazy
<
A
,
B
>
h
,
java
.
util
.
function
.
Function
<
B
,
C
>
i
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录