Wed, 18 Jun 2014 12:30:29 -0400
8027886: javac allows illegal receiver parameters
8029042: Receiver parameter not supported on local class constructor
Reviewed-by: jfranck, jlahoda
1 /*
2 * Copyright (c) 2008, 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 import java.lang.annotation.*;
26 /*
27 * @test
28 * @bug 8006775
29 * @summary new type annotation location: multicatch
30 * @author Werner Dietl
31 * @compile MultiCatch.java
32 */
34 class DefaultScope {
35 void exception01() {
36 try {
37 System.out.println("Hello 1!");
38 } catch (@B NullPointerException | @C IllegalArgumentException e) {
39 e.toString();
40 }
41 }
42 /* Disabled: there is no syntax to annotate all components
43 * of the multicatch.
44 void exception02() {
45 try {
46 System.out.println("Hello 2!");
47 } catch @A (@B NullPointerException | @C IllegalArgumentException e) {
48 e.toString();
49 }
50 }
51 */
52 }
54 class ModifiedVars {
55 void exception01() {
56 try {
57 System.out.println("Hello 1!");
58 } catch (final @B NullPointerException | @C IllegalArgumentException e) {
59 e.toString();
60 }
61 }
62 void exception02() {
63 try {
64 System.out.println("Hello 1!");
65 } catch (@Decl @B NullPointerException | @C IllegalArgumentException e) {
66 e.toString();
67 }
68 }
69 }
71 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
72 @interface A { }
73 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
74 @interface B { }
75 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
76 @interface C { }
78 @interface Decl { }