找出调度任务注解里的 bug

来自 注解
Java 25 LTS 入门 4分钟 找出 1处问题

找出运行时调度器始终无法识别这个任务的原因。

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));
    }
}
在试验场中打开
报告错误