AJDT compiler cannot compile generic class with bounds while JDT compiler compiles without any probl [message #594520] |
Thu, 27 July 2006 11:01 |
Thomas Darimont Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Hello,
I have some trouble with compiling some generic classes within an
Eclipse AspectJ Project:
Here is an example which reproduces this error:
A basic Message Interface:
package de.tutorials.aspectj;
public interface IMessage {
void publish();
}
An error message Interface:
package de.tutorials.aspectj;
public interface IErrorMessage extends IMessage{
StackTraceElement[] getStackTrace();
}
A generic Message:
package de.tutorials.aspectj;
public class GenericMessage {
public GenericMessage(Class<? extends IMessage> theObjectType) {
//...
}
public Object createProxy() {
// TODO ...
return null;
}
}
The generic ObjectFactory interface:
package de.tutorials.aspectj;
public interface IObjectFactory<E> {
public <T extends E> T create(Class<T> theObjectType, Object[]
theParameters);
}
A factory for creating Messages:
package de.tutorials.aspectj;
public class MessageFactory implements IObjectFactory<IMessage>{
public <T extends IMessage> T create(Class<T> theObjectType, Object[]
theParameters) {
return theObjectType.cast(new
GenericMessage(theObjectType).createProxy());
}
}
We use our MessageFactory to create an ErrorMessage without need for
casting...
package de.tutorials.aspectj;
public class Main {
public static void main(String[] args) {
IErrorMessage message = new
MessageFactory().create(IErrorMessage.class, new Object[]{"Foo","Bar"});
}
}
-> AspectJ Compiler reports:
The type MessageFactory must implement the inherited abstract method
IObjectFactory<IMessage>.create(Class<T>, Object[])
de.tutorials.aspectj/src/de/tutorials/aspectj MessageFactory.java
-> JDT Compiler compiles this without any complaints!?
Eclipse Version 3.2
AJDT Version 1.4
AspectJ Version: 1.5.2
Any hints?
Kind regards,
Thomas
|
|
|
Powered by
FUDForum. Page generated in 0.03082 seconds