11/*
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.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
5151 */
5252public final class TestHiddenMethod {
5353
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 () {
5858 // doPrivileged calls a method that has the @Hidden
5959 // annotation
6060 AccessController .doPrivileged (new PrivilegedAction <Void >() {
@@ -65,8 +65,19 @@ public Void run() {
6565 return null ;
6666 }
6767 });
68+
6869 MyEvent event = new MyEvent ();
6970 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 ();
7081 recording .stop ();
7182
7283 List <RecordedEvent > events = Events .fromRecording (recording );
@@ -78,9 +89,7 @@ public Void run() {
7889 System .out .println ("visibleEvent:" + visibleEvent );
7990
8091 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 );
8493 }
8594 }
8695
0 commit comments