jjg@309: /* ohair@554: * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. jjg@309: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@309: * jjg@309: * This code is free software; you can redistribute it and/or modify it jjg@309: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this jjg@309: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. jjg@309: * jjg@309: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@309: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@309: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@309: * version 2 for more details (a copy is included in the LICENSE file that jjg@309: * accompanied this code). jjg@309: * jjg@309: * You should have received a copy of the GNU General Public License version jjg@309: * 2 along with this work; if not, write to the Free Software Foundation, jjg@309: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@309: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jjg@309: */ jjg@309: jjg@309: package com.sun.tools.javac.code; jjg@309: jjg@309: import static com.sun.tools.javac.code.TargetType.TargetAttribute.*; jjg@309: jjg@309: import java.util.EnumSet; jjg@309: import java.util.Set; jjg@309: jjg@309: /** jjg@309: * Describes the type of program element an extended annotation (or extended jjg@309: * compound attribute) targets. jjg@309: * jjg@309: * By comparison, a Tree.Kind has enum values for all elements in the AST, and jjg@309: * it does not provide enough resolution for type arguments (i.e., whether an jjg@309: * annotation targets a type argument in a local variable, method return type, jjg@309: * or a typecast). jjg@309: * jjg@581: *
This is NOT part of any supported API.
jjg@581: * If you write code that depends on this, you do so at your own risk.
jjg@309: * This code and its internal interfaces are subject to change or
jjg@309: * deletion without notice.
jjg@309: */
jjg@309: public enum TargetType {
jjg@309:
jjg@309: //
jjg@309: // Some target types are commented out, because Java doesn't permit such
jjg@309: // targets. They are included here to confirm that their omission is
jjg@309: // intentional omission not an accidental omission.
jjg@309: //
jjg@309:
jjg@309: /** For annotations on typecasts. */
jjg@310: TYPECAST(0x00, IsLocal),
jjg@309:
jjg@309: /** For annotations on a type argument or nested array of a typecast. */
jjg@310: TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation, IsLocal),
jjg@309:
jjg@309: /** For annotations on type tests. */
jjg@310: INSTANCEOF(0x02, IsLocal),
jjg@309:
jjg@309: /** For annotations on a type argument or nested array of a type test. */
jjg@310: INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation, IsLocal),
jjg@309:
jjg@309: /** For annotations on object creation expressions. */
jjg@310: NEW(0x04, IsLocal),
jjg@309:
jjg@309: /**
jjg@309: * For annotations on a type argument or nested array of an object creation
jjg@309: * expression.
jjg@309: */
jjg@310: NEW_GENERIC_OR_ARRAY(0x05, HasLocation, IsLocal),
jjg@309:
jjg@309:
jjg@309: /** For annotations on the method receiver. */
jjg@309: METHOD_RECEIVER(0x06),
jjg@309:
jjg@309: // invalid location
jjg@309: //@Deprecated METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation),
jjg@309:
jjg@309: /** For annotations on local variables. */
jjg@310: LOCAL_VARIABLE(0x08, IsLocal),
jjg@309:
jjg@309: /** For annotations on a type argument or nested array of a local. */
jjg@310: LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation, IsLocal),
jjg@309:
jjg@309: // handled by regular annotations
jjg@309: //@Deprecated METHOD_RETURN(0x0A),
jjg@309:
jjg@309: /**
jjg@309: * For annotations on a type argument or nested array of a method return
jjg@309: * type.
jjg@309: */
jjg@309: METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation),
jjg@309:
jjg@309: // handled by regular annotations
jjg@309: //@Deprecated METHOD_PARAMETER(0x0C),
jjg@309:
jjg@309: /** For annotations on a type argument or nested array of a method parameter. */
jjg@309: METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation),
jjg@309:
jjg@309: // handled by regular annotations
jjg@309: //@Deprecated FIELD(0x0E),
jjg@309:
jjg@309: /** For annotations on a type argument or nested array of a field. */
jjg@309: FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation),
jjg@309:
jjg@309: /** For annotations on a bound of a type parameter of a class. */
jjg@309: CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter),
jjg@309:
jjg@309: /**
jjg@309: * For annotations on a type argument or nested array of a bound of a type
jjg@309: * parameter of a class.
jjg@309: */
jjg@309: CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter),
jjg@309:
jjg@309: /** For annotations on a bound of a type parameter of a method. */
jjg@309: METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter),
jjg@309:
jjg@309: /**
jjg@309: * For annotations on a type argument or nested array of a bound of a type
jjg@309: * parameter of a method.
jjg@309: */
jjg@309: METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter),
jjg@309:
jjg@309: /** For annotations on the type of an "extends" or "implements" clause. */
jjg@309: CLASS_EXTENDS(0x14),
jjg@309:
jjg@309: /** For annotations on the inner type of an "extends" or "implements" clause. */
jjg@309: CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation),
jjg@309:
jjg@309: /** For annotations on a throws clause in a method declaration. */
jjg@309: THROWS(0x16),
jjg@309:
jjg@309: // invalid location
jjg@309: //@Deprecated THROWS_GENERIC_OR_ARRAY(0x17, HasLocation),
jjg@309:
jjg@309: /** For annotations in type arguments of object creation expressions. */
jjg@310: NEW_TYPE_ARGUMENT(0x18, IsLocal),
jjg@310: NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation, IsLocal),
jjg@309:
jjg@310: METHOD_TYPE_ARGUMENT(0x1A, IsLocal),
jjg@310: METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation, IsLocal),
jjg@309:
jjg@309: WILDCARD_BOUND(0x1C, HasBound),
jjg@309: WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation),
jjg@309:
jjg@310: CLASS_LITERAL(0x1E, IsLocal),
jjg@310: CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation, IsLocal),
jjg@309:
jjg@309: METHOD_TYPE_PARAMETER(0x20, HasParameter),
jjg@309:
jjg@309: // invalid location
jjg@309: //@Deprecated METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter),
jjg@309:
jjg@309: CLASS_TYPE_PARAMETER(0x22, HasParameter),
jjg@309:
jjg@309: // invalid location
jjg@309: //@Deprecated CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter),
jjg@309:
jjg@309: /** For annotations with an unknown target. */
jjg@309: UNKNOWN(-1);
jjg@309:
jjg@309: static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22;
jjg@309:
jjg@309: private final int targetTypeValue;
jjg@309: private Set