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

access to a field by expression T.super.name is failed

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_8

      Description



      Name: viR10068 Date: 03/29/2001


      The JLS Second edition says:
      [15.11.2 Accessing Superclass Members using super]
      "Suppose that a field access expression T.super.name appears within class C,
      and the immediate superclass of the class denoted by T is a class whose
      fully qualified name is S. Then T.super.name is treated exactly as if it had
      been the expression ((S)T.this).name.
      Thus the expression T.super.name can access the field named name that is
      visible in the class named by S, even if that field is hidden by a
      declaration of a field named name in the class named by T."

      However, if the test containing described field access expression is compiled
      with the flag -target 1.2 than the NoSuchMethodError is thrown
      for method access$001(Lref;)I while running resulting class file.

      New JCK tests are failed due to this bug:
      lang/EXPR/expr634/expr63401/expr63401.html
      lang/EXPR/expr636/expr63601/expr63601.html
      lang/EXPR/expr647/expr64701/expr64701.html

      Note, if the test case is compiled in default mode (without flag -target 1.2),
      all works fine.

      To reproduce this bug:
      1. compile the source T.java
      3. run T.class

      ---------------------------- T.java -----------------------------------
      package test;

      import java.io.PrintStream;

      class S {
          int i = 324;
      }

      public class T extends S {

          int i = 243;
          
          class C {
              int i = T.super.i;
              int test() {
                  System.out.println("Value i = " +i);
                  return 0/*STATUS_PASSED*/;
              }
          }

          public static void main(String argv[]) {
              System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }

          public static int run(String argv[],PrintStream out) {
              return new T().new C().test();
          }
      }
      ------------------------------------------------------------------------

      The run log:
      % java -version
      java version "1.4.0-internal"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-internal-b57)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b57, mixed mode)
      % javac -d . T.java && java -Xfuture test.T ; echo $status
      Value i = 324
      95
      % javac -d . -target 1.2 T.java && java -Xfuture test.T ; echo $status
      Exception in thread "main" java.lang.NoSuchMethodError: test.S.access$001(Ltest/T;)I
              at test.T$C.<init>(T.java:14)
              at test.T.run(T.java:26)
              at test.T.main(T.java:22)
      1
      %

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gafter Neal Gafter
              Reporter:
              vivsunw Viv Viv (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: