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

wrong handling of an expression which is access to a static field

    XMLWordPrintable

Details

    • 1.1
    • sparc
    • generic
    • Not verified

    Description



      Name: ###@###.### Date: 09/05/96

      the compiler does not consider an expression which is access
                   to a static field via an object represented by a method invokation
                   as a variable. It considers such expression as producing a value.

      Tests: compilation of the following test:

      class list
      {
      static int cnt;

      public list next;

      list getNext()
      {
      return next;
      }

      list(list tail)
      {
      next = tail;
      }
      }

      public class test
      {
      public static list getNext(list l)
      {
      return l.getNext();
      }

      public static void main(String argv[])
      {
      list x, y = new list(null);

      y.cnt++;
      x = new list(y);
      System.out.println(getNext(x).cnt);
      getNext(x).cnt++;
      }
      }

      breaks down the compiler. The produced output looks like this:

      novo40% javac test.java
      sun.tools.java.CompilerError: invalid lhs
      at sun.tools.tree.Expression.codeLValue(Expression.java:250)
      at sun.tools.tree.IncDecExpression.codeIncDec(IncDecExpression.java:87)
      at sun.tools.tree.PostIncExpression.code(PostIncExpression.java:41)
      at sun.tools.tree.ExpressionStatement.code(ExpressionStatement.java:77)
      at sun.tools.tree.CompoundStatement.code(CompoundStatement.java:137)
      at sun.tools.javac.SourceField.code(SourceField.java:406)
      at sun.tools.javac.SourceField.code(SourceField.java:368)
      at sun.tools.javac.SourceClass.compileClass(SourceClass.java:564)
      at sun.tools.javac.SourceClass.compile(SourceClass.java:527)
      at sun.tools.javac.Main.compile(Main.java:193)
      at sun.tools.javac.Main.main(Main.java:289)
      (, (method getNext x#-300261856) (<empty>.cnt))test.java:0: class test:void main(java.lang.String[])@sun.tools.java.CompilerError: invalid lhs
      class list
      ^
      1 error

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

      Attachments

        Activity

          People

            busersunw Btplusnull User (Inactive)
            wensunw Wen Wen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: