Mon, 24 Nov 2014 12:49:30 -0500
8029012: parameter_index for type annotation not updated after outer.this added
Summary: Fix javac's handling of type annotations when synthetic parameters are added
Reviewed-by: jjg, mcimadamore
jjg@215 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
jjg@215 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@215 | 4 | * |
jjg@215 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@215 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@215 | 7 | * published by the Free Software Foundation. |
jjg@215 | 8 | * |
jjg@215 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@215 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@215 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@215 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@215 | 13 | * accompanied this code). |
jjg@215 | 14 | * |
jjg@215 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@215 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@215 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@215 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
jjg@215 | 22 | */ |
jjg@215 | 23 | |
jjg@215 | 24 | /* |
jjg@215 | 25 | * @test |
jjg@215 | 26 | * @bug 6595666 |
jjg@215 | 27 | * @summary fix -Werror |
jjg@215 | 28 | */ |
jjg@215 | 29 | |
jjg@215 | 30 | import java.io.*; |
jjg@215 | 31 | import java.util.*; |
jjg@215 | 32 | |
jjg@215 | 33 | public class T6595666 { |
jjg@215 | 34 | void m() { |
jjg@215 | 35 | // the following line must create warnings with -Xlint, because of unchecked conversion |
jjg@215 | 36 | List<Integer> list = new ArrayList(); |
jjg@215 | 37 | } |
jjg@215 | 38 | |
jjg@215 | 39 | public static void main(String... args) throws Exception { |
jjg@215 | 40 | File testSrc = new File(System.getProperty("test.src", ".")); |
jjg@215 | 41 | |
jjg@215 | 42 | String basename = T6595666.class.getName(); |
jjg@215 | 43 | File srcFile = new File(testSrc, basename+".java"); |
jjg@215 | 44 | File classFile = new File(basename+".class"); |
jjg@215 | 45 | classFile.delete(); |
jjg@215 | 46 | if (classFile.exists()) |
jjg@215 | 47 | throw new Exception("setup error, can't delete " + classFile); |
jjg@215 | 48 | |
jjg@215 | 49 | compile(1, "-d", ".", "-Xlint", "-Werror", srcFile.getPath()); |
jjg@215 | 50 | if (classFile.exists()) |
jjg@215 | 51 | throw new Exception("failed: found " + classFile); |
jjg@215 | 52 | |
jjg@215 | 53 | compile(0, "-d", ".", "-Xlint", srcFile.getPath()); |
jjg@215 | 54 | if (!classFile.exists()) |
jjg@215 | 55 | throw new Exception("failed: " + classFile + " not found"); |
jjg@215 | 56 | } |
jjg@215 | 57 | |
jjg@215 | 58 | private static void compile(int rc, String... args) throws Exception { |
jjg@215 | 59 | System.err.println("compile: " + Arrays.asList(args)); |
jjg@215 | 60 | StringWriter sw = new StringWriter(); |
jjg@215 | 61 | PrintWriter pw = new PrintWriter(sw); |
jjg@215 | 62 | int rc2 = com.sun.tools.javac.Main.compile(args, pw); |
jjg@215 | 63 | pw.close(); |
jjg@215 | 64 | System.err.println(sw); |
jjg@215 | 65 | if (rc != rc2) |
jjg@215 | 66 | throw new Exception("bad exit code; expected " + rc + ", found " + rc2); |
jjg@215 | 67 | } |
jjg@215 | 68 | } |