Skip to content

Commit 4f9f9e2

Browse files
authored
BAEL-4233: Why doesn't a missing annotation cause a ClassNotFoundException at runtime? (eugenp#11024)
1 parent b8a05bc commit 4f9f9e2

4 files changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.baeldung.missingannotation;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.RetentionPolicy;
5+
6+
@Retention(RetentionPolicy.RUNTIME)
7+
public @interface A {
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.baeldung.missingannotation;
2+
3+
@A
4+
@C(D.class)
5+
public class B {
6+
7+
public static void main(String[] args) {
8+
System.out.println("It worked");
9+
}
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.baeldung.missingannotation;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.RetentionPolicy;
5+
6+
@Retention(RetentionPolicy.RUNTIME)
7+
public @interface C {
8+
Class<?> value();
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.baeldung.missingannotation;
2+
3+
public class D {
4+
}

0 commit comments

Comments
 (0)