8204973: Add build support for filtering translations
authorerikj
Fri, 15 Jun 2018 09:53:28 -0700
changeset 50590 5fa19bad622d
parent 50589 e5d741569070
child 50591 9f4c08c444e8
8204973: Add build support for filtering translations Reviewed-by: ihse, naoto, dfuchs
make/CompileJavaModules.gmk
make/ZipSource.gmk
make/autoconf/configure.ac
make/autoconf/jdk-options.m4
make/autoconf/spec.gmk.in
make/common/JavaCompilation.gmk
make/common/MakeBase.gmk
make/common/ZipArchive.gmk
make/conf/jib-profiles.js
make/gensrc/Gensrc-jdk.localedata.gmk
make/gensrc/GensrcCommonLangtools.gmk
make/gensrc/GensrcProperties.gmk
test/jdk/TEST.ROOT
test/jdk/TEST.groups
test/jdk/build/releaseFile/CheckSource.java
test/jdk/build/translations/VerifyTranslations.java
test/jdk/java/util/logging/LocalizedLevelName.java
test/jdk/sanity/releaseFile/CheckSource.java
test/jtreg-ext/requires/VMProps.java
--- a/make/CompileJavaModules.gmk	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/CompileJavaModules.gmk	Fri Jun 15 09:53:28 2018 -0700
@@ -519,6 +519,7 @@
 # Exclude BreakIterator classes that are just used in compile process to generate
 # data files and shouldn't go in the product
 jdk.localedata_EXCLUDE_FILES += sun/text/resources/ext/BreakIteratorRules_th.java
+jdk.localedata_KEEP_ALL_TRANSLATIONS := true
 ################################################################################
 
 # There is an issue in sjavac that triggers a warning in jdk.jfr that isn't
--- a/make/ZipSource.gmk	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/ZipSource.gmk	Fri Jun 15 09:53:28 2018 -0700
@@ -68,6 +68,17 @@
 # Only evaluate the creation of src.zip in a sub make call when the symlinked
 # src directory structure has been generated.
 ifeq ($(SRC_GENERATED), true)
+
+  # Rewrite the EXCLUDE_TRANSLATIONS locales as exclude patters for java files
+  TRANSLATIONS_PATTERN := $(addprefix %_, $(addsuffix .java, $(EXCLUDE_TRANSLATIONS)))
+
+  # Add excludes for translations for all modules except jdk.localedata
+  $(foreach s, $(SRC_ZIP_SRCS), \
+    $(if $(filter $(notdir $s), jdk.localedata), , \
+      $(eval BUILD_SRC_ZIP_EXCLUDE_PATTERNS_$(dir $s) := $$(TRANSLATIONS_PATTERN)) \
+    ) \
+  )
+
   $(eval $(call SetupZipArchive, BUILD_SRC_ZIP, \
       SRC := $(dir $(SRC_ZIP_SRCS)), \
       INCLUDES := $(SRC_ZIP_INCLUDES), \
--- a/make/autoconf/configure.ac	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/autoconf/configure.ac	Fri Jun 15 09:53:28 2018 -0700
@@ -232,6 +232,7 @@
 JDKOPT_DETECT_INTREE_EC
 JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
 JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
+JDKOPT_EXCLUDE_TRANSLATIONS
 
 ###############################################################################
 #
--- a/make/autoconf/jdk-options.m4	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/autoconf/jdk-options.m4	Fri Jun 15 09:53:28 2018 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, 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
@@ -582,3 +582,25 @@
 
   AC_SUBST(ENABLE_GENERATE_CLASSLIST)
 ])
+
+################################################################################
+#
+# Optionally filter resource translations
+#
+AC_DEFUN([JDKOPT_EXCLUDE_TRANSLATIONS],
+[
+  AC_ARG_WITH([exclude-translations], [AS_HELP_STRING([--with-exclude-translations],
+      [a comma separated list of locales to exclude translations for. Default is
+      to include all translations present in the source.])])
+
+  EXCLUDE_TRANSLATIONS=""
+  AC_MSG_CHECKING([if any translations should be excluded])
+  if test "x$with_exclude_translations" != "x"; then
+    EXCLUDE_TRANSLATIONS="${with_exclude_translations//,/ }"
+    AC_MSG_RESULT([yes: $EXCLUDE_TRANSLATIONS])
+  else
+    AC_MSG_RESULT([no])
+  fi
+
+  AC_SUBST(EXCLUDE_TRANSLATIONS)
+])
--- a/make/autoconf/spec.gmk.in	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/autoconf/spec.gmk.in	Fri Jun 15 09:53:28 2018 -0700
@@ -303,6 +303,8 @@
 
 ENABLE_GENERATE_CLASSLIST := @ENABLE_GENERATE_CLASSLIST@
 
+EXCLUDE_TRANSLATIONS := @EXCLUDE_TRANSLATIONS@
+
 # The boot jdk to use. This is overridden in bootcycle-spec.gmk. Make sure to keep
 # it in sync.
 BOOT_JDK:=@BOOT_JDK@
--- a/make/common/JavaCompilation.gmk	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/common/JavaCompilation.gmk	Fri Jun 15 09:53:28 2018 -0700
@@ -180,6 +180,7 @@
 #   CREATE_API_DIGEST:=Set to true to use a javac plugin to generate a public API
 #        hash which can be used for down stream dependencies to only rebuild
 #        when the API changes. Implicitly used in sjavac.
+#   KEEP_ALL_TRANSLATIONS:=Set to true to skip translation filtering
 SetupJavaCompilation = $(NamedParamsMacroTemplate)
 define SetupJavaCompilationBody
 
@@ -266,6 +267,11 @@
           $$(eval $1_$$(relative_src) := 1) $$(s))))
   endif
 
+  # Filter out any excluded translations
+  ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
+    $1_SRCS := $$(call FilterExcludedTranslations, $$($1_SRCS), .java)
+  endif
+
   ifeq ($$(strip $$($1_SRCS)), )
     ifneq ($$($1_FAIL_NO_SRC), false)
       $$(error No source files found for $1)
@@ -290,6 +296,10 @@
     ifneq (,$$($1_EXCLUDE_PATTERN))
       $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_COPIES))
     endif
+    # Filter out any excluded translations
+    ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
+      $1_ALL_COPIES := $$(call FilterExcludedTranslations, $$($1_ALL_COPIES), .properties)
+    endif
     ifneq (,$$($1_ALL_COPIES))
       # Yep, there are files to be copied!
       $1_ALL_COPY_TARGETS:=
@@ -310,6 +320,10 @@
       ifneq (,$$($1_EXCLUDE_PATTERN))
         $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_CLEANS))
       endif
+      # Filter out any excluded translations
+      ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
+        $1_ALL_CLEANS := $$(call FilterExcludedTranslations, $$($1_ALL_CLEANS), .properties)
+      endif
       ifneq (,$$($1_ALL_CLEANS))
         # Yep, there are files to be copied and cleaned!
         $1_ALL_COPY_CLEAN_TARGETS:=
--- a/make/common/MakeBase.gmk	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/common/MakeBase.gmk	Fri Jun 15 09:53:28 2018 -0700
@@ -1075,6 +1075,22 @@
   )
 
 ################################################################################
+# Given a list of files, filters out locale specific files for translations
+# that should be excluded from this build.
+# $1 - The list of files to filter
+# $2 - The suffix of the files that should be considered (.java or .properties)
+FilterExcludedTranslations = \
+  $(strip $(if $(EXCLUDE_TRANSLATIONS), \
+    $(filter-out \
+        $(foreach suffix, $2, \
+          $(addprefix %_, $(addsuffix $(suffix), $(EXCLUDE_TRANSLATIONS))) \
+        ), \
+        $1 \
+    ), \
+    $1 \
+  ))
+
+################################################################################
 
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, common/MakeBase.gmk))
--- a/make/common/ZipArchive.gmk	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/common/ZipArchive.gmk	Fri Jun 15 09:53:28 2018 -0700
@@ -42,6 +42,10 @@
 #   INCLUDE_FILES
 #   EXCLUDES
 #   EXCLUDE_FILES
+#   EXCLUDE_PATTERNS - Patterns with at most one % wildcard matching filenames
+#                      and not directories.
+#   EXCLUDE_PATTERNS_$dir - Exclude patterns just like above but specific to one
+#                           src dir
 #   SUFFIXES
 #   EXTRA_DEPS
 #   ZIP_OPTIONS extra options to pass to zip
@@ -88,11 +92,26 @@
     $1_ALL_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_SRCS))
   endif
   ifneq ($$($1_EXCLUDE_FILES),)
-    # Cannot precompute ZIP_EXCLUDE_FILES as it is dependent on which src root is being
-    # zipped at the moment.
     $1_SRC_EXCLUDE_FILES := $$(addprefix %, $$($1_EXCLUDE_FILES)) $$($1_EXCLUDE_FILES)
     $1_ALL_SRCS := $$(filter-out $$($1_SRC_EXCLUDE_FILES), $$($1_ALL_SRCS))
+    $$(foreach s, $$($1_SRC), \
+      $$(eval $1_ZIP_EXCLUDES_$$s += \
+          $$(addprefix -x$$(SPACE), $$(patsubst $$s/%,%, $$($1_EXCLUDE_FILES))) \
+      ) \
+    )
   endif
+  ifneq ($$($1_EXCLUDE_PATTERNS), )
+    $1_ALL_SRCS := $$(filter-out $$($1_EXCLUDE_PATTERNS), $$($1_ALL_SRCS))
+    $1_ZIP_EXCLUDES += $$(addprefix -x$(SPACE), $$(subst %,\*,$$($1_EXCLUDE_PATTERNS)))
+  endif
+  # Rewrite src dir specific exclude patterns to zip excludes
+  $$(foreach s, $$($1_SRC), \
+    $$(if $$($1_EXCLUDE_PATTERNS_$$s), \
+      $$(eval $1_ZIP_EXCLUDES_$$s += \
+          $$(addprefix -x$$(SPACE), $$(subst %,\*,$$($1_EXCLUDE_PATTERNS_$$s))) \
+      ) \
+    ) \
+  )
 
   # Use a slightly shorter name for logging, but with enough path to identify this zip.
   $1_NAME:=$$(subst $$(OUTPUTDIR)/,,$$($1_ZIP))
@@ -107,9 +126,9 @@
   $$($1_ZIP) : $$($1_ALL_SRCS) $$($1_EXTRA_DEPS)
 	$(MKDIR) -p $$(@D)
 	$(ECHO) Updating $$($1_NAME)
-	$$(foreach i,$$($1_SRC),(cd $$i && $(ZIPEXE) -qru $$($1_ZIP_OPTIONS) $$@ . $$($1_ZIP_INCLUDES) \
-	    $$($1_ZIP_EXCLUDES) -x \*_the.\* \
-	    $$(addprefix -x$(SPACE), $$(patsubst $$i/%,%, $$($1_EXCLUDE_FILES))) \
+	$$(foreach s,$$($1_SRC),(cd $$s && $(ZIPEXE) -qru $$($1_ZIP_OPTIONS) $$@ . \
+	    $$($1_ZIP_INCLUDES) $$($1_ZIP_EXCLUDES) -x \*_the.\* \
+	    $$($1_ZIP_EXCLUDES_$$s) \
 	    || test "$$$$?" = "12" )$$(NEWLINE)) true
 	$(TOUCH) $$@
 
--- a/make/conf/jib-profiles.js	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/conf/jib-profiles.js	Fri Jun 15 09:53:28 2018 -0700
@@ -242,7 +242,8 @@
         dependencies: ["boot_jdk", "gnumake", "jtreg", "jib"],
         default_make_targets: ["product-bundles", "test-bundles"],
         configure_args: concat(["--enable-jtreg-failure-handler"],
-                               versionArgs(input, common))
+            "--with-exclude-translations=de,es,fr,it,ko,pt_BR,sv,ca,tr,cs,sk,ja_JP_A,ja_JP_HA,ja_JP_HI,ja_JP_I",
+            versionArgs(input, common))
     };
     // Extra settings for debug profiles
     common.debug_suffix = "-debug";
--- a/make/gensrc/Gensrc-jdk.localedata.gmk	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/gensrc/Gensrc-jdk.localedata.gmk	Fri Jun 15 09:53:28 2018 -0700
@@ -38,6 +38,7 @@
 $(eval $(call SetupCompileProperties, COMPILE_PROPERTIES, \
     SRC_DIRS := $(TOPDIR)/src/jdk.localedata/share/classes/sun/util/resources, \
     CLASS := sun.util.resources.LocaleNamesBundle, \
+    KEEP_ALL_TRANSLATIONS := true, \
 ))
 
 # Skip generating zh_HK from zh_TW for this module.
--- a/make/gensrc/GensrcCommonLangtools.gmk	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/gensrc/GensrcCommonLangtools.gmk	Fri Jun 15 09:53:28 2018 -0700
@@ -66,6 +66,9 @@
   PROPSOURCES := $2 \
       $$(shell $(FIND) $(TOPDIR)/src/$(MODULE)/share/classes -name "*.properties")
 
+  # Filter out any excluded translations
+  PROPSOURCES := $$(call FilterExcludedTranslations, $$(PROPSOURCES), .properties)
+
   # Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
   # to .../langtools/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
   # Strip away prefix and suffix, leaving for example only:
@@ -105,6 +108,7 @@
 define SetupParseProperties
   # property files to process
   PARSEPROPSOURCES := $$(addprefix $(TOPDIR)/src/$(MODULE)/share/classes/, $2)
+  PARSEPROPSOURCES := $$(call FilterExcludedTranslations, $$(PARSEPROPSOURCES), .properties)
 
   PARSEPROPALLDIRS := $$(patsubst $(TOPDIR)/src/$(MODULE)/share/classes/%, \
       $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/%, \
--- a/make/gensrc/GensrcProperties.gmk	Fri Jun 15 09:16:48 2018 -0700
+++ b/make/gensrc/GensrcProperties.gmk	Fri Jun 15 09:53:28 2018 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, 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 @@
 # EXCLUDE   Exclude files matching this pattern.
 # CLASS   The super class for the generated classes.
 # MODULE_PATH_ROOT   Module path root, defaults to $(TOPDIR)/src.
+# KEEP_ALL_TRANSLATIONS Set to true to skip filtering of excluded translations.
 SetupCompileProperties = $(NamedParamsMacroTemplate)
 define SetupCompilePropertiesBody
   # Set default value unless overridden
@@ -73,10 +74,13 @@
     $1_SRC_FILES := $$(filter-out $$($1_EXCLUDE), $$($1_SRC_FILES))
   endif
 
+  # Filter out any excluded translations
+  ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
+    $1_SRC_FILES := $$(call FilterExcludedTranslations, $$($1_SRC_FILES), .properties)
+  endif
+
   # Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
   # to .../support/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
-  # Strip away prefix and suffix, leaving for example only:
-  # "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
   $1_JAVAS := $$(patsubst $$($1_MODULE_PATH_ROOT)/%, \
       $(SUPPORT_OUTPUTDIR)/gensrc/%, \
       $$(patsubst %.properties, %.java, \
@@ -99,7 +103,7 @@
   $1_TARGET := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.marker
   $1_CMDLINE_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.cmdline
 
-# Now setup the rule for the generation of the resource bundles.
+  # Now setup the rule for the generation of the resource bundles.
   $$($1_TARGET): $$($1_SRC_FILES) $$($1_JAVAS) $(BUILD_TOOLS_JDK)
 	$(MKDIR) -p $$(@D) $$($1_DIRS)
 	$(ECHO) Compiling $$(words $$($1_SRC_FILES)) properties into resource bundles for $(MODULE)
--- a/test/jdk/TEST.ROOT	Fri Jun 15 09:16:48 2018 -0700
+++ b/test/jdk/TEST.ROOT	Fri Jun 15 09:53:28 2018 -0700
@@ -40,7 +40,8 @@
     vm.gc.Z \
     vm.graal.enabled \
     vm.cds \
-    docker.support
+    docker.support \
+    release.implementor
 
 # Minimum jtreg version
 requiredVersion=4.2 b12
--- a/test/jdk/TEST.groups	Fri Jun 15 09:16:48 2018 -0700
+++ b/test/jdk/TEST.groups	Fri Jun 15 09:53:28 2018 -0700
@@ -39,7 +39,6 @@
     -java/util/Arrays/TimSortStackSize2.java
 
 tier1_part3 = \
-    :build_sanity \
     :jdk_math \
     :jdk_svc_sanity \
     java/nio/Buffer \
@@ -76,6 +75,7 @@
     :jdk_net
 
 tier3 = \
+    :build \
     :jdk_rmi \
     :jdk_beans \
     :jdk_imageio \
@@ -88,8 +88,8 @@
 #
 
 # Build source checking
-build_sanity = \
-    sanity/releaseFile
+build = \
+    build
 
 # java.lang package and VM runtime support
 jdk_lang = \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/build/releaseFile/CheckSource.java	Fri Jun 15 09:53:28 2018 -0700
@@ -0,0 +1,120 @@
+
+/*
+ * Copyright (c) 2018, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8193660
+ * @summary Check SOURCE line in "release" file for closedjdk
+ * @run main CheckSource
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+public class CheckSource {
+
+    CheckSource(String dataFile, boolean isOpenJDK) {
+        // Read data files
+        readFile(dataFile, isOpenJDK);
+    }
+
+    private void readFile(String fileName, boolean isOpenJDK) {
+        String fishForSOURCE = null;
+
+        File file = new File(fileName);
+
+        // open the stream to read in for Entries
+        try (BufferedReader buffRead =
+            new BufferedReader(new FileReader(fileName))) {
+
+            // this is the string read
+            String readIn;
+
+            // let's read some strings!
+            while ((readIn = buffRead.readLine()) != null) {
+                readIn = readIn.trim();
+
+                // throw out blank lines
+                if (readIn.length() == 0)
+                    continue;
+
+                // grab SOURCE line
+                if (readIn.startsWith("SOURCE=")) {
+                    fishForSOURCE = readIn;
+                    break;
+                }
+            }
+        } catch (FileNotFoundException fileExcept) {
+            throw new RuntimeException("File " + fileName +
+                                       " not found reading data!", fileExcept);
+        } catch (IOException ioExcept) {
+            throw new RuntimeException("Unexpected problem reading data!",
+                                       ioExcept);
+        }
+
+        // was SOURCE even found?
+        if (fishForSOURCE == null) {
+            throw new RuntimeException("SOURCE line was not found!");
+        } else {
+            // OK it was found, did it have correct sources?
+            System.out.println("The source string found: " + fishForSOURCE);
+
+            // First it MUST have .: regardless of closed or openJDK
+            if (!fishForSOURCE.contains(".:")) {
+                throw new RuntimeException("The test failed, .: not found!");
+            }
+            // take out the .: source path
+            fishForSOURCE = fishForSOURCE.replace(".:", "");
+
+            // if its closedJDK it MUST have open:
+            if (!isOpenJDK && !fishForSOURCE.contains("open:")) {
+                throw new RuntimeException("The test failed, open: not found!");
+            }
+            // take out the open: source path
+            fishForSOURCE = fishForSOURCE.replace("open:", "");
+
+            // if any other source exists, that's an error
+            if (fishForSOURCE.contains(":")) {
+                throw new RuntimeException("The test failed, additional sources found!");
+            }
+        }
+
+        // Everything was fine
+        System.out.println("The test passed!");
+    }
+
+    public static void main(String args[]) {
+        String jdkPath = System.getProperty("test.jdk");
+        String runtime = System.getProperty("java.runtime.name");
+
+        System.out.println("JDK Path : " + jdkPath);
+        System.out.println("Runtime Name : " + runtime);
+
+        new CheckSource(jdkPath + "/release",
+                              runtime.contains("OpenJDK"));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/build/translations/VerifyTranslations.java	Fri Jun 15 09:53:28 2018 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2018, 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.
+ *
+ * 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.
+ */
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * @test
+ * @requires release.implementor == "Oracle Corporation"
+ * @modules jdk.jlink/jdk.tools.jimage
+ * @summary Oracle builds of OpenJDK should only contain english, chinese and
+ *          japanese translations
+ */
+public class VerifyTranslations {
+
+    /**
+     * The set of translations we want to see in an Oracle built image
+     */
+    private static final Set<String> VALID_TRANSLATION_SUFFIXES = Set.of(
+            "_en", "_en_US", "_en_US_POSIX", "_ja", "_zh_CN", "_zh_TW", "_zh_HK"
+    );
+
+    /**
+     * This regexp will not match locales with 3 letter lang strings because
+     * doing so would trigger a ton of false positives all over the source
+     * tree. This is ok for now but is a potential future flaw in the test.
+     */
+    private static final String BASE_LOCALE_REGEXP
+            = "(_[a-z]{2}(_[A-Z][a-z]{3})?(_([A-Z]{2})|([0-9]{3}))?(_[a-zA-Z]+)?)";
+
+    public static void main(String[] args) {
+        String jdkPath = System.getProperty("test.jdk");
+        String modulesFile = jdkPath + "/lib/modules";
+
+        // Run jimage tool to extract list of all classes and resources in the jdk
+        StringWriter output = new StringWriter();
+        jdk.tools.jimage.Main.run(new String[] { "list", modulesFile }, new PrintWriter(output));
+
+        Pattern classesLocalePattern = Pattern.compile(BASE_LOCALE_REGEXP + "\\.(class|properties)");
+
+        boolean failed = false;
+        String module = "";
+        for (String line : output.toString().split("\n")) {
+            if (line.startsWith("Module: ")) {
+                module = line.substring(8).trim();
+            }
+            // We do not filter resources in jdk.localedata
+            if (!module.equals("jdk.localedata")) {
+                Matcher matcher = classesLocalePattern.matcher(line);
+                if (matcher.find()) {
+                    if (!VALID_TRANSLATION_SUFFIXES.contains(matcher.group(1))) {
+                        System.out.println("Unsupported translation found in lib/modules: "
+                                + module + "/" + line.trim());
+                        failed = true;
+                    }
+                }
+            }
+        }
+
+        // Check all files in src.zip
+        Pattern sourceLocalePattern = Pattern.compile(BASE_LOCALE_REGEXP + "\\.java");
+        String srcZip = jdkPath + "/lib/src.zip";
+        try (ZipInputStream srcZipInput = new ZipInputStream(
+                new BufferedInputStream(new FileInputStream(srcZip)))) {
+            ZipEntry entry;
+            while ((entry = srcZipInput.getNextEntry()) != null) {
+                String name = entry.getName();
+                if (!name.startsWith("jdk.localedata")) {
+                    Matcher matcher = sourceLocalePattern.matcher(name);
+                    if (matcher.find()) {
+                        if (!VALID_TRANSLATION_SUFFIXES.contains(matcher.group(1))) {
+                            System.out.println("Unsupported translation found in lib/src.zip: " + name);
+                            failed = true;
+                        }
+                    }
+                }
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        if (failed) {
+            throw new RuntimeException("lib/modules contains unsupported translations");
+        }
+    }
+}
--- a/test/jdk/java/util/logging/LocalizedLevelName.java	Fri Jun 15 09:16:48 2018 -0700
+++ b/test/jdk/java/util/logging/LocalizedLevelName.java	Fri Jun 15 09:53:28 2018 -0700
@@ -34,19 +34,19 @@
 
 public class LocalizedLevelName {
     private static Object[] namesMap = {
-        "SEVERE",  Locale.ENGLISH, "Severe",        Level.SEVERE,
-        "WARNING", Locale.FRENCH,  "Avertissement", Level.WARNING,
-        "INFO",    Locale.ITALIAN, "Informazioni",  Level.INFO,
-        "SEVERE",  Locale.FRENCH,  "Grave",         Level.SEVERE,
-        "CONFIG",  Locale.GERMAN,  "Konfiguration", Level.CONFIG,
-        "ALL",     Locale.ROOT,    "All",           Level.ALL,
-        "SEVERE",  Locale.ROOT,    "Severe",        Level.SEVERE,
-        "WARNING", Locale.ROOT,    "Warning",       Level.WARNING,
-        "CONFIG",  Locale.ROOT,    "Config",        Level.CONFIG,
-        "INFO",    Locale.ROOT,    "Info",          Level.INFO,
-        "FINE",    Locale.ROOT,    "Fine",          Level.FINE,
-        "FINER",   Locale.ROOT,    "Finer",         Level.FINER,
-        "FINEST",  Locale.ROOT,    "Finest",        Level.FINEST
+        "SEVERE",  Locale.ENGLISH,                 "Severe",       Level.SEVERE,
+        "WARNING", Locale.JAPANESE,                "\u8B66\u544A", Level.WARNING,
+        "INFO",    Locale.SIMPLIFIED_CHINESE,      "\u4FE1\u606F", Level.INFO,
+        "SEVERE",  Locale.TRADITIONAL_CHINESE,     "\u56B4\u91CD", Level.SEVERE,
+        "CONFIG",  Locale.forLanguageTag("zh-HK"), "\u7D44\u614B", Level.CONFIG,
+        "ALL",     Locale.ROOT,                    "All",          Level.ALL,
+        "SEVERE",  Locale.ROOT,                    "Severe",       Level.SEVERE,
+        "WARNING", Locale.ROOT,                    "Warning",      Level.WARNING,
+        "CONFIG",  Locale.ROOT,                    "Config",       Level.CONFIG,
+        "INFO",    Locale.ROOT,                    "Info",         Level.INFO,
+        "FINE",    Locale.ROOT,                    "Fine",         Level.FINE,
+        "FINER",   Locale.ROOT,                    "Finer",        Level.FINER,
+        "FINEST",  Locale.ROOT,                    "Finest",       Level.FINEST
     };
 
     public static void main(String args[]) throws Exception {
--- a/test/jdk/sanity/releaseFile/CheckSource.java	Fri Jun 15 09:16:48 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-
-/*
- * Copyright (c) 2018, 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.
- *
- * 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.
- */
-
-/*
- * @test
- * @bug 8193660
- * @summary Check SOURCE line in "release" file for closedjdk
- * @run main CheckSource
- */
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-public class CheckSource {
-
-    CheckSource(String dataFile, boolean isOpenJDK) {
-        // Read data files
-        readFile(dataFile, isOpenJDK);
-    }
-
-    private void readFile(String fileName, boolean isOpenJDK) {
-        String fishForSOURCE = null;
-
-        File file = new File(fileName);
-
-        // open the stream to read in for Entries
-        try (BufferedReader buffRead =
-            new BufferedReader(new FileReader(fileName))) {
-
-            // this is the string read
-            String readIn;
-
-            // let's read some strings!
-            while ((readIn = buffRead.readLine()) != null) {
-                readIn = readIn.trim();
-
-                // throw out blank lines
-                if (readIn.length() == 0)
-                    continue;
-
-                // grab SOURCE line
-                if (readIn.startsWith("SOURCE=")) {
-                    fishForSOURCE = readIn;
-                    break;
-                }
-            }
-        } catch (FileNotFoundException fileExcept) {
-            throw new RuntimeException("File " + fileName +
-                                       " not found reading data!", fileExcept);
-        } catch (IOException ioExcept) {
-            throw new RuntimeException("Unexpected problem reading data!",
-                                       ioExcept);
-        }
-
-        // was SOURCE even found?
-        if (fishForSOURCE == null) {
-            throw new RuntimeException("SOURCE line was not found!");
-        } else {
-            // OK it was found, did it have correct sources?
-            System.out.println("The source string found: " + fishForSOURCE);
-
-            // First it MUST have .: regardless of closed or openJDK
-            if (!fishForSOURCE.contains(".:")) {
-                throw new RuntimeException("The test failed, .: not found!");
-            }
-            // take out the .: source path
-            fishForSOURCE = fishForSOURCE.replace(".:", "");
-
-            // if its closedJDK it MUST have open:
-            if (!isOpenJDK && !fishForSOURCE.contains("open:")) {
-                throw new RuntimeException("The test failed, open: not found!");
-            }
-            // take out the open: source path
-            fishForSOURCE = fishForSOURCE.replace("open:", "");
-
-            // if any other source exists, that's an error
-            if (fishForSOURCE.contains(":")) {
-                throw new RuntimeException("The test failed, additional sources found!");
-            }
-        }
-
-        // Everything was fine
-        System.out.println("The test passed!");
-    }
-
-    public static void main(String args[]) {
-        String jdkPath = System.getProperty("test.jdk");
-        String runtime = System.getProperty("java.runtime.name");
-
-        System.out.println("JDK Path : " + jdkPath);
-        System.out.println("Runtime Name : " + runtime);
-
-        new CheckSource(jdkPath + "/release",
-                              runtime.contains("OpenJDK"));
-    }
-}
--- a/test/jtreg-ext/requires/VMProps.java	Fri Jun 15 09:16:48 2018 -0700
+++ b/test/jtreg-ext/requires/VMProps.java	Fri Jun 15 09:53:28 2018 -0700
@@ -22,7 +22,10 @@
  */
 package requires;
 
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -31,6 +34,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.concurrent.Callable;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
@@ -80,6 +84,7 @@
         // vm.graal.enabled is true if Graal is used as JIT
         map.put("vm.graal.enabled", isGraalEnabled());
         map.put("docker.support", dockerSupport());
+        map.put("release.implementor", implementor());
         vmGC(map); // vm.gc.X = true/false
         vmOptFinalFlags(map);
 
@@ -396,6 +401,18 @@
     }
 
 
+    private String implementor() {
+        try (InputStream in = new BufferedInputStream(new FileInputStream(
+                System.getProperty("java.home") + "/release"))) {
+            Properties properties = new Properties();
+            properties.load(in);
+            return properties.getProperty("IMPLEMENTOR").replace("\"", "");
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
 
     /**
      * Dumps the map to the file if the file name is given as the property.