test/hotspot/jtreg/serviceability/jvmti/GetSystemProperty/JvmtiGetSystemPropertyTest.java
author cjplummer
Thu, 07 Jun 2018 19:01:18 -0700
changeset 50456 cb75455ada5a
permissions -rw-r--r--
8203329: JDWP/JDI VM information string is incorrect Summary: make sure the native java.vm.info property also gets updated when the java version is. Reviewed-by: sspitsyn, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50456
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     1
/*
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     4
 *
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     8
 *
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    13
 * accompanied this code).
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    14
 *
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    18
 *
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    21
 * questions.
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    22
 */
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    23
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    24
/**
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    25
 * @test
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    26
 * @bug 8203329
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    27
 * @summary Verifies the JVMTI GetSystemProperty API returns the updated java.vm.info value
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    28
 * @library /test/lib
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    29
 * @run main/othervm/native -agentlib:JvmtiGetSystemPropertyTest JvmtiGetSystemPropertyTest
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    30
 *
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    31
 */
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    32
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    33
public class JvmtiGetSystemPropertyTest {
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    34
    private static native String getSystemProperty();
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    35
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    37
        String vm_info = System.getProperty("java.vm.info");
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    38
        String vm_info_jvmti = getSystemProperty();
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    39
        System.out.println("java.vm.info from java:  " + vm_info);
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    40
        System.out.println("java.vm.info from jvmti: " + vm_info_jvmti);
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    41
        if (!vm_info.equals(vm_info_jvmti)) {
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    42
            throw new RuntimeException("java.vm.info poperties not equal: \"" +
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    43
                                       vm_info + "\" != \"" + vm_info_jvmti + "\"");
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    44
        }
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    45
    }
cb75455ada5a 8203329: JDWP/JDI VM information string is incorrect
cjplummer
parents:
diff changeset
    46
}