<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FLanguage%2FAnnotations_Reflection</id>
		<title>Java Tutorial/Language/Annotations Reflection - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FLanguage%2FAnnotations_Reflection"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/Language/Annotations_Reflection&amp;action=history"/>
		<updated>2026-04-18T20:24:54Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/Language/Annotations_Reflection&amp;diff=4858&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/Language/Annotations_Reflection&amp;diff=4858&amp;oldid=prev"/>
				<updated>2010-06-01T05:06:40Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 05:06, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/Language/Annotations_Reflection&amp;diff=4857&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/Language/Annotations_Reflection&amp;diff=4857&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Getting all annotations for a method ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.lang.annotation.Annotation;&lt;br /&gt;
import java.lang.annotation.Retention;&lt;br /&gt;
import java.lang.annotation.RetentionPolicy;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
// A simple annotation type.&lt;br /&gt;
@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;
@interface MyAnnotation {&lt;br /&gt;
  String stringValue();&lt;br /&gt;
  int intValue();&lt;br /&gt;
}&lt;br /&gt;
@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;
@interface What {&lt;br /&gt;
  String description();&lt;br /&gt;
}&lt;br /&gt;
@What(description = &amp;quot;An annotation test class&amp;quot;)&lt;br /&gt;
@MyAnnotation(stringValue = &amp;quot;for class&amp;quot;, intValue = 100)&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  // Annotate a method.&lt;br /&gt;
  @What(description = &amp;quot;An annotation test method&amp;quot;)&lt;br /&gt;
  @MyAnnotation(stringValue = &amp;quot;Annotation Example&amp;quot;, intValue = 100)&lt;br /&gt;
  public static void myMethod() {&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] arg) {&lt;br /&gt;
    try {&lt;br /&gt;
      MainClass ob = new MainClass();&lt;br /&gt;
      Method m = ob.getClass( ).getMethod(&amp;quot;myMethod&amp;quot;);&lt;br /&gt;
      Annotation[] annos = m.getAnnotations();&lt;br /&gt;
      System.out.println(&amp;quot;All annotations for myMeth:&amp;quot;);&lt;br /&gt;
      for(Annotation a : annos)&lt;br /&gt;
      System.out.println(a);&lt;br /&gt;
    } catch (Exception exc) {&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;All annotations for myMeth:&lt;br /&gt;
@What(description=An annotation test method)&lt;br /&gt;
@MyAnnotation(stringValue=Annotation Example, intValue=100)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Obtaining All Annotations: getAnnotations( ) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.lang.annotation.Annotation;&lt;br /&gt;
import java.lang.annotation.Retention;&lt;br /&gt;
import java.lang.annotation.RetentionPolicy;&lt;br /&gt;
// A simple annotation type.&lt;br /&gt;
@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;
@interface MyAnnotation {&lt;br /&gt;
  String stringValue();&lt;br /&gt;
  int intValue();&lt;br /&gt;
}&lt;br /&gt;
@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;
@interface What {&lt;br /&gt;
  String description();&lt;br /&gt;
}&lt;br /&gt;
@What(description = &amp;quot;An annotation test class&amp;quot;)&lt;br /&gt;
@MyAnnotation(stringValue = &amp;quot;for class&amp;quot;, intValue = 100)&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  // Annotate a method.&lt;br /&gt;
  @What(description = &amp;quot;An annotation test method&amp;quot;)&lt;br /&gt;
  @MyAnnotation(stringValue = &amp;quot;Annotation Example&amp;quot;, intValue = 100)&lt;br /&gt;
  public static void myMethod(String str, int i) {&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] arg) {&lt;br /&gt;
    try {&lt;br /&gt;
      MainClass ob = new MainClass();&lt;br /&gt;
      Annotation[] annos = ob.getClass().getAnnotations();&lt;br /&gt;
      &lt;br /&gt;
      System.out.println(&amp;quot;All annotations for Meta2:&amp;quot;);&lt;br /&gt;
      for(Annotation a : annos)&lt;br /&gt;
        System.out.println(a);&lt;br /&gt;
      &lt;br /&gt;
    } catch (Exception exc) {&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;All annotations for Meta2:&lt;br /&gt;
@MyAnnotation(stringValue=for class, intValue=100)&lt;br /&gt;
@What(description=An annotation test class)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Obtaining Annotations at Run Time by Use of Reflection ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.lang.annotation.Retention;&lt;br /&gt;
import java.lang.annotation.RetentionPolicy;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
// A simple annotation type.&lt;br /&gt;
@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;
@interface MyAnnotation {&lt;br /&gt;
  String stringValue();&lt;br /&gt;
  int intValue();&lt;br /&gt;
}&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  // Annotate a method.&lt;br /&gt;
  @MyAnnotation(stringValue = &amp;quot;Annotation Example&amp;quot;, intValue = 100)&lt;br /&gt;
  public static void myMethod() {&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] a) {&lt;br /&gt;
    try {&lt;br /&gt;
      MainClass ob = new MainClass();&lt;br /&gt;
      Class c = ob.getClass();&lt;br /&gt;
      Method m = c.getMethod(&amp;quot;myMethod&amp;quot;);&lt;br /&gt;
      MyAnnotation anno = m.getAnnotation(MyAnnotation.class);&lt;br /&gt;
      System.out.println(anno.stringValue() + &amp;quot; &amp;quot; + anno.intValue());&lt;br /&gt;
    } catch (NoSuchMethodException exc) {&lt;br /&gt;
      System.out.println(&amp;quot;Method Not Found.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Annotation Example 100&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Reflection: getMethod( ) with parameters ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.lang.annotation.Retention;&lt;br /&gt;
import java.lang.annotation.RetentionPolicy;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
// A simple annotation type.&lt;br /&gt;
@Retention(RetentionPolicy.RUNTIME)&lt;br /&gt;
@interface MyAnnotation {&lt;br /&gt;
  String stringValue();&lt;br /&gt;
  int intValue();&lt;br /&gt;
}&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  // Annotate a method.&lt;br /&gt;
  @MyAnnotation(stringValue = &amp;quot;Annotation Example&amp;quot;, intValue = 100)&lt;br /&gt;
  public static void myMethod(String str, int i) {&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] a) {&lt;br /&gt;
    try {&lt;br /&gt;
      MainClass ob = new MainClass();&lt;br /&gt;
      Class c = ob.getClass();&lt;br /&gt;
      Method m = c.getMethod(&amp;quot;myMethod&amp;quot;, String.class, int.class);&lt;br /&gt;
      MyAnnotation anno = m.getAnnotation(MyAnnotation.class);&lt;br /&gt;
      System.out.println(anno.stringValue() + &amp;quot; &amp;quot; + anno.intValue());&lt;br /&gt;
    } catch (NoSuchMethodException exc) {&lt;br /&gt;
      System.out.println(&amp;quot;Method Not Found.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Annotation Example 100&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>