8152742: jlink --include-locales th fails with ArrayIndexOutOfBoundsException
authornaoto
Tue, 05 Apr 2016 09:13:30 -0700
changeset 36860 dad1a46b0a88
parent 36859 1a821b9a7245
child 36926 c49df7b25461
8152742: jlink --include-locales th fails with ArrayIndexOutOfBoundsException Reviewed-by: mchung, okutsu
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Tue Apr 05 12:02:54 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Tue Apr 05 09:13:30 2016 -0700
@@ -41,12 +41,13 @@
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
 import jdk.internal.org.objectweb.asm.ClassReader;
-import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.internal.ResourcePrevisitor;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.Utils;
+import jdk.tools.jlink.plugin.PluginException;
+import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
  * Plugin to explicitly specify the locale data included in jdk.localedata
@@ -84,8 +85,8 @@
     private static final String METAINFONAME = "LocaleDataMetaInfo";
     private static final String META_FILES =
         "*module-info.class," +
-        "*LocaleDataProvider*," +
-        "*" + METAINFONAME + "*,";
+        "*LocaleDataProvider.class," +
+        "*" + METAINFONAME + ".class,";
     private static final String INCLUDE_LOCALE_FILES =
         "*sun/text/resources/ext/[^\\/]+_%%.class," +
         "*sun/util/resources/ext/[^\\/]+_%%.class," +
@@ -116,7 +117,8 @@
             if (resource.getModule().equals(MODULENAME)) {
                 String path = resource.getPath();
                 resource = predicate.test(path) ? resource: null;
-                if (resource != null) {
+                if (resource != null &&
+                    resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
                     byte[] bytes = resource.getBytes();
                     ClassReader cr = new ClassReader(bytes);
                     if (Arrays.stream(cr.getInterfaces())
@@ -249,10 +251,10 @@
             files += INCLUDE_LOCALE_FILES.replaceAll("%%", isoSpecial + "_[0-9]{3}");
         }
 
-        // Add Thai BreakIterator related files
+        // Add Thai BreakIterator related data files
         if (lang.equals("th")) {
             files += "*sun/text/resources/thai_dict," +
-                     "*sun/text/resources/[^\\/]+_th,";
+                     "*sun/text/resources/[^\\/]+BreakIteratorData_th,";
         }
 
         // Add Taiwan resource bundles for Hong Kong