1 /** A valid JSR-14 Java program, which illustrates some corner-cases in
2 * the 'smart lexer' lookahead implementation of the grammar. It should
3 * compile correctly using a JSR-14 javac, as well as parse correctly
4 * (no syntax errors) using the java15.cup grammar in this package. */
5 public class Test15<X> {
8 C c1 = new C<Integer>(), c2 = new C<B>(), c3 = new C<B[]>();
11 boolean d = a < b, e = a < b;
14 boolean h = ( a < f[1] );
16 Object i = ( A < B[] > ) cc3;
17 Object j = ( A < B > ) cc2;
18 Object k = ( A < A < B[] > >) null;
19 Object kk= ( A < A < B[] >>) null;
20 Test15<X>.H hh = null;
22 Test15<X>.H hhh = null;
23 for (boolean l=a<b, m=a<b; a<b ; l=a<b, f[0]++)
28 if (m instanceof C<Integer>)
30 for (boolean n = m instanceof C<Integer>,
32 p = cc3 instanceof C<B[]>;
33 cc3 instanceof C<B[]>;
34 n = m instanceof C<Integer>,
36 p = cc3 instanceof C<B[]>)
38 for (;m instanceof C<Integer>;)
42 Object o1 = new A<A<B>>(),
43 o2 = new A<A<A<B>>>(),
44 o3 = new A<A<D<B,A<B>>>>();
46 // new, "explicit parameter" version of method invocation.
47 A<Integer> aa = Test15.<A<Integer>>foo();
48 /* although the spec says this should work:
49 A<Integer> aa_ = <A<Integer>>foo();
50 * Neal Gafter has assured me that this is a bug in the spec.
51 * Type arguments are only valid after a dot. */
53 // "explicit parameters" with constructor invocations.
54 new <String> K<Integer>("xh"); // prototype 2.2 chokes on this.
55 this.new <String> K<Integer>("xh");
58 static class A<T> { T t; }
60 static class C<T> extends A<T> { }
61 static class D<A,B> { }
62 static class E<X,Y extends A<X>> { }
63 static interface F { }
65 static class G { A<? extends F> a; A<? super C<Integer>> b; }
67 static class I extends A<Object[]> { }
68 static class J extends A<byte[]> { }
69 class K<Y> { <T>K(T t) { Test15.<T>foo(); } }
71 static <T> T foo() { return null; }