langtools/test/tools/javac/SynthName2.java
author lana
Thu, 21 Jan 2016 09:46:01 -0800
changeset 35340 38f7386ed942
parent 26662 7cf828d7c8fc
permissions -rw-r--r--
Added tag jdk-9+102 for changeset 7e3feb2ba5b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
26662
7cf828d7c8fc 8055080: Group 9d: golden files for tests in tools/javac dir
sogoel
parents: 5520
diff changeset
     2
 * @test /nodynamiccopyright/
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug 4462714
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary using of synthetic names in local class causes ClassFormatError
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * @author gafter
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 *
26662
7cf828d7c8fc 8055080: Group 9d: golden files for tests in tools/javac dir
sogoel
parents: 5520
diff changeset
     7
 * @compile/fail/ref=SynthName2.out -XDrawDiagnostics SynthName2.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
import java.io.PrintStream;
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
26662
7cf828d7c8fc 8055080: Group 9d: golden files for tests in tools/javac dir
sogoel
parents: 5520
diff changeset
    12
class SynthName2 {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
    public static void main(String args[]) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
        run(args, System.out);
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
    public static void run(String args[],PrintStream out) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
        int  res1, res2;
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
        Intf ob = meth(1, 2);
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
        res1 = ob.getFirst();
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
        res2 = ob.getSecond();
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
        if ( res1 == 1 && res2 == 2 )
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
        out.println("Failed:  res1=" + res1 + ", res2=" + res2);
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
        throw new Error("test failed!");
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
    interface Intf {
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
        int getFirst();
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
        int getSecond();
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
    static Intf meth(final int prm1, final int zzz) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
        class InnClass implements Intf {
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
            int val$prm1 = prm1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
            int val$zzz  = zzz;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
            int locVar;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
            public int getFirst() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
                locVar = val$prm1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
                return prm1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
            public int getSecond() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
                return zzz;
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
        return new InnClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
}