TargetType.java revision 580
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*/
/**
* Describes the type of program element an extended annotation (or extended
* compound attribute) targets.
*
* By comparison, a Tree.Kind has enum values for all elements in the AST, and
* it does not provide enough resolution for type arguments (i.e., whether an
* annotation targets a type argument in a local variable, method return type,
* or a typecast).
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
public enum TargetType {
//
// Some target types are commented out, because Java doesn't permit such
// targets. They are included here to confirm that their omission is
// intentional omission not an accidental omission.
//
/** For annotations on typecasts. */
/** For annotations on a type argument or nested array of a typecast. */
/** For annotations on type tests. */
/** For annotations on a type argument or nested array of a type test. */
/** For annotations on object creation expressions. */
/**
* For annotations on a type argument or nested array of an object creation
* expression.
*/
/** For annotations on the method receiver. */
METHOD_RECEIVER(0x06),
// invalid location
//@Deprecated METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation),
/** For annotations on local variables. */
/** For annotations on a type argument or nested array of a local. */
// handled by regular annotations
//@Deprecated METHOD_RETURN(0x0A),
/**
* For annotations on a type argument or nested array of a method return
* type.
*/
// handled by regular annotations
//@Deprecated METHOD_PARAMETER(0x0C),
/** For annotations on a type argument or nested array of a method parameter. */
// handled by regular annotations
//@Deprecated FIELD(0x0E),
/** For annotations on a type argument or nested array of a field. */
/** For annotations on a bound of a type parameter of a class. */
/**
* For annotations on a type argument or nested array of a bound of a type
* parameter of a class.
*/
/** For annotations on a bound of a type parameter of a method. */
/**
* For annotations on a type argument or nested array of a bound of a type
* parameter of a method.
*/
/** For annotations on the type of an "extends" or "implements" clause. */
CLASS_EXTENDS(0x14),
/** For annotations on the inner type of an "extends" or "implements" clause. */
/** For annotations on a throws clause in a method declaration. */
THROWS(0x16),
// invalid location
//@Deprecated THROWS_GENERIC_OR_ARRAY(0x17, HasLocation),
/** For annotations in type arguments of object creation expressions. */
// invalid location
//@Deprecated METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter),
// invalid location
//@Deprecated CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter),
/** For annotations with an unknown target. */
UNKNOWN(-1);
static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22;
private final int targetTypeValue;
this.targetTypeValue = (byte)targetTypeValue;
}
/**
* Returns whether or not this TargetType represents an annotation whose
* target is an inner type of a generic or array type.
*
* @return true if this TargetType represents an annotation on an inner
* type, false otherwise
*/
public boolean hasLocation() {
}
public TargetType getGenericComplement() {
if (hasLocation())
return this;
else
}
/**
* Returns whether or not this TargetType represents an annotation whose
* target has a parameter index.
*
* @return true if this TargetType has a parameter index,
* false otherwise
*/
public boolean hasParameter() {
}
/**
* Returns whether or not this TargetType represents an annotation whose
* target is a type parameter bound.
*
* @return true if this TargetType represents an type parameter bound
* annotation, false otherwise
*/
public boolean hasBound() {
}
/**
* Returns whether or not this TargetType represents an annotation whose
* target is exclusively a tree in a method body
*
* Note: wildcard bound targets could target a local tree and a class
* member declaration signature tree
*/
public boolean isLocal() {
}
public int targetTypeValue() {
return this.targetTypeValue;
}
private static TargetType[] buildTargets() {
}
for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) {
}
return targets;
}
public static boolean isValidTargetTypeValue(int tag) {
targets = buildTargets();
return true;
}
targets = buildTargets();
return UNKNOWN;
}
static enum TargetAttribute {
}
}