THE Java™ Programming Language, Fourth Edition
Chapter 15. Annotations I don't like spinach, and I'm glad I don't, because if I liked it I'd eat it, and I just hate it. Claren ...
An annotation type is a special kind of interface, designated by the @ character preceding the interface keyword.[1] Annotations ...
In essence, the elements of an annotation type are like the fields of an object, that is instantiated for each program element t ...
} This updates the revision to be 3.0, by specifying the major value and again allowing the minor value to default to 0. An anno ...
public void badMethod() { / ... / } Otherwise, for each element that does not have a default value you must list an initializer, ...
You can have more than one element in the annotation type and still call one of them value. If you do, and all other elements ha ...
Our Revision annotation type could also be annotated with: @Target(ElementType.TYPE) to restrict its applicability to type decla ...
The second problem with annotations is that anyone can define their own. A key benefit of annotations is their suitability for a ...
information about the class itself, such as the modifiers applied to it (public, abstract, final, and so on) or the package it i ...
Over the next few pages you'll see how to perform a much more detailed examination of a class's supertypes and its members. Refl ...
16.1. The Class Class There is a Class object for every type. This includes each class, enum, interface, annotation, array, and ...
Taking an unknown type token Class<?> and turning it into a type token of a known type is a common action when working wit ...
// used in printType() for labeling type names private static String[] basic = { "class", "interface", "enum", "annotation" }, s ...
implements java.util.Map<K, V> implements java.lang.Cloneable implements java.io.Serializable extends java.util.AbstractMa ...
public booleanisPrimitive() Returns true if this Class object is one of the Class objects representing the eight primitive types ...
Returns the Type object for the superclass of this type. This returns null if this Class object represents the Object class, an ...
everything ultimately extends it. Use the reference for the Class object for the Object type. Exercise 16.2: Modify TypeDesc to ...
The first form finds a public field that is either declared or inherited, while the second finds only a declared field that need ...
private static void printMembers(Member[] mems) { for (Member m : mems) { if (m.getDeclaringClass() == Object.class) continue; S ...
its element type followed by []. Local inner classes and anonymous inner classes do not have canonical names. You can get the ca ...
«
12
13
14
15
16
17
18
19
20
21
»
Free download pdf