test/tools/javac/4846262/CheckEBCDICLocaleTest.java

Thu, 21 Feb 2013 15:26:46 +0000

author
mcimadamore
date
Thu, 21 Feb 2013 15:26:46 +0000
changeset 1599
9f0ec00514b6
parent 1591
dc8b7aa7cef3
child 1637
2e21ecd7a5ad
permissions
-rw-r--r--

8007461: Regression: bad overload resolution when inner class and outer class have method with same name
Summary: Fix regression in varargs method resolution introduced by bad refactoring
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 4846262
    27  * @summary check that javac operates correctly in EBCDIC locale
    28  * @library /tools/javac/lib
    29  * @build ToolBox
    30  * @run main CheckEBCDICLocaleTest
    31  */
    33 import java.io.File;
    34 import java.nio.file.Files;
    35 import java.nio.file.Paths;
    36 import java.util.Arrays;
    37 import com.sun.tools.javac.util.ArrayUtils;
    39 //original test: test/tools/javac/4846262/Test.sh
    40 public class CheckEBCDICLocaleTest {
    42     private static final String TestSrc =
    43         "public class Test {\n" +
    44         "    public void test() {\n" +
    45         "        abcdefg\n" +
    46         "    }\n" +
    47         "}";
    49     private static final String TestOut =
    50         "output/Test.java:3: error: not a statement\n" +
    51         "        abcdefg\n" +
    52         "        ^\n" +
    53         "output/Test.java:3: error: ';' expected\n" +
    54         "        abcdefg\n" +
    55         "               ^\n" +
    56         "2 errors\n";
    58     public static void main(String[] args) throws Exception {
    59         new CheckEBCDICLocaleTest().test();
    60     }
    62     public void test() throws Exception {
    63         String native2asciiBinary = Paths.get(
    64                 System.getProperty("test.jdk"),"bin", "native2ascii").toString();
    65         String testVMOpts = System.getProperty("test.tool.vm.opts");
    66         String[] mainArgs = ToolBox.getJavacBin();
    68         ToolBox.createJavaFileFromSource(TestSrc);
    69         Files.createDirectory(Paths.get("output"));
    71 //"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java
    72         ToolBox.AnyToolArgs nativeCmdParams =
    73                 new ToolBox.AnyToolArgs()
    74                 .setAllArgs(native2asciiBinary, testVMOpts,
    75                     "-reverse", "-encoding", "IBM1047",
    76                     "Test.java", "output/Test.java");
    77         ToolBox.executeCommand(nativeCmdParams);
    79 //"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp
    80         ToolBox.AnyToolArgs javacParams =
    81                 new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
    82                 .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Duser.language=en",
    83                 "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047",
    84                 "output/Test.java"))
    85                 .setErrOutput(new File("Test.tmp"));
    86         ToolBox.executeCommand(javacParams);
    88 //"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out
    89         nativeCmdParams.setAllArgs(native2asciiBinary, "-encoding", "IBM1047",
    90                     "Test.tmp", "Test.out");
    91         ToolBox.executeCommand(nativeCmdParams);
    93 //diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
    94         ToolBox.compareLines(Paths.get("Test.out"),
    95                 Arrays.asList(TestOut.split("\n")), null);
    97     }
    99 }

mercurial