Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
bb5d828b
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看板
提交
bb5d828b
编写于
2月 06, 2014
作者:
V
vromero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8030855: Default methods should be visible under source previous to 8
Reviewed-by: jjg, dlsmith
上级
889ba5f3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
32 deletion
+40
-32
src/share/classes/com/sun/tools/javac/code/Source.java
src/share/classes/com/sun/tools/javac/code/Source.java
+0
-3
src/share/classes/com/sun/tools/javac/comp/Resolve.java
src/share/classes/com/sun/tools/javac/comp/Resolve.java
+6
-11
test/tools/javac/defaultMethodsVisibility/DefaultMethodsNotVisibleForSourceLessThan8Test.java
...ility/DefaultMethodsNotVisibleForSourceLessThan8Test.java
+34
-18
未找到文件。
src/share/classes/com/sun/tools/javac/code/Source.java
浏览文件 @
bb5d828b
...
...
@@ -203,9 +203,6 @@ public enum Source {
public
boolean
allowDefaultMethods
()
{
return
compareTo
(
JDK1_8
)
>=
0
;
}
public
boolean
allowDefaultMethodsResolution
()
{
return
compareTo
(
JDK1_7
)
>=
0
;
}
public
boolean
allowStaticInterfaceMethods
()
{
return
compareTo
(
JDK1_8
)
>=
0
;
}
...
...
src/share/classes/com/sun/tools/javac/comp/Resolve.java
浏览文件 @
bb5d828b
...
...
@@ -92,10 +92,9 @@ public class Resolve {
TreeInfo
treeinfo
;
Types
types
;
JCDiagnostic
.
Factory
diags
;
public
final
boolean
boxingEnabled
;
// = source.allowBoxing();
public
final
boolean
varargsEnabled
;
// = source.allowVarargs();
public
final
boolean
boxingEnabled
;
public
final
boolean
varargsEnabled
;
public
final
boolean
allowMethodHandles
;
public
final
boolean
allowDefaultMethodsResolution
;
public
final
boolean
allowStructuralMostSpecific
;
private
final
boolean
debugResolve
;
private
final
boolean
compactMethodDiags
;
...
...
@@ -137,7 +136,6 @@ public class Resolve {
verboseResolutionMode
=
VerboseResolutionMode
.
getVerboseResolutionMode
(
options
);
Target
target
=
Target
.
instance
(
context
);
allowMethodHandles
=
target
.
hasMethodHandles
();
allowDefaultMethodsResolution
=
source
.
allowDefaultMethodsResolution
();
allowStructuralMostSpecific
=
source
.
allowStructuralMostSpecific
();
polymorphicSignatureScope
=
new
Scope
(
syms
.
noSymbol
);
...
...
@@ -1681,7 +1679,6 @@ public class Resolve {
bestSoFar
:
methodNotFound
;
for
(
InterfaceLookupPhase
iphase2
:
InterfaceLookupPhase
.
values
())
{
if
(
iphase2
==
InterfaceLookupPhase
.
DEFAULT_OK
&&
!
allowDefaultMethodsResolution
)
break
;
//keep searching for abstract methods
for
(
Type
itype
:
itypes
[
iphase2
.
ordinal
()])
{
if
(!
itype
.
isInterface
())
continue
;
//skip j.l.Object (included by Types.closure())
...
...
@@ -1714,10 +1711,8 @@ public class Resolve {
//from superinterfaces)
if
((
s
.
flags
()
&
(
ABSTRACT
|
INTERFACE
|
ENUM
))
!=
0
)
{
return
this
;
}
else
if
(
rs
.
allowDefaultMethodsResolution
)
{
return
DEFAULT_OK
;
}
else
{
return
null
;
return
DEFAULT_OK
;
}
}
},
...
...
@@ -3341,9 +3336,9 @@ public class Resolve {
if
((
env1
.
enclClass
.
sym
.
flags
()
&
STATIC
)
!=
0
)
staticOnly
=
true
;
env1
=
env1
.
outer
;
}
if
(
allowDefaultMethodsResolution
&&
c
.
isInterface
()
&&
name
==
names
.
_super
&&
!
isStatic
(
env
)
&&
types
.
isDirectSuperInterface
(
c
,
env
.
enclClass
.
sym
))
{
if
(
c
.
isInterface
()
&&
name
==
names
.
_super
&&
!
isStatic
(
env
)
&&
types
.
isDirectSuperInterface
(
c
,
env
.
enclClass
.
sym
))
{
//this might be a default super call if one of the superinterfaces is 'c'
for
(
Type
t
:
pruneInterfaces
(
env
.
enclClass
.
type
))
{
if
(
t
.
tsym
==
c
)
{
...
...
test/tools/javac/
T8029240/DefaultMethodsNotVisibileForSource7
Test.java
→
test/tools/javac/
defaultMethodsVisibility/DefaultMethodsNotVisibleForSourceLessThan8
Test.java
浏览文件 @
bb5d828b
...
...
@@ -23,20 +23,21 @@
/*
* @test
* @bug 8029240
* @bug 8029240
8030855
* @summary Default methods not always visible under -source 7
* Default methods should be visible under source previous to 8
* @library /tools/javac/lib
* @build ToolBox
* @run main DefaultMethodsNotVisib
ileForSource7
Test
* @run main DefaultMethodsNotVisib
leForSourceLessThan8
Test
*/
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
public
class
DefaultMethodsNotVisib
ileForSource7
Test
{
public
class
DefaultMethodsNotVisib
leForSourceLessThan8
Test
{
// common definitions
// this one should be compiled with source 8, the rest with source
7
// this one should be compiled with source 8, the rest with source
< 8
static
final
String
ISrc
=
"interface I {\n"
+
" default void m() {}\n"
+
...
...
@@ -54,22 +55,22 @@ public class DefaultMethodsNotVisibileForSource7Test {
// test legacy implementations
static
final
String
C1Src
=
"class C1 implements I {\n"
+
"
@Override
public void m() {}\n"
+
" public void m() {}\n"
+
"}"
;
static
final
String
C2Src
=
"class C2 implements J {\n"
+
"
@Override
public void m() {}\n"
+
" public void m() {}\n"
+
"}"
;
static
final
String
C3Src
=
"class C3 extends A {\n"
+
"
@Override
public void m() {}\n"
+
" public void m() {}\n"
+
"}"
;
static
final
String
C4Src
=
"class C4 extends B {\n"
+
"
@Override
public void m() {}\n"
+
" public void m() {}\n"
+
"}"
;
//test legacy invocations
...
...
@@ -99,10 +100,25 @@ public class DefaultMethodsNotVisibileForSource7Test {
"}"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
DefaultMethodsNotVisibileForSource7Test
().
run
();
String
[]
sources
=
new
String
[]
{
"1.2"
,
"1.3"
,
"1.4"
,
"1.5"
,
"1.6"
,
"1.7"
,
};
for
(
String
source
:
sources
)
{
new
DefaultMethodsNotVisibleForSourceLessThan8Test
().
run
(
source
);
}
}
void
run
()
throws
Exception
{
String
outDir
;
String
source
;
void
run
(
String
source
)
throws
Exception
{
this
.
source
=
source
;
outDir
=
"out"
+
source
.
replace
(
'.'
,
'_'
);
testsPreparation
();
testLegacyImplementations
();
testLegacyInvocations
();
...
...
@@ -110,27 +126,27 @@ public class DefaultMethodsNotVisibileForSource7Test {
}
void
testsPreparation
()
throws
Exception
{
Files
.
createDirectory
(
Paths
.
get
(
"out"
));
Files
.
createDirectory
(
Paths
.
get
(
outDir
));
/* as an extra check let's make sure that interface 'I' can't be compiled
* with source
7
* with source
< 8
*/
ToolBox
.
JavaToolArgs
javacArgs
=
new
ToolBox
.
JavaToolArgs
(
ToolBox
.
Expect
.
FAIL
)
.
setOptions
(
"-d"
,
"out"
,
"-source"
,
"7"
)
.
setOptions
(
"-d"
,
outDir
,
"-source"
,
source
)
.
setSources
(
ISrc
);
ToolBox
.
javac
(
javacArgs
);
//but it should compile with source >= 8
javacArgs
=
new
ToolBox
.
JavaToolArgs
()
.
setOptions
(
"-d"
,
"out"
)
.
setOptions
(
"-d"
,
outDir
)
.
setSources
(
ISrc
);
ToolBox
.
javac
(
javacArgs
);
javacArgs
=
new
ToolBox
.
JavaToolArgs
()
.
setOptions
(
"-cp"
,
"out"
,
"-d"
,
"out"
,
"-source"
,
"7"
)
.
setOptions
(
"-cp"
,
outDir
,
"-d"
,
outDir
,
"-source"
,
source
)
.
setSources
(
JSrc
,
ASrc
,
BSrc
);
ToolBox
.
javac
(
javacArgs
);
}
...
...
@@ -139,7 +155,7 @@ public class DefaultMethodsNotVisibileForSource7Test {
//compile C1-4
ToolBox
.
JavaToolArgs
javacArgs
=
new
ToolBox
.
JavaToolArgs
()
.
setOptions
(
"-cp"
,
"out"
,
"-d"
,
"out"
,
"-source"
,
"7"
)
.
setOptions
(
"-cp"
,
outDir
,
"-d"
,
outDir
,
"-source"
,
source
)
.
setSources
(
C1Src
,
C2Src
,
C3Src
,
C4Src
);
ToolBox
.
javac
(
javacArgs
);
}
...
...
@@ -148,7 +164,7 @@ public class DefaultMethodsNotVisibileForSource7Test {
//compile LegacyInvocation
ToolBox
.
JavaToolArgs
javacArgs
=
new
ToolBox
.
JavaToolArgs
()
.
setOptions
(
"-cp"
,
"out"
,
"-d"
,
"out"
,
"-source"
,
"7"
)
.
setOptions
(
"-cp"
,
outDir
,
"-d"
,
outDir
,
"-source"
,
source
)
.
setSources
(
LegacyInvocationSrc
);
ToolBox
.
javac
(
javacArgs
);
}
...
...
@@ -157,7 +173,7 @@ public class DefaultMethodsNotVisibileForSource7Test {
//compile SubA, SubB
ToolBox
.
JavaToolArgs
javacArgs
=
new
ToolBox
.
JavaToolArgs
()
.
setOptions
(
"-cp"
,
"out"
,
"-d"
,
"out"
,
"-source"
,
"7"
)
.
setOptions
(
"-cp"
,
outDir
,
"-d"
,
outDir
,
"-source"
,
source
)
.
setSources
(
SubASrc
,
SubBSrc
);
ToolBox
.
javac
(
javacArgs
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录