--- old/common/autoconf/generated-configure.sh 2017-04-11 19:40:51.000000000 -0500 +++ new/common/autoconf/generated-configure.sh 2017-04-11 19:40:51.000000000 -0500 @@ -993,9 +993,8 @@ OPENJDK_TARGET_CPU_ISADIR OPENJDK_TARGET_CPU_LEGACY_LIB OPENJDK_TARGET_CPU_LEGACY -REQUIRED_OS_VERSION -REQUIRED_OS_ARCH -REQUIRED_OS_NAME +OPENJDK_MODULE_TARGET_OS_ARCH +OPENJDK_MODULE_TARGET_OS_NAME COMPILE_TYPE OPENJDK_TARGET_CPU_ENDIAN OPENJDK_TARGET_CPU_BITS @@ -5174,7 +5173,7 @@ #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1490856742 +DATE_WHEN_GENERATED=1491957642 ############################################################################### # @@ -16022,32 +16021,17 @@ $as_echo "$COMPILE_TYPE" >&6; } - if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then - REQUIRED_OS_NAME=SunOS - REQUIRED_OS_VERSION=5.10 - fi - if test "x$OPENJDK_TARGET_OS" = "xlinux"; then - REQUIRED_OS_NAME=Linux - REQUIRED_OS_VERSION=2.6 - fi - if test "x$OPENJDK_TARGET_OS" = "xwindows"; then - REQUIRED_OS_NAME=Windows - if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then - REQUIRED_OS_VERSION=5.2 - else - REQUIRED_OS_VERSION=5.1 - fi - fi - if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then - REQUIRED_OS_NAME="Mac OS X" - REQUIRED_OS_VERSION=11.2 - fi - if test "x$OPENJDK_TARGET_OS" = "xaix"; then - REQUIRED_OS_NAME=AIX - REQUIRED_OS_VERSION=7.1 + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + OPENJDK_MODULE_TARGET_OS_NAME="macos" + else + OPENJDK_MODULE_TARGET_OS_NAME="$OPENJDK_TARGET_OS" fi - REQUIRED_OS_ARCH=${OPENJDK_TARGET_CPU} + if test "x$OPENJDK_TARGET_CPU" = xx86_64; then + OPENJDK_MODULE_TARGET_OS_ARCH="amd64" + else + OPENJDK_MODULE_TARGET_OS_ARCH="$OPENJDK_TARGET_CPU" + fi --- old/common/autoconf/platform.m4 2017-04-11 19:40:55.000000000 -0500 +++ new/common/autoconf/platform.m4 2017-04-11 19:40:55.000000000 -0500 @@ -433,37 +433,22 @@ ]) -AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES], +AC_DEFUN([PLATFORM_SET_MODULE_TARGET_OS_VALUES], [ - if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then - REQUIRED_OS_NAME=SunOS - REQUIRED_OS_VERSION=5.10 - fi - if test "x$OPENJDK_TARGET_OS" = "xlinux"; then - REQUIRED_OS_NAME=Linux - REQUIRED_OS_VERSION=2.6 - fi - if test "x$OPENJDK_TARGET_OS" = "xwindows"; then - REQUIRED_OS_NAME=Windows - if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then - REQUIRED_OS_VERSION=5.2 - else - REQUIRED_OS_VERSION=5.1 - fi + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + OPENJDK_MODULE_TARGET_OS_NAME="macos" + else + OPENJDK_MODULE_TARGET_OS_NAME="$OPENJDK_TARGET_OS" fi - if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then - REQUIRED_OS_NAME="Mac OS X" - REQUIRED_OS_VERSION=11.2 - fi - if test "x$OPENJDK_TARGET_OS" = "xaix"; then - REQUIRED_OS_NAME=AIX - REQUIRED_OS_VERSION=7.1 - fi - REQUIRED_OS_ARCH=${OPENJDK_TARGET_CPU} - - AC_SUBST(REQUIRED_OS_NAME) - AC_SUBST(REQUIRED_OS_ARCH) - AC_SUBST(REQUIRED_OS_VERSION) + + if test "x$OPENJDK_TARGET_CPU" = xx86_64; then + OPENJDK_MODULE_TARGET_OS_ARCH="amd64" + else + OPENJDK_MODULE_TARGET_OS_ARCH="$OPENJDK_TARGET_CPU" + fi + + AC_SUBST(OPENJDK_MODULE_TARGET_OS_NAME) + AC_SUBST(OPENJDK_MODULE_TARGET_OS_ARCH) ]) #%%% Build and target systems %%% @@ -480,7 +465,7 @@ PLATFORM_EXTRACT_TARGET_AND_BUILD PLATFORM_SETUP_TARGET_CPU_BITS - PLATFORM_SET_RELEASE_FILE_OS_VALUES + PLATFORM_SET_MODULE_TARGET_OS_VALUES PLATFORM_SETUP_LEGACY_VARS ]) --- old/common/autoconf/spec.gmk.in 2017-04-11 19:40:55.000000000 -0500 +++ new/common/autoconf/spec.gmk.in 2017-04-11 19:40:55.000000000 -0500 @@ -101,10 +101,9 @@ OPENJDK_BUILD_CPU_BITS:=@OPENJDK_BUILD_CPU_BITS@ OPENJDK_BUILD_CPU_ENDIAN:=@OPENJDK_BUILD_CPU_ENDIAN@ -# OS values for use in release file. -REQUIRED_OS_NAME:=@REQUIRED_OS_NAME@ -REQUIRED_OS_ARCH:=@REQUIRED_OS_ARCH@ -REQUIRED_OS_VERSION:=@REQUIRED_OS_VERSION@ +# OS values for use in ModuleTarget class file attribute. +OPENJDK_MODULE_TARGET_OS_NAME:=@OPENJDK_MODULE_TARGET_OS_NAME@ +OPENJDK_MODULE_TARGET_OS_ARCH:=@OPENJDK_MODULE_TARGET_OS_ARCH@ LIBM:=@LIBM@ LIBDL:=@LIBDL@ --- old/make/CreateJmods.gmk 2017-04-11 19:40:56.000000000 -0500 +++ new/make/CreateJmods.gmk 2017-04-11 19:40:56.000000000 -0500 @@ -135,8 +135,8 @@ $(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@) $(JMOD) create \ --module-version $(VERSION_SHORT) \ - --os-name '$(REQUIRED_OS_NAME)' \ - --os-arch '$(REQUIRED_OS_ARCH)' \ + --os-name '$(OPENJDK_MODULE_TARGET_OS_NAME)' \ + --os-arch '$(OPENJDK_MODULE_TARGET_OS_ARCH)' \ --module-path $(JMODS_DIR) \ --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \ $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@) --- old/make/Images.gmk 2017-04-11 19:40:56.000000000 -0500 +++ new/make/Images.gmk 2017-04-11 19:40:56.000000000 -0500 @@ -119,7 +119,6 @@ --module-path $(IMAGES_OUTPUTDIR)/jmods \ --endian $(OPENJDK_BUILD_CPU_ENDIAN) \ --release-info $(BASE_RELEASE_FILE) \ - --release-info add:OS_VERSION=\"$(REQUIRED_OS_VERSION)\" \ --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \ --dedup-legal-notices=error-if-not-same-content \ $(JLINK_JLI_CLASSES) \ --- old/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java 2017-04-11 19:40:57.000000000 -0500 +++ new/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java 2017-04-11 19:40:57.000000000 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,6 +59,7 @@ import jdk.tools.jlink.internal.BasicImageWriter; import jdk.tools.jlink.internal.ExecutableImage; +import jdk.tools.jlink.internal.Platform; import jdk.tools.jlink.plugin.ResourcePool; import jdk.tools.jlink.plugin.ResourcePoolEntry; import jdk.tools.jlink.plugin.ResourcePoolEntry.Type; @@ -133,7 +134,7 @@ private final Map launchers; private final Path mdir; private final Set modules = new HashSet<>(); - private String targetOsName; + private Platform targetPlatform; /** * Default image builder constructor. @@ -151,11 +152,14 @@ @Override public void storeFiles(ResourcePool files) { try { - this.targetOsName = files.moduleView(). - findModule("java.base").get().osName(); - if (this.targetOsName == null) { + String targetOsName = files.moduleView() + .findModule("java.base") + .map(ResourcePoolModule::osName) + .orElse(null); + if (targetOsName == null) { throw new PluginException("ModuleTarget attribute is missing for java.base module"); } + this.targetPlatform = Platform.toPlatform(targetOsName); checkResourcePool(files); @@ -476,7 +480,7 @@ } private boolean isWindows() { - return targetOsName.startsWith("Windows"); + return targetPlatform == Platform.WINDOWS; } /** --- old/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java 2017-04-11 19:40:57.000000000 -0500 +++ new/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java 2017-04-11 19:40:57.000000000 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,8 @@ import java.util.TreeSet; import java.util.function.Predicate; import java.util.stream.Collectors; + +import jdk.tools.jlink.internal.Platform; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.ResourcePool; import jdk.tools.jlink.plugin.ResourcePoolBuilder; @@ -115,7 +117,7 @@ @Override public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) { ResourcePoolModule javaBase = in.moduleView().findModule("java.base").get(); - String[] jvmlibs = jvmlibs(javaBase.osName()); + String[] jvmlibs = jvmlibs(javaBase); TreeSet existing = new TreeSet<>(new JvmComparator()); TreeSet removed = new TreeSet<>(new JvmComparator()); if (!keepAll) { @@ -257,21 +259,15 @@ return orig.copyWithContent(content); } - private static String[] jvmlibs(String osName) { - if (isWindows(osName)) { - return new String[] { "jvm.dll" }; - } else if (isMac(osName)) { - return new String[] { "libjvm.dylib", "libjvm.a" }; - } else { - return new String[] { "libjvm.so", "libjvm.a" }; + private static String[] jvmlibs(ResourcePoolModule module) { + Platform platform = Platform.getTargetPlatform(module); + switch (platform) { + case WINDOWS: + return new String[] { "jvm.dll" }; + case MACOS: + return new String[] { "libjvm.dylib", "libjvm.a" }; + default: + return new String[] { "libjvm.so", "libjvm.a" }; } } - - private static boolean isWindows(String osName) { - return osName.startsWith("Windows"); - } - - private static boolean isMac(String osName) { - return osName.startsWith("Mac OS") || osName.startsWith("Darwin"); - } } --- /dev/null 2017-04-11 19:40:58.000000000 -0500 +++ new/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Platform.java 2017-04-11 19:40:58.000000000 -0500 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.tools.jlink.internal; + +import jdk.tools.jlink.plugin.ResourcePoolModule; + +import java.util.Locale; + +/** + * Supported platforms + */ +public enum Platform { + WINDOWS, + LINUX, + SOLARIS, + MACOS, + AIX, + UNKNOWN; + + /** + * Returns the {@code Platform} of the given OS name specified + * in the {@code ModuleTarget} attribute. + * + * @param osName OS name in ModuleTarget attribute + */ + public static Platform toPlatform(String osName) { + try { + return Platform.valueOf(osName.toUpperCase(Locale.ENGLISH)); + } catch (IllegalArgumentException e) { + return Platform.UNKNOWN; + } + } + + /** + * Returns the {@code Platform} to which the given module is target to. + */ + public static Platform getTargetPlatform(ResourcePoolModule module) { + String osName = module.osName(); + if (osName != null) { + return toPlatform(osName); + } else { + return Platform.UNKNOWN; + } + } +} --- old/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java 2017-04-11 19:40:59.000000000 -0500 +++ new/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java 2017-04-11 19:40:58.000000000 -0500 @@ -71,17 +71,23 @@ .forEach(this::checkAttributes); } - // JMOD files are created with osName and osArch that may be different - // than os.name and os.arch system property + // JMOD files are created with OS name and arch matching the bundle name private boolean checkOSName(String name) { - if (name.equals(OS_NAME)) - return true; - if (OS_NAME.startsWith("Windows")) { - return name.startsWith("Windows"); - } else { - System.err.println("ERROR: " + name + " but expected: " + OS_NAME); - return false; + return name.equals("windows"); + } + + switch (OS_NAME) { + case "Linux": + return name.equals("linux"); + case "SunOS": + return name.equals("solaris"); + case "Mac OS X": + return name.equals("macos"); + default: + // skip validation on unknown platform + System.out.println("Skip checking OS name in ModuleTarget: " + name); + return true; } } @@ -94,10 +100,12 @@ case "x86": return name.equals("x86"); case "amd64": - return name.equals("x86_64"); + case "x86_64": + return name.equals("amd64"); default: - System.err.println("ERROR: " + name + " but expected: " + OS_ARCH); - return false; + // skip validation on unknown platform + System.out.println("Skip checking OS arch in ModuleTarget: " + name); + return true; } }