Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
ab6d3e9c
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看板
提交
ab6d3e9c
编写于
2月 01, 2011
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
Reviewed-by: jjg
上级
c2bfaaf2
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
276 addition
and
61 deletion
+276
-61
src/share/classes/javax/lang/model/type/DisjunctiveType.java
src/share/classes/javax/lang/model/type/DisjunctiveType.java
+49
-0
src/share/classes/javax/lang/model/type/TypeKind.java
src/share/classes/javax/lang/model/type/TypeKind.java
+9
-2
src/share/classes/javax/lang/model/type/TypeVisitor.java
src/share/classes/javax/lang/model/type/TypeVisitor.java
+11
-1
src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java
...e/classes/javax/lang/model/util/AbstractTypeVisitor6.java
+17
-2
src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java
...e/classes/javax/lang/model/util/AbstractTypeVisitor7.java
+12
-2
src/share/classes/javax/lang/model/util/ElementKindVisitor6.java
...re/classes/javax/lang/model/util/ElementKindVisitor6.java
+20
-3
src/share/classes/javax/lang/model/util/ElementKindVisitor7.java
...re/classes/javax/lang/model/util/ElementKindVisitor7.java
+15
-2
src/share/classes/javax/lang/model/util/ElementScanner6.java
src/share/classes/javax/lang/model/util/ElementScanner6.java
+20
-13
src/share/classes/javax/lang/model/util/ElementScanner7.java
src/share/classes/javax/lang/model/util/ElementScanner7.java
+13
-1
src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java
.../javax/lang/model/util/SimpleAnnotationValueVisitor7.java
+3
-3
src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java
.../classes/javax/lang/model/util/SimpleElementVisitor6.java
+16
-6
src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java
.../classes/javax/lang/model/util/SimpleElementVisitor7.java
+17
-4
src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java
...are/classes/javax/lang/model/util/SimpleTypeVisitor6.java
+6
-3
src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java
...are/classes/javax/lang/model/util/SimpleTypeVisitor7.java
+18
-4
src/share/classes/javax/lang/model/util/TypeKindVisitor7.java
...share/classes/javax/lang/model/util/TypeKindVisitor7.java
+14
-1
src/share/classes/javax/lang/model/util/Types.java
src/share/classes/javax/lang/model/util/Types.java
+1
-1
test/tools/javac/processing/model/element/TestResourceVariable.java
.../javac/processing/model/element/TestResourceVariable.java
+35
-13
未找到文件。
src/share/classes/javax/lang/model/type/DisjunctiveType.java
0 → 100644
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, 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. 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.
*/
package
javax.lang.model.type
;
import
java.util.List
;
/**
* Represents a disjunctive type.
*
* As of the {@link javax.lang.model.SourceVersion#RELEASE_7
* RELEASE_7} source version, disjunctive types can appear as the type
* of a multi-catch exception parameter.
*
* @since 1.7
*/
public
interface
DisjunctiveType
extends
TypeMirror
{
/**
* Return the alternatives comprising this disjunctive type.
*
* The alternatives are formally referred to as <i>disjuncts</i>.
*
* @return the alternatives comprising this disjunctive type.
*/
List
<?
extends
TypeMirror
>
getAlternatives
();
}
src/share/classes/javax/lang/model/type/TypeKind.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2005, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 20
11
, 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
...
...
@@ -137,7 +137,14 @@ public enum TypeKind {
* An implementation-reserved type.
* This is not the type you are looking for.
*/
OTHER
;
OTHER
,
/**
* A disjunctive type.
*
* @since 1.7
*/
DISJUNCTIVE
;
/**
* Returns {@code true} if this kind corresponds to a primitive
...
...
src/share/classes/javax/lang/model/type/TypeVisitor.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2005, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 20
11
, 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
...
...
@@ -162,4 +162,14 @@ public interface TypeVisitor<R, P> {
* a visitor implementation may optionally throw this exception
*/
R
visitUnknown
(
TypeMirror
t
,
P
p
);
/**
* Visits a disjunctive type.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @since 1.7
*/
R
visitDisjunctive
(
DisjunctiveType
t
,
P
p
);
}
src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
1
, 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
...
...
@@ -29,7 +29,8 @@ import javax.lang.model.type.*;
/**
* A skeletal visitor of types with default behavior appropriate for
* the version 6 language level.
* the {@link javax.lang.model.SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
...
...
@@ -94,6 +95,20 @@ public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
return
t
.
accept
(
this
,
null
);
}
/**
* Visits a {@code DisjunctiveType} element by calling {@code
* visitUnknown}.
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code visitUnknown}
*
* @since 1.7
*/
public
R
visitDisjunctive
(
DisjunctiveType
t
,
P
p
)
{
return
visitUnknown
(
t
,
p
);
}
/**
* {@inheritDoc}
*
...
...
src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
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
...
...
@@ -29,7 +29,8 @@ import javax.lang.model.type.*;
/**
* A skeletal visitor of types with default behavior appropriate for
* the version 7 language level.
* the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
...
...
@@ -64,4 +65,13 @@ public abstract class AbstractTypeVisitor7<R, P> extends AbstractTypeVisitor6<R,
protected
AbstractTypeVisitor7
()
{
super
();
}
/**
* Visits a {@code DisjunctiveType} in a manner defined by a subclass.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the visit as defined by a subclass
*/
public
abstract
R
visitDisjunctive
(
DisjunctiveType
t
,
P
p
);
}
src/share/classes/javax/lang/model/util/ElementKindVisitor6.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
1
, 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
...
...
@@ -199,7 +199,8 @@ public class ElementKindVisitor6<R, P>
* Visits a variable element, dispatching to the visit method for
* the specific {@linkplain ElementKind kind} of variable, {@code
* ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
* {@code LOCAL_VARIABLE}, or {@code PARAMETER}.
* {@code LOCAL_VARIABLE}, {@code PARAMETER}, or {@code RESOURCE_VARIABLE}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
...
...
@@ -223,10 +224,12 @@ public class ElementKindVisitor6<R, P>
case
PARAMETER:
return
visitVariableAsParameter
(
e
,
p
);
case
RESOURCE_VARIABLE:
return
visitVariableAsResourceVariable
(
e
,
p
);
default
:
throw
new
AssertionError
(
"Bad kind "
+
k
+
" for VariableElement"
+
e
);
}
}
/**
...
...
@@ -289,6 +292,20 @@ public class ElementKindVisitor6<R, P>
return
defaultAction
(
e
,
p
);
}
/**
* Visits a {@code RESOURCE_VARIABLE} variable element by calling
* {@code visitUnknown}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code visitUnknown}
*
* @since 1.7
*/
public
R
visitVariableAsResourceVariable
(
VariableElement
e
,
P
p
)
{
return
visitUnknown
(
e
,
p
);
}
/**
* Visits an executable element, dispatching to the visit method
* for the specific {@linkplain ElementKind kind} of executable,
...
...
src/share/classes/javax/lang/model/util/ElementKindVisitor7.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
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
...
...
@@ -34,7 +34,7 @@ import javax.lang.model.SourceVersion;
/**
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link
* SourceVersion#RELEASE_
6 RELEASE_6
} source version. For {@linkplain
* SourceVersion#RELEASE_
7 RELEASE_7
} source version. For {@linkplain
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
...
...
@@ -94,4 +94,17 @@ public class ElementKindVisitor7<R, P> extends ElementKindVisitor6<R, P> {
protected
ElementKindVisitor7
(
R
defaultValue
)
{
super
(
defaultValue
);
}
/**
* Visits a {@code RESOURCE_VARIABLE} variable element by calling
* {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public
R
visitVariableAsResourceVariable
(
VariableElement
e
,
P
p
)
{
return
defaultAction
(
e
,
p
);
}
}
src/share/classes/javax/lang/model/util/ElementScanner6.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
1
, 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
...
...
@@ -152,8 +152,8 @@ public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e
the element to visit
* @param p
a visitor-specified parameter
* @param e
{@inheritDoc}
* @param p
{@inheritDoc}
* @return the result of scanning
*/
public
R
visitPackage
(
PackageElement
e
,
P
p
)
{
...
...
@@ -163,8 +163,8 @@ public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e
the element to visit
* @param p
a visitor-specified parameter
* @param e
{@inheritDoc}
* @param p
{@inheritDoc}
* @return the result of scanning
*/
public
R
visitType
(
TypeElement
e
,
P
p
)
{
...
...
@@ -172,21 +172,28 @@ public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
}
/**
* {@inheritDoc} This implementation scans the enclosed elements.
* {@inheritDoc}
*
* This implementation scans the enclosed elements, unless the
* element is a {@code RESOURCE_VARIABLE} in which case {@code
* visitUnknown} is called.
*
* @param e
the element to visit
* @param p
a visitor-specified parameter
* @param e
{@inheritDoc}
* @param p
{@inheritDoc}
* @return the result of scanning
*/
public
R
visitVariable
(
VariableElement
e
,
P
p
)
{
return
scan
(
e
.
getEnclosedElements
(),
p
);
if
(
e
.
getKind
()
!=
ElementKind
.
RESOURCE_VARIABLE
)
return
scan
(
e
.
getEnclosedElements
(),
p
);
else
return
visitUnknown
(
e
,
p
);
}
/**
* {@inheritDoc} This implementation scans the parameters.
*
* @param e
the element to visit
* @param p
a visitor-specified parameter
* @param e
{@inheritDoc}
* @param p
{@inheritDoc}
* @return the result of scanning
*/
public
R
visitExecutable
(
ExecutableElement
e
,
P
p
)
{
...
...
@@ -196,8 +203,8 @@ public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e
the element to visit
* @param p
a visitor-specified parameter
* @param e
{@inheritDoc}
* @param p
{@inheritDoc}
* @return the result of scanning
*/
public
R
visitTypeParameter
(
TypeParameterElement
e
,
P
p
)
{
...
...
src/share/classes/javax/lang/model/util/ElementScanner7.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
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
...
...
@@ -105,4 +105,16 @@ public class ElementScanner7<R, P> extends ElementScanner6<R, P> {
protected
ElementScanner7
(
R
defaultValue
){
super
(
defaultValue
);
}
/**
* This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
@Override
public
R
visitVariable
(
VariableElement
e
,
P
p
)
{
return
scan
(
e
.
getEnclosedElements
(),
p
);
}
}
src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
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
...
...
@@ -36,8 +36,8 @@ import javax.annotation.processing.SupportedSourceVersion;
/**
* A simple visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version. Visit methods call {@link
*
#
defaultAction} passing their arguments to {@code defaultAction}'s
* source version. Visit methods call {@link
#defaultAction
* defaultAction} passing their arguments to {@code defaultAction}'s
* corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
...
...
src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
1
, 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
...
...
@@ -38,8 +38,11 @@ import static javax.lang.model.SourceVersion.*;
* source version.
*
* Visit methods corresponding to {@code RELEASE_6} language
* constructs call {@link #defaultAction}, passing their arguments to
* {@code defaultAction}'s corresponding parameters.
* constructs call {@link #defaultAction defaultAction}, passing their
* arguments to {@code defaultAction}'s corresponding parameters.
*
* For constructs introduced in {@code RELEASE_7} and later, {@code
* visitUnknown} is called instead.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
...
...
@@ -137,14 +140,21 @@ public class SimpleElementVisitor6<R, P> extends AbstractElementVisitor6<R, P> {
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
* {@inheritDoc}
*
* This implementation calls {@code defaultAction}, unless the
* element is a {@code RESOURCE_VARIABLE} in which case {@code
* visitUnknown} is called.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
* @return the result of {@code defaultAction}
or {@code visitUnknown}
*/
public
R
visitVariable
(
VariableElement
e
,
P
p
)
{
return
defaultAction
(
e
,
p
);
if
(
e
.
getKind
()
!=
ElementKind
.
RESOURCE_VARIABLE
)
return
defaultAction
(
e
,
p
);
else
return
visitUnknown
(
e
,
p
);
}
/**
...
...
src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
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
...
...
@@ -36,9 +36,10 @@ import static javax.lang.model.SourceVersion.*;
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* Visit methods corresponding to {@code RELEASE_7} language
* constructs call {@link #defaultAction}, passing their arguments to
* {@code defaultAction}'s corresponding parameters.
* Visit methods corresponding to {@code RELEASE_7} and earlier
* language constructs call {@link #defaultAction defaultAction},
* passing their arguments to {@code defaultAction}'s corresponding
* parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
...
...
@@ -89,4 +90,16 @@ public class SimpleElementVisitor7<R, P> extends SimpleElementVisitor6<R, P> {
protected
SimpleElementVisitor7
(
R
defaultValue
){
super
(
defaultValue
);
}
/**
* This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public
R
visitVariable
(
VariableElement
e
,
P
p
)
{
return
defaultAction
(
e
,
p
);
}
}
src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
1
, 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
...
...
@@ -36,8 +36,11 @@ import static javax.lang.model.SourceVersion.*;
* {@link SourceVersion#RELEASE_6 RELEASE_6} source version.
*
* Visit methods corresponding to {@code RELEASE_6} language
* constructs call {@link #defaultAction}, passing their arguments to
* {@code defaultAction}'s corresponding parameters.
* constructs call {@link #defaultAction defaultAction}, passing their
* arguments to {@code defaultAction}'s corresponding parameters.
*
* For constructs introduced in {@code RELEASE_7} and later, {@code
* visitUnknown} is called instead.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
...
...
src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
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
...
...
@@ -34,9 +34,10 @@ import static javax.lang.model.SourceVersion.*;
* A simple visitor of types with default behavior appropriate for the
* {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
*
* Visit methods corresponding to {@code RELEASE_7} language
* constructs call {@link #defaultAction}, passing their arguments to
* {@code defaultAction}'s corresponding parameters.
* Visit methods corresponding to {@code RELEASE_7} and earlier
* language constructs call {@link #defaultAction defaultAction},
* passing their arguments to {@code defaultAction}'s corresponding
* parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
...
...
@@ -88,4 +89,17 @@ public class SimpleTypeVisitor7<R, P> extends SimpleTypeVisitor6<R, P> {
protected
SimpleTypeVisitor7
(
R
defaultValue
){
super
(
defaultValue
);
}
/**
* This implementation visits a {@code DisjunctiveType} by calling
* {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public
R
visitDisjunctive
(
DisjunctiveType
t
,
P
p
)
{
return
defaultAction
(
t
,
p
);
}
}
src/share/classes/javax/lang/model/util/TypeKindVisitor7.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
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
...
...
@@ -92,4 +92,17 @@ public class TypeKindVisitor7<R, P> extends TypeKindVisitor6<R, P> {
protected
TypeKindVisitor7
(
R
defaultValue
)
{
super
(
defaultValue
);
}
/**
* This implementation visits a {@code DisjunctiveType} by calling
* {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public
R
visitDisjunctive
(
DisjunctiveType
t
,
P
p
)
{
return
defaultAction
(
t
,
p
);
}
}
src/share/classes/javax/lang/model/util/Types.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2005, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 20
11
, 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
...
...
test/tools/javac/processing/model/element/TestResourceVariable.java
浏览文件 @
ab6d3e9c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
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
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 6911256 6964740 6967842
* @bug 6911256 6964740 6967842
6961571
* @summary Test that the resource variable kind is appropriately set
* @author Joseph D. Darcy
* @library ../../../lib
...
...
@@ -31,8 +31,6 @@
* @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
*/
// Bug should be filed for this misbehavior
import
java.io.*
;
import
javax.annotation.processing.*
;
import
javax.lang.model.*
;
...
...
@@ -82,6 +80,33 @@ public class TestResourceVariable extends JavacTestingAbstractProcessor implemen
try
(
TestResourceVariable
trv1
=
this
;
TestResourceVariable
trv2
=
trv1
)
{}
}
/**
* Verify that a resource variable modeled as an element behaves
* as expected under 6 and 7 specific visitors.
*/
private
static
void
testResourceVariable
(
Element
element
)
{
ElementVisitor
visitor6
=
new
ElementKindVisitor6
<
Void
,
Void
>()
{};
try
{
visitor6
.
visit
(
element
);
throw
new
RuntimeException
(
"Expected UnknownElementException not thrown."
);
}
catch
(
UnknownElementException
uee
)
{
;
// Expected.
}
ElementKindVisitor7
visitor7
=
new
ElementKindVisitor7
<
Object
,
Void
>()
{
@Override
public
Object
visitVariableAsResourceVariable
(
VariableElement
e
,
Void
p
)
{
return
e
;
// a non-null value
}
};
if
(
visitor7
.
visit
(
element
)
==
null
)
{
throw
new
RuntimeException
(
"Null result of resource variable visitation."
);
}
}
class
ResourceVariableScanner
extends
TreeScanner
<
Void
,
CompilationUnitTree
>
{
private
Trees
trees
;
...
...
@@ -92,17 +117,14 @@ public class TestResourceVariable extends JavacTestingAbstractProcessor implemen
@Override
public
Void
visitVariable
(
VariableTree
node
,
CompilationUnitTree
cu
)
{
Element
element
=
trees
.
getElement
(
trees
.
getPath
(
cu
,
node
));
if
(
element
==
null
)
{
System
.
out
.
println
(
"Null variable element: "
+
node
);
}
else
{
System
.
out
.
println
(
"Name: "
+
element
.
getSimpleName
()
+
"\tKind: "
+
element
.
getKind
());
}
if
(
element
!=
null
&&
element
.
getKind
()
==
ElementKind
.
RESOURCE_VARIABLE
)
{
System
.
out
.
println
(
"Name: "
+
element
.
getSimpleName
()
+
"\tKind: "
+
element
.
getKind
());
if
(
element
.
getKind
()
==
ElementKind
.
RESOURCE_VARIABLE
)
{
testResourceVariable
(
element
);
resourceVariableCount
++;
}
return
super
.
visitVariable
(
node
,
cu
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录