Path: blob/master/test/jdk/tools/launcher/DiacriticTest.java
41144 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 801724826* @summary Compiler Diacritics Issue27* @run main DiacriticTest28*/2930import java.io.File;31import java.io.IOException;32import java.nio.file.InvalidPathException;33import java.nio.charset.UnmappableCharacterException;34import java.util.ArrayList;35import java.util.HashMap;3637public class DiacriticTest extends TestHelper {3839// NFD-normalized form of the class name40static String NAME_NFD="ClassA\u0301";41// NFC-normalized form of the same class name42static String NAME_NFC="Class\u00C1";4344public static void main(String[] args) throws IOException {45if (!isMacOSX) {46System.out.println("This test is for Mac OS X only. Passing.");47return;48}4950String lang = System.getenv("LANG");51if (lang != null && !lang.contains("UTF-8")) {52System.out.println("LANG variable set to the language that " +53"does not support unicode, test passes vacuously");54return;55}5657File sourceFile = new File(NAME_NFC + ".java");58String source = "public class " + NAME_NFC + " { " +59" public static void main(String args[]) {\n" +60" System.out.println(\"Success!\");\n" +61" }\n" +62"}\n";63ArrayList<String> content = new ArrayList<>();64content.add(source);65try {66createFile(sourceFile, content);67} catch (UnmappableCharacterException | InvalidPathException ipe) {68System.out.println("The locale or file system is configured in a way " +69"that prevents file creation. Real testing impossible.");70return;71}7273HashMap<String, String> env = new HashMap<>();74env.put("LC_CTYPE", "UTF-8");7576TestResult tr;77tr = doExec(env, javacCmd, NAME_NFD + ".java");78System.out.println(tr.testOutput);79if (!tr.isOK()) {80System.out.println(tr);81throw new RuntimeException("Compilation failed");82}83tr = doExec(env, javaCmd, "-cp", ".", NAME_NFD);84System.out.println(tr.testOutput);85if (!tr.isOK()) {86System.out.println(tr);87throw new RuntimeException("Test execution failed");88}89}90}919293