JDK-7000973 : isBogus needs to be called on the to-be-returned entry, not on the current entry
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-11-17
  • Updated: 2011-05-18
  • Resolved: 2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b121Fixed
Related Reports
Relates :  
Description
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

Comments
EVALUATION Yes. See Suggested fix.
17-11-2010

SUGGESTED FIX 1.1 --- a/src/share/classes/com/sun/tools/javac/code/Scope.java 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Scope.java 1.3 @@ -528,7 +528,7 @@ 1.4 } 1.5 public Entry next() { 1.6 Entry e = super.shadowed; 1.7 - while (isBogus()) 1.8 + while (e.isBogus()) 1.9 e = e.shadowed; 1.10 return e; 1.11 }
17-11-2010