mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01:00
25 lines
673 B
Java
25 lines
673 B
Java
package reflection;
|
|
|
|
import java.lang.annotation.Annotation;
|
|
|
|
public class ReflectiveAccess {
|
|
public static @interface TestAnnotation {
|
|
}
|
|
|
|
@TestAnnotation
|
|
public static class TestClass {
|
|
}
|
|
|
|
public static <A extends Annotation> A getAnnotation(Class<?> classContainingAnnotation, Class<A> annotationClass) {
|
|
return classContainingAnnotation.getAnnotation(annotationClass);
|
|
}
|
|
|
|
public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
|
Class<?> testClass = Class.forName("reflection.ReflectiveAccess$TestClass");
|
|
|
|
testClass.newInstance();
|
|
|
|
getAnnotation(TestClass.class, TestAnnotation.class);
|
|
}
|
|
}
|