AddModuleExportsAndOpensTest.java revision 12290:8953c0318163
154359Sroberto/* 254359Sroberto * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 354363Sroberto * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4132454Sroberto * 5132454Sroberto * This code is free software; you can redistribute it and/or modify it 654359Sroberto * under the terms of the GNU General Public License version 2 only, as 754359Sroberto * published by the Free Software Foundation. 854359Sroberto * 954359Sroberto * This code is distributed in the hope that it will be useful, but WITHOUT 1054359Sroberto * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1154359Sroberto * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1254359Sroberto * version 2 for more details (a copy is included in the LICENSE file that 1354359Sroberto * accompanied this code). 1454359Sroberto * 1554359Sroberto * You should have received a copy of the GNU General Public License version 16285612Sdelphij * 2 along with this work; if not, write to the Free Software Foundation, 17285612Sdelphij * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18293650Sglebius * 1954359Sroberto * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2082505Sroberto * or visit www.oracle.com if you need additional information or have any 21285612Sdelphij * questions. 22285612Sdelphij */ 2354359Sroberto 24285612Sdelphijpackage MyPackage; 25285612Sdelphij 2654359Sroberto/** 2754359Sroberto * @test 28298770Sdelphij * @summary Verifies the JVMTI AddModuleExports and AddModuleOpens API 29298770Sdelphij * @compile AddModuleExportsAndOpensTest.java 30298770Sdelphij * @run main/othervm/native -agentlib:AddModuleExportsAndOpensTest MyPackage.AddModuleExportsAndOpensTest 31298770Sdelphij */ 32298770Sdelphij 3354359Srobertoimport java.io.PrintStream; 34182007Srobertoimport java.lang.reflect.Module; 35182007Sroberto 36182007Srobertopublic class AddModuleExportsAndOpensTest { 37289997Sglebius 38289997Sglebius static { 39182007Sroberto try { 40285612Sdelphij System.loadLibrary("AddModuleExportsAndOpensTest"); 41285612Sdelphij } catch (UnsatisfiedLinkError ule) { 42285612Sdelphij System.err.println("Could not load AddModuleExportsAndOpensTest library"); 43285612Sdelphij System.err.println("java.library.path: " 44285612Sdelphij + System.getProperty("java.library.path")); 45182007Sroberto throw ule; 46289997Sglebius } 47289997Sglebius } 48289997Sglebius 49289997Sglebius native static int check(Module baseModule, Module thisModule); 50289997Sglebius 51289997Sglebius public static void main(String args[]) { 52289997Sglebius Module baseModule = Object.class.getModule(); 53289997Sglebius Module thisModule = AddModuleExportsAndOpensTest.class.getClassLoader().getUnnamedModule(); 54289997Sglebius int status = check(baseModule, thisModule); 55289997Sglebius if (status != 0) { 56289997Sglebius throw new RuntimeException("Non-zero status returned from the agent: " + status); 57289997Sglebius } 58298770Sdelphij } 59298770Sdelphij} 60298770Sdelphij