Flylib.com

Books Software

 
 
 

Inherited


Inherited java.lang.annotation

Java 5.0 @Documented @Retention(RUNTIME) @Target(ANNOTATION_TYPE) annotation

When an annotation type that has an @Inherited meta-annotation is applied to a class, that annotation should be inherited by subclasses and descendants of the annotated class. The inheritance is only for classes and their subclasses. If an @Inherited annotation type is applied to a method or program element other than a class, no inheritance applies. If the @Inherited annotation type also has runtime Retention , reflective access to the annotation through java.lang.reflect.AnnotatedElement manages the inheritance of the annotation.

Figure 10-79. java.lang.annotation.Inherited

public @interface

Inherited

{
}


Retention java.lang.annotation

Java 5.0 @Documented @Retention(RUNTIME) @Target(ANNOTATION_TYPE) annotation

A meta-annotation of this type specifies how long the annotated annotation type should be retained. The value( ) of this annotation type is one of the three RetentionPolicy enumerated constants. See RetentionPolicy for details. If an annotation type does not have an @Retention meta-annotation, its default retention is RetentionPolicy.CLASS .

Figure 10-80. java.lang.annotation.Retention

public @interface

Retention

{

// Public Instance Methods

RetentionPolicy

value

( );  
}


RetentionPolicy java.lang.annotation

Java 5.0 serializable comparable enum

The constants declared by the enumerated type specify the possible retention values for an @Retention meta-annotation. Annotations with SOURCE retention appear in Java source code only and are discarded by the compiler. Annotations with CLASS retention are compiled into the class file and are visible to tools that read class files but are not loaded by the Java VM at runtime. (This is the default retention for annotation types that do not have an @Retention meta-annotation.) Finally, annotations with RUNTIME retention are stored in the class file and loaded by the Java interpreter at runtime. These annotations are available for reflective access through java.lang.reflect.AnnotatedElement .

Figure 10-81. java.lang.annotation.RetentionPolicy

public enum

RetentionPolicy

{

// Enumerated Constants


SOURCE

,

CLASS

,

RUNTIME

;

// Public Class Methods

public static RetentionPolicy

valueOf

(String

name

);  
     public static final RetentionPolicy[ ]

values

( );  
}

Returned By

Retention.value( )


Target java.lang.annotation

Java 5.0 @Documented @Retention(RUNTIME) @Target(ANNOTATION_TYPE) annotation

A meta-annotation of this type specifies what program elements the annotated annotation type can be applied to. The value( ) of a Target annotation is an array of ElementType enumerated constants. See ElementType for details on the allowed values. If an annotation type does not have an @Target meta-annotation, it can be applied to any program element.

Figure 10-82. java.lang.annotation.Target

public @interface

Target

{

// Public Instance Methods

ElementType[ ]

value

( );  
}


Package java.lang.instrument

Java 5.0

This package defines the API for instrumenting a Java VM by transforming class files to add profiling support, code coverage testing, or other features.

The -javaagent command-line option to the Java interpreter provides a hook for running the premain( ) method of a Java instrumentation agent . An Instrumentation object passed to the premain( ) method provides an entry point into this package, and methods of Instrumentation allow loaded classes to be redefined and ClassFileTransformer objects to be registered for classes not yet loaded.

Interfaces

public interface

ClassFileTransformer

;
public interface

Instrumentation

;

Classes

public final class

ClassDefinition

;

Exceptions

public class

IllegalClassFormatException

extends Exception;
public class

UnmodifiableClassException

extends Exception;