langtools/test/tools/javac/SynthName2.java
author shade
Tue, 02 Feb 2016 18:15:15 +0300
changeset 35639 f34e7e8b4eac
parent 26662 7cf828d7c8fc
permissions -rw-r--r--
8148787: StringConcatFactory exactness check produces bad bytecode when a non-arg concat is requested Reviewed-by: vlivanov, psandoz

/*
 * @test /nodynamiccopyright/
 * @bug 4462714
 * @summary using of synthetic names in local class causes ClassFormatError
 * @author gafter
 *
 * @compile/fail/ref=SynthName2.out -XDrawDiagnostics SynthName2.java
 */

import java.io.PrintStream;

class SynthName2 {
    public static void main(String args[]) {
        run(args, System.out);
    }
    public static void run(String args[],PrintStream out) {
        int  res1, res2;
        Intf ob = meth(1, 2);

        res1 = ob.getFirst();
        res2 = ob.getSecond();

        if ( res1 == 1 && res2 == 2 )
            return;
        out.println("Failed:  res1=" + res1 + ", res2=" + res2);
        throw new Error("test failed!");
    }
    interface Intf {
        int getFirst();
        int getSecond();
    }
    static Intf meth(final int prm1, final int zzz) {
        class InnClass implements Intf {
            int val$prm1 = prm1;
            int val$zzz  = zzz;
            int locVar;
            public int getFirst() {
                locVar = val$prm1;
                return prm1;
            }
            public int getSecond() {
                return zzz;
            }
        }
        return new InnClass();
    }
}