7021987: native2ascii "file cannot be read" error message is broken
authoralanb
Wed, 02 Mar 2011 16:56:07 +0000
changeset 8560 f2abd715d39b
parent 8559 826c03991926
child 8561 ca8d6ccdd9dc
child 8568 f59001e07166
7021987: native2ascii "file cannot be read" error message is broken Reviewed-by: lancea, mchung
jdk/src/share/classes/sun/tools/native2ascii/Main.java
jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh
--- a/jdk/src/share/classes/sun/tools/native2ascii/Main.java	Tue Mar 01 15:05:32 2011 -0800
+++ b/jdk/src/share/classes/sun/tools/native2ascii/Main.java	Wed Mar 02 16:56:07 2011 +0000
@@ -94,7 +94,7 @@
      * Run the converter
      */
     public synchronized boolean convert(String argv[]){
-        Vector v = new Vector(2);
+        List<String> v = new ArrayList<>(2);
         File outputFile = null;
         boolean createOutputFile = false;
 
@@ -115,7 +115,7 @@
                     usage();
                     return false;
                 }
-                v.addElement(argv[i]);
+                v.add(argv[i]);
             }
         }
         if (encodingString == null)
@@ -126,11 +126,11 @@
             initializeConverter();
 
             if (v.size() == 1)
-                inputFileName = (String)v.elementAt(0);
+                inputFileName = v.get(0);
 
             if (v.size() == 2) {
-                inputFileName = (String)v.elementAt(0);
-                outputFileName = (String)v.elementAt(1);
+                inputFileName = v.get(0);
+                outputFileName = v.get(1);
                 createOutputFile = true;
             }
 
@@ -363,9 +363,7 @@
 
     private String formatMsg(String key, String arg) {
         String msg = getMsg(key);
-        String[] args = new String[1];
-        args[0] = arg;
-        return MessageFormat.format(msg, (Object)args);
+        return MessageFormat.format(msg, arg);
     }
 
 
--- a/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh	Tue Mar 01 15:05:32 2011 -0800
+++ b/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh	Wed Mar 02 16:56:07 2011 +0000
@@ -24,7 +24,7 @@
 #
 
 # @test
-# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817
+# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987
 # @summary Tests miscellaneous native2ascii bugfixes and regressions
 
 
@@ -100,6 +100,15 @@
 $N2A -reverse -encoding MS932 $TESTSRC/A2N_4701617 x.out
 check 4701617 $TESTSRC/A2N_4701617.expected x.out
 
+# Check that the inputfile appears in the error message when not found
+
+badin="DoesNotExist"
+$N2A $badin x.out | grep "$badin" > /dev/null
+if [ $? != 0 ]; then
+    echo "\"$badin\" expected to appear in error message"
+    exit 1
+fi
+
 # for win32 only ensure when output file pre-exists that
 # native2ascii tool will simply overwrite with the expected
 # output file (fixed bugID 4710890)