Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
b23cd9e0
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看板
提交
b23cd9e0
编写于
4月 01, 2014
作者:
A
amurillo
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
5fb8fa53
896e062b
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
468 addition
and
47 deletion
+468
-47
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
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
...un/tools/javac/processing/JavacProcessingEnvironment.java
+2
-2
src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
...com/sun/tools/javac/processing/JavacRoundEnvironment.java
+2
-2
src/share/classes/com/sun/tools/javap/ClassWriter.java
src/share/classes/com/sun/tools/javap/ClassWriter.java
+4
-1
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
test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java
...ac/processing/environment/ProcessingEnvAnnoDiscovery.java
+78
-0
test/tools/javac/processing/environment/round/Anno.java
test/tools/javac/processing/environment/round/Anno.java
+28
-0
test/tools/javac/processing/environment/round/ParameterAnnotations.java
...ac/processing/environment/round/ParameterAnnotations.java
+33
-0
test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
...ocessing/environment/round/TestElementsAnnotatedWith.java
+3
-1
test/tools/javap/T4975569.java
test/tools/javap/T4975569.java
+2
-2
test/tools/javap/T8035104.java
test/tools/javap/T8035104.java
+67
-0
未找到文件。
src/share/classes/com/sun/tools/javac/code/Symbol.java
浏览文件 @
b23cd9e0
/*
/*
* 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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* 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 {
...
@@ -467,11 +467,24 @@ public abstract class Symbol extends AnnoConstruct implements Element {
private
boolean
hiddenIn
(
ClassSymbol
clazz
,
Types
types
)
{
private
boolean
hiddenIn
(
ClassSymbol
clazz
,
Types
types
)
{
Symbol
sym
=
hiddenInInternal
(
clazz
,
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
)
{
/** This method looks in the supertypes graph that has the current class as the
Scope
.
Entry
e
=
c
.
members
().
lookup
(
name
);
* 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
)
{
while
(
e
.
scope
!=
null
)
{
if
(
e
.
sym
.
kind
==
kind
&&
if
(
e
.
sym
.
kind
==
kind
&&
(
kind
!=
MTH
||
(
kind
!=
MTH
||
...
@@ -481,18 +494,19 @@ public abstract class Symbol extends AnnoConstruct implements Element {
...
@@ -481,18 +494,19 @@ public abstract class Symbol extends AnnoConstruct implements Element {
}
}
e
=
e
.
next
();
e
=
e
.
next
();
}
}
List
<
Symbol
>
hiddenSyms
=
List
.
nil
();
Symbol
hiddenSym
=
null
;
for
(
Type
st
:
types
.
interfaces
(
c
.
type
).
prepend
(
types
.
supertype
(
c
.
type
)))
{
for
(
Type
st
:
types
.
interfaces
(
currentClass
.
type
)
.
prepend
(
types
.
supertype
(
currentClass
.
type
)))
{
if
(
st
!=
null
&&
(
st
.
hasTag
(
CLASS
)))
{
if
(
st
!=
null
&&
(
st
.
hasTag
(
CLASS
)))
{
Symbol
sym
=
hiddenInInternal
((
ClassSymbol
)
st
.
tsym
,
types
);
Symbol
sym
=
hiddenInInternal
((
ClassSymbol
)
st
.
tsym
,
types
);
if
(
sym
!=
null
)
{
if
(
sym
==
this
)
{
hiddenSyms
=
hiddenSyms
.
prepend
(
hiddenInInternal
((
ClassSymbol
)
st
.
tsym
,
types
));
return
this
;
}
else
if
(
sym
!=
null
)
{
hiddenSym
=
sym
;
}
}
}
}
}
}
return
hiddenSyms
.
contains
(
this
)
?
return
hiddenSym
;
this
:
(
hiddenSyms
.
isEmpty
()
?
null
:
hiddenSyms
.
head
);
}
}
/** Is this symbol inherited into a given class?
/** Is this symbol inherited into a given class?
...
...
src/share/classes/com/sun/tools/javac/code/Type.java
浏览文件 @
b23cd9e0
/*
/*
* 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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* 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 {
...
@@ -1481,8 +1481,21 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
}
}
public
String
toString
()
{
public
String
toString
()
{
if
(
inst
!=
null
)
return
inst
.
toString
();
return
(
inst
==
null
)
?
qtype
+
"?"
:
inst
.
toString
();
else
return
qtype
+
"?"
;
}
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
@Override
...
@@ -1492,8 +1505,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
...
@@ -1492,8 +1505,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
@Override
@Override
public
Type
baseType
()
{
public
Type
baseType
()
{
if
(
inst
!=
null
)
return
inst
.
baseType
();
return
(
inst
==
null
)
?
this
:
inst
.
baseType
();
else
return
this
;
}
}
/** get all bounds of a given kind */
/** get all bounds of a given kind */
...
...
src/share/classes/com/sun/tools/javac/comp/Infer.java
浏览文件 @
b23cd9e0
/*
/*
* 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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -2119,6 +2119,12 @@ public class Infer {
...
@@ -2119,6 +2119,12 @@ public class Infer {
//back-door to infer
//back-door to infer
return
Infer
.
this
;
return
Infer
.
this
;
}
}
@Override
public
String
toString
()
{
return
"Inference vars: "
+
inferencevars
+
'\n'
+
"Undet vars: "
+
undetvars
;
}
}
}
final
InferenceContext
emptyContext
=
new
InferenceContext
(
List
.<
Type
>
nil
());
final
InferenceContext
emptyContext
=
new
InferenceContext
(
List
.<
Type
>
nil
());
...
...
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
浏览文件 @
b23cd9e0
...
@@ -1038,7 +1038,7 @@ public class ClassWriter extends ClassFile {
...
@@ -1038,7 +1038,7 @@ public class ClassWriter extends ClassFile {
}
}
databuf
.
appendChar
(
pool
.
get
(
inner
));
databuf
.
appendChar
(
pool
.
get
(
inner
));
databuf
.
appendChar
(
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
(
databuf
.
appendChar
(
!
inner
.
name
.
isEmpty
()
?
pool
.
get
(
inner
.
name
)
:
0
);
!
inner
.
name
.
isEmpty
()
?
pool
.
get
(
inner
.
name
)
:
0
);
databuf
.
appendChar
(
flags
);
databuf
.
appendChar
(
flags
);
...
...
src/share/classes/com/sun/tools/javac/jvm/Code.java
浏览文件 @
b23cd9e0
/*
/*
* 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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -2189,9 +2189,9 @@ public class Code {
...
@@ -2189,9 +2189,9 @@ public class Code {
// Keep local variables if
// Keep local variables if
// 1) we need them for debug information
// 1) we need them for debug information
// 2) it is an exception type and it contains type annotations
// 2) it is an exception type and it contains type annotations
if
(!
varDebugInfo
&&
boolean
keepLocalVariables
=
varDebugInfo
||
(!
var
.
sym
.
isExceptionParameter
()
||
(
var
.
sym
.
isExceptionParameter
()
&&
var
.
sym
.
hasTypeAnnotations
());
var
.
sym
.
hasTypeAnnotations
())
)
return
;
if
(!
keepLocalVariables
)
return
;
if
((
var
.
sym
.
flags
()
&
Flags
.
SYNTHETIC
)
!=
0
)
return
;
if
((
var
.
sym
.
flags
()
&
Flags
.
SYNTHETIC
)
!=
0
)
return
;
if
(
varBuffer
==
null
)
if
(
varBuffer
==
null
)
varBuffer
=
new
LocalVar
[
20
];
varBuffer
=
new
LocalVar
[
20
];
...
...
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
浏览文件 @
b23cd9e0
...
@@ -762,14 +762,14 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
...
@@ -762,14 +762,14 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
public
Set
<
TypeElement
>
visitType
(
TypeElement
e
,
Set
<
TypeElement
>
p
)
{
public
Set
<
TypeElement
>
visitType
(
TypeElement
e
,
Set
<
TypeElement
>
p
)
{
// Type parameters are not considered to be enclosed by a type
// Type parameters are not considered to be enclosed by a type
scan
(
e
.
getTypeParameters
(),
p
);
scan
(
e
.
getTypeParameters
(),
p
);
return
s
can
(
e
.
getEnclosedElements
()
,
p
);
return
s
uper
.
visitType
(
e
,
p
);
}
}
@Override
@Override
public
Set
<
TypeElement
>
visitExecutable
(
ExecutableElement
e
,
Set
<
TypeElement
>
p
)
{
public
Set
<
TypeElement
>
visitExecutable
(
ExecutableElement
e
,
Set
<
TypeElement
>
p
)
{
// Type parameters are not considered to be enclosed by an executable
// Type parameters are not considered to be enclosed by an executable
scan
(
e
.
getTypeParameters
(),
p
);
scan
(
e
.
getTypeParameters
(),
p
);
return
s
can
(
e
.
getEnclosedElements
()
,
p
);
return
s
uper
.
visitExecutable
(
e
,
p
);
}
}
void
addAnnotations
(
Element
e
,
Set
<
TypeElement
>
p
)
{
void
addAnnotations
(
Element
e
,
Set
<
TypeElement
>
p
)
{
...
...
src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
浏览文件 @
b23cd9e0
...
@@ -137,14 +137,14 @@ public class JavacRoundEnvironment implements RoundEnvironment {
...
@@ -137,14 +137,14 @@ public class JavacRoundEnvironment implements RoundEnvironment {
public
Set
<
Element
>
visitType
(
TypeElement
e
,
TypeElement
p
)
{
public
Set
<
Element
>
visitType
(
TypeElement
e
,
TypeElement
p
)
{
// Type parameters are not considered to be enclosed by a type
// Type parameters are not considered to be enclosed by a type
scan
(
e
.
getTypeParameters
(),
p
);
scan
(
e
.
getTypeParameters
(),
p
);
return
s
can
(
e
.
getEnclosedElements
()
,
p
);
return
s
uper
.
visitType
(
e
,
p
);
}
}
@Override
@Override
public
Set
<
Element
>
visitExecutable
(
ExecutableElement
e
,
TypeElement
p
)
{
public
Set
<
Element
>
visitExecutable
(
ExecutableElement
e
,
TypeElement
p
)
{
// Type parameters are not considered to be enclosed by an executable
// Type parameters are not considered to be enclosed by an executable
scan
(
e
.
getTypeParameters
(),
p
);
scan
(
e
.
getTypeParameters
(),
p
);
return
s
can
(
e
.
getEnclosedElements
()
,
p
);
return
s
uper
.
visitExecutable
(
e
,
p
);
}
}
@Override
@Override
...
...
src/share/classes/com/sun/tools/javap/ClassWriter.java
浏览文件 @
b23cd9e0
...
@@ -202,7 +202,6 @@ public class ClassWriter extends BasicWriter {
...
@@ -202,7 +202,6 @@ public class ClassWriter extends BasicWriter {
if
(
options
.
verbose
)
{
if
(
options
.
verbose
)
{
println
();
println
();
indent
(+
1
);
indent
(+
1
);
attrWriter
.
write
(
cf
,
cf
.
attributes
,
constant_pool
);
println
(
"minor version: "
+
cf
.
minor_version
);
println
(
"minor version: "
+
cf
.
minor_version
);
println
(
"major version: "
+
cf
.
major_version
);
println
(
"major version: "
+
cf
.
major_version
);
writeList
(
"flags: "
,
flags
.
getClassFlags
(),
"\n"
);
writeList
(
"flags: "
,
flags
.
getClassFlags
(),
"\n"
);
...
@@ -218,6 +217,10 @@ public class ClassWriter extends BasicWriter {
...
@@ -218,6 +217,10 @@ public class ClassWriter extends BasicWriter {
writeMethods
();
writeMethods
();
indent
(-
1
);
indent
(-
1
);
println
(
"}"
);
println
(
"}"
);
if
(
options
.
verbose
)
{
attrWriter
.
write
(
cf
,
cf
.
attributes
,
constant_pool
);
}
}
}
// where
// where
class
JavaTypePrinter
implements
Type
.
Visitor
<
StringBuilder
,
StringBuilder
>
{
class
JavaTypePrinter
implements
Type
.
Visitor
<
StringBuilder
,
StringBuilder
>
{
...
...
test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java
0 → 100644
浏览文件 @
b23cd9e0
/*
* 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
浏览文件 @
b23cd9e0
/*
/*
* 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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -30,6 +30,7 @@ import java.io.PrintWriter;
...
@@ -30,6 +30,7 @@ import java.io.PrintWriter;
import
java.lang.annotation.*
;
import
java.lang.annotation.*
;
import
java.lang.reflect.*
;
import
java.lang.reflect.*
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -51,6 +52,11 @@ public class Driver {
...
@@ -51,6 +52,11 @@ public class Driver {
new
Driver
().
runDriver
(
clazz
.
newInstance
());
new
Driver
().
runDriver
(
clazz
.
newInstance
());
}
}
String
[][]
extraParamsCombinations
=
new
String
[][]
{
new
String
[]
{
},
new
String
[]
{
"-g"
},
};
protected
void
runDriver
(
Object
object
)
throws
Exception
{
protected
void
runDriver
(
Object
object
)
throws
Exception
{
int
passed
=
0
,
failed
=
0
;
int
passed
=
0
,
failed
=
0
;
Class
<?>
clazz
=
object
.
getClass
();
Class
<?>
clazz
=
object
.
getClass
();
...
@@ -65,18 +71,20 @@ public class Driver {
...
@@ -65,18 +71,20 @@ public class Driver {
throw
new
IllegalArgumentException
(
"Test method needs to return a string: "
+
method
);
throw
new
IllegalArgumentException
(
"Test method needs to return a string: "
+
method
);
String
testClass
=
testClassOf
(
method
);
String
testClass
=
testClassOf
(
method
);
try
{
for
(
String
[]
extraParams
:
extraParamsCombinations
)
{
String
compact
=
(
String
)
method
.
invoke
(
object
);
try
{
String
fullFile
=
wrap
(
compact
);
String
compact
=
(
String
)
method
.
invoke
(
object
);
ClassFile
cf
=
compileAndReturn
(
fullFile
,
testClass
);
String
fullFile
=
wrap
(
compact
);
List
<
TypeAnnotation
>
actual
=
ReferenceInfoUtil
.
extendedAnnotationsOf
(
cf
);
ClassFile
cf
=
compileAndReturn
(
fullFile
,
testClass
,
extraParams
);
ReferenceInfoUtil
.
compare
(
expected
,
actual
,
cf
);
List
<
TypeAnnotation
>
actual
=
ReferenceInfoUtil
.
extendedAnnotationsOf
(
cf
);
out
.
println
(
"PASSED: "
+
method
.
getName
());
ReferenceInfoUtil
.
compare
(
expected
,
actual
,
cf
);
++
passed
;
out
.
println
(
"PASSED: "
+
method
.
getName
());
}
catch
(
Throwable
e
)
{
++
passed
;
out
.
println
(
"FAILED: "
+
method
.
getName
());
}
catch
(
Throwable
e
)
{
out
.
println
(
" "
+
e
.
toString
());
out
.
println
(
"FAILED: "
+
method
.
getName
());
++
failed
;
out
.
println
(
" "
+
e
.
toString
());
++
failed
;
}
}
}
}
}
...
@@ -156,7 +164,7 @@ public class Driver {
...
@@ -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
source
=
writeTestFile
(
fullFile
);
File
clazzFile
=
compileTestFile
(
source
,
testClass
);
File
clazzFile
=
compileTestFile
(
source
,
testClass
);
return
ClassFile
.
read
(
clazzFile
);
return
ClassFile
.
read
(
clazzFile
);
...
@@ -170,8 +178,12 @@ public class Driver {
...
@@ -170,8 +178,12 @@ public class Driver {
return
f
;
return
f
;
}
}
protected
File
compileTestFile
(
File
f
,
String
testClass
)
{
protected
File
compileTestFile
(
File
f
,
String
testClass
,
String
...
extraParams
)
{
int
rc
=
com
.
sun
.
tools
.
javac
.
Main
.
compile
(
new
String
[]
{
"-source"
,
"1.8"
,
"-g"
,
f
.
getPath
()
});
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
)
if
(
rc
!=
0
)
throw
new
Error
(
"compilation failed. rc="
+
rc
);
throw
new
Error
(
"compilation failed. rc="
+
rc
);
String
path
;
String
path
;
...
...
test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java
浏览文件 @
b23cd9e0
/*
/*
* 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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* 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.*;
...
@@ -25,6 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
/*
/*
* @test
* @test
* @bug 8028576
* @summary Test population of reference info for exception parameters
* @summary Test population of reference info for exception parameters
* @author Werner Dietl
* @author Werner Dietl
* @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
* @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
...
...
test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java
0 → 100644
浏览文件 @
b23cd9e0
/*
* 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
;
}
}
test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java
0 → 100644
浏览文件 @
b23cd9e0
/*
* 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 8038080
* @summary make sure that all declaration annotations are discovered
* by the processing environment
* @library /tools/javac/lib
* @build JavacTestingAbstractProcessor ProcessingEnvAnnoDiscovery
* @compile/process -processor ProcessingEnvAnnoDiscovery ProcessingEnvAnnoDiscovery.java
*/
import
java.lang.annotation.*
;
import
java.util.Set
;
import
javax.annotation.processing.*
;
import
javax.lang.model.element.*
;
import
com.sun.tools.javac.util.*
;
@ProcessingEnvAnnoDiscovery
.
Anno1
public
class
ProcessingEnvAnnoDiscovery
<
@ProcessingEnvAnnoDiscovery
.
Anno4
T
>
extends
JavacTestingAbstractProcessor
{
private
int
round
=
0
;
public
boolean
process
(
Set
<?
extends
TypeElement
>
annos
,
RoundEnvironment
rEnv
)
{
if
(
round
++
==
0
)
{
System
.
out
.
println
(
annos
);
Assert
.
check
(
annos
.
contains
(
eltUtils
.
getTypeElement
(
"java.lang.annotation.Target"
)));
Assert
.
check
(
annos
.
contains
(
eltUtils
.
getTypeElement
(
"ProcessingEnvAnnoDiscovery.Anno1"
)));
Assert
.
check
(
annos
.
contains
(
eltUtils
.
getTypeElement
(
"ProcessingEnvAnnoDiscovery.Anno2"
)));
Assert
.
check
(
annos
.
contains
(
eltUtils
.
getTypeElement
(
"ProcessingEnvAnnoDiscovery.Anno3"
)));
Assert
.
check
(
annos
.
contains
(
eltUtils
.
getTypeElement
(
"ProcessingEnvAnnoDiscovery.Anno4"
)));
Assert
.
check
(
annos
.
contains
(
eltUtils
.
getTypeElement
(
"ProcessingEnvAnnoDiscovery.Anno5"
)));
Assert
.
check
(
annos
.
size
()
==
6
,
"Found extra annotations"
);
//Anno1-5 + @Target
}
return
true
;
}
@Anno2
public
<
@Anno5
K
>
K
m
(
@Anno3
long
foo
)
{
return
null
;
}
@interface
Anno1
{}
@interface
Anno2
{}
@interface
Anno3
{}
@Target
(
ElementType
.
TYPE_PARAMETER
)
@interface
Anno4
{}
@Target
(
ElementType
.
TYPE_PARAMETER
)
@interface
Anno5
{}
}
test/tools/javac/processing/environment/round/Anno.java
0 → 100644
浏览文件 @
b23cd9e0
/*
* 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.
*/
import
java.lang.annotation.*
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.*;
@Retention
(
RUNTIME
)
public
@interface
Anno
{}
test/tools/javac/processing/environment/round/ParameterAnnotations.java
0 → 100644
浏览文件 @
b23cd9e0
/*
* 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.
*/
/**
* Class to hold annotations for ElementsAnnotatedWithTest.
*/
@AnnotatedElementInfo
(
annotationName
=
"Anno"
,
expectedSize
=
1
,
names
={
"annotatedParameter"
})
public
class
ParameterAnnotations
{
private
void
foo
(
@Anno
Object
annotatedParameter
)
{}
}
test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
浏览文件 @
b23cd9e0
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/*
/*
* @test
* @test
* @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049
* @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049
8038080
* @summary Tests that getElementsAnnotatedWith works properly.
* @summary Tests that getElementsAnnotatedWith works properly.
* @author Joseph D. Darcy
* @author Joseph D. Darcy
* @library /tools/javac/lib
* @library /tools/javac/lib
...
@@ -31,12 +31,14 @@
...
@@ -31,12 +31,14 @@
* @compile TestElementsAnnotatedWith.java
* @compile TestElementsAnnotatedWith.java
* @compile InheritedAnnotation.java
* @compile InheritedAnnotation.java
* @compile TpAnno.java
* @compile TpAnno.java
* @compile Anno.java
* @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
* @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
* @compile -processor TestElementsAnnotatedWith -proc:only C2.java
* @compile -processor TestElementsAnnotatedWith -proc:only C2.java
* @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
* @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
* @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only ParameterAnnotations.java
* @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java
* @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java
* @compile Foo.java
* @compile Foo.java
* @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
* @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
...
...
test/tools/javap/T4975569.java
浏览文件 @
b23cd9e0
...
@@ -40,10 +40,10 @@ public class T4975569
...
@@ -40,10 +40,10 @@ public class T4975569
verify
(
"T4975569$Anno"
,
"flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION"
);
verify
(
"T4975569$Anno"
,
"flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION"
);
verify
(
"T4975569$E"
,
"flags: ACC_FINAL, ACC_SUPER, ACC_ENUM"
);
verify
(
"T4975569$E"
,
"flags: ACC_FINAL, ACC_SUPER, ACC_ENUM"
);
verify
(
"T4975569$S"
,
"flags: ACC_BRIDGE, ACC_SYNTHETIC"
,
verify
(
"T4975569$S"
,
"flags: ACC_BRIDGE, ACC_SYNTHETIC"
,
"InnerClasses:\n
static"
);
"InnerClasses:\n static"
);
verify
(
"T4975569$V"
,
"void m(java.lang.String...)"
,
verify
(
"T4975569$V"
,
"void m(java.lang.String...)"
,
"flags: ACC_VARARGS"
);
"flags: ACC_VARARGS"
);
verify
(
"T4975569$Prot"
,
"InnerClasses:\n
protected"
);
verify
(
"T4975569$Prot"
,
"InnerClasses:\n protected"
);
//verify("T4975569$Priv", "InnerClasses");
//verify("T4975569$Priv", "InnerClasses");
if
(
errors
>
0
)
if
(
errors
>
0
)
throw
new
Error
(
errors
+
" found."
);
throw
new
Error
(
errors
+
" found."
);
...
...
test/tools/javap/T8035104.java
0 → 100644
浏览文件 @
b23cd9e0
/*
* 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 8035104
* @summary reorder class file attributes in javap listing
*/
import
java.io.*
;
public
class
T8035104
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
T8035104
().
run
();
}
public
void
run
()
throws
Exception
{
String
[]
lines
=
javap
(
"-v"
,
T8035104
.
class
.
getName
()).
split
(
"[\r\n]+"
);
int
minor
=
-
1
;
int
SourceFile
=
-
1
;
for
(
int
i
=
0
;
i
<
lines
.
length
;
i
++)
{
String
line
=
lines
[
i
];
if
(
line
.
matches
(
" *minor version: [0-9.]+"
))
minor
=
i
;
if
(
line
.
matches
(
" *SourceFile: .+"
))
SourceFile
=
i
;
}
if
(
minor
==
-
1
)
throw
new
Exception
(
"minor version not found"
);
if
(
SourceFile
==
-
1
)
throw
new
Exception
(
"SourceFile not found"
);
if
(
SourceFile
<
minor
)
throw
new
Exception
(
"unexpected order of output"
);
System
.
out
.
println
(
"output OK"
);
}
String
javap
(
String
...
args
)
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
out
=
new
PrintWriter
(
sw
);
int
rc
=
com
.
sun
.
tools
.
javap
.
Main
.
run
(
args
,
out
);
out
.
close
();
System
.
out
.
println
(
sw
.
toString
());
System
.
out
.
println
(
"javap exited, rc="
+
rc
);
return
sw
.
toString
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录