Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/lang/ClassLoader/FindLibrary.java
38821 views
/*1* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test24@bug 818120525@summary JRE fails to load/register security providers when started from UNC pathname26*/2728import java.io.File;29import java.lang.reflect.Method;30import java.lang.reflect.Constructor;3132public class FindLibrary {33public static void main(String[] args) throws Exception {34// this test is most relevant to windows. should pass silently on35// other OSes3637Class<?> innerClazz = Class.forName("sun.misc.Launcher$ExtClassLoader");38Class<?>[] ctorArgTypes = {File[].class};3940File tmpFile = new File(System.getProperty("java.home"));41File[] f = new File[1];42String uncFileName = "\\\\127.0.0.1\\" + tmpFile.getAbsolutePath().replace(':', '$');43System.out.println("Testing UNC path of :" + uncFileName);4445f[0] = new File(uncFileName); // a UNC path that must exist46Object[] ctorArgs = {f};47Constructor constructor = innerClazz.getDeclaredConstructor(File[].class);48constructor.setAccessible(true);49Object o = constructor.newInstance(ctorArgs);50Method m = innerClazz.getMethod("findLibrary", String.class);51m.setAccessible(true);52//buggy JDK will throw IllegalArgumentException with next call53m.invoke(o, "test");54}55}565758