|
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 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 8006582 |
|
27 * @summary javac should generate method parameters correctly. |
|
28 * @build Tester |
|
29 * @compile -parameters AnonymousClass.java |
|
30 * @run main Tester AnonymousClass AnonymousClass.out |
|
31 */ |
|
32 |
|
33 class AnonymousClass { |
|
34 |
|
35 interface I<T> { |
|
36 T m(); |
|
37 T m(T x, T yx); |
|
38 } |
|
39 |
|
40 private class Inner implements I<String> { |
|
41 public Inner() { } |
|
42 public Inner(String arg, String barg) { } |
|
43 public String m() { return "0"; } |
|
44 public String m(String s, String ts) { return "0"; } |
|
45 } |
|
46 |
|
47 public static class Sinner implements I<Long> { |
|
48 public Sinner() { } |
|
49 public Sinner(Long arg, Long barg) { } |
|
50 public Long m() { return 0L; } |
|
51 public Long m(Long s, Long ts) { return s + ts; } |
|
52 } |
|
53 |
|
54 /** Inner class in constructor context */ |
|
55 public AnonymousClass(final Long a, Long ba) { |
|
56 new I<Long>() { |
|
57 public Long m() { return null; } |
|
58 public Long m(Long i, Long ji) { return i + ji; } |
|
59 }.m(a, ba); |
|
60 new Inner() { |
|
61 public String m() { return null; } |
|
62 public String m(String i, String ji) { return i + ji; } |
|
63 }.m(a.toString(), ba.toString()); |
|
64 new Inner(a.toString(), ba.toString()) { |
|
65 public String m() { return null; } |
|
66 public String m(String i, String ji) { return i + ji; } |
|
67 }.m(a.toString(), ba.toString()); |
|
68 new Sinner() { |
|
69 public Long m() { return null; } |
|
70 public Long m(Long i, Long ji) { return i + ji; } |
|
71 }.m(a, ba); |
|
72 new Sinner(a, ba) { |
|
73 public Long m() { return null; } |
|
74 public Long m(Long i, Long ji) { return i + ji; } |
|
75 }.m(a, ba); |
|
76 } |
|
77 |
|
78 /** Inner class in method context */ |
|
79 public void foo(final Long a, Long ba) { |
|
80 new I<Long>() { |
|
81 public Long m() { return null; } |
|
82 public Long m(Long i, Long ji) { return i + ji; } |
|
83 }.m(a, ba); |
|
84 new Inner() { |
|
85 public String m() { return null; } |
|
86 public String m(String i, String ji) { return i + ji; } |
|
87 }.m(a.toString(), ba.toString()); |
|
88 new Inner(a.toString(), ba.toString()) { |
|
89 public String m() { return null; } |
|
90 public String m(String i, String ji) { return i + ji; } |
|
91 }.m(a.toString(), ba.toString()); |
|
92 new Sinner() { |
|
93 public Long m() { return null; } |
|
94 public Long m(Long i, Long ji) { return i + ji; } |
|
95 }.m(a, ba); |
|
96 new Sinner(a, ba) { |
|
97 public Long m() { return null; } |
|
98 public Long m(Long i, Long ji) { return i + ji; } |
|
99 }.m(a, ba); |
|
100 } |
|
101 } |
|
102 |
|
103 |
|
104 |