Skip to content

Instantly share code, notes, and snippets.

@kazurof
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazurof/b407368a712f4006ecea to your computer and use it in GitHub Desktop.
Save kazurof/b407368a712f4006ecea to your computer and use it in GitHub Desktop.
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
public class ECJProblem {
private static final String nantoka = "kantoka";
public String doSomething(@TestAnnotation(nantoka) String nantoka) {
return "doushita";
}
public static void main(String[] args) throws Exception {
Method meth = ECJProblem.class.getMethod("doSomething", String.class);
Annotation[][] ano = meth.getParameterAnnotations();
System.out.println(((TestAnnotation) ano[0][0]).value());
}
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface TestAnnotation {
String value();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment