AnonymousClass.java revision 3792:d516975e8110
1/* 2 * Copyright (c) 2013, 2016, 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 * @modules jdk.jdeps/com.sun.tools.classfile 29 * @build MethodParametersTester ClassFileVisitor ReflectionVisitor 30 * @compile -parameters AnonymousClass.java 31 * @run main MethodParametersTester AnonymousClass AnonymousClass.out 32 */ 33 34class AnonymousClass { 35 36 interface I<T> { 37 T m(); 38 T m(T x, T yx); 39 } 40 41 private class Inner implements I<String> { 42 public Inner() { } 43 public Inner(String arg, String barg) { } 44 public String m() { return "0"; } 45 public String m(String s, String ts) { return "0"; } 46 } 47 48 public static class Sinner implements I<Long> { 49 public Sinner() { } 50 public Sinner(Long arg, Long barg) { } 51 public Long m() { return 0L; } 52 public Long m(Long s, Long ts) { return s + ts; } 53 } 54 55 /** Inner class in constructor context */ 56 public AnonymousClass(final Long a, Long ba) { 57 new I<Long>() { 58 public Long m() { return null; } 59 public Long m(Long i, Long ji) { return i + ji; } 60 }.m(a, ba); 61 new Inner() { 62 public String m() { return null; } 63 public String m(String i, String ji) { return i + ji; } 64 }.m(a.toString(), ba.toString()); 65 new Inner(a.toString(), ba.toString()) { 66 public String m() { return null; } 67 public String m(String i, String ji) { return i + ji; } 68 }.m(a.toString(), ba.toString()); 69 new Sinner() { 70 public Long m() { return null; } 71 public Long m(Long i, Long ji) { return i + ji; } 72 }.m(a, ba); 73 new Sinner(a, ba) { 74 public Long m() { return null; } 75 public Long m(Long i, Long ji) { return i + ji; } 76 }.m(a, ba); 77 } 78 79 /** Inner class in method context */ 80 public void foo(final Long a, Long ba) { 81 new I<Long>() { 82 public Long m() { return null; } 83 public Long m(Long i, Long ji) { return i + ji; } 84 }.m(a, ba); 85 new Inner() { 86 public String m() { return null; } 87 public String m(String i, String ji) { return i + ji; } 88 }.m(a.toString(), ba.toString()); 89 new Inner(a.toString(), ba.toString()) { 90 public String m() { return null; } 91 public String m(String i, String ji) { return i + ji; } 92 }.m(a.toString(), ba.toString()); 93 new Sinner() { 94 public Long m() { return null; } 95 public Long m(Long i, Long ji) { return i + ji; } 96 }.m(a, ba); 97 new Sinner(a, ba) { 98 public Long m() { return null; } 99 public Long m(Long i, Long ji) { return i + ji; } 100 }.m(a, ba); 101 } 102} 103 104 105 106