|
176 | 176 | \end{description} |
177 | 177 |
|
178 | 178 |
|
| 179 | +\subsectionAndLabel{How to choose which annotation to use}{signature-choosing-annotation} |
| 180 | +
|
| 181 | +Sometimes, there are multiple valid annotations for a value. As an |
| 182 | +example, a non-primitive non-array type is represented identically by |
| 183 | +\<@BinaryName>, \<@ClassGetName>, and \<@FqBinaryName>. Using the lowest |
| 184 | +type in the type hierarchy (in this case, \<@BinaryName>) has two |
| 185 | +advantages. First, it acts as documentation that the value is never a |
| 186 | +primitive or array. Second, it permits the value to be used in any of the |
| 187 | +three contexts: as a \<@BinaryName>, a \<@ClassGetName>, or a |
| 188 | +\<@FqBinaryName>. |
| 189 | +
|
| 190 | +Casting to \<@BinaryName> from one of the other types adds clutter if it is not |
| 191 | +necessary. Suppose that a method returns a \<@ClassGetName> and the value will |
| 192 | +only be used in contexts that require a \<@ClassGetName> (say, it is passed to a |
| 193 | +method that requires an argument of that type). Then there is no point in |
| 194 | +casting to \<@BinaryName> in between, even if you know the type being |
| 195 | +represented is not a primitive or an array. |
| 196 | +
|
| 197 | +
|
179 | 198 | \sectionAndLabel{What the Signature Checker checks}{signature-checks} |
180 | 199 |
|
181 | 200 | Certain methods in the JDK, such as \<Class.forName>, are annotated |
|
196 | 215 | % LocalWords: jls getName ClassGetName ClassLoader LMyClass Ljava jvms |
197 | 216 | % LocalWords: DotSeparatedIdentifiers CharSequence Lmypackage mypackage |
198 | 217 | % LocalWords: FieldDescriptorWithoutPackage InternalForm getSimpleName |
199 | | -% LocalWords: ClassGetSimpleName FqBinaryName CanonicalName |
| 218 | +% LocalWords: ClassGetSimpleName FqBinaryName CanonicalName checkers'' |
| 219 | +% LocalWords: Lpkg |
0 commit comments