9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @modules java.base/jdk.internal.misc 27 * @modules java.base/jdk.internal.loader 28 * java.desktop 29 * @library /testlibrary 30 * @run main/othervm GetSysPkgTest 31 */ 32 33 import java.io.File; 34 import java.lang.reflect.InvocationTargetException; 35 import java.lang.reflect.Method; 36 import jdk.test.lib.*; 37 38 // Test that JVM get_system_package() returns the module location for defined packages. 39 public class GetSysPkgTest { 40 41 private static Object invoke(Method m, Object obj, Object... args) throws Throwable { 42 try { 43 return m.invoke(obj, args); 44 } catch (InvocationTargetException e) { 45 throw e.getCause(); 46 } 47 } 48 49 private static Method findMethod(String name) { 50 for (Method m : jdk.internal.loader.BootLoader.class.getDeclaredMethods()) { 51 if (m.getName().equals(name)) { 52 m.setAccessible(true); 53 return m; 54 } 55 } 56 throw new RuntimeException("Failed to find method " + name + " in java.lang.reflect.Module"); | 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @modules java.base/jdk.internal.misc 27 * @modules java.base/jdk.internal.loader 28 * java.desktop 29 * @library /test/lib 30 * @run main/othervm GetSysPkgTest 31 */ 32 33 import java.io.File; 34 import java.lang.reflect.InvocationTargetException; 35 import java.lang.reflect.Method; 36 import jdk.test.lib.InMemoryJavaCompiler; 37 import jdk.test.lib.process.ProcessTools; 38 import jdk.test.lib.process.OutputAnalyzer; 39 40 // Test that JVM get_system_package() returns the module location for defined packages. 41 public class GetSysPkgTest { 42 43 private static Object invoke(Method m, Object obj, Object... args) throws Throwable { 44 try { 45 return m.invoke(obj, args); 46 } catch (InvocationTargetException e) { 47 throw e.getCause(); 48 } 49 } 50 51 private static Method findMethod(String name) { 52 for (Method m : jdk.internal.loader.BootLoader.class.getDeclaredMethods()) { 53 if (m.getName().equals(name)) { 54 m.setAccessible(true); 55 return m; 56 } 57 } 58 throw new RuntimeException("Failed to find method " + name + " in java.lang.reflect.Module"); |