If an annotation takes java.lang.Class as the value type:
@Target(ElementType.PACKAGE)
@Retention(RetentionPolicy.RUNTIME)
public @interface MainClass {
Class value();
}
At runtime, the raw annotation information in the class files is examined lazily, and the "current" classloader for the code making the getAnnotations call is used.
The problem is - this might not be the ClassLoader developers want to use. Thus, there should be a new API for reading annotations that let you specify which ClassLoader to use.
This functionality is also useful for simplifying the annotation usages in JSR-277. This should be addressed in SE 7 if possible.
@Target(ElementType.PACKAGE)
@Retention(RetentionPolicy.RUNTIME)
public @interface MainClass {
Class value();
}
At runtime, the raw annotation information in the class files is examined lazily, and the "current" classloader for the code making the getAnnotations call is used.
The problem is - this might not be the ClassLoader developers want to use. Thus, there should be a new API for reading annotations that let you specify which ClassLoader to use.
This functionality is also useful for simplifying the annotation usages in JSR-277. This should be addressed in SE 7 if possible.
- relates to
-
JDK-5015623 (ann) cannot read annotation when interface is loaded using custom class loader
-
- Closed
-