Path: blob/master/test/jdk/java/lang/ClassLoader/ExtDirs.java
41149 views
/*1* Copyright (c) 2014, 2018, 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/*24* @test25* @bug 8060206 806736626* @library /test/lib27* @summary Extension mechanism is removed28*/2930import jdk.test.lib.process.ProcessTools;3132import java.lang.Integer;33import java.util.stream.Stream;3435public class ExtDirs {36private static String TEST_CLASSES = System.getProperty("test.classes", ".");3738private static String[] VALUES = new String[] {39null,40"",41"\"\""42};4344public static void main(String... args) throws Exception {45String value = System.getProperty("java.ext.dirs");46System.out.format("java.ext.dirs = '%s'%n", value);47if (args.length > 0) {48int index = Integer.valueOf(args[0]);49String expectedValue = VALUES[index];50if (!(expectedValue == value ||51(value != null && value.isEmpty()) ||52(expectedValue != null & expectedValue.equals(value)))) {53throw new RuntimeException("java.ext.dirs (" +54value + ") != " + expectedValue);55}56// launched by subprocess.57return;58}5960if (value != null) {61throw new RuntimeException("java.ext.dirs not removed: " + value);62}6364fatalError(0, "-Djava.ext.dirs=foo");65start(0);66start(1, "-Djava.ext.dirs=");67start(2, "-Djava.ext.dirs=\"\"");68}6970static String[] launchOptions(int testParam, String... args) {71return Stream.concat(Stream.of(args),72Stream.of("-cp", TEST_CLASSES, "ExtDirs",73String.valueOf(testParam)))74.toArray(String[]::new);75}7677static void start(int testParam, String... args) throws Exception {78ProcessTools.executeTestJava(launchOptions(testParam, args))79.shouldHaveExitValue(0);80}8182static void fatalError(int testParam, String... args) throws Exception {83ProcessTools.executeTestJava(launchOptions(testParam, args))84.stderrShouldContain("Could not create the Java Virtual Machine");85}86}878889