1
2/**
3 * Create some objects and store them into an instance field.
4 */
5public class Main {
6    /**
7     * Entry point.
8     */
9    public static void main(String[] args) {
10        Holder holder = new Holder();
11
12        Blah blah = new Blah();
13
14        /* strictly speaking, this should fail */
15        holder.mValue = blah;
16
17        System.out.println("Assignment was allowed");
18
19        /* try to use the reference; should fail */
20        try {
21            holder.mValue.run();
22            System.err.println("ERROR: did not get expected ICCE");
23        } catch (IncompatibleClassChangeError icce) {
24            System.out.println("Got expected IncompatibleClassChangeError");
25        }
26
27        /* for fun, verify that it's the "alternate" type */
28        //Comparable cmpx = holder.mValue;      /* compiler rejects */
29        Comparable cmp = (Comparable) holder.mValue;
30        cmp.compareTo(cmp);
31
32        System.out.println("Done");
33    }
34}
35