Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6340105

java compiler does not recognise implemented method in anonymous class

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      solaris_10

      Description

      Parent.java and Child.java - compiled Ok.
      Parent.class and Child.java - produces an error.

      --- avl@everest [~/test_java]
      cat Parent.java

      public class Parent < T, B, C > {

          abstract public class Parent_inner {

              abstract protected void foo_1 ( T p1, B p2, C p3 );

              abstract protected void foo_2 ( T p1, B p2, C p3 );
          }

          abstract public class Parent_inner_impl extends Parent_inner {
              protected void foo_1 ( T p1, B p2, C p3 ) {
                  System.out.println("Prent_inner_impl foo_1");
              }
          }
      }


      --- avl@everest [~/test_java]
      cat Child.java

      public class Child extends Parent<String, Integer, Integer > {

          public static void main(String args[]) {

              Child cur_child = new Child();
              Parent_inner test = cur_child.new Parent_inner_impl () {
                  protected void foo_2 ( String p1, Integer p2, Integer p3 ) {
                      System.out.println("Parent_inner_impl foo_2");
                  }
              };
         }
      }
      --- avl@everest [~/test_java]
      javac Child.java Parent.java
      --- avl@everest [~/test_java]
      javac Parent.java
      --- avl@everest [~/test_java]
      javac Child.java
      Child.java:8: <anonymous Child$1> is not abstract and does not override abstract method foo_2(java.lang.Object,java.lang.Object,java.lang.Object) in Parent.Parent_inner
                  protected void foo_2 ( String p1, Integer p2, Integer p3 ) {
                                 ^
      Note: Child.java uses unchecked or unsafe operations.
      Note: Recompile with -Xlint:unchecked for details.
      1 error
      --- avl@everest [~/test_java]
      java -version
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Server VM (build 1.5.0_01-b08, mixed mode)
      --- avl@everest [~/test_java]

      method foo2 already implemented in anonimous class, but compiler say that it is not.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                alapshin Alexey Lapshin (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: