1 /*******************************************************************************
2 * Copyright (c) 2000, 2017 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 * IBM Corporation - initial API and implementation
13 * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
14 * bug 407191 - [1.8] Binary access support for type annotations
15 * Stephan Herrmann - Contribution for
16 * Bug 440474 - [null] textual encoding of external null annotations
17 *******************************************************************************/
18 package org.eclipse.jdt.internal.compiler.env;
19
20 import org.eclipse.jdt.core.compiler.CharOperation;
21 import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
22 import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
23
24 public interface IBinaryType extends IGenericType {
25
26 char[][] NoInterface = CharOperation.NO_CHAR_CHAR;
27 IBinaryNestedType[] NoNestedType = new IBinaryNestedType[0];
28 IBinaryField[] NoField = new IBinaryField[0];
29 IBinaryMethod[] NoMethod = new IBinaryMethod[0];
30 /**
31 * Answer the runtime visible and invisible annotations for this type or null if none.
32 */
33
getAnnotations()34 IBinaryAnnotation[] getAnnotations();
35
36 /**
37 * Answer the runtime visible and invisible type annotations for this type or null if none.
38 */
39
getTypeAnnotations()40 IBinaryTypeAnnotation[] getTypeAnnotations();
41
42 /**
43 * Answer the enclosing method (including method selector and method descriptor), or
44 * null if none.
45 *
46 * For example, "foo()Ljava/lang/Object;V"
47 */
48
getEnclosingMethod()49 char[] getEnclosingMethod();
50 /**
51 * Answer the resolved name of the enclosing type in the
52 * class file format as specified in section 4.2 of the Java 2 VM spec
53 * or null if the receiver is a top level type.
54 *
55 * For example, java.lang.String is java/lang/String.
56 */
57
getEnclosingTypeName()58 char[] getEnclosingTypeName();
59 /**
60 * Answer the receiver's fields or null if the array is empty.
61 */
62
getFields()63 IBinaryField[] getFields();
64 /**
65 * Answer the module to which this type belongs.
66 * {@code null} if the type is associated to the unnamed module.
67 *
68 * @return the module name or {@code null}
69 */
getModule()70 char[] getModule();
71 /**
72 * Answer the receiver's ClassSignature, which describes the type parameters,
73 * super class, and super interfaces as specified in section "4.7.9.1 Signatures"
74 * of the Java SE 8 VM spec.
75 * Returns null if none.
76 *
77 * @return the receiver's signature, null if none
78 */
getGenericSignature()79 char[] getGenericSignature();
80 /**
81 * Answer the resolved names of the receiver's interfaces in the
82 * class file format as specified in section 4.2 of the Java 2 VM spec
83 * or null if the array is empty.
84 *
85 * For example, java.lang.String is java/lang/String.
86 */
87
getInterfaceNames()88 char[][] getInterfaceNames();
89 /**
90 * Answer the receiver's nested types or null if the array is empty.
91 *
92 * This nested type info is extracted from the inner class attributes.
93 * Ask the name environment to find a member type using its compound name.
94 */
95
96 // NOTE: The compiler examines the nested type info & ignores the local types
97 // so the local types do not have to be included.
98
getMemberTypes()99 IBinaryNestedType[] getMemberTypes();
100 /**
101 * Answer the receiver's methods or null if the array is empty.
102 */
103
getMethods()104 IBinaryMethod[] getMethods();
105
106 /**
107 * Answer the list of missing type names which were referenced from
108 * the problem classfile. This list is encoded via an extra attribute.
109 */
getMissingTypeNames()110 char[][][] getMissingTypeNames();
111
112 /**
113 * Answer the resolved name of the type in the
114 * class file format as specified in section 4.2 of the Java 2 VM spec.
115 *
116 * For example, java.lang.String is java/lang/String.
117 */
getName()118 char[] getName();
119
120 /**
121 * Answer the simple name of the type in the class file.
122 * For member A$B, will answer B.
123 * For anonymous will answer null.
124 */
getSourceName()125 char[] getSourceName();
126
127 /**
128 * Answer the resolved name of the receiver's superclass in the
129 * class file format as specified in section 4.2 of the Java 2 VM spec
130 * or null if it does not have one.
131 *
132 * For example, java.lang.String is java/lang/String.
133 */
134
getSuperclassName()135 char[] getSuperclassName();
136 /**
137 * Answer the tagbits set according to the bits for annotations.
138 */
getTagBits()139 long getTagBits();
140 /**
141 * Answer true if the receiver is an anonymous class.
142 * false otherwise
143 */
isAnonymous()144 boolean isAnonymous();
145
146 /**
147 * Answer true if the receiver is a local class.
148 * false otherwise
149 */
isLocal()150 boolean isLocal();
151
152 /**
153 * Answer true if the receiver is a member class.
154 * false otherwise
155 */
isMember()156 boolean isMember();
157
158 /**
159 * Answer the source file attribute, or null if none.
160 *
161 * For example, "String.java"
162 */
163
sourceFileName()164 char[] sourceFileName();
165
166 /**
167 * Answer a type annotation walker that takes into consideration also external annotations.
168 * @param walker previous walker, may be empty, otherwise it will be returned unchanged
169 * @param member if either a IBinaryField or a IBinaryMethod is provided, answer a walker specifically for that member
170 * @param environment for use by the walker
171 * @return either a matching walker with data from external annotations or the walker provided via argument 'walker'.
172 */
enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, Object member, LookupEnvironment environment)173 ITypeAnnotationWalker enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, Object member, LookupEnvironment environment);
174
175 /**
176 * Answer whether a provider for external annotations is associated with this binary type.
177 */
getExternalAnnotationStatus()178 ExternalAnnotationStatus getExternalAnnotationStatus();
179
180 }
181