hotspot/test/runtime/RedefineObject/TestRedefineObject.java
author coleenp
Mon, 13 May 2013 15:37:08 -0400
changeset 17373 7d8bb2a8787e
child 17599 0f82292a2644
permissions -rw-r--r--
8005056: NPG: Crash after redefining java.lang.Object Summary: Need to walk array class vtables replacing old methods too if j.l.o redefined Reviewed-by: sspitsyn, dcubed, ctornqvi
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17373
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     1
/*
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     4
 *
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     8
 *
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    13
 * accompanied this code).
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    14
 *
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    18
 *
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    21
 * questions.
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    22
 */
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    23
import java.io.PrintWriter;
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    24
import com.oracle.java.testlibrary.*;
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    25
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    26
/*
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    27
 * Test to redefine java/lang/Object and verify that it doesn't crash on vtable
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    28
 * call on basic array type.
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    29
 *
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    30
 * @test
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    31
 * @bug 8005056
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    32
 * @library /testlibrary
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    33
 * @build Agent
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    34
 * @run main ClassFileInstaller Agent
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    35
 * @run main Test
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    36
 * @run main/othervm -javaagent:agent.jar Agent
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    37
 */
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    38
public class Test {
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception  {
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    40
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    41
      PrintWriter pw = new PrintWriter("MANIFEST.MF");
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    42
      pw.println("Premain-Class: Agent");
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    43
      pw.println("Can-Retransform-Classes: true");
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    44
      pw.close();
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    45
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    46
      ProcessBuilder pb = new ProcessBuilder();
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    47
      pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "Agent.class"});
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    48
      pb.start().waitFor();
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    49
    }
7d8bb2a8787e 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents:
diff changeset
    50
}