1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  *
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * The contents of this file are subject to the terms of either the Universal Permissive License
   7  * v 1.0 as shown at http://oss.oracle.com/licenses/upl
   8  *
   9  * or the following license:
  10  *
  11  * Redistribution and use in source and binary forms, with or without modification, are permitted
  12  * provided that the following conditions are met:
  13  *
  14  * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
  15  * and the following disclaimer.
  16  *
  17  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
  18  * conditions and the following disclaimer in the documentation and/or other materials provided with
  19  * the distribution.
  20  *
  21  * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
  22  * endorse or promote products derived from this software without specific prior written permission.
  23  *
  24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  25  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  26  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  27  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
  31  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  */
  33 package org.openjdk.jmc.flightrecorder.jdk;
  34 
  35 import static org.openjdk.jmc.common.item.Attribute.attr;
  36 import static org.openjdk.jmc.common.unit.UnitLookup.ADDRESS;
  37 import static org.openjdk.jmc.common.unit.UnitLookup.CLASS;
  38 import static org.openjdk.jmc.common.unit.UnitLookup.CLASS_LOADER;
  39 import static org.openjdk.jmc.common.unit.UnitLookup.FLAG;
  40 import static org.openjdk.jmc.common.unit.UnitLookup.LABELED_IDENTIFIER;
  41 import static org.openjdk.jmc.common.unit.UnitLookup.MEMORY;
  42 import static org.openjdk.jmc.common.unit.UnitLookup.METHOD;
  43 import static org.openjdk.jmc.common.unit.UnitLookup.NUMBER;
  44 import static org.openjdk.jmc.common.unit.UnitLookup.OLD_OBJECT;
  45 import static org.openjdk.jmc.common.unit.UnitLookup.PERCENTAGE;
  46 import static org.openjdk.jmc.common.unit.UnitLookup.PLAIN_TEXT;
  47 import static org.openjdk.jmc.common.unit.UnitLookup.THREAD;
  48 import static org.openjdk.jmc.common.unit.UnitLookup.TIMESPAN;
  49 import static org.openjdk.jmc.common.unit.UnitLookup.TIMESTAMP;
  50 import static org.openjdk.jmc.common.unit.UnitLookup.UNKNOWN;
  51 
  52 import java.util.ArrayList;
  53 import java.util.List;
  54 
  55 import org.openjdk.jmc.common.IDisplayable;
  56 import org.openjdk.jmc.common.IMCClassLoader;
  57 import org.openjdk.jmc.common.IMCFrame;
  58 import org.openjdk.jmc.common.IMCMethod;
  59 import org.openjdk.jmc.common.IMCModule;
  60 import org.openjdk.jmc.common.IMCOldObject;
  61 import org.openjdk.jmc.common.IMCOldObjectGcRoot;
  62 import org.openjdk.jmc.common.IMCPackage;
  63 import org.openjdk.jmc.common.IMCStackTrace;
  64 import org.openjdk.jmc.common.IMCThread;
  65 import org.openjdk.jmc.common.IMCThreadGroup;
  66 import org.openjdk.jmc.common.IMCType;
  67 import org.openjdk.jmc.common.item.Attribute;
  68 import org.openjdk.jmc.common.item.IAttribute;
  69 import org.openjdk.jmc.common.item.IMemberAccessor;
  70 import org.openjdk.jmc.common.item.IType;
  71 import org.openjdk.jmc.common.unit.ContentType;
  72 import org.openjdk.jmc.common.unit.IQuantity;
  73 import org.openjdk.jmc.common.unit.UnitLookup;
  74 import org.openjdk.jmc.common.util.FormatToolkit;
  75 import org.openjdk.jmc.common.util.LabeledIdentifier;
  76 import org.openjdk.jmc.common.util.MCClassLoader;
  77 import org.openjdk.jmc.common.util.MemberAccessorToolkit;
  78 import org.openjdk.jmc.flightrecorder.JfrAttributes;
  79 import org.openjdk.jmc.flightrecorder.jdk.messages.internal.Messages;
  80 
  81 /**
  82  * Various attributes based on JDK flight recorder data.
  83  */
  84 public final class JdkAttributes {
  85 
  86         public static final IAttribute<String> EVENT_THREAD_NAME = Attribute
  87                         .canonicalize(new Attribute<String>("(thread).name", Messages.getString(Messages.ATTR_EVENT_THREAD_NAME), //$NON-NLS-1$
  88                                         Messages.getString(Messages.ATTR_EVENT_THREAD_NAME_DESC), PLAIN_TEXT) {
  89                                 @Override
  90                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
  91                                         final IMemberAccessor<IMCThread, U> accessor = JfrAttributes.EVENT_THREAD.getAccessor(type);
  92                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
  93                                                 @Override
  94                                                 public String getMember(U i) {
  95                                                         IMCThread thread = accessor.getMember(i);
  96                                                         return thread == null ? null : thread.getThreadName();
  97                                                 }
  98                                         };
  99                                 }
 100                         });
 101         public static final IAttribute<String> EVENT_THREAD_GROUP_NAME = Attribute.canonicalize(
 102                         new Attribute<String>("(thread).groupName", Messages.getString(Messages.ATTR_EVENT_THREAD_GROUP), //$NON-NLS-1$
 103                                         Messages.getString(Messages.ATTR_EVENT_THREAD_GROUP_DESC), PLAIN_TEXT) {
 104                                 @Override
 105                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 106                                         final IMemberAccessor<IMCThread, U> accessor = JfrAttributes.EVENT_THREAD.getAccessor(type);
 107                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 108                                                 @Override
 109                                                 public String getMember(U i) {
 110                                                         IMCThread thread = accessor.getMember(i);
 111                                                         if (thread != null) {
 112                                                                 IMCThreadGroup group = thread.getThreadGroup();
 113                                                                 if (group != null) {
 114                                                                         return group.getName();
 115                                                                 }
 116                                                         }
 117                                                         return null;
 118                                                 }
 119                                         };
 120                                 }
 121                         });
 122         public static final IAttribute<IQuantity> EVENT_THREAD_ID = Attribute.canonicalize(
 123                         new Attribute<IQuantity>("(thread).javaThreadId", Messages.getString(Messages.ATTR_EVENT_THREAD_ID), //$NON-NLS-1$
 124                                         Messages.getString(Messages.ATTR_EVENT_THREAD_ID_DESC), NUMBER) {
 125                                 @Override
 126                                 public <U> IMemberAccessor<IQuantity, U> customAccessor(IType<U> type) {
 127                                         final IMemberAccessor<IMCThread, U> accessor = JfrAttributes.EVENT_THREAD.getAccessor(type);
 128                                         return accessor == null ? null : new IMemberAccessor<IQuantity, U>() {
 129                                                 @Override
 130                                                 public IQuantity getMember(U i) {
 131                                                         IMCThread thread = accessor.getMember(i);
 132                                                         return (thread == null || thread.getThreadId() == null) ? null
 133                                                                         : UnitLookup.NUMBER_UNITY.quantity(thread.getThreadId());
 134                                                 }
 135                                         };
 136                                 }
 137                         });
 138 
 139         public static final IAttribute<String> STACK_TRACE_STRING = Attribute.canonicalize(
 140                         new Attribute<String>("(stackTrace).string", Messages.getString(Messages.ATTR_STACK_TRACE_STRING), //$NON-NLS-1$
 141                                         Messages.getString(Messages.ATTR_STACK_TRACE_STRING_DESC), UnitLookup.PLAIN_TEXT) {
 142                                 @Override
 143                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 144                                         final IMemberAccessor<IMCStackTrace, U> accessor = JfrAttributes.EVENT_STACKTRACE.getAccessor(type);
 145                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 146                                                 @Override
 147                                                 public String getMember(U i) {
 148                                                         IMCStackTrace trace = accessor.getMember(i);
 149                                                         // Using default formatting
 150                                                         return trace == null ? null : FormatToolkit.getHumanReadable(trace, "", "", null); //$NON-NLS-1$ //$NON-NLS-2$
 151                                                 }
 152                                         };
 153                                 }
 154                         });
 155 
 156         public static final IAttribute<IMCFrame> STACK_TRACE_TOP_FRAME = Attribute.canonicalize(
 157                         new Attribute<IMCFrame>("(stackTrace).topframe", Messages.getString(Messages.ATTR_STACK_TRACE_FRAME), //$NON-NLS-1$
 158                                         Messages.getString(Messages.ATTR_STACK_TRACE_FRAME_DESC), UnitLookup.STACKTRACE_FRAME) {
 159                                 @Override
 160                                 public <U> IMemberAccessor<IMCFrame, U> customAccessor(IType<U> type) {
 161                                         final IMemberAccessor<IMCStackTrace, U> accessor = JfrAttributes.EVENT_STACKTRACE.getAccessor(type);
 162                                         return accessor == null ? null : new IMemberAccessor<IMCFrame, U>() {
 163                                                 @Override
 164                                                 public IMCFrame getMember(U i) {
 165                                                         IMCStackTrace trace = accessor.getMember(i);
 166                                                         // FIXME: Fix train wreck to avoid NPEs and IndexOutOfBoundsException
 167                                                         return trace == null || trace.getFrames().isEmpty() ? null : trace.getFrames().get(0);
 168                                                 }
 169                                         };
 170                                 }
 171                         });
 172 
 173         public static final IAttribute<String> STACK_TRACE_TOP_PACKAGE = Attribute.canonicalize(
 174                         new Attribute<String>("(stackTrace).topPackage", Messages.getString(Messages.ATTR_STACK_TRACE_PACKAGE), //$NON-NLS-1$
 175                                         Messages.getString(Messages.ATTR_STACK_TRACE_PACKAGE_DESC), PLAIN_TEXT) {
 176                                 @Override
 177                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 178                                         final IMemberAccessor<IMCType, U> accessor = STACK_TRACE_TOP_CLASS.getAccessor(type);
 179                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 180                                                 @Override
 181                                                 public String getMember(U i) {
 182                                                         IMCType type = accessor.getMember(i);
 183                                                         return type == null ? null : FormatToolkit.getPackage(type.getPackage());
 184                                                 }
 185                                         };
 186                                 }
 187                         });
 188 
 189         public static final IAttribute<IMCType> STACK_TRACE_TOP_CLASS = Attribute.canonicalize(
 190                         new Attribute<IMCType>("(stackTrace).topClass", Messages.getString(Messages.ATTR_STACK_TRACE_CLASS), //$NON-NLS-1$
 191                                         Messages.getString(Messages.ATTR_STACK_TRACE_CLASS_DESC), CLASS) {
 192                                 @Override
 193                                 public <U> IMemberAccessor<IMCType, U> customAccessor(IType<U> type) {
 194                                         final IMemberAccessor<IMCMethod, U> accessor = STACK_TRACE_TOP_METHOD.getAccessor(type);
 195                                         return accessor == null ? null : new IMemberAccessor<IMCType, U>() {
 196                                                 @Override
 197                                                 public IMCType getMember(U i) {
 198                                                         IMCMethod method = accessor.getMember(i);
 199                                                         return method == null ? null : method.getType();
 200                                                 }
 201                                         };
 202                                 }
 203                         });
 204         public static final IAttribute<String> STACK_TRACE_TOP_CLASS_STRING = Attribute.canonicalize(
 205                         new Attribute<String>("(stackTrace).topClass.string", Messages.getString(Messages.ATTR_STACK_TRACE_CLASS), //$NON-NLS-1$
 206                                         Messages.getString(Messages.ATTR_STACK_TRACE_CLASS_DESC), PLAIN_TEXT) {
 207                                 @Override
 208                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 209                                         final IMemberAccessor<IMCType, U> accessor = STACK_TRACE_TOP_CLASS.getAccessor(type);
 210                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 211                                                 @Override
 212                                                 public String getMember(U i) {
 213                                                         IMCType type = accessor.getMember(i);
 214                                                         return type == null ? null : type.getFullName();
 215                                                 }
 216                                         };
 217                                 }
 218                         });
 219         public static final IAttribute<IMCMethod> STACK_TRACE_TOP_METHOD = Attribute.canonicalize(
 220                         new Attribute<IMCMethod>("(stackTrace).topMethod", Messages.getString(Messages.ATTR_STACK_TRACE_METHOD), //$NON-NLS-1$
 221                                         Messages.getString(Messages.ATTR_STACK_TRACE_METHOD_DESC), UnitLookup.METHOD) {
 222                                 @Override
 223                                 public <U> IMemberAccessor<IMCMethod, U> customAccessor(IType<U> type) {
 224                                         final IMemberAccessor<IMCFrame, U> accessor = STACK_TRACE_TOP_FRAME.getAccessor(type);
 225                                         return accessor == null ? null : new IMemberAccessor<IMCMethod, U>() {
 226                                                 @Override
 227                                                 public IMCMethod getMember(U i) {
 228                                                         IMCFrame frame = accessor.getMember(i);
 229                                                         return frame == null ? null : frame.getMethod();
 230                                                 }
 231                                         };
 232                                 }
 233                         });
 234         public static final IAttribute<String> STACK_TRACE_TOP_METHOD_STRING = Attribute.canonicalize(
 235                         new Attribute<String>("(stackTrace).topMethodString", Messages.getString(Messages.ATTR_STACK_TRACE_METHOD), //$NON-NLS-1$
 236                                         Messages.getString(Messages.ATTR_STACK_TRACE_METHOD_DESC), UnitLookup.PLAIN_TEXT) {
 237                                 @Override
 238                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 239                                         final IMemberAccessor<IMCMethod, U> accessor = STACK_TRACE_TOP_METHOD.getAccessor(type);
 240                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 241                                                 @Override
 242                                                 public String getMember(U i) {
 243                                                         IMCMethod method = accessor.getMember(i);
 244                                                         return method == null ? null : FormatToolkit.getHumanReadable(method);
 245                                                 }
 246                                         };
 247                                 }
 248                         });
 249 
 250         public static final IAttribute<IMCFrame> STACK_TRACE_BOTTOM_FRAME = Attribute
 251                         .canonicalize(new Attribute<IMCFrame>("(stackTrace).bottomFrame", //$NON-NLS-1$
 252                                         Messages.getString(Messages.ATTR_STACK_TRACE_BOTTOM_FRAME),
 253                                         Messages.getString(Messages.ATTR_STACK_TRACE_BOTTOM_FRAME_DESC), UnitLookup.STACKTRACE_FRAME) {
 254                                 @Override
 255                                 public <U> IMemberAccessor<IMCFrame, U> customAccessor(IType<U> type) {
 256                                         final IMemberAccessor<IMCStackTrace, U> accessor = JfrAttributes.EVENT_STACKTRACE.getAccessor(type);
 257                                         return accessor == null ? null : new IMemberAccessor<IMCFrame, U>() {
 258                                                 @Override
 259                                                 public IMCFrame getMember(U i) {
 260                                                         IMCStackTrace trace = accessor.getMember(i);
 261                                                         if (trace != null) {
 262                                                                 List<? extends IMCFrame> frames = trace.getFrames();
 263                                                                 return frames == null || frames.size() == 0 ? null : frames.get(frames.size() - 1);
 264                                                         }
 265                                                         return null;
 266                                                 }
 267                                         };
 268                                 }
 269                         });
 270 
 271         public static final IAttribute<IMCMethod> STACK_TRACE_BOTTOM_METHOD = Attribute
 272                         .canonicalize(new Attribute<IMCMethod>("(stackTrace).bottomMethod", //$NON-NLS-1$
 273                                         Messages.getString(Messages.ATTR_STACK_TRACE_BOTTOM_METHOD),
 274                                         Messages.getString(Messages.ATTR_STACK_TRACE_BOTTOM_METHOD_DESC), UnitLookup.METHOD) {
 275                                 @Override
 276                                 public <U> IMemberAccessor<IMCMethod, U> customAccessor(IType<U> type) {
 277                                         final IMemberAccessor<IMCFrame, U> accessor = STACK_TRACE_BOTTOM_FRAME.getAccessor(type);
 278                                         return accessor == null ? null : new IMemberAccessor<IMCMethod, U>() {
 279                                                 @Override
 280                                                 public IMCMethod getMember(U i) {
 281                                                         IMCFrame frame = accessor.getMember(i);
 282                                                         return frame == null ? null : frame.getMethod();
 283                                                 }
 284                                         };
 285                                 }
 286                         });
 287         public static final IAttribute<String> STACK_TRACE_BOTTOM_METHOD_STRING = Attribute
 288                         .canonicalize(new Attribute<String>("(stackTrace).bottomMethodString", //$NON-NLS-1$
 289                                         Messages.getString(Messages.ATTR_STACK_TRACE_BOTTOM_METHOD),
 290                                         Messages.getString(Messages.ATTR_STACK_TRACE_BOTTOM_METHOD_DESC), UnitLookup.PLAIN_TEXT) {
 291                                 @Override
 292                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 293                                         final IMemberAccessor<IMCMethod, U> accessor = STACK_TRACE_BOTTOM_METHOD.getAccessor(type);
 294                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 295                                                 @Override
 296                                                 public String getMember(U i) {
 297                                                         IMCMethod method = accessor.getMember(i);
 298                                                         return method == null ? null : FormatToolkit.getHumanReadable(method);
 299                                                 }
 300                                         };
 301                                 }
 302                         });
 303 
 304         public static final IAttribute<Boolean> STACK_TRACE_TRUNCATED = Attribute.canonicalize(
 305                         new Attribute<Boolean>("(stackTrace).truncationState", Messages.getString(Messages.ATTR_STACK_TRACE_DEPTH), //$NON-NLS-1$
 306                                         Messages.getString(Messages.ATTR_STACK_TRACE_DEPTH_DESC), FLAG) {
 307                                 @Override
 308                                 public <U> IMemberAccessor<Boolean, U> customAccessor(IType<U> type) {
 309                                         final IMemberAccessor<IMCStackTrace, U> accessor = JfrAttributes.EVENT_STACKTRACE.getAccessor(type);
 310                                         return accessor == null ? null : new IMemberAccessor<Boolean, U>() {
 311                                                 @Override
 312                                                 public Boolean getMember(U i) {
 313                                                         IMCStackTrace trace = accessor.getMember(i);
 314                                                         // FIXME: Fix train wreck to avoid NPEs and IndexOutOfBoundsException
 315                                                         return trace == null ? null : trace.getTruncationState().isTruncated();
 316                                                 }
 317                                         };
 318                                 }
 319                         });
 320 
 321         public static final IAttribute<String> PID = attr("pid", Messages.getString(Messages.ATTR_PID), PLAIN_TEXT); //$NON-NLS-1$
 322         public static final IAttribute<String> COMMAND_LINE = attr("commandLine", //$NON-NLS-1$
 323                         Messages.getString(Messages.ATTR_COMMAND_LINE), PLAIN_TEXT);
 324 
 325         public static final IAttribute<IQuantity> JVM_SYSTEM = attr("jvmSystem", //$NON-NLS-1$
 326                         Messages.getString(Messages.ATTR_JVM_SYSTEM), Messages.getString(Messages.ATTR_JVM_SYSTEM_DESC),
 327                         PERCENTAGE);
 328         public static final IAttribute<IQuantity> JVM_USER = attr("jvmUser", Messages.getString(Messages.ATTR_JVM_USER), //$NON-NLS-1$
 329                         Messages.getString(Messages.ATTR_JVM_USER_DESC), PERCENTAGE);
 330         public static final IAttribute<IQuantity> JVM_TOTAL = Attribute.canonicalize(new Attribute<IQuantity>("jvmTotal", //$NON-NLS-1$
 331                         Messages.getString(Messages.ATTR_JVM_TOTAL), Messages.getString(Messages.ATTR_JVM_TOTAL_DESC), PERCENTAGE) {
 332                 @Override
 333                 public <U> IMemberAccessor<IQuantity, U> customAccessor(IType<U> type) {
 334                         // Avoid possible future circularity by asking the type directly.
 335                         final IMemberAccessor<IQuantity, U> jvmUserAccessor = type.getAccessor(JVM_USER.getKey());
 336                         final IMemberAccessor<IQuantity, U> jvmSystemAccessor = type.getAccessor(JVM_SYSTEM.getKey());
 337                         if ((jvmUserAccessor == null) || (jvmSystemAccessor == null)) {
 338                                 return null;
 339                         }
 340                         return new IMemberAccessor<IQuantity, U>() {
 341                                 @Override
 342                                 public IQuantity getMember(U i) {
 343                                         IQuantity jvmUser = jvmUserAccessor.getMember(i);
 344                                         IQuantity jvmSystem = jvmSystemAccessor.getMember(i);
 345                                         return jvmUser != null && jvmSystem != null ? jvmUser.add(jvmSystem) : null;
 346                                 }
 347                         };
 348                 }
 349         });
 350         public static final IAttribute<IQuantity> MACHINE_TOTAL = attr("machineTotal", //$NON-NLS-1$
 351                         Messages.getString(Messages.ATTR_MACHINE_TOTAL), Messages.getString(Messages.ATTR_MACHINE_TOTAL_DESC),
 352                         PERCENTAGE);
 353         public static final IAttribute<IQuantity> OTHER_CPU = Attribute.canonicalize(new Attribute<IQuantity>("otherCpu", //$NON-NLS-1$
 354                         Messages.getString(Messages.ATTR_OTHER_CPU), Messages.getString(Messages.ATTR_OTHER_CPU_DESC), PERCENTAGE) {
 355                 @Override
 356                 public <U> IMemberAccessor<IQuantity, U> customAccessor(IType<U> type) {
 357                         final IMemberAccessor<IQuantity, U> jvmTotalAccessor = JVM_TOTAL.getAccessor(type);
 358                         // Avoid possible future circularity by asking the type directly.
 359                         final IMemberAccessor<IQuantity, U> machineTotalAccessor = type.getAccessor(MACHINE_TOTAL.getKey());
 360                         if ((jvmTotalAccessor == null) || (machineTotalAccessor == null)) {
 361                                 return null;
 362                         }
 363                         return new IMemberAccessor<IQuantity, U>() {
 364                                 @Override
 365                                 public IQuantity getMember(U i) {
 366                                         IQuantity jvmTotal = jvmTotalAccessor.getMember(i);
 367                                         IQuantity machineTotal = machineTotalAccessor.getMember(i);
 368                                         return jvmTotal != null && machineTotal != null ? machineTotal.subtract(jvmTotal) : null;
 369                                 }
 370                         };
 371                 }
 372         });
 373 
 374         public static final IAttribute<IQuantity> RECORDING_ID = attr("id", Messages.getString(Messages.ATTR_RECORDING_ID), //$NON-NLS-1$
 375                         NUMBER);
 376         public static final IAttribute<String> RECORDING_NAME = attr("name", //$NON-NLS-1$
 377                         Messages.getString(Messages.ATTR_RECORDING_NAME), PLAIN_TEXT);
 378         public static final IAttribute<IQuantity> RECORDING_START = attr("recordingStart", //$NON-NLS-1$
 379                         Messages.getString(Messages.ATTR_RECORDING_START), TIMESTAMP);
 380         public static final IAttribute<IQuantity> RECORDING_DURATION = attr("recordingDuration", //$NON-NLS-1$
 381                         Messages.getString(Messages.ATTR_RECORDING_DURATION), TIMESPAN);
 382         public static final IAttribute<IQuantity> RECORDING_MAX_SIZE = attr("maxSize", //$NON-NLS-1$
 383                         Messages.getString(Messages.ATTR_RECORDING_MAX_SIZE), MEMORY);
 384         public static final IAttribute<IQuantity> RECORDING_MAX_AGE = attr("maxAge", //$NON-NLS-1$
 385                         Messages.getString(Messages.ATTR_RECORDING_MAX_AGE), TIMESPAN);
 386         public static final IAttribute<String> RECORDING_DESTINATION = attr("destination", //$NON-NLS-1$
 387                         Messages.getString(Messages.ATTR_RECORDING_DESTINATION), PLAIN_TEXT);
 388 
 389         public static final IAttribute<LabeledIdentifier> REC_SETTING_FOR = attr("settingFor", //$NON-NLS-1$
 390                         Messages.getString(Messages.ATTR_REC_SETTING_FOR), LABELED_IDENTIFIER);
 391         public static final IAttribute<String> REC_SETTING_NAME = attr("name", //$NON-NLS-1$
 392                         Messages.getString(Messages.ATTR_REC_SETTING_NAME), PLAIN_TEXT);
 393         public static final IAttribute<String> REC_SETTING_VALUE = attr("value", //$NON-NLS-1$
 394                         Messages.getString(Messages.ATTR_REC_SETTING_VALUE), PLAIN_TEXT);
 395         public static final IAttribute<String> REC_SETTING_FOR_NAME = Attribute.canonicalize(new Attribute<String>(
 396                         "settingFor.string", Messages.getString(Messages.ATTR_REC_SETTING_FOR), null, PLAIN_TEXT) { //$NON-NLS-1$
 397                 @Override
 398                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 399                         final IMemberAccessor<LabeledIdentifier, U> accessor = REC_SETTING_FOR.getAccessor(type);
 400                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 401                                 @Override
 402                                 public String getMember(U i) {
 403                                         LabeledIdentifier identifier = accessor.getMember(i);
 404                                         return identifier == null ? null : identifier.getName();
 405                                 }
 406                         };
 407                 }
 408         });
 409         public static final IAttribute<String> REC_SETTING_FOR_ID = Attribute.canonicalize(new Attribute<String>(
 410                         "settingFor.id", Messages.getString(Messages.ATTR_REC_SETTING_FOR), null, PLAIN_TEXT) { //$NON-NLS-1$
 411                 @Override
 412                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 413                         final IMemberAccessor<LabeledIdentifier, U> accessor = REC_SETTING_FOR.getAccessor(type);
 414                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 415                                 @Override
 416                                 public String getMember(U i) {
 417                                         LabeledIdentifier identifier = accessor.getMember(i);
 418                                         return identifier == null ? null : identifier.getInterfaceId();
 419                                 }
 420                         };
 421                 }
 422         });
 423 
 424         public static final IAttribute<IMCPackage> EXPORTED_PACKAGE = attr("exportedPackage", //$NON-NLS-1$
 425                         Messages.getString(Messages.ATTR_EXPORTED_PACKAGE), UnitLookup.PACKAGE);
 426 
 427         public static final IAttribute<IMCModule> EXPORTING_MODULE = Attribute.canonicalize(new Attribute<IMCModule>(
 428                         "exportingModule", Messages.getString(Messages.ATTR_EXPORTING_MODULE), null, UnitLookup.MODULE) { //$NON-NLS-1$
 429                 @Override
 430                 public <U> IMemberAccessor<IMCModule, U> customAccessor(IType<U> type) {
 431                         final IMemberAccessor<IMCPackage, U> accessor = EXPORTED_PACKAGE.getAccessor(type);
 432                         return accessor == null ? null : new IMemberAccessor<IMCModule, U>() {
 433                                 @Override
 434                                 public IMCModule getMember(U i) {
 435                                         IMCPackage thePackage = accessor.getMember(i);
 436                                         return thePackage == null ? null : thePackage.getModule();
 437                                 }
 438                         };
 439                 }
 440         });
 441 
 442         public static final IAttribute<IQuantity> JVM_START_TIME = attr("jvmStartTime", //$NON-NLS-1$
 443                         Messages.getString(Messages.ATTR_JVM_START_TIME), TIMESTAMP);
 444         public static final IAttribute<String> JVM_NAME = attr("jvmName", Messages.getString(Messages.ATTR_JVM_NAME), //$NON-NLS-1$
 445                         PLAIN_TEXT);
 446         public static final IAttribute<IQuantity> JVM_PID = attr("pid", Messages.getString(Messages.ATTR_JVM_PID), //$NON-NLS-1$
 447                         NUMBER);
 448         public static final IAttribute<String> JVM_VERSION = attr("jvmVersion", //$NON-NLS-1$
 449                         Messages.getString(Messages.ATTR_JVM_VERSION), PLAIN_TEXT);
 450         public static final IAttribute<String> JVM_ARGUMENTS = attr("jvmArguments", //$NON-NLS-1$
 451                         Messages.getString(Messages.ATTR_JVM_ARGUMENTS), PLAIN_TEXT);
 452         public static final IAttribute<String> JAVA_ARGUMENTS = attr("javaArguments", //$NON-NLS-1$
 453                         Messages.getString(Messages.ATTR_JAVA_ARGUMENTS), PLAIN_TEXT);
 454 
 455         public static final IAttribute<String> IO_PATH = attr("path", Messages.getString(Messages.ATTR_IO_PATH), //$NON-NLS-1$
 456                         Messages.getString(Messages.ATTR_IO_PATH_DESC), PLAIN_TEXT);
 457         public static final IAttribute<IQuantity> IO_FILE_BYTES_READ = attr("bytesRead", //$NON-NLS-1$
 458                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_READ),
 459                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_READ_DESC), MEMORY);
 460         public static final IAttribute<Boolean> IO_FILE_READ_EOF = attr("endOfFile", //$NON-NLS-1$
 461                         Messages.getString(Messages.ATTR_IO_FILE_READ_EOF), Messages.getString(Messages.ATTR_IO_FILE_READ_EOF_DESC),
 462                         FLAG);
 463         public static final IAttribute<IQuantity> IO_FILE_BYTES_WRITTEN = attr("bytesWritten", //$NON-NLS-1$
 464                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_WRITTEN),
 465                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_WRITTEN_DESC), MEMORY);
 466         public static final IAttribute<IQuantity> IO_SOCKET_BYTES_READ = attr("bytesRead", //$NON-NLS-1$
 467                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_READ),
 468                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_READ_DESC), MEMORY);
 469         public static final IAttribute<Boolean> IO_SOCKET_READ_EOS = attr("endOfStream", //$NON-NLS-1$
 470                         Messages.getString(Messages.ATTR_IO_SOCKET_READ_EOS),
 471                         Messages.getString(Messages.ATTR_IO_SOCKET_READ_EOS_DESC), FLAG);
 472         public static final IAttribute<IQuantity> IO_SOCKET_BYTES_WRITTEN = attr("bytesWritten", //$NON-NLS-1$
 473                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_WRITTEN),
 474                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_WRITTEN_DESC), MEMORY);
 475         public static final IAttribute<IQuantity> IO_SIZE = Attribute.canonicalize(new Attribute<IQuantity>("size",  //#NON-NLS-1$
 476                         "Size", null, MEMORY) {
 477                 @Override
 478                 public <U> IMemberAccessor<IQuantity, U> customAccessor(IType<U> type){
 479                         List<IMemberAccessor<IQuantity, U>> accessorList = new ArrayList<>();
 480                         accessorList.add(type.getAccessor(JdkAttributes.IO_SOCKET_BYTES_READ.getKey()));
 481                         accessorList.add(type.getAccessor(JdkAttributes.IO_SOCKET_BYTES_WRITTEN.getKey()));
 482                         accessorList.add(type.getAccessor(JdkAttributes.IO_FILE_BYTES_READ.getKey()));
 483                         accessorList.add(type.getAccessor(JdkAttributes.IO_FILE_BYTES_WRITTEN.getKey()));
 484                         for (IMemberAccessor<IQuantity, U> accessor : accessorList) {
 485                                 if(accessor != null) {
 486                                         return accessor;
 487                                 }
 488                         }
 489                         return MemberAccessorToolkit.constant(UnitLookup.BYTE.quantity(0));
 490                 }
 491         });
 492         public static final IAttribute<String> IO_ADDRESS = attr("address", Messages.getString(Messages.ATTR_IO_ADDRESS), //$NON-NLS-1$
 493                         PLAIN_TEXT);
 494         public static final IAttribute<String> IO_HOST = attr("host", Messages.getString(Messages.ATTR_IO_HOST), //$NON-NLS-1$
 495                         Messages.getString(Messages.ATTR_IO_HOST_DESC), PLAIN_TEXT);
 496         public static final IAttribute<IQuantity> IO_PORT = attr("port", Messages.getString(Messages.ATTR_IO_PORT), NUMBER); //$NON-NLS-1$
 497         public static final IAttribute<Object> IO_PORT_ON_ADDRESS = Attribute.canonicalize(new Attribute<Object>(
 498                         "portOnAddress", Messages.getString(Messages.ATTR_IO_PORT_ON_ADDRESS), null, UNKNOWN) { //$NON-NLS-1$
 499                 @Override
 500                 public <U> IMemberAccessor<Object, U> customAccessor(IType<U> type) {
 501                         class PortOnAddress implements IDisplayable {
 502 
 503                                 final String address;
 504                                 final IQuantity port;
 505 
 506                                 PortOnAddress(String address, IQuantity port) {
 507                                         this.address = address;
 508                                         this.port = port;
 509                                 }
 510 
 511                                 @Override
 512                                 public String displayUsing(String formatHint) {
 513                                         return address + " : " + port.displayUsing(formatHint); //$NON-NLS-1$
 514                                 }
 515 
 516                                 @Override
 517                                 public int hashCode() {
 518                                         return 31 * address.hashCode() + port.hashCode();
 519                                 };
 520 
 521                                 @Override
 522                                 public boolean equals(Object o) {
 523                                         return o instanceof PortOnAddress && ((PortOnAddress) o).address.equals(address)
 524                                                         && ((PortOnAddress) o).port.equals(port);
 525                                 };
 526 
 527                         }
 528                         // Avoid possible future circularity by asking the type directly.
 529                         final IMemberAccessor<String, U> addressAccessor = type.getAccessor(IO_ADDRESS.getKey());
 530                         final IMemberAccessor<IQuantity, U> portAccessor = type.getAccessor(IO_PORT.getKey());
 531                         if ((addressAccessor == null) || (portAccessor == null)) {
 532                                 return null;
 533                         }
 534                         return new IMemberAccessor<Object, U>() {
 535                                 @Override
 536                                 public IDisplayable getMember(U i) {
 537                                         String address = addressAccessor.getMember(i);
 538                                         IQuantity port = portAccessor.getMember(i);
 539                                         if (address != null && port != null) {
 540                                                 return new PortOnAddress(address, port);
 541                                         }
 542                                         return null;
 543                                 }
 544                         };
 545                 }
 546         });
 547 
 548         public static final IAttribute<IQuantity> IO_TIMEOUT = attr("timeout", Messages.getString(Messages.ATTR_IO_TIMEOUT), //$NON-NLS-1$
 549                         TIMESPAN);
 550 
 551         public static final IAttribute<IQuantity> TLAB_SIZE = attr("tlabSize", Messages.getString(Messages.ATTR_TLAB_SIZE), //$NON-NLS-1$
 552                         MEMORY);
 553         public static final IAttribute<IQuantity> ALLOCATION_SIZE = attr("allocationSize", //$NON-NLS-1$
 554                         Messages.getString(Messages.ATTR_ALLOCATION_SIZE), MEMORY);
 555         public static final IAttribute<IMCType> ALLOCATION_CLASS = attr("objectClass", //$NON-NLS-1$
 556                         Messages.getString(Messages.ATTR_ALLOCATION_CLASS), Messages.getString(Messages.ATTR_ALLOCATION_CLASS_DESC),
 557                         CLASS);
 558         public static final IAttribute<IMCType> OBJECT_CLASS = attr("objectClass", //$NON-NLS-1$
 559                         Messages.getString(Messages.ATTR_OBJECT_CLASS), CLASS);
 560         public static final IAttribute<String> OBJECT_CLASS_FULLNAME = Attribute.canonicalize(new Attribute<String>(
 561                         "objectClass.humanreadable", Messages.getString(Messages.ATTR_OBJECT_CLASS), null, PLAIN_TEXT) { //$NON-NLS-1$
 562                 @Override
 563                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 564                         final IMemberAccessor<IMCType, U> accessor = OBJECT_CLASS.getAccessor(type);
 565                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 566                                 @Override
 567                                 public String getMember(U i) {
 568                                         IMCType type = accessor.getMember(i);
 569                                         return type == null ? null : type.getFullName();
 570                                 }
 571                         };
 572                 }
 573         });
 574         public static final IAttribute<IQuantity> COUNT = attr("count", Messages.getString(Messages.ATTR_COUNT), NUMBER); //$NON-NLS-1$
 575 
 576         public static final IAttribute<IQuantity> HW_THREADS = attr("hwThreads", //$NON-NLS-1$
 577                         Messages.getString(Messages.ATTR_HW_THREADS), Messages.getString(Messages.ATTR_HW_THREADS_DESC), NUMBER);
 578 
 579         public static final IAttribute<IQuantity> PARALLEL_GC_THREADS = attr("parallelGCThreads", //$NON-NLS-1$
 580                         Messages.getString(Messages.ATTR_PARALLEL_GC_THREADS),
 581                         Messages.getString(Messages.ATTR_PARALLEL_GC_THREADS_DESC), NUMBER);
 582         public static final IAttribute<IQuantity> CONCURRENT_GC_THREADS = attr("concurrentGCThreads", //$NON-NLS-1$
 583                         Messages.getString(Messages.ATTR_CONCURRENT_GC_THREADS),
 584                         Messages.getString(Messages.ATTR_CONCURRENT_GC_THREADS_DESC), NUMBER);
 585         public static final IAttribute<String> YOUNG_COLLECTOR = attr("youngCollector", //$NON-NLS-1$
 586                         Messages.getString(Messages.ATTR_YOUNG_COLLECTOR), Messages.getString(Messages.ATTR_YOUNG_COLLECTOR_DESC),
 587                         PLAIN_TEXT);
 588         public static final IAttribute<String> OLD_COLLECTOR = attr("oldCollector", //$NON-NLS-1$
 589                         Messages.getString(Messages.ATTR_OLD_COLLECTOR), Messages.getString(Messages.ATTR_OLD_COLLECTOR_DESC),
 590                         PLAIN_TEXT);
 591         public static final IAttribute<Boolean> EXPLICIT_GC_CONCURRENT = attr("isExplicitGCConcurrent", //$NON-NLS-1$
 592                         Messages.getString(Messages.ATTR_EXPLICIT_GC_CONCURRENT),
 593                         Messages.getString(Messages.ATTR_EXPLICIT_GC_CONCURRENT_DESC), FLAG);
 594         public static final IAttribute<Boolean> EXPLICIT_GC_DISABLED = attr("isExplicitGCDisabled", //$NON-NLS-1$
 595                         Messages.getString(Messages.ATTR_EXPLICIT_GC_DISABLED),
 596                         Messages.getString(Messages.ATTR_EXPLICIT_GC_DISABLED_DESC), FLAG);
 597         public static final IAttribute<Boolean> USE_DYNAMIC_GC_THREADS = attr("usesDynamicGCThreads", //$NON-NLS-1$
 598                         Messages.getString(Messages.ATTR_USE_DYNAMIC_GC_THREADS),
 599                         Messages.getString(Messages.ATTR_USE_DYNAMIC_GC_THREADS_DESC), FLAG);
 600         public static final IAttribute<IQuantity> GC_TIME_RATIO = attr("gcTimeRatio", //$NON-NLS-1$
 601                         Messages.getString(Messages.ATTR_GC_TIME_RATIO), Messages.getString(Messages.ATTR_GC_TIME_RATIO_DESC),
 602                         NUMBER);
 603 
 604         public static final IAttribute<IQuantity> HEAP_MAX_SIZE = attr("maxSize", //$NON-NLS-1$
 605                         Messages.getString(Messages.ATTR_HEAP_MAX_SIZE), MEMORY);
 606         public static final IAttribute<IQuantity> HEAP_MIN_SIZE = attr("minSize", //$NON-NLS-1$
 607                         Messages.getString(Messages.ATTR_HEAP_MIN_SIZE), MEMORY);
 608         public static final IAttribute<IQuantity> HEAP_INITIAL_SIZE = attr("initialSize", //$NON-NLS-1$
 609                         Messages.getString(Messages.ATTR_HEAP_INITIAL_SIZE), MEMORY);
 610         public static final IAttribute<IQuantity> HEAP_OBJECT_ALIGNMENT = attr("objectAlignment", //$NON-NLS-1$
 611                         Messages.getString(Messages.ATTR_HEAP_OBJECT_ALIGNMENT),
 612                         Messages.getString(Messages.ATTR_HEAP_OBJECT_ALIGNMENT_DESC), MEMORY);
 613         public static final IAttribute<IQuantity> HEAP_ADDRESS_SIZE = attr("heapAddressBits", //$NON-NLS-1$
 614                         Messages.getString(Messages.ATTR_HEAP_ADDRESS_SIZE),
 615                         Messages.getString(Messages.ATTR_HEAP_ADDRESS_SIZE_DESC), NUMBER);
 616         public static final IAttribute<Boolean> HEAP_USE_COMPRESSED_OOPS = attr("usesCompressedOops", //$NON-NLS-1$
 617                         Messages.getString(Messages.ATTR_HEAP_USE_COMPRESSED_OOPS),
 618                         Messages.getString(Messages.ATTR_HEAP_USE_COMPRESSED_OOPS_DESC), FLAG);
 619         public static final IAttribute<String> HEAP_COMPRESSED_OOPS_MODE = attr("compressedOopsMode", //$NON-NLS-1$
 620                         Messages.getString(Messages.ATTR_HEAP_COMPRESSED_OOPS_MODE),
 621                         Messages.getString(Messages.ATTR_HEAP_COMPRESSED_OOPS_MODE_DESC), PLAIN_TEXT);
 622 
 623         public static final IAttribute<IQuantity> YOUNG_GENERATION_MIN_SIZE = attr("minSize", //$NON-NLS-1$
 624                         Messages.getString(Messages.ATTR_YOUNG_GENERATION_MIN_SIZE), MEMORY);
 625         public static final IAttribute<IQuantity> YOUNG_GENERATION_MAX_SIZE = attr("maxSize", //$NON-NLS-1$
 626                         Messages.getString(Messages.ATTR_YOUNG_GENERATION_MAX_SIZE), MEMORY);
 627 
 628         public static final IAttribute<IQuantity> NEW_RATIO = attr("newRatio", Messages.getString(Messages.ATTR_NEW_RATIO), //$NON-NLS-1$
 629                         Messages.getString(Messages.ATTR_NEW_RATIO_DESC), NUMBER);
 630         public static final IAttribute<IQuantity> TENURING_THRESHOLD_INITIAL = attr("initialTenuringThreshold", //$NON-NLS-1$
 631                         Messages.getString(Messages.ATTR_TENURING_THRESHOLD_INITIAL),
 632                         Messages.getString(Messages.ATTR_TENURING_THRESHOLD_INITIAL_DESC), NUMBER);
 633         public static final IAttribute<IQuantity> TENURING_THRESHOLD_MAXIMUM = attr("maxTenuringThreshold", //$NON-NLS-1$
 634                         Messages.getString(Messages.ATTR_TENURING_THRESHOLD_MAXIMUM),
 635                         Messages.getString(Messages.ATTR_TENURING_THRESHOLD_MAXIMUM_DESC), NUMBER);
 636 
 637         public static final IAttribute<Boolean> USES_TLABS = attr("usesTLABs", Messages.getString(Messages.ATTR_USES_TLABS), //$NON-NLS-1$
 638                         Messages.getString(Messages.ATTR_USES_TLABS_DESC), FLAG);
 639         public static final IAttribute<IQuantity> TLAB_MIN_SIZE = attr("minTLABSize", //$NON-NLS-1$
 640                         Messages.getString(Messages.ATTR_TLAB_MIN_SIZE), MEMORY);
 641         public static final IAttribute<IQuantity> TLAB_REFILL_WASTE_LIMIT = attr("tlabRefillWasteLimit", //$NON-NLS-1$
 642                         Messages.getString(Messages.ATTR_TLAB_REFILL_WASTE_LIMIT), MEMORY);
 643 
 644         public static final IAttribute<IQuantity> HEAP_TOTAL = attr("totalSize", //$NON-NLS-1$
 645                         Messages.getString(Messages.ATTR_HEAP_TOTAL), MEMORY);
 646         public static final IAttribute<IQuantity> HEAP_USED = attr("heapUsed", Messages.getString(Messages.ATTR_HEAP_USED), //$NON-NLS-1$
 647                         Messages.getString(Messages.ATTR_HEAP_USED_DESC), MEMORY);
 648         public static final IAttribute<String> GC_WHEN = attr("when", Messages.getString(Messages.ATTR_GC_WHEN), //$NON-NLS-1$
 649                         PLAIN_TEXT);
 650         public static final IAttribute<IQuantity> GC_ID = attr("gcId", Messages.getString(Messages.ATTR_GC_ID), //$NON-NLS-1$
 651                         Messages.getString(Messages.ATTR_GC_ID_DESC), NUMBER);
 652         public static final IAttribute<IQuantity> REFERENCE_COUNT = attr("count", //$NON-NLS-1$
 653                         Messages.getString(Messages.ATTR_REFERENCE_COUNT), NUMBER);
 654         public static final IAttribute<String> GC_PHASE_NAME = attr("name", Messages.getString(Messages.ATTR_GC_PHASE_NAME), //$NON-NLS-1$
 655                         PLAIN_TEXT);
 656 
 657         public static final IAttribute<IQuantity> GC_HEAPSPACE_COMMITTED = attr("heapSpace:committedSize", //$NON-NLS-1$
 658                         Messages.getString(Messages.ATTR_GC_HEAPSPACE_COMMITTED),
 659                         Messages.getString(Messages.ATTR_GC_HEAPSPACE_COMMITTED_DESC), MEMORY);
 660         public static final IAttribute<IQuantity> GC_HEAPSPACE_RESERVED = attr("heapSpace:reservedSize", //$NON-NLS-1$
 661                         Messages.getString(Messages.ATTR_GC_HEAPSPACE_RESERVED),
 662                         Messages.getString(Messages.ATTR_GC_HEAPSPACE_RESERVED_DESC), MEMORY);
 663 
 664         public static final IAttribute<IQuantity> GC_METASPACE_CAPACITY = attr("metaspace:capacity", //$NON-NLS-1$
 665                         Messages.getString(Messages.ATTR_GC_METASPACE_CAPACITY),
 666                         Messages.getString(Messages.ATTR_GC_METASPACE_CAPACITY_DESC), MEMORY);
 667         public static final IAttribute<IQuantity> GC_METASPACE_COMMITTED = attr("metaspace:committed", //$NON-NLS-1$
 668                         Messages.getString(Messages.ATTR_GC_METASPACE_COMMITTED),
 669                         Messages.getString(Messages.ATTR_GC_METASPACE_COMMITTED_DESC), MEMORY);
 670         public static final IAttribute<IQuantity> GC_METASPACE_RESERVED = attr("metaspace:reserved", //$NON-NLS-1$
 671                         Messages.getString(Messages.ATTR_GC_METASPACE_RESERVED),
 672                         Messages.getString(Messages.ATTR_GC_METASPACE_RESERVED_DESC), MEMORY);
 673         public static final IAttribute<IQuantity> GC_METASPACE_USED = attr("metaspace:used", //$NON-NLS-1$
 674                         Messages.getString(Messages.ATTR_GC_METASPACE_USED),
 675                         Messages.getString(Messages.ATTR_GC_METASPACE_USED_DESC), MEMORY);
 676         public static final IAttribute<IQuantity> GC_DATASPACE_COMMITTED = attr("dataSpace:committed", //$NON-NLS-1$
 677                         Messages.getString(Messages.ATTR_GC_METASPACE_DATA_COMMITTED),
 678                         Messages.getString(Messages.ATTR_GC_METASPACE_DATA_COMMITTED_DESC), MEMORY);
 679         public static final IAttribute<IQuantity> GC_DATASPACE_RESERVED = attr("dataSpace:reserved", //$NON-NLS-1$
 680                         Messages.getString(Messages.ATTR_GC_METASPACE_DATA_RESERVED),
 681                         Messages.getString(Messages.ATTR_GC_METASPACE_DATA_RESERVED_DESC), MEMORY);
 682         public static final IAttribute<IQuantity> GC_DATASPACE_USED = attr("dataSpace:used", //$NON-NLS-1$
 683                         Messages.getString(Messages.ATTR_GC_METASPACE_DATA_USED),
 684                         Messages.getString(Messages.ATTR_GC_METASPACE_DATA_USED_DESC), MEMORY);
 685         public static final IAttribute<IQuantity> GC_CLASSSPACE_COMMITTED = attr("classSpace:committed", //$NON-NLS-1$
 686                         Messages.getString(Messages.ATTR_GC_METASPACE_CLASS_COMMITTED),
 687                         Messages.getString(Messages.ATTR_GC_METASPACE_CLASS_COMMITTED_DESC), MEMORY);
 688         public static final IAttribute<IQuantity> GC_CLASSSPACE_RESERVED = attr("classSpace:reserved", //$NON-NLS-1$
 689                         Messages.getString(Messages.ATTR_GC_METASPACE_CLASS_RESERVED),
 690                         Messages.getString(Messages.ATTR_GC_METASPACE_CLASS_RESERVED_DESC), MEMORY);
 691         public static final IAttribute<IQuantity> GC_CLASSSPACE_USED = attr("classSpace:used", //$NON-NLS-1$
 692                         Messages.getString(Messages.ATTR_GC_METASPACE_CLASS_USED),
 693                         Messages.getString(Messages.ATTR_GC_METASPACE_CLASS_USED_DESC), MEMORY);
 694 
 695         public static final IAttribute<IQuantity> GC_THRESHOLD = attr("gcThreshold", //$NON-NLS-1$
 696                         Messages.getString(Messages.ATTR_GC_THRESHOLD), Messages.getString(Messages.ATTR_GC_THRESHOLD_DESC),
 697                         MEMORY);
 698 
 699         public static final IAttribute<IQuantity> OS_MEMORY_TOTAL = attr("totalSize", //$NON-NLS-1$
 700                         Messages.getString(Messages.ATTR_OS_MEMORY_TOTAL), Messages.getString(Messages.ATTR_OS_MEMORY_TOTAL_DESC),
 701                         MEMORY);
 702         public static final IAttribute<IQuantity> OS_MEMORY_USED = attr("usedSize", //$NON-NLS-1$
 703                         Messages.getString(Messages.ATTR_OS_MEMORY_USED), Messages.getString(Messages.ATTR_OS_MEMORY_USED_DESC),
 704                         MEMORY);
 705 
 706         public static final IAttribute<String> FLAG_NAME = attr("name", Messages.getString(Messages.ATTR_FLAG_NAME), //$NON-NLS-1$
 707                         PLAIN_TEXT);
 708         public static final IAttribute<String> FLAG_ORIGIN = attr("origin", Messages.getString(Messages.ATTR_FLAG_ORIGIN), //$NON-NLS-1$
 709                         PLAIN_TEXT);
 710         public static final IAttribute<IQuantity> FLAG_VALUE_NUMBER = attr("value", //$NON-NLS-1$
 711                         Messages.getString(Messages.ATTR_FLAG_VALUE_NUMBER), NUMBER);
 712         public static final IAttribute<Boolean> FLAG_VALUE_BOOLEAN = attr("value", //$NON-NLS-1$
 713                         Messages.getString(Messages.ATTR_FLAG_VALUE_BOOLEAN), FLAG);
 714         public static final IAttribute<String> FLAG_VALUE_TEXT = attr("value", //$NON-NLS-1$
 715                         Messages.getString(Messages.ATTR_FLAG_VALUE_TEXT), PLAIN_TEXT);
 716 
 717         public static final IAttribute<String> THREAD_DUMP_RESULT = attr("result", //$NON-NLS-1$
 718                         Messages.getString(Messages.ATTR_THREAD_DUMP_RESULT), PLAIN_TEXT);
 719         public static final IAttribute<String> DUMP_REASON = attr("reason", Messages.getString(Messages.ATTR_DUMP_REASON), //$NON-NLS-1$
 720                         Messages.getString(Messages.ATTR_DUMP_REASON_DESC), PLAIN_TEXT);
 721         public static final IAttribute<String> DUMP_REASON_RECORDING_ID = attr("recordingId", //$NON-NLS-1$
 722                         Messages.getString(Messages.ATTR_DUMP_REASON_RECORDING_ID),
 723                         Messages.getString(Messages.ATTR_DUMP_REASON_RECORDING_ID_DESC), PLAIN_TEXT);
 724         
 725         public static final IAttribute<String> SHUTDOWN_REASON = attr("reason", //$NON-NLS-1$
 726                         Messages.getString(Messages.ATTR_SHUTDOWN_REASON),
 727                         Messages.getString(Messages.ATTR_SHUTDOWN_REASON_DESC), PLAIN_TEXT);
 728 
 729         public static final IAttribute<IQuantity> CLASSLOADER_LOADED_COUNT = attr("loadedClassCount", //$NON-NLS-1$
 730                         Messages.getString(Messages.ATTR_CLASSLOADER_LOADED_COUNT),
 731                         Messages.getString(Messages.ATTR_CLASSLOADER_LOADED_COUNT_DESC), NUMBER);
 732         public static final IAttribute<IQuantity> CLASSLOADER_UNLOADED_COUNT = attr("unloadedClassCount", //$NON-NLS-1$
 733                         Messages.getString(Messages.ATTR_CLASSLOADER_UNLOADED_COUNT),
 734                         Messages.getString(Messages.ATTR_CLASSLOADER_UNLOADED_COUNT_DESC), NUMBER);
 735 
 736         private static final IAttribute<IMCType> CLASS_DEFINING_CLASSLOADER_V0 = attr("definingClassLoader", //$NON-NLS-1$
 737                         Messages.getString(Messages.ATTR_CLASS_DEFINING_CLASSLOADER), CLASS);
 738         private static final IAttribute<IMCType> CLASS_INITIATING_CLASSLOADER_V0 = attr("initiatingClassLoader", //$NON-NLS-1$
 739                         Messages.getString(Messages.ATTR_CLASS_INITIATING_CLASSLOADER), CLASS);
 740         private static final IAttribute<IMCType> PARENT_CLASSLOADER_V0 = attr("parentClassLoader", //$NON-NLS-1$
 741                         Messages.getString(Messages.ATTR_PARENT_CLASSLOADER), CLASS);
 742         private static final IAttribute<IMCType> CLASSLOADER_V0 = attr("classLoader", //$NON-NLS-1$
 743                         Messages.getString(Messages.ATTR_CLASSLOADER), CLASS);
 744 
 745         public static final IAttribute<IMCClassLoader> CLASS_DEFINING_CLASSLOADER = Attribute
 746                         .canonicalize(new Attribute<IMCClassLoader>("definingClassLoader", //$NON-NLS-1$
 747                                         Messages.getString(Messages.ATTR_CLASS_DEFINING_CLASSLOADER), null, CLASS_LOADER) {
 748                                 @Override
 749                                 public <U> IMemberAccessor<IMCClassLoader, U> customAccessor(IType<U> type) {
 750                                         // V1 is handled by the standard accessor
 751                                         final IMemberAccessor<IMCType, U> accessorV0 = CLASS_DEFINING_CLASSLOADER_V0.getAccessor(type);
 752                                         if (accessorV0 != null) {
 753                                                 return new IMemberAccessor<IMCClassLoader, U>() {
 754                                                         @Override
 755                                                         public IMCClassLoader getMember(U i) {
 756                                                                 IMCType type = accessorV0.getMember(i);
 757                                                                 return new MCClassLoader(type, null);
 758                                                         }
 759                                                 };
 760                                         }
 761                                         return null;
 762                                 }
 763                         });
 764         public static final IAttribute<IMCClassLoader> CLASS_INITIATING_CLASSLOADER = Attribute
 765                         .canonicalize(new Attribute<IMCClassLoader>("initiatingClassLoader", //$NON-NLS-1$
 766                                         Messages.getString(Messages.ATTR_CLASS_INITIATING_CLASSLOADER), null, CLASS_LOADER) {
 767                                 @Override
 768                                 public <U> IMemberAccessor<IMCClassLoader, U> customAccessor(IType<U> type) {
 769                                         // V1 is handled by the standard accessor
 770                                         final IMemberAccessor<IMCType, U> accessorV0 = CLASS_INITIATING_CLASSLOADER_V0.getAccessor(type);
 771                                         if (accessorV0 != null) {
 772                                                 return new IMemberAccessor<IMCClassLoader, U>() {
 773                                                         @Override
 774                                                         public IMCClassLoader getMember(U i) {
 775                                                                 IMCType type = accessorV0.getMember(i);
 776                                                                 return new MCClassLoader(type, null);
 777                                                         }
 778                                                 };
 779                                         }
 780                                         return null;
 781                                 }
 782                         });
 783         public static final IAttribute<IMCClassLoader> PARENT_CLASSLOADER = Attribute
 784                         .canonicalize(new Attribute<IMCClassLoader>("parentClassLoader", //$NON-NLS-1$
 785                                         Messages.getString(Messages.ATTR_PARENT_CLASSLOADER), null, CLASS_LOADER) {
 786                                 @Override
 787                                 public <U> IMemberAccessor<IMCClassLoader, U> customAccessor(IType<U> type) {
 788                                         // V1 is handled by the standard accessor
 789                                         final IMemberAccessor<IMCType, U> accessorV0 = PARENT_CLASSLOADER_V0.getAccessor(type);
 790                                         if (accessorV0 != null) {
 791                                                 return new IMemberAccessor<IMCClassLoader, U>() {
 792                                                         @Override
 793                                                         public IMCClassLoader getMember(U i) {
 794                                                                 IMCType type = accessorV0.getMember(i);
 795                                                                 return new MCClassLoader(type, null);
 796                                                         }
 797                                                 };
 798                                         }
 799                                         return null;
 800                                 }
 801                         });
 802         public static final IAttribute<IMCClassLoader> CLASSLOADER = Attribute
 803                         .canonicalize(new Attribute<IMCClassLoader>("classLoader", //$NON-NLS-1$
 804                                         Messages.getString(Messages.ATTR_CLASSLOADER), null, CLASS_LOADER) {
 805                                 @Override
 806                                 public <U> IMemberAccessor<IMCClassLoader, U> customAccessor(IType<U> type) {
 807                                         // V1 is handled by the standard accessor
 808                                         final IMemberAccessor<IMCType, U> accessorV0 = CLASSLOADER_V0.getAccessor(type);
 809                                         if (accessorV0 != null) {
 810                                                 return new IMemberAccessor<IMCClassLoader, U>() {
 811                                                         @Override
 812                                                         public IMCClassLoader getMember(U i) {
 813                                                                 IMCType type = accessorV0.getMember(i);
 814                                                                 return new MCClassLoader(type, null);
 815                                                         }
 816                                                 };
 817                                         }
 818                                         return null;
 819                                 }
 820                         });
 821         public static final IAttribute<String> CLASS_DEFINING_CLASSLOADER_STRING = Attribute
 822                         .canonicalize(new Attribute<String>("defininingClassLoader.string", //$NON-NLS-1$
 823                                         Messages.getString(Messages.ATTR_CLASS_DEFINING_CLASSLOADER), null, PLAIN_TEXT) {
 824                                 @Override
 825                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 826                                         final IMemberAccessor<IMCClassLoader, U> accessor = CLASS_DEFINING_CLASSLOADER.getAccessor(type);
 827                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 828                                                 @Override
 829                                                 public String getMember(U i) {
 830                                                         IMCClassLoader cl = accessor.getMember(i);
 831                                                         return cl == null ? null : FormatToolkit.getHumanReadable(cl);
 832                                                 }
 833                                         };
 834                                 }
 835                         });
 836         public static final IAttribute<String> CLASS_INITIATING_CLASSLOADER_STRING = Attribute
 837                         .canonicalize(new Attribute<String>("initiatingClassLoader.string", //$NON-NLS-1$
 838                                         Messages.getString(Messages.ATTR_CLASS_INITIATING_CLASSLOADER), null, PLAIN_TEXT) {
 839                                 @Override
 840                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 841                                         final IMemberAccessor<IMCClassLoader, U> accessor = CLASS_INITIATING_CLASSLOADER.getAccessor(type);
 842                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 843                                                 @Override
 844                                                 public String getMember(U i) {
 845                                                         IMCClassLoader cl = accessor.getMember(i);
 846                                                         return cl == null ? null : FormatToolkit.getHumanReadable(cl);
 847                                                 }
 848                                         };
 849                                 }
 850                         });
 851         public static final IAttribute<String> PARENT_CLASSLOADER_STRING = Attribute
 852                         .canonicalize(new Attribute<String>("parentClassLoader.string", //$NON-NLS-1$
 853                                         Messages.getString(Messages.ATTR_PARENT_CLASSLOADER), null, PLAIN_TEXT) {
 854                                 @Override
 855                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 856                                         final IMemberAccessor<IMCClassLoader, U> accessor = PARENT_CLASSLOADER.getAccessor(type);
 857                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 858                                                 @Override
 859                                                 public String getMember(U i) {
 860                                                         IMCClassLoader cl = accessor.getMember(i);
 861                                                         return cl == null ? null : FormatToolkit.getHumanReadable(cl);
 862                                                 }
 863                                         };
 864                                 }
 865                         });
 866 
 867         public static final IAttribute<String> CLASSLOADER_STRING = Attribute
 868                         .canonicalize(new Attribute<String>("classLoader.string", //$NON-NLS-1$
 869                                         Messages.getString(Messages.ATTR_CLASSLOADER), null, PLAIN_TEXT) {
 870                                 @Override
 871                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 872                                         final IMemberAccessor<IMCClassLoader, U> accessor = CLASSLOADER.getAccessor(type);
 873                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 874                                                 @Override
 875                                                 public String getMember(U i) {
 876                                                         IMCClassLoader cl = accessor.getMember(i);
 877                                                         return cl == null ? null : FormatToolkit.getHumanReadable(cl);
 878                                                 }
 879                                         };
 880                                 }
 881                         });
 882 
 883         public static final IAttribute<IMCType> CLASS_LOADED = attr("loadedClass", //$NON-NLS-1$
 884                         Messages.getString(Messages.ATTR_CLASS_LOADED), CLASS);
 885         public static final IAttribute<IMCType> CLASS_UNLOADED = attr("unloadedClass", //$NON-NLS-1$
 886                         Messages.getString(Messages.ATTR_CLASS_UNLOADED), CLASS);
 887         public static final IAttribute<IMCType> CLASS_DEFINED = attr("definedClass", //$NON-NLS-1$
 888                         Messages.getString(Messages.ATTR_CLASS_DEFINED), CLASS);
 889         public static final IAttribute<IQuantity> ANONYMOUS_BLOCK_SIZE = attr("anonymousBlockSize", //$NON-NLS-1$
 890                         Messages.getString(Messages.ATTR_ANONYMOUS_BLOCK_SIZE), MEMORY);
 891         public static final IAttribute<IQuantity> ANONYMOUS_CHUNK_SIZE = attr("anonymousChunkSize", //$NON-NLS-1$ 
 892                         Messages.getString(Messages.ATTR_ANONYMOUS_CHUNK_SIZE), MEMORY);
 893         public static final IAttribute<IQuantity> ANONYMOUS_CLASS_COUNT = attr("anonymousClassCount", //$NON-NLS-1$
 894                         Messages.getString(Messages.ATTR_ANONYMOUS_CLASS_COUNT), NUMBER);
 895         public static final IAttribute<IQuantity> BLOCK_SIZE = attr("blockSize", //$NON-NLS-1$
 896                         Messages.getString(Messages.ATTR_BLOCK_SIZE), MEMORY);
 897         public static final IAttribute<IQuantity> CHUNK_SIZE = attr("chunkSize", //$NON-NLS-1$
 898                         Messages.getString(Messages.ATTR_CHUNK_SIZE), MEMORY);
 899         public static final IAttribute<IQuantity> CLASS_COUNT = attr("classCount", //$NON-NLS-1$
 900                         Messages.getString(Messages.ATTR_CLASS_COUNT), NUMBER);
 901         public static final IAttribute<IQuantity> CLASS_LOADER_DATA = attr("classLoaderData", //$NON-NLS-1$
 902                         Messages.getString(Messages.ATTR_CLASSLOADER_DATA), ADDRESS);   
 903 
 904         public static final IAttribute<IQuantity> COMPILER_COMPILATION_ID = attr("compileId", //$NON-NLS-1$
 905                         Messages.getString(Messages.ATTR_COMPILER_COMPILATION_ID), NUMBER);
 906         public static final IAttribute<IQuantity> COMPILER_CODE_SIZE = attr("codeSize", //$NON-NLS-1$
 907                         Messages.getString(Messages.ATTR_COMPILER_CODE_SIZE), MEMORY);
 908         public static final IAttribute<IQuantity> COMPILER_INLINED_SIZE = attr("inlinedBytes", //$NON-NLS-1$
 909                         Messages.getString(Messages.ATTR_COMPILER_INLINED_SIZE), MEMORY);
 910         public static final IAttribute<IMCMethod> COMPILER_METHOD = attr("method", //$NON-NLS-1$
 911                         Messages.getString(Messages.ATTR_COMPILER_METHOD), METHOD);
 912         public static final IAttribute<String> COMPILER_METHOD_STRING = Attribute.canonicalize(
 913                         new Attribute<String>("method.humanreadable", Messages.getString(Messages.ATTR_COMPILER_METHOD_HUMAN), //$NON-NLS-1$
 914                                         Messages.getString(Messages.ATTR_COMPILER_METHOD_HUMAN_DESC), PLAIN_TEXT) {
 915                                 @Override
 916                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
 917                                         final IMemberAccessor<IMCMethod, U> accessor = COMPILER_METHOD.getAccessor(type);
 918                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
 919                                                 @Override
 920                                                 public String getMember(U i) {
 921                                                         IMCMethod method = accessor.getMember(i);
 922                                                         return method == null ? null : FormatToolkit.getHumanReadable(method);
 923                                                 }
 924                                         };
 925                                 }
 926                         });
 927         public static final IAttribute<String> COMPILER_FAILED_MESSAGE = attr("failureMessage", //$NON-NLS-1$
 928                         Messages.getString(Messages.ATTR_COMPILER_FAILED_MESSAGE), PLAIN_TEXT);
 929         public static final IAttribute<IQuantity> COMPILER_STANDARD_COUNT = attr("standardCompileCount", //$NON-NLS-1$
 930                         Messages.getString(Messages.ATTR_COMPILER_STANDARD_COUNT), NUMBER);
 931         public static final IAttribute<IQuantity> COMPILER_OSR_COUNT = attr("osrCompileCount", //$NON-NLS-1$
 932                         Messages.getString(Messages.ATTR_COMPILER_OSR_COUNT), NUMBER);
 933         public static final IAttribute<IQuantity> COMPILER_COMPILATION_LEVEL = attr("compileLevel", //$NON-NLS-1$
 934                         Messages.getString(Messages.ATTR_COMPILER_COMPILATION_LEVEL), NUMBER);
 935         public static final IAttribute<Boolean> COMPILER_COMPILATION_SUCCEEDED = attr("succeded", //$NON-NLS-1$
 936                         Messages.getString(Messages.ATTR_COMPILER_COMPILATION_SUCCEEDED), FLAG);
 937         public static final IAttribute<Boolean> COMPILER_IS_OSR = attr("isOsr", //$NON-NLS-1$
 938                         Messages.getString(Messages.ATTR_COMPILER_IS_OSR), FLAG);
 939 
 940         public static final IAttribute<IQuantity> START_ADDRESS = attr("startAddress", //$NON-NLS-1$
 941                         Messages.getString(Messages.ATTR_START_ADDRESS), ADDRESS);
 942         public static final IAttribute<IQuantity> COMMITTED_TOP = attr("commitedTopAddress", //$NON-NLS-1$
 943                         Messages.getString(Messages.ATTR_COMMITTED_TOP), ADDRESS);
 944         public static final IAttribute<IQuantity> RESERVED_TOP = attr("reservedTopAddress", //$NON-NLS-1$
 945                         Messages.getString(Messages.ATTR_RESERVED_TOP), ADDRESS);
 946         public static final IAttribute<IQuantity> ENTRIES = attr("entryCount", Messages.getString(Messages.ATTR_ENTRIES), //$NON-NLS-1$
 947                         NUMBER);
 948         public static final IAttribute<IQuantity> METHODS = attr("methodCount", Messages.getString(Messages.ATTR_METHODS), //$NON-NLS-1$
 949                         NUMBER);
 950         public static final IAttribute<IQuantity> ADAPTORS = attr("adaptorCount", //$NON-NLS-1$
 951                         Messages.getString(Messages.ATTR_ADAPTORS), NUMBER);
 952         public static final IAttribute<IQuantity> FULL_COUNT = attr("fullCount", //$NON-NLS-1$
 953                         Messages.getString(Messages.ATTR_FULL_COUNT), NUMBER);
 954         public static final IAttribute<IQuantity> UNALLOCATED = attr("unallocatedCapacity", //$NON-NLS-1$
 955                         Messages.getString(Messages.ATTR_UNALLOCATED), MEMORY);
 956 
 957         private static final String CODE_HEAP_NON_NMETHODS = "CodeHeap 'non-nmethods'"; //$NON-NLS-1$
 958         private static final String CODE_HEAP_NON_PROFILED_NMETHODS = "CodeHeap 'non-profiled nmethods'"; //$NON-NLS-1$
 959         private static final String CODE_HEAP_PROFILED_NMETHODS = "CodeHeap 'profiled nmethods'"; //$NON-NLS-1$
 960 
 961         public static final IAttribute<IQuantity> PROFILED_UNALLOCATED = Attribute
 962                         .canonicalize(createCodeHeapAttribute(UNALLOCATED, CODE_HEAP_PROFILED_NMETHODS, "profiledUnallocated", //$NON-NLS-1$
 963                                         Messages.getString(Messages.ATTR_PROFILED_NMETHODS_UNALLOCATED),
 964                                         Messages.getString(Messages.ATTR_PROFILED_NMETHODS_UNALLOCATED_DESCRIPTION), MEMORY));
 965         public static final IAttribute<IQuantity> PROFILED_ENTRIES = Attribute
 966                         .canonicalize(createCodeHeapAttribute(ENTRIES, CODE_HEAP_PROFILED_NMETHODS, "profiledEntries", //$NON-NLS-1$
 967                                         Messages.getString(Messages.ATTR_PROFILED_NMETHODS_ENTRIES),
 968                                         Messages.getString(Messages.ATTR_PROFILED_NMETHODS_ENTRIES_DESCRIPTION), NUMBER));
 969         public static final IAttribute<IQuantity> PROFILED_METHODS = Attribute
 970                         .canonicalize(createCodeHeapAttribute(METHODS, CODE_HEAP_PROFILED_NMETHODS, "profiledMethods", //$NON-NLS-1$
 971                                         Messages.getString(Messages.ATTR_PROFILED_NMETHODS_METHODS),
 972                                         Messages.getString(Messages.ATTR_PROFILED_NMETHODS_METHODS_DESCRIPTION), NUMBER));
 973         public static final IAttribute<IQuantity> NON_PROFILED_NMETHODS_UNALLOCATED = Attribute
 974                         .canonicalize(createCodeHeapAttribute(UNALLOCATED, CODE_HEAP_NON_PROFILED_NMETHODS,
 975                                         "nonProfiledUnallocated", Messages.getString(Messages.ATTR_NON_PROFILED_NMETHODS_UNALLOCATED), //$NON-NLS-1$
 976                                         Messages.getString(Messages.ATTR_NON_PROFILED_NMETHODS_UNALLOCATED_DESCRIPTION), MEMORY));
 977         public static final IAttribute<IQuantity> NON_PROFILED_NMETHODS_ENTRIES = Attribute
 978                         .canonicalize(createCodeHeapAttribute(ENTRIES, CODE_HEAP_NON_PROFILED_NMETHODS, "nonProfiledEntries", //$NON-NLS-1$
 979                                         Messages.getString(Messages.ATTR_NON_PROFILED_NMETHODS_ENTRIES),
 980                                         Messages.getString(Messages.ATTR_NON_PROFILED_NMETHODS_ENTRIES_DESCRIPTION), NUMBER));
 981         public static final IAttribute<IQuantity> NON_PROFILED_METHODS = Attribute
 982                         .canonicalize(createCodeHeapAttribute(METHODS, CODE_HEAP_NON_PROFILED_NMETHODS, "nonProfiledMethods", //$NON-NLS-1$
 983                                         Messages.getString(Messages.ATTR_NON_PROFILED_NMETHODS_METHODS),
 984                                         Messages.getString(Messages.ATTR_NON_PROFILED_NMETHODS_METHODS_DESCRIPTION), NUMBER));
 985         public static final IAttribute<IQuantity> NON_NMETHODS_UNALLOCATED = Attribute
 986                         .canonicalize(createCodeHeapAttribute(UNALLOCATED, CODE_HEAP_NON_NMETHODS, "nonNmethodsUnallocated", //$NON-NLS-1$
 987                                         Messages.getString(Messages.ATTR_NON_NMETHODS_UNALLOCATED),
 988                                         Messages.getString(Messages.ATTR_NON_NMETHODS_UNALLOCATED_DESCRIPTION), MEMORY));
 989         public static final IAttribute<IQuantity> NON_NMETHODS_ENTRIES = Attribute
 990                         .canonicalize(createCodeHeapAttribute(ENTRIES, CODE_HEAP_NON_NMETHODS, "nonNmethodsEntries", //$NON-NLS-1$
 991                                         Messages.getString(Messages.ATTR_NON_NMETHODS_ENTRIES),
 992                                         Messages.getString(Messages.ATTR_NON_NMETHODS_ENTRIES_DESCRIPTION), NUMBER));
 993         public static final IAttribute<IQuantity> NON_NMETHODS_ADAPTORS = Attribute
 994                         .canonicalize(createCodeHeapAttribute(ADAPTORS, CODE_HEAP_NON_NMETHODS, "nonNmethodsAdaptors", //$NON-NLS-1$
 995                                         Messages.getString(Messages.ATTR_NON_NMETHODS_ADAPTORS),
 996                                         Messages.getString(Messages.ATTR_NON_NMETHODS_ADAPTORS_DESCRIPTION), NUMBER));
 997 
 998         /**
 999          * Workaround for badly constructed JDK 9 segmented code cache events. Creates a synthetic
1000          * attributes for specific code heaps.
1001          *
1002          * @param attribute
1003          *            the attribute to convert
1004          * @param codeHeap
1005          *            the code heap for the new attribute to be for
1006          * @param identifier
1007          *            the identifier of the new attribute
1008          * @param name
1009          *            the name of the new attribute
1010          * @param description
1011          *            the description of the new attribute
1012          * @param contentType
1013          *            the content type of the new attribute
1014          * @return the wrapped attribute for the specified code heap and attribute
1015          */
1016         private static Attribute<IQuantity> createCodeHeapAttribute(
1017                 final IAttribute<IQuantity> attribute, final String codeHeap, String identifier, String name,
1018                 String description, ContentType<IQuantity> contentType) {
1019                 return new Attribute<IQuantity>(identifier, name, description, contentType) {
1020                         @Override
1021                         public <U> IMemberAccessor<IQuantity, U> customAccessor(IType<U> type) {
1022                                 final IMemberAccessor<IQuantity, U> attributeAccessor = attribute.getAccessor(type);
1023                                 final IMemberAccessor<String, U> codeHeapAccessor = CODE_HEAP.getAccessor(type);
1024                                 return attributeAccessor == null || codeHeapAccessor == null ? null
1025                                                 : new IMemberAccessor<IQuantity, U>() {
1026                                                         @Override
1027                                                         public IQuantity getMember(U i) {
1028                                                                 return codeHeapAccessor.getMember(i).equals(codeHeap) ? attributeAccessor.getMember(i)
1029                                                                                 : null;
1030                                                         }
1031                                                 };
1032                         }
1033                 };
1034         }
1035 
1036         public static final IAttribute<String> CODE_HEAP = attr("codeBlobType", Messages.getString(Messages.ATTR_CODE_HEAP), //$NON-NLS-1$
1037                         PLAIN_TEXT);
1038 
1039         public static final IAttribute<IQuantity> SWEEP_INDEX = attr("sweepId", //$NON-NLS-1$
1040                         Messages.getString(Messages.ATTR_SWEEP_INDEX), NUMBER);
1041         public static final IAttribute<IQuantity> SWEEP_FRACTION_INDEX = attr("sweepFractionIndex", //$NON-NLS-1$
1042                         Messages.getString(Messages.ATTR_SWEEP_FRACTION_INDEX), NUMBER);
1043         public static final IAttribute<IQuantity> SWEEP_METHOD_SWEPT = attr("sweptCount", //$NON-NLS-1$
1044                         Messages.getString(Messages.ATTR_SWEEP_METHOD_SWEPT), NUMBER);
1045         public static final IAttribute<IQuantity> SWEEP_METHOD_FLUSHED = attr("flushedCount", //$NON-NLS-1$
1046                         Messages.getString(Messages.ATTR_SWEEP_METHOD_FLUSHED), NUMBER);
1047         public static final IAttribute<IQuantity> SWEEP_METHOD_RECLAIMED = attr("markedCount", //$NON-NLS-1$
1048                         Messages.getString(Messages.ATTR_SWEEP_METHOD_RECLAIMED), NUMBER);
1049         public static final IAttribute<IQuantity> SWEEP_METHOD_ZOMBIFIED = attr("zombifiedCount", //$NON-NLS-1$
1050                         Messages.getString(Messages.ATTR_SWEEP_METHOD_ZOMBIFIED), NUMBER);
1051 
1052         public static final IAttribute<IQuantity> INITIAL_SIZE = attr("initialSize", //$NON-NLS-1$
1053                         Messages.getString(Messages.ATTR_INITIAL_SIZE), MEMORY);
1054         public static final IAttribute<IQuantity> RESERVED_SIZE = attr("reservedSize", //$NON-NLS-1$
1055                         Messages.getString(Messages.ATTR_RESERVED_SIZE), MEMORY);
1056         public static final IAttribute<IQuantity> EXPANSION_SIZE = attr("expansionSize", //$NON-NLS-1$
1057                         Messages.getString(Messages.ATTR_EXPANSION_SIZE), MEMORY);
1058         public static final IAttribute<IQuantity> NON_PROFILED_SIZE = attr("nonProfiledSize", //$NON-NLS-1$
1059                         Messages.getString(Messages.ATTR_NON_PROFILED_SIZE), MEMORY);
1060         public static final IAttribute<IQuantity> PROFILED_SIZE = attr("profiledSize", //$NON-NLS-1$
1061                         Messages.getString(Messages.ATTR_PROFILED_SIZE), MEMORY);
1062         public static final IAttribute<IQuantity> NON_NMETHOD_SIZE = attr("nonNMethodSize", //$NON-NLS-1$
1063                         Messages.getString(Messages.ATTR_NON_NMETHOD_SIZE), MEMORY);
1064 
1065         public static final IAttribute<String> ENVIRONMENT_KEY = attr("key", //$NON-NLS-1$
1066                         Messages.getString(Messages.ATTR_ENVIRONMENT_KEY), PLAIN_TEXT);
1067         public static final IAttribute<String> ENVIRONMENT_VALUE = attr("value", //$NON-NLS-1$
1068                         Messages.getString(Messages.ATTR_ENVIRONMENT_VALUE), PLAIN_TEXT);
1069 
1070         public static final IAttribute<IQuantity> EXCEPTION_THROWABLES_COUNT = attr("throwables", //$NON-NLS-1$
1071                         Messages.getString(Messages.ATTR_EXCEPTION_THROWABLES_COUNT),
1072                         Messages.getString(Messages.ATTR_EXCEPTION_THROWABLES_COUNT_DESC), NUMBER);
1073         public static final IAttribute<IMCType> EXCEPTION_THROWNCLASS = attr("thrownClass", //$NON-NLS-1$
1074                         Messages.getString(Messages.ATTR_EXCEPTION_THROWNCLASS), CLASS);
1075         public static final IAttribute<String> EXCEPTION_THROWNCLASS_NAME = Attribute.canonicalize(
1076                         new Attribute<String>("thrownClassName", Messages.getString(Messages.ATTR_EXCEPTION_THROWNCLASS_NAME), //$NON-NLS-1$
1077                                         Messages.getString(Messages.ATTR_EXCEPTION_THROWNCLASS_NAME_DESC), PLAIN_TEXT) {
1078                                 @Override
1079                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
1080                                         final IMemberAccessor<IMCType, U> accessor = EXCEPTION_THROWNCLASS.getAccessor(type);
1081                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
1082                                                 @Override
1083                                                 public String getMember(U i) {
1084                                                         IMCType type = accessor.getMember(i);
1085                                                         return type == null ? null : type.getFullName();
1086                                                 }
1087                                         };
1088                                 }
1089                         });
1090 
1091         public static final IAttribute<String> EXCEPTION_MESSAGE = attr("message", //$NON-NLS-1$
1092                         Messages.getString(Messages.ATTR_EXCEPTION_MESSAGE), PLAIN_TEXT);
1093 
1094         public static final IAttribute<IQuantity> MONITOR_ADDRESS = attr("address", //$NON-NLS-1$
1095                         Messages.getString(Messages.ATTR_MONITOR_ADDRESS), ADDRESS);
1096         public static final IAttribute<IMCType> MONITOR_CLASS = attr("monitorClass", //$NON-NLS-1$
1097                         Messages.getString(Messages.ATTR_MONITOR_CLASS), CLASS);
1098         public static final IAttribute<IMCThread> MONITOR_PREVIOUS_OWNER = attr("previousOwner", //$NON-NLS-1$
1099                         Messages.getString(Messages.ATTR_MONITOR_PREVIOUS_OWNER), THREAD);
1100 
1101         public static final IAttribute<IQuantity> OS_SWITCH_RATE = attr("switchRate", //$NON-NLS-1$
1102                         Messages.getString(Messages.ATTR_OS_SWITCH_RATE), NUMBER);
1103         public static final IAttribute<String> REFERENCE_STATISTICS_TYPE = attr("type", //$NON-NLS-1$
1104                         Messages.getString(Messages.ATTR_REFERENCE_STATISTICS_TYPE), PLAIN_TEXT);
1105         public static final IAttribute<IQuantity> REFERENCE_STATISTICS_COUNT = attr("count", //$NON-NLS-1$
1106                         Messages.getString(Messages.ATTR_REFERENCE_STATISTICS_COUNT), NUMBER);
1107         public static final IAttribute<IQuantity> GC_SUM_OF_PAUSES = attr("sumOfPauses", //$NON-NLS-1$
1108                         Messages.getString(Messages.ATTR_GC_SUM_OF_PAUSES), Messages.getString(Messages.ATTR_GC_SUM_OF_PAUSES_DESC),
1109                         TIMESPAN);
1110         public static final IAttribute<IQuantity> GC_LONGEST_PAUSE = attr("longestPause", //$NON-NLS-1$
1111                         Messages.getString(Messages.ATTR_GC_LONGEST_PAUSE), Messages.getString(Messages.ATTR_GC_LONGEST_PAUSE_DESC),
1112                         TIMESPAN);
1113         public static final IAttribute<String> GC_NAME = attr("name", Messages.getString(Messages.ATTR_GC_NAME), //$NON-NLS-1$
1114                         Messages.getString(Messages.ATTR_GC_NAME_DESC), PLAIN_TEXT);
1115         public static final IAttribute<String> GC_CAUSE = attr("cause", Messages.getString(Messages.ATTR_GC_CAUSE), //$NON-NLS-1$
1116                         Messages.getString(Messages.ATTR_GC_CAUSE_DESC), PLAIN_TEXT);
1117 
1118         public static final IAttribute<IMCOldObject> OBJECT = attr("object", Messages.getString(Messages.ATTR_REFERRER), //$NON-NLS-1$
1119                         Messages.getString(Messages.ATTR_REFERRER_DESC), OLD_OBJECT);
1120         public static final IAttribute<IQuantity> ALLOCATION_TIME = attr("allocationTime", //$NON-NLS-1$
1121                         Messages.getString(Messages.ATTR_REFERRER), Messages.getString(Messages.ATTR_REFERRER_DESC), TIMESTAMP);
1122         public static final IAttribute<IMCOldObjectGcRoot> GC_ROOT = attr("root", Messages.getString(Messages.ATTR_GC_ROOT), //$NON-NLS-1$
1123                         Messages.getString(Messages.ATTR_GC_ROOT_DESC), UnitLookup.OLD_OBJECT_GC_ROOT);
1124         public static final IAttribute<IMCType> OLD_OBJECT_CLASS = Attribute
1125                         .canonicalize(new Attribute<IMCType>("oldObjectClass", Messages.getString(Messages.ATTR_OLD_OBJECT_CLASS), //$NON-NLS-1$
1126                                         Messages.getString(Messages.ATTR_OLD_OBJECT_CLASS_DESC), CLASS) {
1127                                 @Override
1128                                 public <U> IMemberAccessor<IMCType, U> customAccessor(IType<U> type) {
1129                                         final IMemberAccessor<IMCOldObject, U> accessor = OBJECT.getAccessor(type);
1130                                         return accessor == null ? null : new IMemberAccessor<IMCType, U>() {
1131                                                 @Override
1132                                                 public IMCType getMember(U i) {
1133                                                         IMCOldObject object = accessor.getMember(i);
1134                                                         return object == null ? null : object.getType();
1135                                                 }
1136                                         };
1137                                 }
1138                         });
1139         public static final IAttribute<String> OLD_OBJECT_DESCRIPTION = Attribute.canonicalize(
1140                         new Attribute<String>("oldObjectDescription", Messages.getString(Messages.ATTR_OLD_OBJECT_DESCRIPTION), //$NON-NLS-1$
1141                                         Messages.getString(Messages.ATTR_OLD_OBJECT_DESCRIPTION_DESC), PLAIN_TEXT) {
1142                                 @Override
1143                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
1144                                         final IMemberAccessor<IMCOldObject, U> accessor = OBJECT.getAccessor(type);
1145                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
1146                                                 @Override
1147                                                 public String getMember(U i) {
1148                                                         IMCOldObject object = accessor.getMember(i);
1149                                                         return object == null ? null : object.getDescription();
1150                                                 }
1151                                         };
1152                                 }
1153                         });
1154         public static final IAttribute<Long> OLD_OBJECT_ARRAY_SIZE = Attribute.canonicalize(
1155                         new Attribute<Long>("oldObjectArraySize", Messages.getString(Messages.ATTR_OLD_OBJECT_ARRAY_SIZE), //$NON-NLS-1$
1156                                         Messages.getString(Messages.ATTR_OLD_OBJECT_ARRAY_SIZE_DESC), UnitLookup.RAW_LONG) {
1157                                 @Override
1158                                 public <U> IMemberAccessor<Long, U> customAccessor(IType<U> type) {
1159                                         final IMemberAccessor<IMCOldObject, U> accessor = OBJECT.getAccessor(type);
1160                                         return accessor == null ? null : new IMemberAccessor<Long, U>() {
1161                                                 @Override
1162                                                 public Long getMember(U i) {
1163                                                         IMCOldObject object = accessor.getMember(i);
1164                                                         return object != null && object.getReferrerArray() != null
1165                                                                         ? object.getReferrerArray().getSize() : null;
1166                                                 }
1167                                         };
1168                                 }
1169                         });
1170         public static final IAttribute<IQuantity> OLD_OBJECT_ADDRESS = Attribute.canonicalize(
1171                         new Attribute<IQuantity>("oldObjectAddress", Messages.getString(Messages.ATTR_OLD_OBJECT_ADDRESS), //$NON-NLS-1$
1172                                         Messages.getString(Messages.ATTR_OLD_OBJECT_ADDRESS_DESC), ADDRESS) {
1173                                 @Override
1174                                 public <U> IMemberAccessor<IQuantity, U> customAccessor(IType<U> type) {
1175                                         final IMemberAccessor<IMCOldObject, U> accessor = OBJECT.getAccessor(type);
1176                                         return accessor == null ? null : new IMemberAccessor<IQuantity, U>() {
1177                                                 @Override
1178                                                 public IQuantity getMember(U i) {
1179                                                         IMCOldObject object = accessor.getMember(i);
1180                                                         return object == null ? null : object.getAddress();
1181                                                 }
1182                                         };
1183                                 }
1184                         });
1185 
1186         public static final IAttribute<String> OS_VERSION = attr("osVersion", Messages.getString(Messages.ATTR_OS_VERSION), //$NON-NLS-1$
1187                         PLAIN_TEXT);
1188         public static final IAttribute<IQuantity> NUMBER_OF_SOCKETS = attr("sockets", //$NON-NLS-1$
1189                         Messages.getString(Messages.ATTR_NUMBER_OF_SOCKETS),
1190                         Messages.getString(Messages.ATTR_NUMBER_OF_SOCKETS_DESC), NUMBER);
1191         public static final IAttribute<String> CPU_DESCRIPTION = attr("description", //$NON-NLS-1$
1192                         Messages.getString(Messages.ATTR_CPU_DESCRIPTION), Messages.getString(Messages.ATTR_CPU_DESCRIPTION_DESC),
1193                         PLAIN_TEXT);
1194         public static final IAttribute<String> CPU_TYPE = attr("cpu", Messages.getString(Messages.ATTR_CPU_TYPE), //$NON-NLS-1$
1195                         PLAIN_TEXT);
1196         public static final IAttribute<IQuantity> NUMBER_OF_CORES = attr("cores", //$NON-NLS-1$
1197                         Messages.getString(Messages.ATTR_NUMBER_OF_CORES), Messages.getString(Messages.ATTR_NUMBER_OF_CORES_DESC),
1198                         NUMBER);
1199         public static final IAttribute<Boolean> BLOCKING = attr("blocking", Messages.getString(Messages.ATTR_BLOCKING), //$NON-NLS-1$
1200                         Messages.getString(Messages.ATTR_BLOCKING_DESC), FLAG);
1201         public static final IAttribute<Boolean> SAFEPOINT = attr("safepoint", Messages.getString(Messages.ATTR_SAFEPOINT), //$NON-NLS-1$
1202                         Messages.getString(Messages.ATTR_SAFEPOINT_DESC), FLAG);
1203         public static final IAttribute<String> OPERATION = attr("operation", Messages.getString(Messages.ATTR_OPERATION), //$NON-NLS-1$
1204                         Messages.getString(Messages.ATTR_OPERATION_DESC), PLAIN_TEXT);
1205         public static final IAttribute<IMCThread> CALLER = attr("caller", Messages.getString(Messages.ATTR_CALLER), //$NON-NLS-1$
1206                         Messages.getString(Messages.ATTR_CALLER_DESC), THREAD);
1207         public static final IAttribute<IMCType> BIASED_REVOCATION_LOCK_CLASS = attr("lockClass", //$NON-NLS-1$
1208                         Messages.getString(Messages.ATTR_REVOKATION_LOCK_CLASS),
1209                         Messages.getString(Messages.ATTR_REVOKATION_LOCK_CLASS_DESC), CLASS);
1210         public static final IAttribute<IMCType> BIASED_REVOCATION_CLASS = attr("revokedClass", //$NON-NLS-1$
1211                         Messages.getString(Messages.ATTR_REVOKED_CLASS), Messages.getString(Messages.ATTR_REVOKED_CLASS_DESC),
1212                         CLASS);
1213         public static final IAttribute<Boolean> BIASED_REVOCATION_DISABLE_BIASING = attr("disableBiasing", //$NON-NLS-1$
1214                         Messages.getString(Messages.ATTR_DISABLE_BIASING), FLAG);







1215 }
--- EOF ---