hotspot/test/runtime/ClassFile/JsrRewriting.java
author coleenp
Wed, 05 Apr 2017 01:11:25 +0000
changeset 46363 b53de34a044c
parent 40631 ed82623d7831
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
     2
 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     4
 *
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     7
 * published by the Free Software Foundation.
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     8
 *
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    13
 * accompanied this code).
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    14
 *
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    18
 *
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    21
 * questions.
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    22
 */
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    23
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    24
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    25
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    26
/*
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    27
 * @test JsrRewriting
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    28
 * @summary JSR (jump local subroutine)
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    29
 *      rewriting can overflow memory address size variables
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    30
 * @bug 7020373
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    31
 * @bug 7055247
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    32
 * @bug 7053586
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    33
 * @bug 7185550
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    34
 * @bug 7149464
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    35
 * @key cte_test
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    36
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 30604
diff changeset
    37
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 19971
diff changeset
    38
 *          java.desktop
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 19971
diff changeset
    39
 *          java.management
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    40
 * @run main JsrRewriting
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    41
 */
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    42
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    43
import jdk.test.lib.JDKToolFinder;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    44
import jdk.test.lib.Platform;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    45
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    46
import jdk.test.lib.process.OutputAnalyzer;
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    47
import java.io.File;
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    48
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    49
public class JsrRewriting {
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    50
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    51
    public static void main(String[] args) throws Exception {
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    52
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    53
        // ======= Configure the test
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    54
        String jarFile = System.getProperty("test.src") +
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    55
            File.separator + "JsrRewritingTestCase.jar";
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    56
        String className = "OOMCrashClass4000_1";
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    57
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    58
        // limit is 768MB in native words
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    59
        int mallocMaxTestWords = (1024 * 1024 * 768 / 4);
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    60
        if (Platform.is64bit())
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    61
            mallocMaxTestWords = (mallocMaxTestWords / 2);
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    62
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    63
        // ======= extract the test class
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    64
        ProcessBuilder pb = new ProcessBuilder(new String[] {
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    65
            JDKToolFinder.getJDKTool("jar"),
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    66
            "xvf", jarFile } );
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    67
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    68
        output.shouldHaveExitValue(0);
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    69
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    70
        // ======= execute the test
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    71
        pb = ProcessTools.createJavaProcessBuilder(
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    72
            "-cp", ".",
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    73
            "-XX:+UnlockDiagnosticVMOptions",
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    74
            "-XX:MallocMaxTestWords=" + mallocMaxTestWords,
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    75
            className);
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    76
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    77
        output = new OutputAnalyzer(pb.start());
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    78
        String[] expectedMsgs = {
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    79
            "java.lang.LinkageError",
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    80
            "java.lang.NoSuchMethodError",
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    81
            "Main method not found in class " + className,
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    82
            "insufficient memory"
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    83
        };
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    84
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    85
        MultipleOrMatch(output, expectedMsgs);
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    86
    }
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    87
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    88
    private static void
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    89
        MultipleOrMatch(OutputAnalyzer analyzer, String[] whatToMatch) {
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    90
            String output = analyzer.getOutput();
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    91
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    92
            for (String expected : whatToMatch)
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    93
                if (output.contains(expected))
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    94
                    return;
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    95
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    96
            String err =
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    97
                " stdout: [" + analyzer.getOutput() + "];\n" +
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    98
                " exitValue = " + analyzer.getExitValue() + "\n";
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    99
            System.err.println(err);
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   100
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   101
            StringBuilder msg = new StringBuilder("Output did not contain " +
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   102
                "any of the following expected messages: \n");
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   103
            for (String expected : whatToMatch)
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   104
                msg.append(expected).append(System.lineSeparator());
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   105
            throw new RuntimeException(msg.toString());
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   106
    }
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   107
}
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   108