Tue, 02 Feb 2010 10:56:10 -0800
6918625: handle annotations on array class literals
Reviewed-by: jjg, darcy
Contributed-by: mali@csail.mit.edu, mernst@cs.washington.edu
mcimadamore@360 | 1 | /* |
mcimadamore@360 | 2 | * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. |
mcimadamore@360 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
mcimadamore@360 | 4 | * |
mcimadamore@360 | 5 | * This code is free software; you can redistribute it and/or modify it |
mcimadamore@360 | 6 | * under the terms of the GNU General Public License version 2 only, as |
mcimadamore@360 | 7 | * published by the Free Software Foundation. |
mcimadamore@360 | 8 | * |
mcimadamore@360 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
mcimadamore@360 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
mcimadamore@360 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
mcimadamore@360 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
mcimadamore@360 | 13 | * accompanied this code). |
mcimadamore@360 | 14 | * |
mcimadamore@360 | 15 | * You should have received a copy of the GNU General Public License version |
mcimadamore@360 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
mcimadamore@360 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
mcimadamore@360 | 18 | * |
mcimadamore@360 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
mcimadamore@360 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
mcimadamore@360 | 21 | * have any questions. |
mcimadamore@360 | 22 | */ |
mcimadamore@360 | 23 | |
mcimadamore@360 | 24 | /* |
mcimadamore@360 | 25 | * @test |
mcimadamore@360 | 26 | * @bug 6869075 |
mcimadamore@360 | 27 | * @summary regression: javac crashes when compiling compound string assignment with generics |
mcimadamore@360 | 28 | * @author mcimadamore |
mcimadamore@360 | 29 | */ |
mcimadamore@360 | 30 | |
mcimadamore@360 | 31 | public class T6869075 { |
mcimadamore@360 | 32 | |
mcimadamore@360 | 33 | static class Foo<X> { |
mcimadamore@360 | 34 | X x; |
mcimadamore@360 | 35 | Foo (X x) { |
mcimadamore@360 | 36 | this.x = x; |
mcimadamore@360 | 37 | } |
mcimadamore@360 | 38 | } |
mcimadamore@360 | 39 | |
mcimadamore@360 | 40 | static void test1(Foo<String> foo) { |
mcimadamore@360 | 41 | String start = foo.x; |
mcimadamore@360 | 42 | equals(foo.x += "foo", start + "foo"); |
mcimadamore@360 | 43 | } |
mcimadamore@360 | 44 | |
mcimadamore@360 | 45 | static void test2(Foo<String> foo) { |
mcimadamore@360 | 46 | String start = foo.x; |
mcimadamore@360 | 47 | equals((foo.x += "foo"), (start + "foo")); |
mcimadamore@360 | 48 | } |
mcimadamore@360 | 49 | |
mcimadamore@360 | 50 | static void test3(Foo<String> foo) { |
mcimadamore@360 | 51 | String start = foo.x; |
mcimadamore@360 | 52 | equals(((foo.x += "foo")), ((start + "foo"))); |
mcimadamore@360 | 53 | } |
mcimadamore@360 | 54 | |
mcimadamore@360 | 55 | public static void main(String[] args) { |
mcimadamore@360 | 56 | test1(new Foo<String>("Hello!")); |
mcimadamore@360 | 57 | test2(new Foo<String>("Hello!")); |
mcimadamore@360 | 58 | test3(new Foo<String>("Hello!")); |
mcimadamore@360 | 59 | } |
mcimadamore@360 | 60 | |
mcimadamore@360 | 61 | static void equals(String found, String req) { |
mcimadamore@360 | 62 | if (!found.equals(req)) { |
mcimadamore@360 | 63 | throw new AssertionError("Error (expected: "+ req + |
mcimadamore@360 | 64 | " - found: " + found + ")"); |
mcimadamore@360 | 65 | } |
mcimadamore@360 | 66 | } |
mcimadamore@360 | 67 | } |