hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java
author dsamersoff
Fri, 10 Apr 2015 05:22:56 -0700
changeset 30235 000cc9f42b61
parent 29678 dd2f3932c21e
child 30604 b8d532cb6420
permissions -rw-r--r--
8044416: serviceability/sa/jmap-hashcode/Test8028623.java fails with AssertionFailure: can not get class data for java/lang/UNIXProcess$Platform$$Lambda Summary: Lambda object is not counted when SA builds class data cache but is reached inside live region. Reviewed-by: sla, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22525
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28015
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
22525
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
     4
 *
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
     8
 *
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    13
 * accompanied this code).
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    14
 *
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    18
 *
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    21
 * questions.
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    22
 */
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    23
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    24
/*
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    25
 * @test
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    26
 * @bug 8028623
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    27
 * @summary Test hashing of extended characters in Serviceability Agent.
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    28
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28015
diff changeset
    29
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28015
diff changeset
    30
 *          java.compiler
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28015
diff changeset
    31
 *          java.management
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28015
diff changeset
    32
 *          jdk.jvmstat/sun.jvmstat.monitor
24835
be963975e2f7 8043915: Tests get ClassNotFoundException: com.oracle.java.testlibrary.StreamPumper
ykantser
parents: 22529
diff changeset
    33
 * @build com.oracle.java.testlibrary.*
22529
4db9ba24613d 8032466: serviceability/sa/jmap-hashcode/Test8028623.java fails with compilation errors
kevinw
parents: 22525
diff changeset
    34
 * @compile -encoding utf8 Test8028623.java
4db9ba24613d 8032466: serviceability/sa/jmap-hashcode/Test8028623.java fails with compilation errors
kevinw
parents: 22525
diff changeset
    35
 * @run main Test8028623
22525
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    36
 */
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    37
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    38
import com.oracle.java.testlibrary.JDKToolLauncher;
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    39
import com.oracle.java.testlibrary.OutputBuffer;
27882
ceece07bef14 8039995: Test serviceability/sa/jmap-hashcode/Test8028623.java fails on some Linux/Mac machines.
kevinw
parents: 25050
diff changeset
    40
import com.oracle.java.testlibrary.Platform;
22525
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    41
import com.oracle.java.testlibrary.ProcessTools;
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    42
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    43
import java.io.File;
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    44
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    45
public class Test8028623 {
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    46
28015
91c0f12618bf 8061785: [TEST_BUG] serviceability/sa/jmap-hashcode/Test8028623.java has utf8 character corrupted by earlier merge
kevinw
parents: 27882
diff changeset
    47
  public static int \u00CB = 1;
22525
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    48
  public static String dumpFile = "heap.out";
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    49
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    50
  public static void main (String[] args) {
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    51
28015
91c0f12618bf 8061785: [TEST_BUG] serviceability/sa/jmap-hashcode/Test8028623.java has utf8 character corrupted by earlier merge
kevinw
parents: 27882
diff changeset
    52
    System.out.println(\u00CB);
22525
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    53
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    54
    try {
27882
ceece07bef14 8039995: Test serviceability/sa/jmap-hashcode/Test8028623.java fails on some Linux/Mac machines.
kevinw
parents: 25050
diff changeset
    55
        if (!Platform.shouldSAAttach()) {
ceece07bef14 8039995: Test serviceability/sa/jmap-hashcode/Test8028623.java fails on some Linux/Mac machines.
kevinw
parents: 25050
diff changeset
    56
            System.out.println("SA attach not expected to work - test skipped.");
ceece07bef14 8039995: Test serviceability/sa/jmap-hashcode/Test8028623.java fails on some Linux/Mac machines.
kevinw
parents: 25050
diff changeset
    57
            return;
ceece07bef14 8039995: Test serviceability/sa/jmap-hashcode/Test8028623.java fails on some Linux/Mac machines.
kevinw
parents: 25050
diff changeset
    58
        }
22525
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    59
        int pid = ProcessTools.getProcessId();
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    60
        JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    61
                                              .addToolArg("-F")
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    62
                                              .addToolArg("-dump:live,format=b,file=" + dumpFile)
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    63
                                              .addToolArg(Integer.toString(pid));
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    64
        ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    65
        OutputBuffer output = ProcessTools.getOutput(pb);
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    66
        Process p = pb.start();
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    67
        int e = p.waitFor();
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    68
        System.out.println("stdout:");
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    69
        System.out.println(output.getStdout());
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    70
        System.out.println("stderr:");
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    71
        System.out.println(output.getStderr());
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    72
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    73
        if (e != 0) {
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    74
            throw new RuntimeException("jmap returns: " + e);
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    75
        }
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    76
        if (! new File(dumpFile).exists()) {
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    77
            throw new RuntimeException("dump file NOT created: '" + dumpFile + "'");
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    78
        }
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    79
    } catch (Throwable t) {
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    80
        t.printStackTrace();
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    81
        throw new RuntimeException("Test failed with: " + t);
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    82
    }
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    83
  }
7d87b35a87f2 8028623: SA: hash codes in SymbolTable mismatching java_lang_String::hash_code for extended characters.
kevinw
parents:
diff changeset
    84
}