8242933: jdk/jfr/api/consumer/TestHiddenMethod uses nashorn script engine
Reviewed-by: mgronlun
This commit is contained in:
parent
d07d6bd123
commit
e34508cba2
@ -28,12 +28,11 @@ import static jdk.test.lib.Asserts.assertEquals;
|
||||
import static jdk.test.lib.Asserts.assertFalse;
|
||||
import static jdk.test.lib.Asserts.assertTrue;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
|
||||
import jdk.jfr.Event;
|
||||
import jdk.jfr.Recording;
|
||||
import jdk.jfr.consumer.RecordedEvent;
|
||||
@ -48,8 +47,7 @@ import jdk.test.lib.jfr.Events;
|
||||
* @requires vm.hasJFR
|
||||
*
|
||||
* @library /test/lib
|
||||
* @modules java.scripting
|
||||
* jdk.jfr
|
||||
* @modules jdk.jfr
|
||||
*
|
||||
* @run main/othervm jdk.jfr.api.consumer.TestHiddenMethod
|
||||
*/
|
||||
@ -59,27 +57,18 @@ public final class TestHiddenMethod {
|
||||
try (Recording recording = new Recording()) {
|
||||
recording.enable(MyEvent.class).withThreshold(Duration.ofMillis(0));
|
||||
recording.start();
|
||||
|
||||
// Commit event with hidden methods
|
||||
ScriptEngineManager manager = new ScriptEngineManager();
|
||||
ScriptEngine engine = manager.getEngineByName("nashorn");
|
||||
engine.eval(
|
||||
"function emit() {"
|
||||
+ " print('About to emit event from Javascript');"
|
||||
+ " var TestEvent = Java.type(\"jdk.jfr.api.consumer.TestHiddenMethod$MyEvent\");"
|
||||
+ " var event = new TestEvent;"
|
||||
+ " event.begin();"
|
||||
+ " event.end();"
|
||||
+ " event.commit();"
|
||||
+ " print('Event emitted from Javascript!');"
|
||||
+ "}"
|
||||
+ "emit();");
|
||||
|
||||
// Commit event with visible method
|
||||
MyEvent visible = new MyEvent();
|
||||
visible.begin();
|
||||
visible.end();
|
||||
visible.commit();
|
||||
// doPrivileged calls a method that has the @Hidden
|
||||
// annotation
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
MyEvent event = new MyEvent();
|
||||
event.commit();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
MyEvent event = new MyEvent();
|
||||
event.commit();
|
||||
recording.stop();
|
||||
|
||||
List<RecordedEvent> events = Events.fromRecording(recording);
|
||||
|
Loading…
x
Reference in New Issue
Block a user