test/tools/javac/MethodParameters/AnonymousClass.java

changeset 1594
267225edc1fe
child 2137
a48d3b981083
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/MethodParameters/AnonymousClass.java	Wed Feb 20 15:47:14 2013 -0800
     1.3 @@ -0,0 +1,104 @@
     1.4 +/*
     1.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + */
    1.26 +
    1.27 +/*
    1.28 + * @test
    1.29 + * @bug 8006582
    1.30 + * @summary javac should generate method parameters correctly.
    1.31 + * @build Tester
    1.32 + * @compile -parameters AnonymousClass.java
    1.33 + * @run main Tester AnonymousClass
    1.34 + */
    1.35 +
    1.36 +class AnonymousClass {
    1.37 +
    1.38 +    interface I<T> {
    1.39 +        T m();
    1.40 +        T m(T x, T yx);
    1.41 +    }
    1.42 +
    1.43 +    private class Inner implements I<String> {
    1.44 +        public Inner()  { }
    1.45 +        public Inner(String arg, String barg)  { }
    1.46 +        public String m() { return "0"; }
    1.47 +        public String m(String s, String ts) { return "0"; }
    1.48 +    }
    1.49 +
    1.50 +    public static class Sinner implements I<Long> {
    1.51 +        public Sinner()  { }
    1.52 +        public Sinner(Long arg, Long barg)  { }
    1.53 +        public Long m() { return 0L; }
    1.54 +        public Long m(Long s, Long ts) { return s + ts; }
    1.55 +    }
    1.56 +
    1.57 +    /** Inner class in constructor context */
    1.58 +    public AnonymousClass(final Long a, Long ba) {
    1.59 +        new I<Long>() {
    1.60 +            public Long m() { return null; }
    1.61 +            public Long m(Long i, Long ji) { return i + ji; }
    1.62 +        }.m(a, ba);
    1.63 +        new Inner() {
    1.64 +            public String m() { return null; }
    1.65 +            public String m(String i, String ji) { return i + ji; }
    1.66 +        }.m(a.toString(), ba.toString());
    1.67 +        new Inner(a.toString(), ba.toString()) {
    1.68 +            public String m() { return null; }
    1.69 +            public String m(String i, String ji) { return i + ji; }
    1.70 +        }.m(a.toString(), ba.toString());
    1.71 +        new Sinner() {
    1.72 +            public Long m() { return null; }
    1.73 +            public Long m(Long i, Long ji) { return i + ji; }
    1.74 +        }.m(a, ba);
    1.75 +        new Sinner(a, ba) {
    1.76 +            public Long m() { return null; }
    1.77 +            public Long m(Long i, Long ji) { return i + ji; }
    1.78 +        }.m(a, ba);
    1.79 +    }
    1.80 +
    1.81 +    /** Inner class in method context */
    1.82 +    public void foo(final Long a, Long ba) {
    1.83 +        new I<Long>() {
    1.84 +            public Long m() { return null; }
    1.85 +            public Long m(Long i, Long ji) { return i + ji; }
    1.86 +        }.m(a, ba);
    1.87 +        new Inner() {
    1.88 +            public String m() { return null; }
    1.89 +            public String m(String i, String ji) { return i + ji; }
    1.90 +        }.m(a.toString(), ba.toString());
    1.91 +        new Inner(a.toString(), ba.toString()) {
    1.92 +            public String m() { return null; }
    1.93 +            public String m(String i, String ji) { return i + ji; }
    1.94 +        }.m(a.toString(), ba.toString());
    1.95 +        new Sinner() {
    1.96 +            public Long m() { return null; }
    1.97 +            public Long m(Long i, Long ji) { return i + ji; }
    1.98 +        }.m(a, ba);
    1.99 +        new Sinner(a, ba) {
   1.100 +            public Long m() { return null; }
   1.101 +            public Long m(Long i, Long ji) { return i + ji; }
   1.102 +        }.m(a, ba);
   1.103 +    }
   1.104 +}
   1.105 +
   1.106 +
   1.107 +

mercurial