Java Annotation Targets: @Target and ElementType Explained

Su Suriya Ravichandran Updated 18 Nov 2026
13 min read ·Lesson 236 of 306

Java annotation targets decide where an annotation may be written: on a class, a method, a field, a parameter, a type argument and so on. You set them with the @Target meta-annotation and the constants of the ElementType enum.

Targets protect your annotations from misuse. If @Audited only makes sense on methods, @Target(ElementType.METHOD) makes the compiler reject it anywhere else. In Java Custom Annotations you used @Target briefly; this lesson covers every target in depth and ends with a small web router that uses three different targets together.


Java Annotation Targets Syntax

@Target takes one ElementType or an array of them. It is placed on the annotation type declaration, next to @Retention.

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)                         // one target
@interface OneTarget { }

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER}) // several targets
@interface ManyTargets { }

Note: @Target is itself an annotation from java.lang.annotation, covered in Java Built-in Annotations. It only affects where the annotation compiles; @Retention still decides whether you can read it at runtime.


All ElementType Constants

ElementTypeWhere the annotation may appearExample
TYPEClass, interface, enum, record, annotation type@Entity class User { }
FIELDField, including enum constants@Column private String name;
METHODMethod@Test void login() { }
PARAMETERMethod or constructor parametervoid find(@PathParam("id") int id)
CONSTRUCTORConstructor@Inject public Service() { }
LOCAL_VARIABLELocal variable@Todo("x") int count = 0;
ANNOTATION_TYPEAnother annotation type (meta-annotation)@Stereotype @interface Service { }
PACKAGEPackage declaration in package-info.java@Deprecated package com.app.old;
TYPE_PARAMETERGeneric type parameter declarationclass Box<@Entity T> { }
TYPE_USEAny use of a typeList<@NonEmpty String>
MODULEModule declaration in module-info.java@Deprecated module com.app { }
RECORD_COMPONENTRecord componentrecord Customer(@Sensitive String phone) { }

The first eight are declaration contexts: they annotate something you declare. TYPE_USE is a type context: it annotates the type itself wherever the type is written.


Restricting an Annotation to One Target

The most common case is a single target. This @Audited annotation is only valid on methods:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD) // allowed on methods only
@interface Audited { }

public class SingleTarget {

    @Audited
    public void transferFunds() { }

    public static void main(String[] args) throws NoSuchMethodException {
        boolean audited = SingleTarget.class
                .getMethod("transferFunds")
                .isAnnotationPresent(Audited.class);
        System.out.println("transferFunds audited? " + audited);
    }
}

Output:

transferFunds audited? true

How it works:

  • @Target(ElementType.METHOD) tells the compiler that @Audited belongs on methods.
  • getMethod("transferFunds") finds the public method, and isAnnotationPresent confirms the annotation is there at runtime.

What Happens With the Wrong Target

Now put the same annotation on a field:

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@interface Audited { }

public class WrongTarget {

    @Audited // a field is not a method
    private double balance;
}
WrongTarget.java:9: error: annotation interface not applicable to this kind of declaration
    @Audited // a field is not a method
    ^
1 error

The program never compiles, so the mistake cannot reach production. This is the main reason to always declare a target.


Allowing Multiple Annotation Targets

Pass an array to allow several kinds of declarations. A @Since annotation that records the version a feature arrived in fits classes, fields, constructors and methods:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
@interface Since {
    String value();
}

@Since("1.0")
public class MultiTarget {

    @Since("1.2")
    private String couponCode;

    @Since("1.1")
    public MultiTarget() { }

    @Since("2.0")
    public void applyCoupon() { }

    public static void main(String[] args) throws ReflectiveOperationException {
        Class<MultiTarget> type = MultiTarget.class;
        Field field = type.getDeclaredField("couponCode");
        Constructor<MultiTarget> constructor = type.getConstructor();
        Method method = type.getMethod("applyCoupon");

        System.out.println("class       -> " + type.getAnnotation(Since.class).value());
        System.out.println("field       -> " + field.getAnnotation(Since.class).value());
        System.out.println("constructor -> " + constructor.getAnnotation(Since.class).value());
        System.out.println("method      -> " + method.getAnnotation(Since.class).value());
    }
}

Output:

class       -> 1.0
field       -> 1.2
constructor -> 1.1
method      -> 2.0

How it works:

  • The array {TYPE, FIELD, METHOD, CONSTRUCTOR} lists every allowed place. Putting @Since on a parameter would still fail to compile.
  • Each reflective object (Class, Field, Constructor, Method) has its own getAnnotation method, so you read the value from exactly the element you annotated.

When @Target Is Missing

An annotation type without @Target is allowed in all declaration contexts but in no type contexts:

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;

@Retention(RetentionPolicy.RUNTIME)
@interface Reviewed { } // no @Target

@Reviewed
public class NoTarget<@Reviewed T> {            // class and type parameter: OK

    @Reviewed private int count;                 // field: OK

    @Reviewed public NoTarget() { }              // constructor: OK

    @Reviewed void save(@Reviewed String name) { // method and parameter: OK
        @Reviewed int retries = 3;               // local variable: OK
    }

    List<@Reviewed String> names;                // type use: NOT allowed
}
NoTarget.java:19: error: annotation @Reviewed not applicable in this type context
    List<@Reviewed String> names;                // type use: NOT allowed
         ^
1 error

How it works:

  • Every declaration in the class accepts @Reviewed, because no @Target means "any declaration".
  • List<@Reviewed String> annotates a use of the type String, not a declaration, so it needs ElementType.TYPE_USE explicitly.

Note: Relying on the default makes your annotation too permissive. Declare @Target even when you want many contexts, so readers see the intent and the compiler catches mistakes.


LOCAL_VARIABLE Target

Local variable annotations compile fine, but they are never stored in a way reflection can read, even with RUNTIME retention. They are useful for the compiler, annotation processors and IDE tools only.

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.Arrays;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.LOCAL_VARIABLE})
@interface Todo {
    String value();
}

public class LocalVar {

    @Todo("add caching")
    static int lookupPrice(String sku) {
        @Todo("read from database") int price = 499;
        return price;
    }

    public static void main(String[] args) throws NoSuchMethodException {
        Method method = LocalVar.class.getDeclaredMethod("lookupPrice", String.class);
        System.out.println("On method: " + Arrays.toString(method.getAnnotations()));
        System.out.println("Price: " + lookupPrice("JAVA-101"));
    }
}

Output:

On method: [@Todo("add caching")]
Price: 499

How it works:

  • The method annotation is visible because methods keep RUNTIME annotations in the class file.
  • The local variable annotation @Todo("read from database") compiles, but there is no reflection API for local variables, so it never shows up at runtime.

TYPE_USE and TYPE_PARAMETER Targets

TYPE_PARAMETER annotates the declaration of a generic parameter such as T. TYPE_USE is broader: it can go on any written type, including generic arguments, casts, new expressions, throws clauses and array element types. Null-checking tools such as the Checker Framework use TYPE_USE for annotations like @NonNull.

CodeAnnotation sits on
List<@NonEmpty String> tags;The type argument String
(@NonEmpty Object) valueThe cast type
new @NonEmpty ArrayList<>()The created type
String @NonEmpty [] names;The array type
class Repository<@Entity T>The type parameter T (TYPE_PARAMETER)

Reading type-use annotations requires the getAnnotatedType() family of methods, not getAnnotation():

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.AnnotatedParameterizedType;
import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Field;
import java.util.List;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface NonEmpty { }

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_PARAMETER)
@interface Entity { }

class Repository<@Entity T> { }

public class TypeUse {

    // the annotation sits on the type argument, not on the field
    List<@NonEmpty String> tags;

    public static void main(String[] args) throws Exception {
        Object tagsList = (@NonEmpty Object) List.of("java");   // cast: TYPE_USE allowed
        System.out.println("Cast worked: " + tagsList);

        Field field = TypeUse.class.getDeclaredField("tags");
        System.out.println("Field annotations: " + field.getAnnotations().length);

        AnnotatedParameterizedType listType = (AnnotatedParameterizedType) field.getAnnotatedType();
        AnnotatedType elementType = listType.getAnnotatedActualTypeArguments()[0];
        System.out.println("Element type: " + elementType.getType().getTypeName());
        System.out.println("Has @NonEmpty: " + elementType.isAnnotationPresent(NonEmpty.class));

        var typeParameter = Repository.class.getTypeParameters()[0];
        System.out.println("Type parameter " + typeParameter.getName()
                + " has @Entity: " + typeParameter.isAnnotationPresent(Entity.class));
    }
}

Output:

Cast worked: [java]
Field annotations: 0
Element type: java.lang.String
Has @NonEmpty: true
Type parameter T has @Entity: true

How it works:

  • field.getAnnotations() returns nothing, because @NonEmpty belongs to the type argument String, not to the field tags.
  • field.getAnnotatedType() returns the full annotated type List<@NonEmpty String>. Casting it to AnnotatedParameterizedType gives access to the annotated type arguments, where @NonEmpty lives.
  • getTypeParameters() returns TypeVariable objects, which also implement AnnotatedElement, so isAnnotationPresent works on T directly.

RECORD_COMPONENT Target and Annotation Propagation

An annotation on a record component is copied by the compiler to every generated member whose kind matches its @Target: the component itself, the private field, the accessor method and the canonical constructor parameter.

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.RECORD_COMPONENT)
@interface Sensitive { }

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@interface Masked { }

record Customer(String name, @Sensitive @Masked String phone) { }

public class RecordTarget {
    public static void main(String[] args) throws Exception {
        var component = Customer.class.getRecordComponents()[1];
        var field = Customer.class.getDeclaredField("phone");
        var accessor = Customer.class.getMethod("phone");

        System.out.println("component " + component.getName()
                + ": @Sensitive=" + component.isAnnotationPresent(Sensitive.class)
                + ", @Masked=" + component.isAnnotationPresent(Masked.class));
        System.out.println("field     " + field.getName()
                + ": @Sensitive=" + field.isAnnotationPresent(Sensitive.class)
                + ", @Masked=" + field.isAnnotationPresent(Masked.class));
        System.out.println("accessor  " + accessor.getName()
                + "(): @Sensitive=" + accessor.isAnnotationPresent(Sensitive.class)
                + ", @Masked=" + accessor.isAnnotationPresent(Masked.class));
    }
}

Output:

component phone: @Sensitive=true, @Masked=false
field     phone: @Sensitive=false, @Masked=true
accessor  phone(): @Sensitive=false, @Masked=true

How it works:

  • @Sensitive targets only RECORD_COMPONENT, so it stays on the component and is not copied anywhere else.
  • @Masked targets FIELD and METHOD, so the compiler copies it to the generated private final String phone field and the phone() accessor, but not to the component.
  • This is how libraries such as Jackson or Jakarta Validation see annotations written on records: they read the field or accessor, so those annotations need FIELD or METHOD in their target list.

ANNOTATION_TYPE Target: Building Meta-Annotations

ANNOTATION_TYPE lets an annotation be placed on other annotation types. This is how you build a family of related annotations. Spring's @Service and @Repository are both marked with @Component this way.

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE) // only on other annotations
@interface Stereotype {
    String value();
}

@Stereotype("service")
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface Service { }

@Stereotype("repository")
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface Repository { }

@Service
class PaymentService { }

@Repository
class OrderRepository { }

class PlainHelper { }

public class MetaAnnotationDemo {

    static String describe(Class<?> type) {
        for (Annotation annotation : type.getAnnotations()) {
            Stereotype stereotype = annotation.annotationType().getAnnotation(Stereotype.class);
            if (stereotype != null) {
                return type.getSimpleName() + " is a " + stereotype.value()
                        + " (via @" + annotation.annotationType().getSimpleName() + ")";
            }
        }
        return type.getSimpleName() + " is not a managed component";
    }

    public static void main(String[] args) {
        System.out.println(describe(PaymentService.class));
        System.out.println(describe(OrderRepository.class));
        System.out.println(describe(PlainHelper.class));
    }
}

Output:

PaymentService is a service (via @Service)
OrderRepository is a repository (via @Repository)
PlainHelper is not a managed component

How it works:

  • @Stereotype can only be written on annotation types. Putting it on PaymentService directly would not compile.
  • annotation.annotationType() returns the Class of the annotation, for example Service.class. Asking that class for @Stereotype reveals the meta-annotation.
  • The scanner never mentions @Service or @Repository by name, so new stereotypes work without changing it.

PACKAGE and MODULE Targets

These two targets are written in special files instead of normal classes:

// file: com/gocourse/legacy/package-info.java
@Deprecated(since = "3.0")
package com.gocourse.legacy;
// file: module-info.java
@Deprecated(forRemoval = true)
module com.gocourse.reports { }

You read them with SomeClass.class.getPackage().getAnnotation(...) and SomeClass.class.getModule().getAnnotation(...). A custom annotation needs @Target(ElementType.PACKAGE) or @Target(ElementType.MODULE) to be allowed there.


Real-World Example: A Mini Web Router With Three Targets

Web frameworks such as Spring MVC and Jakarta REST combine annotation targets: a class-level annotation for the base path, method-level annotations for each route and parameter-level annotations for values from the URL. This example builds a small router that does the same.

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

// ---------- annotations: one per target ----------
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface Controller {
    String value(); // base path
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface Get {
    String value(); // path after the base
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@interface PathParam {
    String value(); // name of the {placeholder}
}

// ---------- a controller written by the "user" ----------
@Controller("/courses")
class CourseController {

    @Get("")
    public String listCourses() {
        return "Java, Python, Go";
    }

    @Get("/{id}")
    public String findCourse(@PathParam("id") int courseId) {
        return "Course #" + courseId;
    }

    @Get("/{id}/lessons/{lesson}")
    public String findLesson(@PathParam("id") int courseId, @PathParam("lesson") String lessonSlug) {
        return "Course #" + courseId + ", lesson '" + lessonSlug + "'";
    }
}

// ---------- the "framework" ----------
class Router {

    private record Route(String[] segments, Method handler, Object controller) { }

    private final List<Route> routes = new ArrayList<>();

    void register(Object controller) {
        Class<?> type = controller.getClass();
        Controller base = type.getAnnotation(Controller.class);
        if (base == null) {
            throw new IllegalArgumentException(type.getSimpleName() + " is not a @Controller");
        }

        Method[] methods = type.getDeclaredMethods();
        Arrays.sort(methods, Comparator.comparing(Method::getName)); // stable order
        for (Method method : methods) {
            Get get = method.getAnnotation(Get.class);
            if (get != null) {
                String fullPath = base.value() + get.value();
                routes.add(new Route(fullPath.substring(1).split("/"), method, controller));
                System.out.println("Mapped GET " + fullPath + " -> " + method.getName());
            }
        }
    }

    String dispatch(String path) throws ReflectiveOperationException {
        String[] requestSegments = path.substring(1).split("/");
        for (Route route : routes) {
            Map<String, String> pathValues = match(route.segments(), requestSegments);
            if (pathValues == null) {
                continue;
            }
            Parameter[] parameters = route.handler().getParameters();
            Object[] arguments = new Object[parameters.length];
            for (int i = 0; i < parameters.length; i++) {
                String name = parameters[i].getAnnotation(PathParam.class).value();
                String rawValue = pathValues.get(name);
                arguments[i] = parameters[i].getType() == int.class ? Integer.parseInt(rawValue) : rawValue;
            }
            return (String) route.handler().invoke(route.controller(), arguments);
        }
        return "404 Not Found";
    }

    private static Map<String, String> match(String[] pattern, String[] actual) {
        if (pattern.length != actual.length) {
            return null;
        }
        Map<String, String> values = new HashMap<>();
        for (int i = 0; i < pattern.length; i++) {
            if (pattern[i].startsWith("{")) {
                values.put(pattern[i].substring(1, pattern[i].length() - 1), actual[i]);
            } else if (!pattern[i].equals(actual[i])) {
                return null;
            }
        }
        return values;
    }
}

public class MiniRouter {
    public static void main(String[] args) throws ReflectiveOperationException {
        Router router = new Router();
        router.register(new CourseController());
        System.out.println();

        List<String> requests = List.of(
                "/courses",
                "/courses/42",
                "/courses/42/lessons/annotation-targets",
                "/students");
        for (String path : requests) {
            System.out.println("GET " + path + " => " + router.dispatch(path));
        }
    }
}

Output:

Mapped GET /courses/{id} -> findCourse
Mapped GET /courses/{id}/lessons/{lesson} -> findLesson
Mapped GET /courses -> listCourses

GET /courses => Java, Python, Go
GET /courses/42 => Course #42
GET /courses/42/lessons/annotation-targets => Course #42, lesson 'annotation-targets'
GET /students => 404 Not Found

How it works:

  1. Three targets, three jobs. @Controller (TYPE) gives the base path, @Get (METHOD) maps each handler and @PathParam (PARAMETER) names the URL value each argument receives. Writing @PathParam on a method would not compile, so the user cannot mix them up.
  2. Registration. register reads @Controller from the class, then every @Get method, and joins the two paths. /courses + /{id} becomes /courses/{id}. Methods are sorted by name because getDeclaredMethods() has no guaranteed order.
  3. Matching. match compares the request path segment by segment. A segment in braces, such as {id}, captures the request value under the name id.
  4. Binding parameters. For each method parameter, getAnnotation(PathParam.class) gives the placeholder name. The value is converted to int when the parameter type is int, so findCourse receives the number 42, not the text "42".
  5. Invoking. Method.invoke calls the handler on the controller object. How invoke and other reflective calls work in detail is the subject of the next lesson, Java Reflection API.
  6. No match. /students matches no route, so dispatch returns 404 Not Found.

0 Comments

Reviewed before they appear

No comments yet.

Java
Java Introduction Java Features Java Syntax Java Comments Java Statements Java Output Java Variables Java Data Types Java Type Casting Java Operators Java Strings Java Numbers Java Math Java Booleans Java User Input Java Conditions Java If Else Java Switch Java While Loop Java For Loop Java Break Java Continue Java Arrays Java Methods Java Parameters Java Return Values Java Scope Java Recursion Install Java Install JDK Java IDEs Java JDK Java JRE Java JVM Java Compiler Java File Compile Java Run Java JShell Basics Java Packages Java OOP Java Classes Java Objects Class Methods Constructors Constructor Overload this Keyword static Keyword final Keyword Encapsulation Inheritance Polymorphism Abstraction Access Modifiers super Keyword Method Overload Method Override Instanceof Operator Nested Classes Inner Classes Anonymous Classes Enums Records Array Basics Array Length Loop Arrays Multidimensional Arrays Array Copy Array Sorting Array Search ArrayList LinkedList HashSet TreeSet HashMap TreeMap Queue Interface Deque Interface Stack Class Iterator List Interface Set Interface Map Interface Collections Class Comparable Comparator Generics Basics Generic Classes Generic Methods Wildcards String Basics String Length String Methods String Concatenation String Compare String Search String Replace String Split String Format StringBuilder StringBuffer Text Blocks Regular Expressions Number Types Integer Class Float Class Double Class BigInteger BigDecimal Math Class Random Numbers Number Format Date Basics LocalDate LocalTime LocalDateTime ZonedDateTime Date Formatting Date Parsing Period Class Duration Class Java Instant Class Java Exception Basics Java try...catch Java Multiple Catch Blocks Java finally Block Java throw Keyword Java throws Keyword Java Checked Exceptions Java Unchecked Exceptions Java Custom Exceptions Java try-with-resources Java Exception Chaining Java File Basics Java Create Files Java Read Files Java Write Files Java Delete Files Java File Paths Java File Class Java BufferedReader Java BufferedWriter Java FileInputStream Java FileOutputStream Java Object Streams Java Directory Handling Java NIO Basics Java Files API Java Input Java Scanner Class Java Console Input Java PrintStream Java InputStream Java OutputStream Java Reader Class Java Writer Class Java Buffered Streams Java Data Streams Java Generics Introduction Java Generic Types Java Generic Methods Java Bounded Types Java Wildcards Java Type Erasure Java Generic Interfaces Java Generic Collections Java Lambda Basics Java Lambda Syntax Java Functional Interfaces Java Method References Java Stream API Java Stream Creation Java Stream Filter Java Stream Map Java Stream Reduce Java Stream Sort Java Stream Collect Java Collectors Class Java Optional Class Java Parallel Streams Java Threads: Thread Basics Create a Thread in Java Java Thread Class Java Runnable Interface Java Thread States Java Thread Sleep Java Thread Join Java Thread Priority Java Synchronization Java Thread Safety Java Race Conditions Java Deadlocks Java Executor Service Java Thread Pools Java Callable Interface Java Future Interface Java CompletableFuture Java Concurrent Collections Java Atomic Classes Java Virtual Threads Java Networking Basics Java URL Class Java URI Class Java HttpClient Java HTTP Requests Java HTTP Responses Java Socket Basics Java ServerSocket Java DatagramSocket Java WebSocket Basics Java JDBC Basics Java JDBC Setup Java Database Connection Java JDBC Connection Interface Java JDBC Statement Java PreparedStatement Java ResultSet Java JDBC CRUD Operations Java JDBC Transactions Java JDBC Batch Update Java Connection Pooling with HikariCP Java JPA Basics: Entities, EntityManager and JPQL Java Hibernate Basics: SessionFactory, Session and HQL Package in Java: Basics Explained with Examples Create Package in Java: Step-by-Step Guide with Examples Import Package in Java: The import Statement Explained Access Control in Java: Packages, Classes and Members JAR File in Java: Create, Run and Inspect JAR Files Java Modules: Introduction to the Java Module System module-info in Java: Every Module Directive Explained Java Module Path: How --module-path Finds Your Modules Java Classpath: How -cp and CLASSPATH Find Your Classes Java Annotations: Basics of @ Metadata in Java Java Built-in Annotations: @Override, @Deprecated and More Java Custom Annotations: Create Your Own @interface Java Annotation Targets: @Target and ElementType Explained Java Reflection API: Inspect and Use Classes at Runtime Java Class Metadata: Names, Modifiers, Hierarchy and Generic Java Dynamic Objects: Create Objects Dynamically With Reflec Java Dynamic Proxy: Intercept Method Calls With Proxy and In Java Security Java Secure Coding Java Password Hashing Java Input Validation Java Cryptography Basics Java KeyStore Basics Java TLS Basics Java SecureRandom Java JUnit Basics Java JUnit Test Methods JUnit Assertions JUnit Test Fixtures JUnit Parameterized Tests Mockito in Java Java Mock Objects Java Integration Testing Java Code Coverage Maven in Java Create a Maven Project in Java Maven Dependencies Maven Plugins Gradle in Java Gradle Build Gradle Dependencies Build Executable JAR in Java Build WAR File in Java HTTP Basics in Java Java Servlet Basics Servlet Lifecycle in Java HttpServletRequest in Java HttpServletResponse in Java JSP in Java JSTL in JSP REST API in Java JSON in Java Java Web Application Spring Framework Basics Spring Boot Tutorial Spring MVC Spring Data JPA Spring Security Spring Boot REST API Jakarta EE Basics Java Deployment JAR Deployment Java WAR Deployment Run Java as a Service Docker Java: Dockerize a Java Application Java Environment Variables and Configuration Java Logging Basics Java Production Setup Java JVM Options Java JVM Monitoring Java Hello World App Java Calculator App Java Number Guess Game Java Student Manager Java Library System Java Bank App Java Todo App Java File Manager Java Quiz App Java REST API Project Java Chat Server Java Employee Manager Java E-commerce API
Ask about this post
AI Ask about this post

Ask questions about Java Annotation Targets: @Target and ElementType Explained and get answers drawn from it.

Signed-in readers only.