From efeb942f9fbfe6a5f411c026d57e18bb4a6fb3c4 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 22 May 2015 16:43:39 -0700 Subject: [PATCH] 8074431: Remove native2ascii tool Reviewed-by: erikj, alanb, okutsu, mfang, naoto --- jdk/make/launcher/Launcher-jdk.dev.gmk | 4 - jdk/src/bsd/doc/man/ja/native2ascii.1 | 24 -- jdk/src/bsd/doc/man/native2ascii.1 | 87 ---- .../share/classes/java/util/Properties.java | 6 +- .../java/util/prefs/WindowsPreferences.java | 4 +- .../sun/tools/native2ascii/A2NFilter.java | 144 ------- .../classes/sun/tools/native2ascii/Main.java | 375 ------------------ .../sun/tools/native2ascii/N2AFilter.java | 74 ---- .../resources/MsgNative2ascii.java | 43 -- .../tools/javac/resources/javac.properties | 2 +- jdk/test/TEST.groups | 2 - jdk/test/sun/tools/native2ascii/A2N_4630463 | 1 - .../tools/native2ascii/A2N_4630463.expected | 1 - jdk/test/sun/tools/native2ascii/A2N_4630971 | 4 - jdk/test/sun/tools/native2ascii/A2N_4701617 | 11 - .../tools/native2ascii/A2N_4701617.expected | 11 - jdk/test/sun/tools/native2ascii/A2N_6247817 | 1 - jdk/test/sun/tools/native2ascii/N2A_4636448 | 1 - .../tools/native2ascii/N2A_4636448.expected | 1 - .../tools/native2ascii/Native2AsciiTests.sh | 129 ------ .../sun/tools/native2ascii/NativeErrors.java | 117 ------ .../sun/tools/native2ascii/Permission.java | 85 ---- .../resources/ImmutableResourceTest.java | 68 ---- jdk/test/sun/tools/native2ascii/test1 | 1 - jdk/test/sun/tools/native2ascii/test3 | 1 - jdk/test/tools/launcher/VersionCheck.java | 1 - 26 files changed, 3 insertions(+), 1195 deletions(-) delete mode 100644 jdk/src/bsd/doc/man/ja/native2ascii.1 delete mode 100644 jdk/src/bsd/doc/man/native2ascii.1 delete mode 100644 jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/A2NFilter.java delete mode 100644 jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/Main.java delete mode 100644 jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/N2AFilter.java delete mode 100644 jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/resources/MsgNative2ascii.java delete mode 100644 jdk/test/sun/tools/native2ascii/A2N_4630463 delete mode 100644 jdk/test/sun/tools/native2ascii/A2N_4630463.expected delete mode 100644 jdk/test/sun/tools/native2ascii/A2N_4630971 delete mode 100644 jdk/test/sun/tools/native2ascii/A2N_4701617 delete mode 100644 jdk/test/sun/tools/native2ascii/A2N_4701617.expected delete mode 100644 jdk/test/sun/tools/native2ascii/A2N_6247817 delete mode 100644 jdk/test/sun/tools/native2ascii/N2A_4636448 delete mode 100644 jdk/test/sun/tools/native2ascii/N2A_4636448.expected delete mode 100644 jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh delete mode 100644 jdk/test/sun/tools/native2ascii/NativeErrors.java delete mode 100644 jdk/test/sun/tools/native2ascii/Permission.java delete mode 100644 jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.java delete mode 100644 jdk/test/sun/tools/native2ascii/test1 delete mode 100644 jdk/test/sun/tools/native2ascii/test3 diff --git a/jdk/make/launcher/Launcher-jdk.dev.gmk b/jdk/make/launcher/Launcher-jdk.dev.gmk index 7d3781707cb..5c01b4fb498 100644 --- a/jdk/make/launcher/Launcher-jdk.dev.gmk +++ b/jdk/make/launcher/Launcher-jdk.dev.gmk @@ -32,7 +32,3 @@ $(eval $(call SetupLauncher,jdeps, \ $(eval $(call SetupLauncher,jimage,\ -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "jdk.tools.jimage.Main"$(COMMA) }')) - -$(eval $(call SetupLauncher,native2ascii, \ - -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.native2ascii.Main"$(COMMA) }')) - diff --git a/jdk/src/bsd/doc/man/ja/native2ascii.1 b/jdk/src/bsd/doc/man/ja/native2ascii.1 deleted file mode 100644 index c7232ea9b2f..00000000000 --- a/jdk/src/bsd/doc/man/ja/native2ascii.1 +++ /dev/null @@ -1,24 +0,0 @@ -." Copyright (c) 1997, 2012, 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. -." -.TH native2ascii 1 "07 May 2011" - -.LP diff --git a/jdk/src/bsd/doc/man/native2ascii.1 b/jdk/src/bsd/doc/man/native2ascii.1 deleted file mode 100644 index 7e7ec7cfaa9..00000000000 --- a/jdk/src/bsd/doc/man/native2ascii.1 +++ /dev/null @@ -1,87 +0,0 @@ -'\" t -.\" Copyright (c) 1997, 2013, 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. -.\" -.\" Arch: generic -.\" Software: JDK 8 -.\" Date: 21 November 2013 -.\" SectDesc: Internationalization Tools -.\" Title: native2ascii.1 -.\" -.if n .pl 99999 -.TH native2ascii 1 "21 November 2013" "JDK 8" "Internationalization Tools" -.\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- - -.SH NAME -native2ascii \- Creates localizable applications by converting a file with characters in any supported character encoding to one with ASCII and/or Unicode escapes or vice versa\&. -.SH SYNOPSIS -.sp -.nf - -\fBnative2ascii\fR [ \fIinputfile\fR ] [ \fIoutputfile\fR ] -.fi -.sp -.TP -\fIinputfile\fR -The encoded file to be converted to ASCII\&. -.TP -\fIoutputfile\fR -The converted ASCII file\&. -.SH DESCRIPTION -The \f3native2ascii\fR command converts encoded files supported by the Java Runtime Environment (JRE) to files encoded in ASCII, using Unicode escapes (\f3\eu\fR\fIxxxx\fR) notation for all characters that are not part of the ASCII character set\&. This process is required for properties files that contain characters not in ISO-8859-1 character sets\&. The tool can also perform the reverse conversion\&. -.PP -If the \f3outputfile\fR value is omitted, then standard output is used for output\&. If, in addition, the \f3inputfile\fR value is omitted, then standard input is used for input\&. -.SH OPTIONS -.TP --reverse -.br -Perform the reverse operation: Converts a file encoded in ISO-8859-1 with Unicode escapes to a file in any character encoding supported by the JRE\&. -.TP --encoding \fIencoding_name\fR -.br -Specifies the name of the character encoding to be used by the conversion procedure\&. If this option is not present, then the default character encoding (as determined by the \f3java\&.nio\&.charset\&.Charset\&.defaultCharset\fR method) is used\&. The \f3encoding_name\fR string must be the name of a character encoding that is supported by the JRE\&. See Supported Encodings at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/intl/encoding\&.doc\&.html -.TP --J\fIoption\fR -.br -Passes \f3option\fR to the Java Virtual Machine (JVM), where option is one of the options described on the reference page for the Java application launcher\&. For example, \f3-J-Xms48m\fR sets the startup memory to 48 MB\&. See java(1)\&. -.RE -.br -'pl 8.5i -'bp diff --git a/jdk/src/java.base/share/classes/java/util/Properties.java b/jdk/src/java.base/share/classes/java/util/Properties.java index a075da67d1c..0d983e52f96 100644 --- a/jdk/src/java.base/share/classes/java/util/Properties.java +++ b/jdk/src/java.base/share/classes/java/util/Properties.java @@ -73,8 +73,7 @@ import jdk.internal.util.xml.PropertiesDefaultHandler; * Unicode escapes as defined in section 3.3 of * The Java™ Language Specification; * only a single 'u' character is allowed in an escape - * sequence. The native2ascii tool can be used to convert property files to and - * from other character encodings. + * sequence. * *

The {@link #loadFromXML(InputStream)} and {@link * #storeToXML(OutputStream, String, String)} methods load and store properties @@ -108,9 +107,6 @@ import jdk.internal.util.xml.PropertiesDefaultHandler; *

This class is thread-safe: multiple threads can share a single * Properties object without the need for external synchronization. * - * @see native2ascii tool for Solaris - * @see native2ascii tool for Windows - * * @author Arthur van Hoff * @author Michael McCloskey * @author Xueming Shen diff --git a/jdk/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java b/jdk/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java index 63dfcfb166e..1e93cb88a32 100644 --- a/jdk/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java +++ b/jdk/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java @@ -1013,7 +1013,6 @@ class WindowsPreferences extends AbstractPreferences { * description of the encoding algorithm. */ private static String toJavaValueString(byte[] windowsNameArray) { - // Use modified native2ascii algorithm String windowsName = byteArrayToString(windowsNameArray); StringBuilder javaName = new StringBuilder(); char ch; @@ -1055,8 +1054,7 @@ class WindowsPreferences extends AbstractPreferences { * Encoding algorithm adds "/" character to capital letters, i.e. * "A" is encoded as "/A". Character '\' is encoded as '//', * '/' is encoded as '\'. - * Then encoding scheme similar to jdk's native2ascii converter is used - * to convert java string to a byte array of ASCII characters. + * Then convert java string to a byte array of ASCII characters. */ private static byte[] toWindowsValueString(String javaName) { StringBuilder windowsName = new StringBuilder(); diff --git a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/A2NFilter.java b/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/A2NFilter.java deleted file mode 100644 index c36ae889dfa..00000000000 --- a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/A2NFilter.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2001, 2005, 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. - */ - -/** - * This FilterReader class processes a sequence of characters from - * a source stream containing a mixture of 7-bit ASCII data and - * 'back-tick U' escaped sequences representing characters which have - * the possibility of being encoded in a user specified encoding - * The filter relies on knowing the target encoding and makes a - * determination as to whether a given supplied character in its - * source character stream is encodeable in the target encoding. - * If not, it is remains in its back-tick U escaped form. - */ - -package sun.tools.native2ascii; -import java.io.*; - - -class A2NFilter extends FilterReader { - - // maintain a trailing buffer to hold any incompleted - // unicode escaped sequences - private char[] trailChars = null; - - public A2NFilter(Reader in) { - super(in); - } - - public int read(char[] buf, int off, int len) throws IOException { - int numChars = 0; // how many characters have been read - int retChars = 0; // how many characters we'll return - - char[] cBuf = new char[len]; - int cOffset = 0; // offset at which we'll start reading - boolean eof = false; - - // copy trailing chars from previous invocation to input buffer - if (trailChars != null) { - for (int i = 0; i < trailChars.length; i++) - cBuf[i] = trailChars[i]; - numChars = trailChars.length; - trailChars = null; - } - - int n = in.read(cBuf, numChars, len - numChars); - if (n < 0) { - eof = true; - if (numChars == 0) - return -1; // EOF; - } else { - numChars += n; - } - - for (int i = 0; i < numChars;) { - char c = cBuf[i++]; - - if (c != '\\' || (eof && numChars <= 5)) { - // Not a backslash, so copy and continue - // Always pass non backslash chars straight thru - // for regular encoding. If backslash occurs in - // input stream at the final 5 chars then don't - // attempt to read-ahead and de-escape since these - // are literal occurrences of U+005C which need to - // be encoded verbatim in the target encoding. - buf[retChars++] = c; - continue; - } - - int remaining = numChars - i; - if (remaining < 5) { - // Might be the first character of a unicode escape, but we - // don't have enough characters to tell, so save it and finish - trailChars = new char[1 + remaining]; - trailChars[0] = c; - for (int j = 0; j < remaining; j++) - trailChars[1 + j] = cBuf[i + j]; - break; - } - // At this point we have at least five characters remaining - - c = cBuf[i++]; - if (c != 'u') { - // Not a unicode escape, so copy and continue - buf[retChars++] = '\\'; - buf[retChars++] = c; - continue; - } - - // The next four characters are the hex part of a unicode escape - char rc = 0; - boolean isUE = true; - try { - rc = (char)Integer.parseInt(new String(cBuf, i, 4), 16); - } catch (NumberFormatException x) { - isUE = false; - } - if (isUE && Main.canConvert(rc)) { - // We'll be able to convert this - buf[retChars++] = rc; - i += 4; // Align beyond the current uXXXX sequence - } else { - // We won't, so just retain the original sequence - buf[retChars++] = '\\'; - buf[retChars++] = 'u'; - continue; - } - - } - - return retChars; - } - - public int read() throws IOException { - char[] buf = new char[1]; - - if (read(buf, 0, 1) == -1) - return -1; - else - return (int)buf[0]; - } - -} diff --git a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/Main.java b/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/Main.java deleted file mode 100644 index 00e833228b6..00000000000 --- a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/Main.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (c) 1996, 2012, 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. - */ - -/* - */ - -/* - Currently javac and load() method in java.util.Properties - supports only Latin1 encoding input. - But in Asian platforms programmer or message translator - uses the editor which support othere than latin1 encoding - to specify their native language string. - So if programmer or message translator wants to use other than - Latin1 character in his/her program source or properties file - they must convert the file to ASCII plus \udddd notation. - (javac/load() modification is not appropriate due to - time constraints for JDK1.1) - This utility is for the purpose of that conversion. - - NAME - native2ascii - convert native encoding file to ascii file - include \udddd Unicode notation - - SYNOPSIS - native2ascii [options] [inputfile [outputfile]] - - DESCRIPTION - If outputfile is not described standard output is used as - output file, and if inputfile is not also described - stardard input is used as input file. - - Options - - -reverse - convert ascii with \udddd notation to native encoding - - -encoding encoding_name - Specify the encoding name which is used by conversion. - 8859_[1 - 9], JIS, EUCJIS, SJIS is currently supported. - Default encoding is taken from System property "file.encoding". - -*/ - -package sun.tools.native2ascii; - -import java.io.*; -import java.util.*; -import java.text.MessageFormat; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.Charset; -import java.nio.charset.IllegalCharsetNameException; -import java.io.UnsupportedEncodingException; -import java.nio.charset.UnsupportedCharsetException; - -/** - * Main program of the native2ascii - */ - -public class Main { - - String inputFileName = null; - String outputFileName = null; - File tempFile = null; - boolean reverse = false; - static String encodingString = null; - static String defaultEncoding = null; - static CharsetEncoder encoder = null; - - /** - * Run the converter - */ - public synchronized boolean convert(String argv[]) { - List v = new ArrayList<>(2); - File outputFile = null; - boolean createOutputFile = false; - - // Parse arguments - for (int i = 0; i < argv.length; i++) { - if (argv[i].equals("-encoding")) { - if ((i + 1) < argv.length) { - encodingString = argv[++i]; - } else { - error(getMsg("err.bad.arg")); - usage(); - return false; - } - } else if (argv[i].equals("-reverse")) { - reverse = true; - } else { - if (v.size() > 1) { - usage(); - return false; - } - v.add(argv[i]); - } - } - - if (encodingString == null) { - defaultEncoding = Charset.defaultCharset().name(); - } - char[] lineBreak = System.getProperty("line.separator").toCharArray(); - - try { - initializeConverter(); - - if (v.size() == 1) { - inputFileName = v.get(0); - } - - if (v.size() == 2) { - inputFileName = v.get(0); - outputFileName = v.get(1); - createOutputFile = true; - } - - if (createOutputFile) { - outputFile = new File(outputFileName); - if (outputFile.exists() && !outputFile.canWrite()) { - throw new Exception(formatMsg("err.cannot.write", outputFileName)); - } - } - - if (reverse) { - try (BufferedReader reader = getA2NInput(inputFileName); - Writer osw = getA2NOutput(outputFileName);) { - String line; - while ((line = reader.readLine()) != null) { - osw.write(line.toCharArray()); - osw.write(lineBreak); - if (outputFileName == null) { // flush stdout - osw.flush(); - } - } - } - } else { - // N2A - try (BufferedReader in = getN2AInput(inputFileName); - BufferedWriter out = getN2AOutput(outputFileName);) { - String inLine; - while ((inLine = in.readLine()) != null) { - out.write(inLine.toCharArray()); - out.write(lineBreak); - if (outputFileName == null) { // flush stdout - out.flush(); - } - } - } - } - - // Since we are done rename temporary file to desired output file - if (createOutputFile) { - if (outputFile.exists()) { - // Some win32 platforms can't handle atomic - // rename if source and target file paths are - // identical. To make things simple we just unconditionally - // delete the target file before calling renameTo() - outputFile.delete(); - } - tempFile.renameTo(outputFile); - } - } catch (Exception e) { - error(e.toString()); - return false; - } - - return true; - } - - private void error(String msg){ - System.out.println(msg); - } - - private void usage(){ - System.out.println(getMsg("usage")); - } - - - private BufferedReader getN2AInput(String inFile) throws Exception { - - InputStream forwardIn; - if (inFile == null) - forwardIn = System.in; - else { - File f = new File(inFile); - if (!f.canRead()){ - throw new Exception(formatMsg("err.cannot.read", f.getName())); - } - - try { - forwardIn = new FileInputStream(inFile); - } catch (IOException e) { - throw new Exception(formatMsg("err.cannot.read", f.getName())); - } - } - - BufferedReader r = (encodingString != null) ? - new BufferedReader(new InputStreamReader(forwardIn, - encodingString)) : - new BufferedReader(new InputStreamReader(forwardIn)); - return r; - } - - - private BufferedWriter getN2AOutput(String outFile) throws Exception { - Writer output; - BufferedWriter n2aOut; - - if (outFile == null) - output = new OutputStreamWriter(System.out,"US-ASCII"); - - else { - File f = new File(outFile); - - File tempDir = f.getParentFile(); - - if (tempDir == null) - tempDir = new File(System.getProperty("user.dir")); - - tempFile = File.createTempFile("_N2A", - ".TMP", - tempDir); - tempFile.deleteOnExit(); - - try { - output = new FileWriter(tempFile); - } catch (IOException e){ - throw new Exception(formatMsg("err.cannot.write", tempFile.getName())); - } - } - - n2aOut = new BufferedWriter(new N2AFilter(output)); - return n2aOut; - } - - private BufferedReader getA2NInput(String inFile) throws Exception { - Reader in; - BufferedReader reader; - - if (inFile == null) - in = new InputStreamReader(System.in, "US-ASCII"); - else { - File f = new File(inFile); - if (!f.canRead()){ - throw new Exception(formatMsg("err.cannot.read", f.getName())); - } - - try { - in = new FileReader(inFile); - } catch (Exception e) { - throw new Exception(formatMsg("err.cannot.read", f.getName())); - } - } - - reader = new BufferedReader(new A2NFilter(in)); - return reader; - } - - private Writer getA2NOutput(String outFile) throws Exception { - - OutputStreamWriter w = null; - OutputStream output = null; - - if (outFile == null) - output = System.out; - else { - File f = new File(outFile); - - File tempDir = f.getParentFile(); - if (tempDir == null) - tempDir = new File(System.getProperty("user.dir")); - tempFile = File.createTempFile("_N2A", - ".TMP", - tempDir); - tempFile.deleteOnExit(); - - try { - output = new FileOutputStream(tempFile); - } catch (IOException e){ - throw new Exception(formatMsg("err.cannot.write", tempFile.getName())); - } - } - - w = (encodingString != null) ? - new OutputStreamWriter(output, encodingString) : - new OutputStreamWriter(output); - - return (w); - } - - private static Charset lookupCharset(String csName) { - if (Charset.isSupported(csName)) { - try { - return Charset.forName(csName); - } catch (UnsupportedCharsetException x) { - throw new Error(x); - } - } - return null; - } - - public static boolean canConvert(char ch) { - return (encoder != null && encoder.canEncode(ch)); - } - - private static void initializeConverter() throws UnsupportedEncodingException { - Charset cs = null; - - try { - cs = (encodingString == null) ? - lookupCharset(defaultEncoding): - lookupCharset(encodingString); - - encoder = (cs != null) ? - cs.newEncoder() : - null; - } catch (IllegalCharsetNameException e) { - throw new Error(e); - } - } - - private static ResourceBundle rsrc; - - static { - try { - rsrc = ResourceBundle.getBundle( - "sun.tools.native2ascii.resources.MsgNative2ascii"); - } catch (MissingResourceException e) { - throw new Error("Missing message file."); - } - } - - private String getMsg(String key) { - try { - return (rsrc.getString(key)); - } catch (MissingResourceException e) { - throw new Error("Error in message file format."); - } - } - - private String formatMsg(String key, String arg) { - String msg = getMsg(key); - return MessageFormat.format(msg, arg); - } - - - /** - * Main program - */ - public static void main(String argv[]){ - Main converter = new Main(); - System.exit(converter.convert(argv) ? 0 : 1); - } -} diff --git a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/N2AFilter.java b/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/N2AFilter.java deleted file mode 100644 index c1b7efb319e..00000000000 --- a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/N2AFilter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2001, 2008, 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. - */ - - -/** - * This FilterWriter class takes an existing Writer and uses - * the 'back-tick U' escape notation to escape characters which are - * encountered within the input character based stream which - * are outside the 7-bit ASCII range. The native platforms linefeed - * character is emitted for each line of processed input - */ - -package sun.tools.native2ascii; -import java.io.*; -import java.nio.BufferOverflowException; - -class N2AFilter extends FilterWriter { - - public N2AFilter(Writer out) { super(out); } - - public void write(char b) throws IOException { - char[] buf = new char[1]; - buf[0] = b; - write(buf, 0, 1); - } - - public void write(char[] buf, int off, int len) throws IOException { - - String lineBreak = System.getProperty("line.separator"); - - //System.err.println ("xx Out buffer length is " + buf.length ); - for (int i = 0; i < len; i++) { - if ((buf[i] > '\u007f')) { - // write \udddd - out.write('\\'); - out.write('u'); - String hex = - Integer.toHexString(buf[i]); - StringBuilder hex4 = new StringBuilder(hex); - hex4.reverse(); - int length = 4 - hex4.length(); - for (int j = 0; j < length; j++) { - hex4.append('0'); - } - for (int j = 0; j < 4; j++) { - out.write(hex4.charAt(3 - j)); - } - } else - out.write(buf[i]); - } - } -} diff --git a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/resources/MsgNative2ascii.java b/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/resources/MsgNative2ascii.java deleted file mode 100644 index 55b22bcc67a..00000000000 --- a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/resources/MsgNative2ascii.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1998, 2010, 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 sun.tools.native2ascii.resources; - -import java.util.ListResourceBundle; - -public class MsgNative2ascii extends ListResourceBundle { - - public Object[][] getContents() { - Object[][] temp = new Object[][] { - {"err.bad.arg", "-encoding requires argument"}, - {"err.cannot.read", "{0} could not be read."}, - {"err.cannot.write", "{0} could not be written."}, - {"usage", "Usage: native2ascii" + - " [-reverse] [-encoding encoding] [inputfile [outputfile]]"}, - }; - - return temp; - } -} diff --git a/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties b/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties index f435c6cca14..f5ce0f8deef 100644 --- a/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties +++ b/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties @@ -634,4 +634,4 @@ main.path.msg=\ [The source classpath is "{0}"]\n\ [The library classpath is "{1}"] javac.err.invalid.encoding.char=\ - The source file encoding may be different with this platform encoding. Please use -encoding option to adjust file encoding, or apply native2ascii utility to make source file ASCII encoding. + The source file encoding may be different with this platform encoding. Please use -encoding option to adjust file encoding, or make sure source file converted to ASCII encoding. diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index d6af5fa5799..dafec986fbd 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -214,14 +214,12 @@ core_tools = \ jdk/internal/jimage \ jdk/internal/jrtfs \ sun/tools/java \ - sun/tools/native2ascii \ sun/tools/jrunscript svc_tools = \ com/sun/tools/attach \ sun/tools \ -sun/tools/java \ - -sun/tools/native2ascii \ -sun/tools/jrunscript \ sun/jvmstat \ demo/jvmti diff --git a/jdk/test/sun/tools/native2ascii/A2N_4630463 b/jdk/test/sun/tools/native2ascii/A2N_4630463 deleted file mode 100644 index 846e6fac844..00000000000 --- a/jdk/test/sun/tools/native2ascii/A2N_4630463 +++ /dev/null @@ -1 +0,0 @@ -\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF diff --git a/jdk/test/sun/tools/native2ascii/A2N_4630463.expected b/jdk/test/sun/tools/native2ascii/A2N_4630463.expected deleted file mode 100644 index 6c694dc3fb9..00000000000 --- a/jdk/test/sun/tools/native2ascii/A2N_4630463.expected +++ /dev/null @@ -1 +0,0 @@ -€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ diff --git a/jdk/test/sun/tools/native2ascii/A2N_4630971 b/jdk/test/sun/tools/native2ascii/A2N_4630971 deleted file mode 100644 index 263852a641b..00000000000 --- a/jdk/test/sun/tools/native2ascii/A2N_4630971 +++ /dev/null @@ -1,4 +0,0 @@ -#input test file 4630971 for bug native2ascii -reverse -#occurence of a backslash character in last 5 chars -#of input file should not hang native2ascii -reverse -Hello world\\\\\ diff --git a/jdk/test/sun/tools/native2ascii/A2N_4701617 b/jdk/test/sun/tools/native2ascii/A2N_4701617 deleted file mode 100644 index 0ccf547c303..00000000000 --- a/jdk/test/sun/tools/native2ascii/A2N_4701617 +++ /dev/null @@ -1,11 +0,0 @@ -\uFF61\uFF62\uFF63\uFF64\uFF65\uFF66 -\uFF67\uFF68\uFF69\uFF6A\uFF6B\uFF6C -\uFF6D\uFF6E\uFF6F\uFF70\uFF71\uFF72 -\uFF73\uFF74\uFF75\uFF76\uFF77\uFF78 -\uFF79\uFF7A\uFF7B\uFF7C\uFF7D\uFF7E -\uFF7F\uFF80\uFF81\uFF82\uFF83\uFF84 -\uFF85\uFF86\uFF87\uFF88\uFF89\uFF8A -\uFF8B\uFF8C\uFF8D\uFF8E\uFF8F\uFF90 -\uFF91\uFF92\uFF93\uFF94\uFF95\uFF96 -\uFF97\uFF98\uFF99\uFF9A\uFF9B\uFF9C -\uFF9D\uFF9E\uFF9F diff --git a/jdk/test/sun/tools/native2ascii/A2N_4701617.expected b/jdk/test/sun/tools/native2ascii/A2N_4701617.expected deleted file mode 100644 index 741d22ad860..00000000000 --- a/jdk/test/sun/tools/native2ascii/A2N_4701617.expected +++ /dev/null @@ -1,11 +0,0 @@ -¡¢£¤¥¦ -§¨©ª«¬ -­®¯°±² -³´µ¶·¸ -¹º»¼½¾ -¿ÀÁÂÃÄ -ÅÆÇÈÉÊ -ËÌÍÎÏÐ -ÑÒÓÔÕÖ -רÙÚÛÜ -ÝÞß diff --git a/jdk/test/sun/tools/native2ascii/A2N_6247817 b/jdk/test/sun/tools/native2ascii/A2N_6247817 deleted file mode 100644 index ea566cb3a9b..00000000000 --- a/jdk/test/sun/tools/native2ascii/A2N_6247817 +++ /dev/null @@ -1 +0,0 @@ -\user diff --git a/jdk/test/sun/tools/native2ascii/N2A_4636448 b/jdk/test/sun/tools/native2ascii/N2A_4636448 deleted file mode 100644 index 6c694dc3fb9..00000000000 --- a/jdk/test/sun/tools/native2ascii/N2A_4636448 +++ /dev/null @@ -1 +0,0 @@ -€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ diff --git a/jdk/test/sun/tools/native2ascii/N2A_4636448.expected b/jdk/test/sun/tools/native2ascii/N2A_4636448.expected deleted file mode 100644 index e2bcea3a295..00000000000 --- a/jdk/test/sun/tools/native2ascii/N2A_4636448.expected +++ /dev/null @@ -1 +0,0 @@ -\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008a\u008b\u008c\u008d\u008e\u008f\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009a\u009b\u009c\u009d\u009e\u009f\u00a0\u00a1\u00a2\u00a3\u00a4\u00a5\u00a6\u00a7\u00a8\u00a9\u00aa\u00ab\u00ac\u00ad\u00ae\u00af\u00b0\u00b1\u00b2\u00b3\u00b4\u00b5\u00b6\u00b7\u00b8\u00b9\u00ba\u00bb\u00bc\u00bd\u00be\u00bf\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u00c6\u00c7\u00c8\u00c9\u00ca\u00cb\u00cc\u00cd\u00ce\u00cf\u00d0\u00d1\u00d2\u00d3\u00d4\u00d5\u00d6\u00d7\u00d8\u00d9\u00da\u00db\u00dc\u00dd\u00de\u00df\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5\u00e6\u00e7\u00e8\u00e9\u00ea\u00eb\u00ec\u00ed\u00ee\u00ef\u00f0\u00f1\u00f2\u00f3\u00f4\u00f5\u00f6\u00f7\u00f8\u00f9\u00fa\u00fb\u00fc\u00fd\u00fe\u00ff diff --git a/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh b/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh deleted file mode 100644 index 5c886c2100d..00000000000 --- a/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh +++ /dev/null @@ -1,129 +0,0 @@ -#! /bin/sh -e - -# -# Copyright (c) 2002, 2011, 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 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987 8067964 -# @summary Tests miscellaneous native2ascii bugfixes and regressions - - -if [ "${TESTSRC}" = "" ]; then TESTSRC=.; fi -if [ "${TESTJAVA}" = "" ]; then TESTJAVA=$1; shift; fi - -case `uname -s` in - Windows* | CYGWIN*) OS=Windows;; - SunOS|Linux) OS=Unix;; -esac - -N2A=$TESTJAVA/bin/native2ascii - -check() { - bug=$1; shift - expected=$1; shift - out=$1; shift - - # Strip carriage returns from output when comparing with n2a test output - # on win32 systems - if [ ${OS} = Windows ]; then - sed -e 's@\\r@@g' $out >$out.1 - sed -e 's@\\r@@g' $expected >$out.expected - else - cp $out $out.1 - cp $expected $out.expected - fi - if (set -x; diff -c $out.expected $out.1); then - echo "$bug passed" - else - echo "$bug failed" - exit 1 - fi -} - -# Check that native2ascii -reverse with an ISO-8859-1 encoded file works -# as documented. 4630463 fixes a bug in the ISO-8859-1 encoder which -# prevented encoding of valid ISO-8859-1 chars > 0x7f - -rm -f x.* -$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630463 x.out -check 4630463 $TESTSRC/A2N_4630463.expected x.out - -# Take file encoded in ISO-8859-1 with range of chars , 0x7f < c < 0xff -# invoke native2ascii with input filename and output filename identical -# Ensure that output file is as expected by comparing to expected output. -# 4636448 Fixed bug whereby output file was clobbered if infile and outfile -# referred to same filename. This bug only applies to Solaris/Linux, since on -# Windows you can't write to a file that's open for reading. - -if [ $OS = Unix ]; then - rm -f x.* - cp $TESTSRC/N2A_4636448 x.in - chmod +w x.in - ls -l x.in - if $N2A -encoding ISO-8859-1 x.in x.in; then - check 4636448 $TESTSRC/N2A_4636448.expected x.in - fi -fi - -# Ensure that files containing backslashes adjacent to EOF don't -# hang native2ascii -reverse - -rm -f x.* -$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630971 x.out -check 4630971 $TESTSRC/A2N_4630971 x.out - -# Check reverse (char -> native) encoding of Japanese Halfwidth -# Katakana characters for MS932 (default WinNT Japanese encoding) -# Regression test for bugID 4701617 - -rm -f x.* -$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) - -if [ OS = Windows ]; then - rm -f x.* - cp $TESTSRC/test3 x.in - chmod a+x x.in - ls -l x.in - touch x.out - $N2A -encoding ISO-8859-1 x.in x.out - check 4710890 $TESTSRC/test3 x.out -fi - -rm -rf x.* -$N2A -reverse $TESTSRC/A2N_6247817 x.out -check 4701617 $TESTSRC/A2N_6247817 x.out - diff --git a/jdk/test/sun/tools/native2ascii/NativeErrors.java b/jdk/test/sun/tools/native2ascii/NativeErrors.java deleted file mode 100644 index 81b1920b36a..00000000000 --- a/jdk/test/sun/tools/native2ascii/NativeErrors.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 1998, 1999, 2014 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 4136352 - * @library /lib/testlibrary - * @summary Test Native2ASCII error messages - * - */ - -import java.io.File; -import java.util.ResourceBundle; -import java.util.MissingResourceException; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.ProcessTools; - -public class NativeErrors { - - private static ResourceBundle rsrc; - - static { - try { - rsrc = ResourceBundle.getBundle( - "sun.tools.native2ascii.resources.MsgNative2ascii"); - } catch (MissingResourceException e) { - throw new Error("Missing message file."); - } - } - - public static void main(String args[]) throws Throwable { - // Execute command in another vm. Verify stdout for expected err msg. - - // Test with no input file given. - checkResult(executeCmd("-encoding"), "err.bad.arg"); - - File f0 = new File(System.getProperty("test.src", "."), "test123"); - String path0 = f0.getPath(); - if ( f0.exists() ) { - throw new Error("Input file should not exist: " + path0); - } - checkResult(executeCmd(path0), "err.cannot.read"); - - File f1 = new File(System.getProperty("test.src", "."), "test1"); - File f2 = File.createTempFile("test2", ".tmp"); - String path1 = f1.getPath(); - String path2 = f2.getPath(); - if ( !f1.exists() ) { - throw new Error("Missing input file: " + path1); - } - if ( !f2.setWritable(false) ) { - throw new Error("Output file cannot be made read only: " + path2); - } - f2.deleteOnExit(); - if ( f2.canWrite() ) { - String msg = "Output file is still writable. " + - "Probably because test is run as root. Read-only test skipped."; - System.out.println(msg); - } else { - // Test write to a read-only file. - checkResult(executeCmd(path1, path2), "err.cannot.write"); - } - } - - private static String executeCmd(String... toolArgs) throws Throwable { - JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); - for (String s : toolArgs) { - cmd.addToolArg(s); - } - OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); - if (output == null || output.getStdout() == null) { - throw new Exception("Output was null. Process did not finish correctly."); - } - if (output.getExitValue() == 0) { - throw new Exception("Process exit code was 0, but error was expected."); - } - return output.getStdout(); - } - - private static void checkResult( - String errorReceived, String errorKey) throws Exception { - String errorExpected = rsrc.getString(errorKey); - if (errorExpected == null) { - throw new Exception("No error message for key: " + errorKey); - } - // Remove template tag from error message. - errorExpected = errorExpected.replaceAll("\\{0\\}", ""); - - System.out.println("received: " + errorReceived); - System.out.println("expected: " + errorExpected); - if (errorReceived.indexOf(errorExpected) < 0) { - throw new RuntimeException("Native2ascii bad arg error broken."); - } - } - -} diff --git a/jdk/test/sun/tools/native2ascii/Permission.java b/jdk/test/sun/tools/native2ascii/Permission.java deleted file mode 100644 index 53718d21fd7..00000000000 --- a/jdk/test/sun/tools/native2ascii/Permission.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2012, 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 7177216 - * @summary resulting file of native2ascii should have normal permission - */ - -import java.io.*; -import java.nio.file.*; -import java.nio.file.attribute.*; -import sun.tools.native2ascii.Main; - -public class Permission { - - private static void cleanup(String... fnames) throws Throwable { - for (String fname : fnames) { - Files.deleteIfExists(Paths.get(fname)); - } - } - - public static void realMain(String[] args) throws Throwable { - if (!System.getProperty("os.name").startsWith("Windows")) { - String src = "native2ascii_permtest_src"; - String dst = "native2ascii_permtest_dst"; - - cleanup(src, dst); - try { - try (FileOutputStream fos = new FileOutputStream(src)) { - fos.write('a'); fos.write('b'); fos.write('c'); - } - String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst}; - if (!new Main().convert(n2aArgs)) { - fail("n2a failed."); - } - equal(Files.getPosixFilePermissions(Paths.get(src)), - Files.getPosixFilePermissions(Paths.get(dst))); - String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src}; - if (!new Main().convert(a2nArgs)) { - fail("a2n failed."); - } - equal(Files.getPosixFilePermissions(Paths.get(src)), - Files.getPosixFilePermissions(Paths.get(dst))); - } finally { - cleanup(src, dst); - } - } - } - - //--------------------- Infrastructure --------------------------- - static volatile int passed = 0, failed = 0; - static void pass() {passed++;} - static void fail() {failed++; Thread.dumpStack();} - static void fail(String msg) {System.out.println(msg); fail();} - static void unexpected(Throwable t) {failed++; t.printStackTrace();} - static void check(boolean cond) {if (cond) pass(); else fail();} - static void equal(Object x, Object y) { - if (x == null ? y == null : x.equals(y)) pass(); - else fail(x + " not equal to " + y);} - public static void main(String[] args) throws Throwable { - try {realMain(args);} catch (Throwable t) {unexpected(t);} - System.out.println("\nPassed = " + passed + " failed = " + failed); - if (failed > 0) throw new AssertionError("Some tests failed");} -} diff --git a/jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.java b/jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.java deleted file mode 100644 index 2a00ab813f4..00000000000 --- a/jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2005, 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 6287579 - * @summary SubClasses of ListResourceBundle should fix getContents() - * @run main ImmutableResourceTest - * - * @author Tim Bell - * - */ -import java.util.ResourceBundle; - -public class ImmutableResourceTest { - - public static void main(String[] args) throws Exception { - /* Reach under the covers and get the message strings */ - sun.tools.native2ascii.resources.MsgNative2ascii msgs = - new sun.tools.native2ascii.resources.MsgNative2ascii (); - Object [][] testData = msgs.getContents(); - - /* Shred our copy of the message strings */ - for (int ii = 0; ii < testData.length; ii++) { - testData[ii][0] = "T6287579"; - testData[ii][1] = "yyy"; - } - - /* - * Try to lookup the shredded key. - * If this is successful we have a problem. - */ - String ss = null; - try { - ss = msgs.getString("T6287579"); - } catch (java.util.MissingResourceException mre) { - /* - * Ignore the expected MissingResourceException since key - * "T6287579" is not in the canonical MsgNative2ascii. - */ - } - if ("yyy".equals(ss)) { - throw new Exception ("SubClasses of ListResourceBundle should fix getContents()"); - } - System.out.println("...Finished."); - } -} diff --git a/jdk/test/sun/tools/native2ascii/test1 b/jdk/test/sun/tools/native2ascii/test1 deleted file mode 100644 index 35f7ab26c98..00000000000 --- a/jdk/test/sun/tools/native2ascii/test1 +++ /dev/null @@ -1 +0,0 @@ -This file exists as a readable placeholder for NativeErrors.java. diff --git a/jdk/test/sun/tools/native2ascii/test3 b/jdk/test/sun/tools/native2ascii/test3 deleted file mode 100644 index b816ce24a64..00000000000 --- a/jdk/test/sun/tools/native2ascii/test3 +++ /dev/null @@ -1 +0,0 @@ -This file exists as a non-writable placeholder for Native2AsciiTests diff --git a/jdk/test/tools/launcher/VersionCheck.java b/jdk/test/tools/launcher/VersionCheck.java index d7044446588..687917177e3 100644 --- a/jdk/test/tools/launcher/VersionCheck.java +++ b/jdk/test/tools/launcher/VersionCheck.java @@ -93,7 +93,6 @@ public class VersionCheck extends TestHelper { "kinit", "klist", "ktab", - "native2ascii", "orbd", "pack200", "packager",