hotspot/test/runtime/ClassFile/JsrRewriting.java
author jjg
Sun, 20 Oct 2013 12:01:43 -0700
changeset 21480 9d08c2d0fafd
parent 19971 37d89625f15c
child 29678 dd2f3932c21e
permissions -rw-r--r--
8025109: Better encapsulation for AnnotatedType Reviewed-by: jjg Contributed-by: wdietl@gmail.com
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
/*
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
     2
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
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
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    36
 * @library /testlibrary
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    37
 * @run main JsrRewriting
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    38
 */
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    39
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    40
import com.oracle.java.testlibrary.*;
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    41
import java.io.File;
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    42
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    43
public class JsrRewriting {
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    44
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    45
    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
    46
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    47
        // ======= Configure the test
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    48
        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
    49
            File.separator + "JsrRewritingTestCase.jar";
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    50
        String className = "OOMCrashClass4000_1";
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    51
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    52
        // 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
    53
        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
    54
        if (Platform.is64bit())
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    55
            mallocMaxTestWords = (mallocMaxTestWords / 2);
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    56
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    57
        // ======= extract the test class
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    58
        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
    59
            JDKToolFinder.getJDKTool("jar"),
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    60
            "xvf", jarFile } );
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    61
        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
    62
        output.shouldHaveExitValue(0);
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    63
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    64
        // ======= execute the test
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    65
        pb = ProcessTools.createJavaProcessBuilder(
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    66
            "-cp", ".",
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    67
            "-XX:+UnlockDiagnosticVMOptions",
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    68
            "-XX:MallocMaxTestWords=" + mallocMaxTestWords,
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    69
            className);
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents:
diff changeset
    70
19971
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    71
        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
    72
        String[] expectedMsgs = {
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    73
            "java.lang.LinkageError",
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    74
            "java.lang.NoSuchMethodError",
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    75
            "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
    76
            "insufficient memory"
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    77
        };
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    78
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    79
        MultipleOrMatch(output, expectedMsgs);
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    80
    }
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    81
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    82
    private static void
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    83
        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
    84
            String output = analyzer.getOutput();
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    85
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    86
            for (String expected : whatToMatch)
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    87
                if (output.contains(expected))
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    88
                    return;
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    89
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    90
            String err =
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    91
                " stdout: [" + analyzer.getOutput() + "];\n" +
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    92
                " exitValue = " + analyzer.getExitValue() + "\n";
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    93
            System.err.println(err);
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    94
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    95
            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
    96
                "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
    97
            for (String expected : whatToMatch)
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
    98
                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
    99
            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
   100
    }
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   101
}
37d89625f15c 7149464: [TESTBUG] Test runtime/7020373/Test7020373.sh failed to clean up files after test
mseledtsov
parents: 16457
diff changeset
   102