Last active
August 29, 2015 14:02
-
-
Save kazurof/b407368a712f4006ecea to your computer and use it in GitHub Desktop.
used by blog http://kazurof.hateblo.jp/entry/2014/06/23/011354
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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