test/tools/javac/api/T6306137.java

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

author
mcimadamore
date
Thu, 21 Feb 2013 15:26:46 +0000
changeset 1599
9f0ec00514b6
parent 1553
b386b8c45387
child 1821
1936a884b290
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) 2005, 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     6306137
    27  * @summary JSR 199: encoding option doesn't affect standard file manager
    28  * @compile -encoding utf-8 T6306137.java
    29  * @run main T6306137
    30  * @author  Peter von der Ahé
    31  */
    33 import java.io.File;
    34 import java.util.Arrays;
    35 import javax.tools.*;
    37 public class T6306137 {
    38     boolean error;
    39     final StandardJavaFileManager fm;
    40     final JavaCompiler compiler;
    41     Iterable<? extends JavaFileObject> files;
    42     DiagnosticListener<JavaFileObject> dl;
    44     T6306137() {
    45         dl = new DiagnosticListener<JavaFileObject>() {
    46                 public void report(Diagnostic<? extends JavaFileObject> message) {
    47                     if (message.getKind() == Diagnostic.Kind.ERROR)
    48                         error = true;
    49                     System.out.println(message.getSource()
    50                                        +":"+message.getStartPosition()+":"
    51                                        +message.getStartPosition()+":"+message.getPosition());
    52                     System.out.println(message.toString());
    53                     System.out.format("Found problem: %s%n", message.getCode());
    54                     System.out.flush();
    55                 }
    56         };
    57         compiler = ToolProvider.getSystemJavaCompiler();
    58         fm = compiler.getStandardFileManager(dl, null, null);
    59         String srcdir = System.getProperty("test.src");
    60         files =
    61             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6306137.java")));
    62     }
    64     void test(String encoding, boolean good) {
    65         error = false;
    66         Iterable<String> args = Arrays.asList("-source", "6", "-encoding", encoding, "-d", ".");
    67         compiler.getTask(null, fm, dl, args, null, files).call();
    68         if (error == good) {
    69             if (error) {
    70                 throw new AssertionError("Error reported");
    71             } else {
    72                 throw new AssertionError("No error reported");
    73             }
    74         }
    75     }
    77     public static void main(String[] args) {
    78         T6306137 self = new T6306137();
    79         self.test("utf-8", true);
    80         self.test("ascii", false);
    81         self.test("utf-8", true);
    82     }
    83 }

mercurial