Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
AW: a problem compiling a Java 5 project with generics

AW: a problem compiling a Java 5 project with generics

2006-10-18       - By peter reilly
Reply:     <<     11     12     13     14     15     16     17     18     19     20     >>  

The original code may be slightly incorrect (my understanding
of java generics is not high).

Test1.java is defined as:
public class Test1<T extends Base> {
      public class Inner1 {
              protected T v;
              public Inner1(T v) {this.v = v;}
              public T getV() {return this.v;}
      }
      public Inner1 getInner(T v) {return new Inner1(v);}
}

It could also be defined as:
package test;
public class Test1<T extends Base> {
      public class Inner1<T extends Base> {
              protected T v;
              public Inner1(T v) {this.v = v;}
              public T getV() {return this.v;}
      }
      public Inner1 getInner(T v) {return new Inner1<T>(v);}
}

The second definition makes the Inner1 class explictlly be a generic class,
Test2 then is:
package test;
public class Test2<T extends Base> extends Test1<T> {
      public class Inner2 extends Inner1<T> {
              public Inner2(T v) {super(v);}
      }
}

and Test3 is unchanged.

In this case, compilation works fine.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.