Path: blob/master/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java
41154 views
/*1* Copyright (c) 2017, 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*/2223import java.io.File;2425/*26* @test27* @modules jdk.compiler28* @summary Test cases which run against customized image, check the situation where29* 1. logger providers are in unnamed module,30* 2. clients are in named/unnamed module, image,31* patched system module, or Xbootclasspath32* This test does not require existence of java.logging module,33* but require jdk.compiler module34* @library /test/lib35* @build Base jdk.test.lib.compiler.CompilerUtils36* @run main/othervm UnnamedLoggerForImageTest37*/3839public class UnnamedLoggerForImageTest extends Base {4041public static void main(String args[]) throws Throwable {42UnnamedLoggerForImageTest t = new UnnamedLoggerForImageTest();43t.setup();44t.test();45}4647private void setup() throws Throwable {48setupAllClient();4950setupUnnamedLogger();5152setupJavaBaseImage();53setupClientImage();54}5556private void test() throws Throwable {57if (!checkJMODS()) {58return;59}6061// logger client is in unnamed module62runTest(IMAGE,63"--class-path", DEST_UNNAMED_LOGGER.toString()64+ File.pathSeparator + DEST_UNNAMED_CLIENT.toString(),65CLIENT_B, "unnamed", LOGGER_B);66// logger client is in named module m.t.a67runTest(IMAGE,68"--class-path", DEST_UNNAMED_LOGGER.toString(),69"--module-path", DEST_NAMED_CLIENT.toString(),70"-m", CLIENT_A, "unnamed", LOGGER_B);71// logger client is in named module m.t.a which is in customized image72runTest(IMAGE_CLIENT,73"--class-path", DEST_UNNAMED_LOGGER.toString(),74"-m", CLIENT_A, "unnamed", LOGGER_B);75// logger client gets logger through boot class BootUsage76runTest(IMAGE,77"--class-path", DEST_UNNAMED_LOGGER.toString()78+ File.pathSeparator + DEST_BOOT_CLIENT.toString(),79"-Xbootclasspath/a:" + DEST_BOOT_USAGE.toString(),80BOOT_CLIENT, "system", LAZY_LOGGER, LOGGER_B);81// logger client gets logger through patched class82// java.base/java.lang.PatchedUsage83runTest(IMAGE,84"--class-path", DEST_UNNAMED_LOGGER.toString()85+ File.pathSeparator + DEST_PATCHED_CLIENT.toString(),86"--patch-module", "java.base=" + DEST_PATCHED_USAGE.toString(),87PATCHED_CLIENT, "system", LAZY_LOGGER, LOGGER_B);88}89}909192