Hi all,
I found a problem but I have no idea how to solve it and why it happens. The
problem happens when you create a superclass with a parametrized method and
an interface for it, after that you create a second pair of interface/class
that extends the first one and defines the type of the parameter. Bellow you
can find all class involved. IMPORTANT: if you run it on eclipse everything
works, but if you compile it javac it doesn't work.
The output should be:
here comes the hello world!
hello world
I'm using java 6 to compile it and eclipse galileo 20090920-1017.
-- MyAnnotation.java
@Target( { ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
}
-- InterfaceA.java
public interface InterfaceA<T extends Object> {
void fire(T t);
}
-- ClassA.java
public class ClassA<T extends Object> implements InterfaceA<T> {
@Override
@MyAnnotation
public void fire(T t) {
System.out.println(t);
}
}
-- InterfaceB.java
public interface InterfaceB extends InterfaceA<String> {
/* comment the line bellow and everything works again */
@Override
void fire(String t);
}
-- ClassB.java
public class ClassB extends ClassA<String> implements InterfaceB {
}
-- Main.java
public class Main {
static class MyInterceptor implements MethodInterceptor {
public Object invoke(MethodInvocation mi) throws Throwable {
System.out.println("here comes the hello world!");
return mi.proceed();
}
}
static class MyModule extends AbstractModule {
@Override
protected void configure() {
bind(InterfaceB.class).to(ClassB.class);
bindInterceptor(Matchers.any(), Matchers
.annotatedWith(MyAnnotation.class), new MyInterceptor());
}
}
public static void main(String[] args) {
Injector injector = Guice.createInjector(new MyModule());
InterfaceB ib = injector.getInstance(InterfaceB.class);
ib.fire("hello world");
}
}
If you want this as zip file, please send me an e-mail and I will be very
happy to send it: [email protected]
--
Eduardo S. Nunes
http://enunes.org
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.