This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 51420 - [gjast] NPE on empty files
Summary: [gjast] NPE on empty files
Status: CLOSED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: _ tball
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-11 14:43 UTC by Roman Strobl
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NPE (2.83 KB, text/plain)
2004-11-11 14:44 UTC, Roman Strobl
Details
Dump file (3.01 KB, text/plain)
2004-12-21 14:15 UTC, Jan Becicka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Strobl 2004-11-11 14:43:55 UTC
[Netbeans 200411101900; JDS v.2; JDK 1.5.0_01-b06]

Try to create an empty class and change file
attributes to read-only. The file needs to be
completely empty (no source code). Then open the
class in editor and launch from context menu on
right-click any refactoring-related action. E.g.
rename, change method parameters or move class.
The attached NPE is thrown.
Comment 1 Roman Strobl 2004-11-11 14:44:27 UTC
Created attachment 18850 [details]
NPE
Comment 2 Martin Matula 2004-11-11 15:11:26 UTC
Honzo, please look at it.
Comment 3 Jan Becicka 2004-12-21 14:14:22 UTC
Problem is in ASTProvider. See attachment. Tomasi, can you look at it?
Thanks.
Comment 4 Jan Becicka 2004-12-21 14:15:26 UTC
Created attachment 19390 [details]
Dump file
Comment 5 Tomas Hurka 2005-01-20 17:01:45 UTC
lastToken of ASTree representing COMPILATION_UNIT is -1
Comment 6 _ tball 2005-01-20 19:25:29 UTC
Let me see if I get this right:  there are no tokens, but you still
want gjast to return a valid token and token index.  Your team will
first need to specify what behavior you want before asking me to
implement it.
Comment 7 _ tball 2005-01-20 19:30:45 UTC
By the way, it was for exactly this sort of problem (and others) that
I recommended last year that we have an EOF token.  That suggestion
was rejected by the rest of the team.
Comment 8 Martin Matula 2005-01-20 21:26:55 UTC
Tom, I am surprised by your comments and by the fact that we do not
have the EOF token - I was under impression we do have it. It seems
that we have forgotten about it along the way. As far as I remember,
nobody refused it. Looking into my e-mails archive, I found an e-mail
from you named "Need EOF token" containing the text (probably sent out
after we had a call?):

Martin,
Here's the email you requested so we remember to define an EOF token,
so that comments at the end of a file won't be discarded.  I don't
think Tomas needs to change his Scanner necessarily, as the token can
be appended when scanning is finished.  Whatever is easiest.
Tom

The e-mail apparently indicates we *agreed* to add the EOF token.
The next day Tomas replied:

OK, I will do it and let you know.

These are the only two e-mails on this topic I found. If you look at
the ParserTokens.java, the EOF token is there - it was added by you
together with the new interfaces in the parser library to allow
plugging the gjast in (about a week after the above e-mails were
exchanged).
It seems that since then we forgot about it and never actually added
the token to the token array, which was kind of a surprise to me - I
admit I completely forgot about it.
Please let us know if you would consider it being risky to add it now.
I will also discuss this with Tomas tomorrow.
Comment 9 Martin Matula 2005-01-21 15:32:24 UTC
FYI, Tomas was as surprised as me to hear that we don't have the EOF
token, so we just checked it and found out the token array returned by
gjast *does contain* EOF for both non-empty and empty files.
Comment 10 _ tball 2005-01-22 03:53:17 UTC
Added test for empty COMPILATION_UNIT trees.
Comment 11 Roman Strobl 2005-02-21 12:58:41 UTC
Verified on 200502201900.
Comment 12 Quality Engineering 2007-09-20 10:58:32 UTC
Reorganization of java component