test/hotspot/jtreg/runtime/BadObjectClass/BootstrapRedefine.java
author prr
Thu, 26 Jul 2018 10:00:40 -0700
changeset 51251 0a7a0a6dfa22
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28373
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
     1
/*
46790
8c4deba6a0ee 8177741: Fix hotspot tests to use --patch-module instead of -Xmodule
hseigel
parents: 45112
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
28373
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
     4
 *
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
     8
 *
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    13
 * accompanied this code).
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    14
 *
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    18
 *
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    21
 * questions.
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    22
 */
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    23
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    24
/*
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    25
 * @test
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    26
 * @bug 6583051
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    27
 * @summary Give error if java.lang.Object has been incompatibly overridden on the bootpath
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    28
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 36508
diff changeset
    29
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28373
diff changeset
    30
 *          java.management
28373
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    31
 * @run main BootstrapRedefine
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    32
 */
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    33
45112
fbec2bfa3839 8180037: move jdk.test.lib.InMemoryJavaCompiler to a separate package
iignatyev
parents: 40631
diff changeset
    34
import jdk.test.lib.compiler.InMemoryJavaCompiler;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    35
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    36
import jdk.test.lib.process.OutputAnalyzer;
28373
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    37
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    38
public class BootstrapRedefine {
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    39
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    40
    public static void main(String[] args) throws Exception {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    41
        String source = "package java.lang;" +
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    42
                        "public class Object {" +
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    43
                        "    void dummy1() { return; }" +
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    44
                        "    void dummy2() { return; }" +
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    45
                        "    void dummy3() { return; }" +
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    46
                        "}";
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    47
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    48
        ClassFileInstaller.writeClassToDisk("java/lang/Object",
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    49
                                        InMemoryJavaCompiler.compile("java.lang.Object", source,
46790
8c4deba6a0ee 8177741: Fix hotspot tests to use --patch-module instead of -Xmodule
hseigel
parents: 45112
diff changeset
    50
                                        "--patch-module=java.base"),
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    51
                                        "mods/java.base");
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 30604
diff changeset
    52
40244
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 37773
diff changeset
    53
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base", "-version");
28373
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    54
        new OutputAnalyzer(pb.start())
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    55
            .shouldContain("Incompatible definition of java.lang.Object")
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    56
            .shouldHaveExitValue(1);
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    57
    }
26fdc99d32f8 6583051: crash when adding non-static methods to java.lang.Object class
coleenp
parents:
diff changeset
    58
}