mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
Verify that Proxy instances have access to annotations' default values
For quick access, the sezpoz library stores lists in META-INF/annotations/ of classes that have been annotated in a special way. To support the use case where the annotations actually changed since sezpoz stored said lists, sezpoz then creates proxy instances for the annotations to provide some backwards compatibility: as long as there are default values for any newly-introduced annotation values, everything is groovy. Therefore, let's make sure that proxy instances inherit the annotations' default values. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
0a179355f4
commit
6c57bd9174
@ -1,4 +1,6 @@
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
import avian.testing.annotations.Color;
|
||||
import avian.testing.annotations.Test;
|
||||
@ -27,6 +29,7 @@ public class Annotations {
|
||||
Method noAnno = Annotations.class.getMethod("noAnnotation");
|
||||
expect(noAnno.getAnnotation(Test.class) == null);
|
||||
expect(noAnno.getAnnotations().length == 0);
|
||||
testProxyDefaultValue();
|
||||
}
|
||||
|
||||
@Test("couscous")
|
||||
@ -39,4 +42,16 @@ public class Annotations {
|
||||
public static void noAnnotation() {
|
||||
|
||||
}
|
||||
|
||||
private static void testProxyDefaultValue() {
|
||||
ClassLoader loader = Annotations.class.getClassLoader();
|
||||
InvocationHandler handler = new InvocationHandler() {
|
||||
public Object invoke(Object proxy, Method method, Object... args) {
|
||||
return method.getDefaultValue();
|
||||
}
|
||||
};
|
||||
Test test = (Test)
|
||||
Proxy.newProxyInstance(loader, new Class[] { Test.class }, handler);
|
||||
expect("Hello, world!".equals(test.value()));
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,5 @@ import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Test {
|
||||
public String value();
|
||||
public String value() default "Hello, world!";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user