Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
ba90eb5c
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看板
提交
ba90eb5c
编写于
3月 24, 2014
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
aef64240
c3097ee2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
249 addition
and
39 deletion
+249
-39
src/share/classes/com/sun/tools/javac/code/Symbol.java
src/share/classes/com/sun/tools/javac/code/Symbol.java
+25
-11
src/share/classes/com/sun/tools/javac/code/Type.java
src/share/classes/com/sun/tools/javac/code/Type.java
+17
-5
src/share/classes/com/sun/tools/javac/comp/Infer.java
src/share/classes/com/sun/tools/javac/comp/Infer.java
+7
-1
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
+1
-1
src/share/classes/com/sun/tools/javac/jvm/Code.java
src/share/classes/com/sun/tools/javac/jvm/Code.java
+4
-4
test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java
.../javac/IncorrectInheritance/IncorrectInheritanceTest.java
+68
-0
test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java
...ac/annotations/typeAnnotations/referenceinfos/Driver.java
+28
-16
test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java
...s/typeAnnotations/referenceinfos/ExceptionParameters.java
+2
-1
test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java
...tools/javac/classfiles/InnerClasses/SyntheticClasses.java
+97
-0
未找到文件。
src/share/classes/com/sun/tools/javac/code/Symbol.java
浏览文件 @
ba90eb5c
/*
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
4
, 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
...
...
@@ -467,11 +467,24 @@ public abstract class Symbol extends AnnoConstruct implements Element {
private
boolean
hiddenIn
(
ClassSymbol
clazz
,
Types
types
)
{
Symbol
sym
=
hiddenInInternal
(
clazz
,
types
);
return
sym
!=
null
&&
sym
!=
this
;
Assert
.
check
(
sym
!=
null
,
"the result of hiddenInInternal() can't be null"
);
/* If we find the current symbol then there is no symbol hiding it
*/
return
sym
!=
this
;
}
private
Symbol
hiddenInInternal
(
ClassSymbol
c
,
Types
types
)
{
Scope
.
Entry
e
=
c
.
members
().
lookup
(
name
);
/** This method looks in the supertypes graph that has the current class as the
* initial node, till it finds the current symbol or another symbol that hides it.
* If the current class has more than one supertype (extends one class and
* implements one or more interfaces) then null can be returned, meaning that
* a wrong path in the supertypes graph was selected. Null can only be returned
* as a temporary value, as a result of the recursive call.
*/
private
Symbol
hiddenInInternal
(
ClassSymbol
currentClass
,
Types
types
)
{
if
(
currentClass
==
owner
)
{
return
this
;
}
Scope
.
Entry
e
=
currentClass
.
members
().
lookup
(
name
);
while
(
e
.
scope
!=
null
)
{
if
(
e
.
sym
.
kind
==
kind
&&
(
kind
!=
MTH
||
...
...
@@ -481,18 +494,19 @@ public abstract class Symbol extends AnnoConstruct implements Element {
}
e
=
e
.
next
();
}
List
<
Symbol
>
hiddenSyms
=
List
.
nil
();
for
(
Type
st
:
types
.
interfaces
(
c
.
type
).
prepend
(
types
.
supertype
(
c
.
type
)))
{
Symbol
hiddenSym
=
null
;
for
(
Type
st
:
types
.
interfaces
(
currentClass
.
type
)
.
prepend
(
types
.
supertype
(
currentClass
.
type
)))
{
if
(
st
!=
null
&&
(
st
.
hasTag
(
CLASS
)))
{
Symbol
sym
=
hiddenInInternal
((
ClassSymbol
)
st
.
tsym
,
types
);
if
(
sym
!=
null
)
{
hiddenSyms
=
hiddenSyms
.
prepend
(
hiddenInInternal
((
ClassSymbol
)
st
.
tsym
,
types
));
if
(
sym
==
this
)
{
return
this
;
}
else
if
(
sym
!=
null
)
{
hiddenSym
=
sym
;
}
}
}
return
hiddenSyms
.
contains
(
this
)
?
this
:
(
hiddenSyms
.
isEmpty
()
?
null
:
hiddenSyms
.
head
);
return
hiddenSym
;
}
/** Is this symbol inherited into a given class?
...
...
src/share/classes/com/sun/tools/javac/code/Type.java
浏览文件 @
ba90eb5c
/*
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
4
, 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
...
...
@@ -1481,8 +1481,21 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
}
public
String
toString
()
{
if
(
inst
!=
null
)
return
inst
.
toString
();
else
return
qtype
+
"?"
;
return
(
inst
==
null
)
?
qtype
+
"?"
:
inst
.
toString
();
}
public
String
debugString
()
{
String
result
=
"inference var = "
+
qtype
+
"\n"
;
if
(
inst
!=
null
)
{
result
+=
"inst = "
+
inst
+
'\n'
;
}
for
(
InferenceBound
bound:
InferenceBound
.
values
())
{
List
<
Type
>
aboundList
=
bounds
.
get
(
bound
);
if
(
aboundList
.
size
()
>
0
)
{
result
+=
bound
+
" = "
+
aboundList
+
'\n'
;
}
}
return
result
;
}
@Override
...
...
@@ -1492,8 +1505,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
@Override
public
Type
baseType
()
{
if
(
inst
!=
null
)
return
inst
.
baseType
();
else
return
this
;
return
(
inst
==
null
)
?
this
:
inst
.
baseType
();
}
/** get all bounds of a given kind */
...
...
src/share/classes/com/sun/tools/javac/comp/Infer.java
浏览文件 @
ba90eb5c
/*
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
4
, 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
...
...
@@ -2119,6 +2119,12 @@ public class Infer {
//back-door to infer
return
Infer
.
this
;
}
@Override
public
String
toString
()
{
return
"Inference vars: "
+
inferencevars
+
'\n'
+
"Undet vars: "
+
undetvars
;
}
}
final
InferenceContext
emptyContext
=
new
InferenceContext
(
List
.<
Type
>
nil
());
...
...
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
浏览文件 @
ba90eb5c
...
...
@@ -1038,7 +1038,7 @@ public class ClassWriter extends ClassFile {
}
databuf
.
appendChar
(
pool
.
get
(
inner
));
databuf
.
appendChar
(
inner
.
owner
.
kind
==
TYP
?
pool
.
get
(
inner
.
owner
)
:
0
);
inner
.
owner
.
kind
==
TYP
&&
!
inner
.
name
.
isEmpty
()
?
pool
.
get
(
inner
.
owner
)
:
0
);
databuf
.
appendChar
(
!
inner
.
name
.
isEmpty
()
?
pool
.
get
(
inner
.
name
)
:
0
);
databuf
.
appendChar
(
flags
);
...
...
src/share/classes/com/sun/tools/javac/jvm/Code.java
浏览文件 @
ba90eb5c
/*
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
4
, 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
...
...
@@ -2189,9 +2189,9 @@ public class Code {
// Keep local variables if
// 1) we need them for debug information
// 2) it is an exception type and it contains type annotations
if
(!
varDebugInfo
&&
(!
var
.
sym
.
isExceptionParameter
()
||
var
.
sym
.
hasTypeAnnotations
())
)
return
;
boolean
keepLocalVariables
=
varDebugInfo
||
(
var
.
sym
.
isExceptionParameter
()
&&
var
.
sym
.
hasTypeAnnotations
());
if
(!
keepLocalVariables
)
return
;
if
((
var
.
sym
.
flags
()
&
Flags
.
SYNTHETIC
)
!=
0
)
return
;
if
(
varBuffer
==
null
)
varBuffer
=
new
LocalVar
[
20
];
...
...
test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java
0 → 100644
浏览文件 @
ba90eb5c
/*
* Copyright (c) 2014, 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 8034924
* @summary Incorrect inheritance of inaccessible static method
* @library /tools/javac/lib
* @build ToolBox
* @run main IncorrectInheritanceTest
*/
public
class
IncorrectInheritanceTest
{
private
static
final
String
ASrc
=
"package pkg;\n"
+
"\n"
+
"public class A {\n"
+
" static void foo(Object o) {}\n"
+
" private static void bar(Object o) {}\n"
+
"}"
;
private
static
final
String
BSrc
=
"import pkg.A;\n"
+
"class B extends A {\n"
+
" public void foo(Object o) {}\n"
+
" public void bar(Object o) {}\n"
+
"}"
;
private
static
final
String
CSrc
=
"class C extends B {\n"
+
" public void m(Object o) {\n"
+
" foo(o);\n"
+
" bar(o);\n"
+
" }\n"
+
"}"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
IncorrectInheritanceTest
().
test
();
}
public
void
test
()
throws
Exception
{
ToolBox
.
JavaToolArgs
javacParams
=
new
ToolBox
.
JavaToolArgs
()
.
setSources
(
ASrc
,
BSrc
,
CSrc
);
ToolBox
.
javac
(
javacParams
);
}
}
test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java
浏览文件 @
ba90eb5c
/*
* Copyright (c) 2009, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 201
4
, 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
...
...
@@ -30,6 +30,7 @@ import java.io.PrintWriter;
import
java.lang.annotation.*
;
import
java.lang.reflect.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -51,6 +52,11 @@ public class Driver {
new
Driver
().
runDriver
(
clazz
.
newInstance
());
}
String
[][]
extraParamsCombinations
=
new
String
[][]
{
new
String
[]
{
},
new
String
[]
{
"-g"
},
};
protected
void
runDriver
(
Object
object
)
throws
Exception
{
int
passed
=
0
,
failed
=
0
;
Class
<?>
clazz
=
object
.
getClass
();
...
...
@@ -65,18 +71,20 @@ public class Driver {
throw
new
IllegalArgumentException
(
"Test method needs to return a string: "
+
method
);
String
testClass
=
testClassOf
(
method
);
try
{
String
compact
=
(
String
)
method
.
invoke
(
object
);
String
fullFile
=
wrap
(
compact
);
ClassFile
cf
=
compileAndReturn
(
fullFile
,
testClass
);
List
<
TypeAnnotation
>
actual
=
ReferenceInfoUtil
.
extendedAnnotationsOf
(
cf
);
ReferenceInfoUtil
.
compare
(
expected
,
actual
,
cf
);
out
.
println
(
"PASSED: "
+
method
.
getName
());
++
passed
;
}
catch
(
Throwable
e
)
{
out
.
println
(
"FAILED: "
+
method
.
getName
());
out
.
println
(
" "
+
e
.
toString
());
++
failed
;
for
(
String
[]
extraParams
:
extraParamsCombinations
)
{
try
{
String
compact
=
(
String
)
method
.
invoke
(
object
);
String
fullFile
=
wrap
(
compact
);
ClassFile
cf
=
compileAndReturn
(
fullFile
,
testClass
,
extraParams
);
List
<
TypeAnnotation
>
actual
=
ReferenceInfoUtil
.
extendedAnnotationsOf
(
cf
);
ReferenceInfoUtil
.
compare
(
expected
,
actual
,
cf
);
out
.
println
(
"PASSED: "
+
method
.
getName
());
++
passed
;
}
catch
(
Throwable
e
)
{
out
.
println
(
"FAILED: "
+
method
.
getName
());
out
.
println
(
" "
+
e
.
toString
());
++
failed
;
}
}
}
...
...
@@ -156,7 +164,7 @@ public class Driver {
}
}
private
ClassFile
compileAndReturn
(
String
fullFile
,
String
testClass
)
throws
Exception
{
private
ClassFile
compileAndReturn
(
String
fullFile
,
String
testClass
,
String
...
extraParams
)
throws
Exception
{
File
source
=
writeTestFile
(
fullFile
);
File
clazzFile
=
compileTestFile
(
source
,
testClass
);
return
ClassFile
.
read
(
clazzFile
);
...
...
@@ -170,8 +178,12 @@ public class Driver {
return
f
;
}
protected
File
compileTestFile
(
File
f
,
String
testClass
)
{
int
rc
=
com
.
sun
.
tools
.
javac
.
Main
.
compile
(
new
String
[]
{
"-source"
,
"1.8"
,
"-g"
,
f
.
getPath
()
});
protected
File
compileTestFile
(
File
f
,
String
testClass
,
String
...
extraParams
)
{
List
<
String
>
options
=
new
ArrayList
<>();
options
.
addAll
(
Arrays
.
asList
(
"-source"
,
"1.8"
));
options
.
addAll
(
Arrays
.
asList
(
extraParams
));
options
.
add
(
f
.
getPath
());
int
rc
=
com
.
sun
.
tools
.
javac
.
Main
.
compile
(
options
.
toArray
(
new
String
[
options
.
size
()]));
if
(
rc
!=
0
)
throw
new
Error
(
"compilation failed. rc="
+
rc
);
String
path
;
...
...
test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java
浏览文件 @
ba90eb5c
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2014,
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
...
...
@@ -25,6 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
/*
* @test
* @bug 8028576
* @summary Test population of reference info for exception parameters
* @author Werner Dietl
* @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
...
...
test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java
0 → 100644
浏览文件 @
ba90eb5c
/*
* Copyright (c) 2014, 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 8034854
* @summary Verify that the InnerClasses attribute has outer_class_info_index zero if it has
* inner_name_index zero (for synthetic classes)
* @compile SyntheticClasses.java
* @run main SyntheticClasses
*/
import
java.io.*
;
import
java.util.*
;
import
com.sun.tools.classfile.*
;
public
class
SyntheticClasses
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
ConstantPoolException
{
new
SyntheticClasses
().
run
();
}
private
void
run
()
throws
IOException
,
ConstantPoolException
{
File
testClasses
=
new
File
(
System
.
getProperty
(
"test.classes"
));
for
(
File
classFile
:
testClasses
.
listFiles
())
{
ClassFile
cf
=
ClassFile
.
read
(
classFile
);
if
(
cf
.
getName
().
matches
(
".*\\$[0-9]+"
))
{
EnclosingMethod_attribute
encl
=
(
EnclosingMethod_attribute
)
cf
.
getAttribute
(
Attribute
.
EnclosingMethod
);
if
(
encl
!=
null
)
{
if
(
encl
.
method_index
!=
0
)
throw
new
IllegalStateException
(
"Invalid EnclosingMethod.method_index: "
+
encl
.
method_index
+
"."
);
}
}
InnerClasses_attribute
attr
=
(
InnerClasses_attribute
)
cf
.
getAttribute
(
Attribute
.
InnerClasses
);
if
(
attr
!=
null
)
{
for
(
InnerClasses_attribute
.
Info
info
:
attr
.
classes
)
{
if
(
cf
.
major_version
<
51
)
throw
new
IllegalStateException
();
if
(
info
.
inner_name_index
==
0
&&
info
.
outer_class_info_index
!=
0
)
throw
new
IllegalStateException
(
"Invalid outer_class_info_index="
+
info
.
outer_class_info_index
+
"; inner_name_index="
+
info
.
inner_name_index
+
"."
);
}
}
}
}
}
class
SyntheticConstructorAccessTag
{
private
static
class
A
{
private
A
(){}
}
public
void
test
()
{
new
A
();
}
}
class
SyntheticEnumMapping
{
private
int
convert
(
E
e
)
{
switch
(
e
)
{
case
A:
return
0
;
default
:
return
-
1
;
}
}
enum
E
{
A
}
}
interface
SyntheticAssertionsDisabled
{
public
default
void
test
()
{
assert
false
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录