src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java
author egahlin
Wed, 05 Dec 2018 16:40:12 +0100
changeset 52850 f527b24990d7
parent 52334 a181612f0715
child 52901 3ba9ff4d4aaf
permissions -rw-r--r--
8205516: JFR tool Reviewed-by: mgronlun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     1
/*
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     4
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    10
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    15
 * accompanied this code).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    16
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    20
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    23
 * questions.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    24
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    25
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    26
package jdk.jfr.internal;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    27
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    28
import static java.util.concurrent.TimeUnit.MICROSECONDS;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
import static java.util.concurrent.TimeUnit.MILLISECONDS;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    30
import static java.util.concurrent.TimeUnit.NANOSECONDS;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
import static java.util.concurrent.TimeUnit.SECONDS;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
import java.io.FileOutputStream;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    34
import java.io.FileWriter;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
import java.io.IOException;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    36
import java.io.PrintWriter;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    37
import java.io.RandomAccessFile;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    38
import java.lang.annotation.Annotation;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    39
import java.lang.annotation.Repeatable;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    40
import java.lang.reflect.Field;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    41
import java.lang.reflect.InvocationTargetException;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    42
import java.lang.reflect.Method;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    43
import java.lang.reflect.Modifier;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    44
import java.nio.file.Path;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    45
import java.time.Duration;
50745
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
    46
import java.time.LocalDateTime;
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    47
import java.util.ArrayList;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    48
import java.util.Arrays;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    49
import java.util.Collections;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    50
import java.util.HashMap;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    51
import java.util.List;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    52
import java.util.Map;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    53
import java.util.Objects;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    54
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    55
import jdk.internal.org.objectweb.asm.ClassReader;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    56
import jdk.internal.org.objectweb.asm.util.CheckClassAdapter;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    57
import jdk.jfr.Event;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    58
import jdk.jfr.FlightRecorderPermission;
50745
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
    59
import jdk.jfr.Recording;
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
import jdk.jfr.RecordingState;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
import jdk.jfr.internal.handlers.EventHandler;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    62
import jdk.jfr.internal.settings.PeriodSetting;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
import jdk.jfr.internal.settings.StackTraceSetting;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
import jdk.jfr.internal.settings.ThresholdSetting;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    65
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    66
public final class Utils {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    67
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    68
    private static Boolean SAVE_GENERATED;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    69
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    70
    public static final String EVENTS_PACKAGE_NAME = "jdk.jfr.events";
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    71
    public static final String INSTRUMENT_PACKAGE_NAME = "jdk.jfr.internal.instrument";
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    72
    public static final String HANDLERS_PACKAGE_NAME = "jdk.jfr.internal.handlers";
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    73
    public static final String REGISTER_EVENT = "registerEvent";
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    74
    public static final String ACCESS_FLIGHT_RECORDER = "accessFlightRecorder";
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    75
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    76
    private final static String LEGACY_EVENT_NAME_PREFIX = "com.oracle.jdk.";
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    77
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    78
    public static void checkAccessFlightRecorder() throws SecurityException {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    79
        SecurityManager sm = System.getSecurityManager();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    80
        if (sm != null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    81
            sm.checkPermission(new FlightRecorderPermission(ACCESS_FLIGHT_RECORDER));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    82
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    83
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    84
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    85
    public static void checkRegisterPermission() throws SecurityException {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    86
        SecurityManager sm = System.getSecurityManager();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    87
        if (sm != null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    88
            sm.checkPermission(new FlightRecorderPermission(REGISTER_EVENT));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    89
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    90
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    91
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    92
    private static enum TimespanUnit {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    93
        NANOSECONDS("ns", 1000), MICROSECONDS("us", 1000), MILLISECONDS("ms", 1000), SECONDS("s", 60), MINUTES("m", 60), HOURS("h", 24), DAYS("d", 7);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    94
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    95
        final String text;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    96
        final long amount;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    97
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    98
        TimespanUnit(String unit, long amount) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    99
            this.text = unit;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   100
            this.amount = amount;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   101
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   102
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   103
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   104
    public static String formatBytes(long bytes, String separation) {
52850
f527b24990d7 8205516: JFR tool
egahlin
parents: 52334
diff changeset
   105
        if (bytes == 1) {
f527b24990d7 8205516: JFR tool
egahlin
parents: 52334
diff changeset
   106
            return "1 byte";
f527b24990d7 8205516: JFR tool
egahlin
parents: 52334
diff changeset
   107
        }
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   108
        if (bytes < 1024) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   109
            return bytes + " bytes";
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   110
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   111
        int exp = (int) (Math.log(bytes) / Math.log(1024));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   112
        char bytePrefix = "kMGTPE".charAt(exp - 1);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   113
        return String.format("%.1f%s%cB", bytes / Math.pow(1024, exp), separation, bytePrefix);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   114
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   115
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   116
    public static String formatTimespan(Duration dValue, String separation) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   117
        if (dValue == null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   118
            return "0";
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   119
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   120
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   121
        long value = dValue.toNanos();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   122
        TimespanUnit result = TimespanUnit.NANOSECONDS;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   123
        for (TimespanUnit unit : TimespanUnit.values()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   124
            result = unit;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   125
            long amount = unit.amount;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   126
            if (result == TimespanUnit.DAYS || value < amount || value % amount != 0) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   127
                break;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   128
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   129
            value /= amount;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   130
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   131
        return String.format("%d%s%s", value, separation, result.text);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   132
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   133
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   134
    public static long parseTimespan(String s) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   135
        if (s.endsWith("ns")) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   136
            return Long.parseLong(s.substring(0, s.length() - 2).trim());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   137
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   138
        if (s.endsWith("us")) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   139
            return NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 2).trim()), MICROSECONDS);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   140
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   141
        if (s.endsWith("ms")) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   142
            return NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 2).trim()), MILLISECONDS);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   143
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   144
        if (s.endsWith("s")) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   145
            return NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), SECONDS);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   146
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   147
        if (s.endsWith("m")) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   148
            return 60 * NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), SECONDS);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   149
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   150
        if (s.endsWith("h")) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   151
            return 60 * 60 * NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), SECONDS);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   152
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   153
        if (s.endsWith("d")) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   154
            return 24 * 60 * 60 * NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), SECONDS);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   155
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   156
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   157
        try {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   158
            Long.parseLong(s);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   159
        } catch (NumberFormatException nfe) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   160
            throw new NumberFormatException("'" + s + "' is not a valid timespan. Shoule be numeric value followed by a unit, i.e. 20 ms. Valid units are ns, us, s, m, h and d.");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   161
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   162
        // Only accept values with units
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   163
        throw new NumberFormatException("Timespan + '" + s + "' is missing unit. Valid units are ns, us, s, m, h and d.");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   164
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   165
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   166
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   167
     * Return all annotations as they are visible in the source code
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   168
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   169
     * @param clazz class to return annotations from
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   170
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   171
     * @return list of annotation
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   172
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   173
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   174
    static List<Annotation> getAnnotations(Class<?> clazz) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   175
        List<Annotation> annos = new ArrayList<>();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   176
        for (Annotation a : clazz.getAnnotations()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   177
            annos.addAll(getAnnotation(a));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   178
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   179
        return annos;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   180
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   181
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   182
    private static List<? extends Annotation> getAnnotation(Annotation a) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   183
        Class<?> annotated = a.annotationType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   184
        Method valueMethod = getValueMethod(annotated);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   185
        if (valueMethod != null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   186
            Class<?> returnType = valueMethod.getReturnType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   187
            if (returnType.isArray()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   188
                Class<?> candidate = returnType.getComponentType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   189
                Repeatable r = candidate.getAnnotation(Repeatable.class);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   190
                if (r != null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   191
                    Class<?> repeatClass = r.value();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   192
                    if (annotated == repeatClass) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   193
                        return getAnnotationValues(a, valueMethod);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   194
                    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   195
                }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   196
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   197
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   198
        List<Annotation> annos = new ArrayList<>();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   199
        annos.add(a);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   200
        return annos;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   201
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   202
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   203
    static boolean isAfter(RecordingState stateToTest, RecordingState b) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   204
        return stateToTest.ordinal() > b.ordinal();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   205
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   206
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   207
    static boolean isBefore(RecordingState stateToTest, RecordingState b) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   208
        return stateToTest.ordinal() < b.ordinal();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   209
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   210
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   211
    static boolean isState(RecordingState stateToTest, RecordingState... states) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   212
        for (RecordingState s : states) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   213
            if (s == stateToTest) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   214
                return true;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   215
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   216
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   217
        return false;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   218
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   219
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   220
    private static List<Annotation> getAnnotationValues(Annotation a, Method valueMethod) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   221
        try {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   222
            return Arrays.asList((Annotation[]) valueMethod.invoke(a, new Object[0]));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   223
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   224
            return new ArrayList<>();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   225
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   226
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   227
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   228
    private static Method getValueMethod(Class<?> annotated) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   229
        try {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   230
            return annotated.getMethod("value", new Class<?>[0]);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   231
        } catch (NoSuchMethodException e) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   232
            return null;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   233
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   234
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   235
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   236
    public static void touch(Path dumpFile) throws IOException {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   237
        RandomAccessFile raf = new RandomAccessFile(dumpFile.toFile(), "rw");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   238
        raf.close();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   239
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   240
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   241
    public static Class<?> unboxType(Class<?> t) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   242
        if (t == Integer.class) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   243
            return int.class;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   244
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   245
        if (t == Long.class) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   246
            return long.class;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   247
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   248
        if (t == Float.class) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   249
            return float.class;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   250
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   251
        if (t == Double.class) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   252
            return double.class;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   253
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   254
        if (t == Byte.class) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   255
            return byte.class;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   256
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   257
        if (t == Short.class) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   258
            return short.class;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   259
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   260
        if (t == Boolean.class) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   261
            return boolean.class;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   262
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   263
        if (t == Character.class) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   264
            return char.class;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   265
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   266
        return t;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   267
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   268
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   269
    static long nanosToTicks(long nanos) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   270
        return (long) (nanos * JVM.getJVM().getTimeConversionFactor());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   271
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   272
52334
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   273
    static synchronized EventHandler getHandler(Class<? extends jdk.internal.event.Event> eventClass) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   274
        Utils.ensureValidEventSubclass(eventClass);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   275
        try {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   276
            Field f = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   277
            SecuritySupport.setAccessible(f);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   278
            return (EventHandler) f.get(null);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   279
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   280
            throw new InternalError("Could not access event handler");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   281
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   282
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   283
52334
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   284
    static synchronized void setHandler(Class<? extends jdk.internal.event.Event> eventClass, EventHandler handler) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   285
        Utils.ensureValidEventSubclass(eventClass);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   286
        try {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   287
            Field field = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   288
            SecuritySupport.setAccessible(field);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   289
            field.set(null, handler);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   290
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   291
            throw new InternalError("Could not access event handler");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   292
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   293
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   294
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   295
    public static Map<String, String> sanitizeNullFreeStringMap(Map<String, String> settings) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   296
        HashMap<String, String> map = new HashMap<>(settings.size());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   297
        for (Map.Entry<String, String> e : settings.entrySet()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   298
            String key = e.getKey();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   299
            if (key == null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   300
                throw new NullPointerException("Null key is not allowed in map");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   301
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   302
            String value = e.getValue();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   303
            if (value == null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   304
                throw new NullPointerException("Null value is not allowed in map");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   305
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   306
            map.put(key, value);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   307
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   308
        return map;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   309
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   310
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   311
    public static <T> List<T> sanitizeNullFreeList(List<T> elements, Class<T> clazz) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   312
        List<T> sanitized = new ArrayList<>(elements.size());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   313
        for (T element : elements) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   314
            if (element == null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   315
                throw new NullPointerException("Null is not an allowed element in list");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   316
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   317
            if (element.getClass() != clazz) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   318
                throw new ClassCastException();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   319
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   320
            sanitized.add(element);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   321
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   322
        return sanitized;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   323
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   324
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   325
    static List<Field> getVisibleEventFields(Class<?> clazz) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   326
        Utils.ensureValidEventSubclass(clazz);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   327
        List<Field> fields = new ArrayList<>();
52334
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   328
        for (Class<?> c = clazz; c != jdk.internal.event.Event.class; c = c.getSuperclass()) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   329
            for (Field field : c.getDeclaredFields()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   330
                // skip private field in base classes
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   331
                if (c == clazz || !Modifier.isPrivate(field.getModifiers())) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   332
                    fields.add(field);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   333
                }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   334
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   335
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   336
        return fields;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   337
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   338
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   339
    public static void ensureValidEventSubclass(Class<?> eventClass) {
52334
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   340
        if (jdk.internal.event.Event.class.isAssignableFrom(eventClass) && Modifier.isAbstract(eventClass.getModifiers())) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   341
            throw new IllegalArgumentException("Abstract event classes are not allowed");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   342
        }
52334
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   343
        if (eventClass == Event.class || eventClass == jdk.internal.event.Event.class || !jdk.internal.event.Event.class.isAssignableFrom(eventClass)) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   344
            throw new IllegalArgumentException("Must be a subclass to " + Event.class.getName());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   345
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   346
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   347
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   348
    public static void writeGeneratedASM(String className, byte[] bytes) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   349
        if (SAVE_GENERATED == null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   350
            // We can't calculate value statically because it will force
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   351
            // initialization of SecuritySupport, which cause
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   352
            // UnsatisfiedLinkedError on JDK 8 or non-Oracle JDKs
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   353
            SAVE_GENERATED = SecuritySupport.getBooleanProperty("jfr.save.generated.asm");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   354
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   355
        if (SAVE_GENERATED) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   356
            try {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   357
                try (FileOutputStream fos = new FileOutputStream(className + ".class")) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   358
                    fos.write(bytes);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   359
                }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   360
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   361
                try (FileWriter fw = new FileWriter(className + ".asm"); PrintWriter pw = new PrintWriter(fw)) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   362
                    ClassReader cr = new ClassReader(bytes);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   363
                    CheckClassAdapter.verify(cr, true, pw);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   364
                }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   365
                Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Instrumented code saved to " + className + ".class and .asm");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   366
            } catch (IOException e) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   367
                Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Could not save instrumented code, for " + className + ".class and .asm");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   368
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   369
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   370
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   371
52334
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   372
    public static void ensureInitialized(Class<? extends jdk.internal.event.Event> eventClass) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   373
        SecuritySupport.ensureClassIsInitialized(eventClass);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   374
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   375
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   376
    public static Object makePrimitiveArray(String typeName, List<Object> values) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   377
        int length = values.size();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   378
        switch (typeName) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   379
        case "int":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   380
            int[] ints = new int[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   381
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   382
                ints[i] = (int) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   383
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   384
            return ints;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   385
        case "long":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   386
            long[] longs = new long[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   387
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   388
                longs[i] = (long) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   389
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   390
            return longs;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   391
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   392
        case "float":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   393
            float[] floats = new float[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   394
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   395
                floats[i] = (float) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   396
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   397
            return floats;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   398
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   399
        case "double":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   400
            double[] doubles = new double[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   401
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   402
                doubles[i] = (double) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   403
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   404
            return doubles;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   405
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   406
        case "short":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   407
            short[] shorts = new short[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   408
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   409
                shorts[i] = (short) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   410
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   411
            return shorts;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   412
        case "char":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   413
            char[] chars = new char[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   414
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   415
                chars[i] = (char) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   416
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   417
            return chars;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   418
        case "byte":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   419
            byte[] bytes = new byte[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   420
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   421
                bytes[i] = (byte) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   422
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   423
            return bytes;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   424
        case "boolean":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   425
            boolean[] booleans = new boolean[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   426
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   427
                booleans[i] = (boolean) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   428
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   429
            return booleans;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   430
        case "java.lang.String":
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   431
            String[] strings = new String[length];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   432
            for (int i = 0; i < length; i++) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   433
                strings[i] = (String) values.get(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   434
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   435
            return strings;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   436
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   437
        return null;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   438
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   439
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   440
    public static boolean isSettingVisible(Control c, boolean hasEventHook) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   441
        if (c instanceof ThresholdSetting) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   442
            return !hasEventHook;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   443
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   444
        if (c instanceof PeriodSetting) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   445
            return hasEventHook;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   446
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   447
        if (c instanceof StackTraceSetting) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   448
            return !hasEventHook;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   449
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   450
        return true;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   451
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   452
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   453
    public static boolean isSettingVisible(long typeId, boolean hasEventHook) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   454
        if (ThresholdSetting.isType(typeId)) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   455
            return !hasEventHook;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   456
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   457
        if (PeriodSetting.isType(typeId)) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   458
            return hasEventHook;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   459
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   460
        if (StackTraceSetting.isType(typeId)) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   461
            return !hasEventHook;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   462
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   463
        return true;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   464
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   465
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   466
    public static Type getValidType(Class<?> type, String name) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   467
        Objects.requireNonNull(type, "Null is not a valid type for value descriptor " + name);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   468
        if (type.isArray()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   469
            type = type.getComponentType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   470
            if (type != String.class && !type.isPrimitive()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   471
                throw new IllegalArgumentException("Only arrays of primitives and Strings are allowed");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   472
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   473
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   474
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   475
        Type knownType = Type.getKnownType(type);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   476
        if (knownType == null || knownType == Type.STACK_TRACE) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   477
            throw new IllegalArgumentException("Only primitive types, java.lang.Thread, java.lang.String and java.lang.Class are allowed for value descriptors. " + type.getName());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   478
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   479
        return knownType;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   480
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   481
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   482
    public static <T> List<T> smallUnmodifiable(List<T> list) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   483
        if (list.isEmpty()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   484
            return Collections.emptyList();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   485
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   486
        if (list.size() == 1) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   487
            return Collections.singletonList(list.get(0));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   488
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   489
        return Collections.unmodifiableList(list);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   490
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   491
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   492
    public static String upgradeLegacyJDKEvent(String eventName) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   493
        if (eventName.length() <= LEGACY_EVENT_NAME_PREFIX.length()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   494
            return eventName;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   495
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   496
        if (eventName.startsWith(LEGACY_EVENT_NAME_PREFIX)) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   497
            int index = eventName.lastIndexOf(".");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   498
            if (index == LEGACY_EVENT_NAME_PREFIX.length() - 1) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   499
                return Type.EVENT_NAME_PREFIX + eventName.substring(index + 1);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   500
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   501
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   502
        return eventName;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   503
    }
50745
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
   504
52334
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   505
    public static void verifyMirror(Class<?> mirror, Class<?> real) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   506
        Class<?> cMirror = Objects.requireNonNull(mirror);
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   507
        Class<?> cReal = Objects.requireNonNull(real);
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   508
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   509
        while (cReal != null) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   510
            Map<String, Field> mirrorFields = new HashMap<>();
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   511
            if (cMirror != null) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   512
                for (Field f : cMirror.getDeclaredFields()) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   513
                    if (isSupportedType(f.getType())) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   514
                        mirrorFields.put(f.getName(), f);
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   515
                    }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   516
                }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   517
            }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   518
            for (Field realField : cReal.getDeclaredFields()) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   519
                if (isSupportedType(realField.getType())) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   520
                    String fieldName = realField.getName();
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   521
                    Field mirrorField = mirrorFields.get(fieldName);
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   522
                    if (mirrorField == null) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   523
                        throw new InternalError("Missing mirror field for " + cReal.getName() + "#" + fieldName);
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   524
                    }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   525
                    if (realField.getModifiers() != mirrorField.getModifiers()) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   526
                        throw new InternalError("Incorrect modifier for mirror field "+ cMirror.getName() + "#" + fieldName);
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   527
                    }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   528
                    mirrorFields.remove(fieldName);
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   529
                }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   530
            }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   531
            if (!mirrorFields.isEmpty()) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   532
                throw new InternalError(
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   533
                        "Found additional fields in mirror class " + cMirror.getName() + " " + mirrorFields.keySet());
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   534
            }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   535
            if (cMirror != null) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   536
                cMirror = cMirror.getSuperclass();
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   537
            }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   538
            cReal = cReal.getSuperclass();
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   539
        }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   540
    }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   541
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   542
    private static boolean isSupportedType(Class<?> type) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   543
        if (Modifier.isTransient(type.getModifiers()) || Modifier.isStatic(type.getModifiers())) {
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   544
            return false;
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   545
        }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   546
        return Type.isValidJavaFieldType(type.getName());
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   547
    }
a181612f0715 8203629: Produce events in the JDK without a dependency on jdk.jfr
egahlin
parents: 50745
diff changeset
   548
50745
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
   549
    public static String makeFilename(Recording recording) {
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
   550
        String pid = JVM.getJVM().getPid();
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
   551
        String date = Repository.REPO_DATE_FORMAT.format(LocalDateTime.now());
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
   552
        String idText = recording == null ? "" :  "-id-" + Long.toString(recording.getId());
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
   553
        return "hotspot-" + "pid-" + pid + idText + "-" + date + ".jfr";
a390cbb82d47 8203929: Limit amount of data for JFR.dump
egahlin
parents: 50113
diff changeset
   554
    }
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   555
}