test/jdk/jdk/jfr/event/io/EvilInstrument.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 51214 67736b4846a0
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    36 import java.lang.instrument.Instrumentation;
    36 import java.lang.instrument.Instrumentation;
    37 import java.net.ServerSocket;
    37 import java.net.ServerSocket;
    38 import java.net.Socket;
    38 import java.net.Socket;
    39 import java.security.ProtectionDomain;
    39 import java.security.ProtectionDomain;
    40 import java.util.concurrent.CountDownLatch;
    40 import java.util.concurrent.CountDownLatch;
       
    41 import jdk.test.lib.Utils;
    41 
    42 
    42 
    43 
    43 /**
    44 /**
    44  * @test
    45  * @test
    45  * @key jfr
    46  * @key jfr
    49  * @requires vm.hasJFR
    50  * @requires vm.hasJFR
    50  *
    51  *
    51  * @library /test/lib /test/jdk
    52  * @library /test/lib /test/jdk
    52  * @modules java.instrument
    53  * @modules java.instrument
    53  *
    54  *
       
    55  * @build jdk.jfr.event.io.EvilInstrument
    54  * @run shell MakeJAR.sh EvilInstrument 'Can-Redefine-Classes: true'
    56  * @run shell MakeJAR.sh EvilInstrument 'Can-Redefine-Classes: true'
    55  * @run main/othervm -javaagent:EvilInstrument.jar jdk.jfr.event.io.EvilInstrument
    57  * @run main/othervm -javaagent:EvilInstrument.jar jdk.jfr.event.io.EvilInstrument
    56  */
    58  */
    57 
    59 
    58 public class EvilInstrument {
    60 public class EvilInstrument {
    85             }
    87             }
    86         }
    88         }
    87     }
    89     }
    88 
    90 
    89     public static File createScratchFile() throws IOException {
    91     public static File createScratchFile() throws IOException {
    90         return File.createTempFile("EvilTransformer", null, new File(".")).getAbsoluteFile();
    92         return Utils.createTempFile("EvilTransformer", null).toFile();
    91     }
    93     }
    92 
    94 
    93     class EvilTransformer implements ClassFileTransformer {
    95     class EvilTransformer implements ClassFileTransformer {
    94         File scratch;
    96         File scratch;
    95         Socket s;
    97         Socket s;