author | egahlin |
Sun, 09 Jun 2019 11:28:13 +0200 | |
changeset 55302 | 686dedba1d9a |
permissions | -rw-r--r-- |
55302
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
1 |
/* |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
4 |
* |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
10 |
* |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
15 |
* accompanied this code). |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
16 |
* |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
20 |
* |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
23 |
* questions. |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
24 |
*/ |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
25 |
|
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
26 |
package jdk.jfr.startupargs; |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
27 |
|
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
28 |
import jdk.jfr.Event; |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
29 |
import jdk.jfr.EventType; |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
30 |
import jdk.jfr.FlightRecorder; |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
31 |
import jdk.jfr.Name; |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
32 |
import jdk.jfr.Recording; |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
33 |
|
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
34 |
/** |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
35 |
* @test |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
36 |
* @summary Start a FlightRecording without any settings (not even default). |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
37 |
* @key jfr |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
38 |
* @requires vm.hasJFR |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
39 |
* @library /test/lib |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
40 |
* @run main/othervm jdk.jfr.startupargs.TestStartNoSettings |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
41 |
* -XX:StartFlightRecording=settings=none |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
42 |
*/ |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
43 |
public class TestStartNoSettings { |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
44 |
|
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
45 |
@Name("UserEvent") |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
46 |
static class UserEvent extends Event { |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
47 |
} |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
48 |
|
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
49 |
public static void main(String[] a) throws Exception { |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
50 |
boolean userEnabled = false; |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
51 |
try (Recording r = new Recording()) { |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
52 |
r.start(); |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
53 |
UserEvent e = new UserEvent(); |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
54 |
e.commit(); |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
55 |
for (EventType et : FlightRecorder.getFlightRecorder().getEventTypes()) { |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
56 |
if (et.isEnabled()) { |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
57 |
if (!et.getName().equals("UserEvent")) { |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
58 |
throw new Exception("Only 'UserEvent' should be enabled"); |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
59 |
} |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
60 |
userEnabled = true; |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
61 |
} |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
62 |
} |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
63 |
} |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
64 |
|
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
65 |
if (!userEnabled) { |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
66 |
throw new Exception("Expected 'UserEvent' to be enabled with -XX:StartFlightRecording=settings=none"); |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
67 |
} |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
68 |
} |
686dedba1d9a
8216064: -XX:StartFlightRecording:settings= doesn't work properly
egahlin
parents:
diff
changeset
|
69 |
} |