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

isBogus needs to be called on the to-be-returned entry, not on the current entry

XMLWordPrintable

    • b121
    • generic
    • generic
    • Not verified

      From Jan Lahoda:
      Hi,
          in Scope.ImportScope.ImportEntry.entry, there is:
                      Entry e = super.shadowed;
               
             while (isBogus())
                          e = e.shadowed;
                      return e;

      As isBogus() does not depend on value of "e", this loop cannot complete normally. The condition probably should be "e.isBogus()". Unfortunatelly, I do not have a standalone test case, but the above change fixes the problem in cases where I have seen it.

      http://hg.netbeans.org/main/nb-javac/rev/8e89a1125150

      hl

      -------------
      Yes, it lead to a NPE. The stack trace is:
      http://bugzilla-attachments-191963.netbeans.org/bugzilla/attachment.cgi?id=102981

      Was happening to me on com.sun.tools.javac.comp.Attr in a specific situation, probably dependent on particular classfiles in NB caches, which got lost, so I cannot perform more experiments. I think that it was related to:
      import com.sun.tools.javac.tree.JCTree.*

      Seems that to reproduce, it should be enough to have ImportScope that has two ImportEntry-s (+sentinel) in the given row: first that is not bogus (so that it can be returned from the lookup method) and the second one that is bogus (next() on the non-bogus entry will return it, and calling next() on the bogus entry will cause the problem). I do not know how to reliably construct such scope, however.

      Jan

            jjg Jonathan Gibbons
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: