Spot the bug in the scheduled job annotation

from Annotations
Java 25 LTS beginner 4 min 1 issue to find

Find why the runtime scheduler never recognizes this job.

Java
import java.lang.annotation.*;

@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
@interface Scheduled {}

class CleanupJob {
    @Scheduled
    public void run() {}
}

public class Main {
    public static void main(String[] args) throws Exception {
        var method = CleanupJob.class.getDeclaredMethod("run");
        System.out.println(method.isAnnotationPresent(Scheduled.class));
    }
}
Open in playground
Report an error