< prev index next >

test/jdk/jdk/jfr/api/metadata/valuedescriptor/TestGetAnnotations.java

Print this page
rev 51054 : imported patch 9000013-aixDisableJFR-requires.patch


  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jfr.api.metadata.valuedescriptor;
  27 
  28 import java.util.ArrayList;
  29 import java.util.List;
  30 
  31 import jdk.jfr.AnnotationElement;
  32 import jdk.jfr.Description;
  33 import jdk.jfr.Event;
  34 import jdk.jfr.EventType;
  35 import jdk.jfr.Label;
  36 import jdk.jfr.Name;
  37 import jdk.jfr.ValueDescriptor;
  38 import jdk.test.lib.Asserts;
  39 
  40 /*
  41  * @test
  42  * @summary Test ValueDescriptor.getAnnotations()
  43  * @key jfr

  44  * @library /test/lib
  45  * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestGetAnnotations
  46  */
  47 public class TestGetAnnotations {
  48 
  49     public static void main(String[] args) throws Throwable {
  50         EventType type = EventType.getEventType(MyEvent.class);
  51 
  52         List<String> actual = new ArrayList<>();
  53         for (ValueDescriptor d : type.getFields()) {
  54             String descName = d.getName();
  55             for (AnnotationElement a : d.getAnnotationElements()) {
  56                 String annName = a.getTypeName();
  57                 String annValue = a.getValue("value").toString();
  58                 actual.add(String.format("%s: %s = %s", descName, annName, annValue));
  59             }
  60         }
  61 
  62         System.out.println("Actual annotations:");
  63         for (String s : actual) {




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jfr.api.metadata.valuedescriptor;
  27 
  28 import java.util.ArrayList;
  29 import java.util.List;
  30 
  31 import jdk.jfr.AnnotationElement;
  32 import jdk.jfr.Description;
  33 import jdk.jfr.Event;
  34 import jdk.jfr.EventType;
  35 import jdk.jfr.Label;
  36 import jdk.jfr.Name;
  37 import jdk.jfr.ValueDescriptor;
  38 import jdk.test.lib.Asserts;
  39 
  40 /**
  41  * @test
  42  * @summary Test ValueDescriptor.getAnnotations()
  43  * @key jfr
  44  * @requires vm.hasJFR
  45  * @library /test/lib
  46  * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestGetAnnotations
  47  */
  48 public class TestGetAnnotations {
  49 
  50     public static void main(String[] args) throws Throwable {
  51         EventType type = EventType.getEventType(MyEvent.class);
  52 
  53         List<String> actual = new ArrayList<>();
  54         for (ValueDescriptor d : type.getFields()) {
  55             String descName = d.getName();
  56             for (AnnotationElement a : d.getAnnotationElements()) {
  57                 String annName = a.getTypeName();
  58                 String annValue = a.getValue("value").toString();
  59                 actual.add(String.format("%s: %s = %s", descName, annName, annValue));
  60             }
  61         }
  62 
  63         System.out.println("Actual annotations:");
  64         for (String s : actual) {


< prev index next >