This discussion is archived
5 Replies Latest reply: Feb 1, 2011 8:45 AM by 82757 RSS

Generics bug in Sun compiler?

82757 Newbie
Currently Being Moderated
The code show compiles using the oracle compiler, but when executed generate a NoSuchMethodError. Apparently, this doesn't occur when run under Eclipse, presumably compiled byJikes. Is this a known bug? (Compiled using 1.6.0_21)
public class Bug  {

    public static void main(String[] args) {

        X x = new X();
        x.da();
   }


    public static interface A {
        void foo();
    }

    public static interface B {
        void bar();
    }

    public static class FooBar implements A, B {
        @Override public void foo() {

        }

        @Override public void bar() {

        }
    }

    public static class Z<T extends A & B, TT extends T> {

        final TT t;

        public Z(final TT t) {
            this.t = t;
        }

        void da() {
                t.foo();
                t.bar();
        }

    }

    public static class X extends Z<FooBar, FooBar> {
        public X() {
            super(new FooBar());
        }
    }


}
Exception in thread "main" java.lang.NoSuchMethodError: com.iontrading.anvil.tradelibrary.bus.Bug$A.bar()V
     at com.iontrading.anvil.tradelibrary.bus.Bug$Z.da(Bug.java:40)
     at com.iontrading.anvil.tradelibrary.bus.Bug.main(Bug.java:8)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points