1
1
/*
2
- * Copyright (c) 2014, 2018 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2014, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
51
51
*/
52
52
public final class TestHiddenMethod {
53
53
54
- public static void main ( String [] args ) throws Throwable {
55
- try ( Recording recording = new Recording ()) {
56
- recording . enable ( MyEvent . class ). withThreshold ( Duration . ofMillis ( 0 ));
57
- recording . start ();
54
+ // Must call in separate thread because JTREG uses reflection
55
+ // to invoke main method, which uses hidden methods.
56
+ public static class TestThread extends Thread {
57
+ public void run () {
58
58
// doPrivileged calls a method that has the @Hidden
59
59
// annotation
60
60
AccessController .doPrivileged (new PrivilegedAction <Void >() {
@@ -65,8 +65,19 @@ public Void run() {
65
65
return null ;
66
66
}
67
67
});
68
+
68
69
MyEvent event = new MyEvent ();
69
70
event .commit ();
71
+ }
72
+ }
73
+
74
+ public static void main (String [] args ) throws Throwable {
75
+ try (Recording recording = new Recording ()) {
76
+ recording .enable (MyEvent .class ).withThreshold (Duration .ofMillis (0 ));
77
+ recording .start ();
78
+ Thread t = new TestThread ();
79
+ t .start ();
80
+ t .join ();
70
81
recording .stop ();
71
82
72
83
List <RecordedEvent > events = Events .fromRecording (recording );
@@ -78,9 +89,7 @@ public Void run() {
78
89
System .out .println ("visibleEvent:" + visibleEvent );
79
90
80
91
assertTrue (hasHiddenStackFrame (hiddenEvent ), "No hidden frame in hidden event: " + hiddenEvent );
81
-
82
- // Temporary disable this test until JDK-8272064 is resolved.
83
- // assertFalse(hasHiddenStackFrame(visibleEvent), "Hidden frame in visible event: " + visibleEvent);
92
+ assertFalse (hasHiddenStackFrame (visibleEvent ), "Hidden frame in visible event: " + visibleEvent );
84
93
}
85
94
}
86
95
0 commit comments