jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java
changeset 11530 a9d059c15b80
parent 9698 8b66cd6c5ebc
child 14342 8435a30053c1
equal deleted inserted replaced
11529:e08d565262ce 11530:a9d059c15b80
    67                     try {
    67                     try {
    68                         Class cl = Class.forName("com.sun.management.GcInfo");
    68                         Class cl = Class.forName("com.sun.management.GcInfo");
    69                         Field f = cl.getDeclaredField("builder");
    69                         Field f = cl.getDeclaredField("builder");
    70                         f.setAccessible(true);
    70                         f.setAccessible(true);
    71                         return (GcInfoBuilder)f.get(gcNotifInfo.getGcInfo());
    71                         return (GcInfoBuilder)f.get(gcNotifInfo.getGcInfo());
    72                     } catch(ClassNotFoundException e) {
    72                     } catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
    73                         return null;
       
    74                     } catch(NoSuchFieldException e) {
       
    75                         return null;
       
    76                     } catch(IllegalAccessException e) {
       
    77                         return null;
    73                         return null;
    78                     }
    74                     }
    79                 }
    75                 }
    80             });
    76             });
    81         CompositeType gict = null;
    77         CompositeType gict = null;
    82         synchronized(compositeTypeByBuilder) {
    78         synchronized(compositeTypeByBuilder) {
    83             gict = compositeTypeByBuilder.get(builder);
    79             gict = compositeTypeByBuilder.get(builder);
    84             if(gict == null) {
    80             if(gict == null) {
    85                 OpenType[] gcNotifInfoItemTypes = new OpenType[] {
    81                 OpenType<?>[] gcNotifInfoItemTypes = new OpenType<?>[] {
    86                     SimpleType.STRING,
    82                     SimpleType.STRING,
    87                     SimpleType.STRING,
    83                     SimpleType.STRING,
    88                     SimpleType.STRING,
    84                     SimpleType.STRING,
    89                     builder.getGcInfoCompositeType(),
    85                     builder.getGcInfoCompositeType(),
    90                 };
    86                 };
   139         GC_ACTION,
   135         GC_ACTION,
   140         GC_CAUSE,
   136         GC_CAUSE,
   141         GC_INFO
   137         GC_INFO
   142     };
   138     };
   143     private static HashMap<GcInfoBuilder,CompositeType> compositeTypeByBuilder =
   139     private static HashMap<GcInfoBuilder,CompositeType> compositeTypeByBuilder =
   144         new HashMap<GcInfoBuilder,CompositeType>();
   140         new HashMap<>();
   145 
   141 
   146     public static String getGcName(CompositeData cd) {
   142     public static String getGcName(CompositeData cd) {
   147         String gcname = getString(cd, GC_NAME);
   143         String gcname = getString(cd, GC_NAME);
   148         if (gcname == null) {
   144         if (gcname == null) {
   149             throw new IllegalArgumentException("Invalid composite data: " +
   145             throw new IllegalArgumentException("Invalid composite data: " +
   193     // This is only used for validation.
   189     // This is only used for validation.
   194     private static CompositeType baseGcNotifInfoCompositeType = null;
   190     private static CompositeType baseGcNotifInfoCompositeType = null;
   195     private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
   191     private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
   196         if (baseGcNotifInfoCompositeType == null) {
   192         if (baseGcNotifInfoCompositeType == null) {
   197             try {
   193             try {
   198                 OpenType[] baseGcNotifInfoItemTypes = new OpenType[] {
   194                 OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
   199                     SimpleType.STRING,
   195                     SimpleType.STRING,
   200                     SimpleType.STRING,
   196                     SimpleType.STRING,
   201                     SimpleType.STRING,
   197                     SimpleType.STRING,
   202                     GcInfoCompositeData.getBaseGcInfoCompositeType()
   198                     GcInfoCompositeData.getBaseGcInfoCompositeType()
   203                 };
   199                 };