Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Java compile error in 3.2 referencing inner class from a type parameter
Java compile error in 3.2 referencing inner class from a type parameter [message #231421] Wed, 14 June 2006 10:58 Go to next message
Eclipse UserFriend
Originally posted by: jlarocca.us.ibm.com

I am getting an "Illegal qualified access from the type parameter T"
flagged by the JDT when I attempt to reference an inner class from a type
parameter. This occurs in the following method declaration with regards to
the "T.X1" return type.

public <T extends X> T.X1 getSomething(Class<T> c) {

Yet, the same thing is ok with the javac compiler. I have a simple test
case included below that gets compile errors in the problems view in
eclipse. But, if I take the same code and export an ant build script, run
that build script (with clean), and then use eclipse to do Run As Java
Application ... the code compiles and runs ok (even though eclipse still
thinks it has a compiler error).

I'm using Eclipse 3.2 RC6 with IBM Java 1.5 compiler. Note that I tried
this on Eclipse 3.1.2 and it compiles and runs ok, so this is specific to
Eclipse 3.2 it appears. Any suggestions? Had anyone else encountered
something similar? Does this belong in bugzilla?

Here is the simplified test case ...

public class TestTemplate {
public static void main(String[] args) {
TestTemplate t = new TestTemplate();
Y.X1 yx1 = t.getSomething(Y.class);
}

public class Y extends X {
public Y() {
}
}

public class X {
X1 x1;
int i;

public class X1 {
public X1() {
}

public String getString() {
return "Test String";
}
}

public X() {
x1 = new X1();
}

public X.X1 getX1() {
return x1;
}
}

public TestTemplate() {
}

public <T extends X> T.X1 getSomething(Class<T> c) {
X x = new X();
T.X1 x1 = (T.X1) x.getX1();
System.out.println("X1 " + x1.getString());
return x1;
}
}
Thanks,

Jennifer La Rocca
Re: Java compile error in 3.2 referencing inner class from a type parameter [message #231451 is a reply to message #231421] Wed, 14 June 2006 13:29 Go to previous message
Eclipse UserFriend
Jennifer La Rocca a écrit :
> I am getting an "Illegal qualified access from the type parameter T"
> flagged by the JDT when I attempt to reference an inner class from a type
> parameter. This occurs in the following method declaration with regards to
> the "T.X1" return type.
>
> public <T extends X> T.X1 getSomething(Class<T> c) {
>
> Yet, the same thing is ok with the javac compiler. I have a simple test
> case included below that gets compile errors in the problems view in
> eclipse. But, if I take the same code and export an ant build script, run
> that build script (with clean), and then use eclipse to do Run As Java
> Application ... the code compiles and runs ok (even though eclipse still
> thinks it has a compiler error).
javac 1.6b86 also rejects your test case. I would say this was a bug
that has been fixed in latest version of javac.
--
Olivier
Previous Topic:How to include dependencies in JAR export
Next Topic:Is it possible to use Eclipse/JDT as embedded Java IDE in an application?
Goto Forum:
  


Current Time: Tue May 06 13:17:02 EDT 2025

Powered by FUDForum. Page generated in 0.03515 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top