hotspot/test/serviceability/jvmti/AddModuleExportsAndOpens/MyPackage/AddModuleExportsAndOpensTest.java
author alanb
Fri, 07 Apr 2017 08:04:46 +0000
changeset 44520 0553e129e0ec
parent 42307 cefc81dc1d52
permissions -rw-r--r--
8177530: Module system implementation refresh (4/2017) Reviewed-by: lfoltan, sspitsyn Contributed-by: alan.bateman@oracle.com, harold.seigel@oracle.com, mandy.chung@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42307
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     1
/*
44520
0553e129e0ec 8177530: Module system implementation refresh (4/2017)
alanb
parents: 42307
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
42307
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     4
 *
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     8
 *
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    13
 * accompanied this code).
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    14
 *
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    18
 *
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    21
 * questions.
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    22
 */
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    23
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    24
package MyPackage;
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    25
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    26
/**
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    27
 * @test
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    28
 * @summary Verifies the JVMTI AddModuleExports and AddModuleOpens API
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    29
 * @compile AddModuleExportsAndOpensTest.java
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    30
 * @run main/othervm/native -agentlib:AddModuleExportsAndOpensTest MyPackage.AddModuleExportsAndOpensTest
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    31
 */
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    32
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    33
import java.io.PrintStream;
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    34
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    35
public class AddModuleExportsAndOpensTest {
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    36
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    37
    static {
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    38
        try {
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    39
            System.loadLibrary("AddModuleExportsAndOpensTest");
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    40
        } catch (UnsatisfiedLinkError ule) {
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    41
            System.err.println("Could not load AddModuleExportsAndOpensTest library");
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    42
            System.err.println("java.library.path: "
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    43
                + System.getProperty("java.library.path"));
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    44
            throw ule;
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    45
        }
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    46
    }
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    47
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    48
    native static int check(Module baseModule, Module thisModule);
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    49
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    50
    public static void main(String args[]) {
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    51
        Module baseModule = Object.class.getModule();
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    52
        Module thisModule = AddModuleExportsAndOpensTest.class.getClassLoader().getUnnamedModule();
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    53
        int status = check(baseModule, thisModule);
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    54
        if (status != 0) {
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    55
            throw new RuntimeException("Non-zero status returned from the agent: " + status);
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    56
        }
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    57
    }
cefc81dc1d52 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    58
}