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

static field after method call in left side of assignment crashes compiler

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.4
    • Not verified

      Compiler crashes with an exception in codeLValue on assignment to "y.getNext().i".
      The effect disappears when ".next" is used instead of the method call ".getNext()"
      or when "i" is not static.

      See log:

      > cat expr006.java
      // Ident: @(#)expr006.java 1.1 96/02/09
      // Copyright 09 Feb 1996 Sun Microsystems, Inc. All Rights Reserved

      class SomeClass {
      static int i;
      SomeClass next;

      SomeClass getNext() {
      return next;
      }
      void f() {
      SomeClass y = new SomeClass();
      y.next = y;
      y.next.i = 777;
      y.getNext().i = 777;
      }
      }
      > /usr/local/java/1.0/bin/javac expr006.java
      sun.tools.java.CompilerError: invalid lhs
      at sun.tools.tree.Expression.codeLValue(Expression.java:250)
      at sun.tools.tree.AssignExpression.code(AssignExpression.java:64)
      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 y#-300277984 getNext) (<empty>.i))expr006.java:0: class SomeClass:void f()@sun.tools.java.CompilerError: invalid lhs
      // Ident: @(#)expr006.java 1.1 96/02/09
      ^
      1 error
      >

            fyellinsunw Frank Yellin (Inactive)
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: