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

invalid method invocation with keyword super

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • tools
    • sparc
    • solaris_8



      Name: ngR10089 Date: 01/29/2004


       
      The latest spec of "Adding Generics to the Java Programming Language: Public
      Draft Specification, Version 1.0", 5.6 reads:

          The syntax for method invocation is extended to support this:
          Syntax (see JLS, Sec. 15.12)

            MethodInvocation ::= MethodExpr ( ArgumentListOpt )
            MethodExpr ::= MethodName
                              | Primary . TypeArgumentsOpt Identifier
                              | super . TypeArgumentsOpt Identifier
                              | ClassName . super . TypeArgumentsOpt Identifier


      However compiler (jdk1.5.0-b35) rejects method invocation in the form
      super.<Arg> method() and ClassName.super.<Arg> method().

      See test below.

      > java -version
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b35)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b35, mixed mode)

      > javac -d . -source 1.5 test.java
      test.java:29: <identifier> expected
              return super.<Integer>get();
                           ^
      test.java:33: <identifier> expected
                  return cl_c.super.<Integer>get();
                                    ^
      2 errors


      --------------- test.java-------------
      package p;
      import java.io.PrintStream;

      public class test {

          public static void main(String argv[]) {
              System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }
          public static int run(String argv[],PrintStream out) {
              cl_c v = new cl_c();
              cl_c.cl_d x = v.new cl_d();
              cl_a<Integer> x1 = v.met();
              cl_a<Integer> x2 = x.get();
              return 0/*STATUS_PASSED*/;
          }
      }

      class cl_a<A> {
      }

      class cl_b {
          <A> cl_a<A> get() {
              return new cl_a<A>();
          }
      }

      class cl_c extends cl_b {
          cl_a<Integer> met() {
              return super.<Integer>get();
          }
          class cl_d {
              cl_a<Integer> get() {
                  return cl_c.super.<Integer>get();
              }
          }
      }
      ---------------------------------------

      New JCK tests
      lang/EXPR/expr680/expr68003/expr68003.html
      lang/EXPR/expr680/expr68004/expr68004.html
      fail due to this bug.



      ======================================================================

            gafter Neal Gafter (Inactive)
            nvgsunw Nvg Nvg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: