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 152941 - NullPointerException at org.netbeans.api.java.source.ModificationResult.commit
Summary: NullPointerException at org.netbeans.api.java.source.ModificationResult.commit
Status: RESOLVED WONTFIX
Alias: None
Product: contrib
Classification: Unclassified
Component: Jackpot (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: issues@contrib
URL: http://statistics.netbeans.org/except...
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-11 12:17 UTC by gtg
Modified: 2010-04-27 18:42 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 138350


Attachments
stacktrace (2.27 KB, text/plain)
2008-11-11 12:18 UTC, gtg
Details
The message file when exception is thrown. (703.25 KB, text/plain)
2008-11-12 06:45 UTC, gtg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gtg 2008-11-11 12:17:28 UTC
Build: NetBeans IDE Dev (Build 200810300201)
VM: Java HotSpot(TM) 64-Bit Server VM, 10.0-b23, Java(TM) SE Runtime Environment, 1.6.0_07-b06
OS: Linux, 2.6.25.18-0.2-default, amd64

Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:187)
        at org.netbeans.api.java.source.ModificationResult.getResultingSource(ModificationResult.java:342)
        at org.netbeans.modules.jackpot.ui.QueryResultsView.displayTransformResult(QueryResultsView.java:320)
        at org.netbeans.modules.jackpot.ui.QueryResultsView.access$800(QueryResultsView.java:91)
        at org.netbeans.modules.jackpot.ui.QueryResultsView$.mouseClicked(QueryResultsView.java:233)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
Comment 1 gtg 2008-11-11 12:18:35 UTC
Created attachment 73623 [details]
stacktrace
Comment 2 Petr Dvorak 2008-11-11 14:39:10 UTC
Hi! Can you please provide steps to reproduce or some additional details about what you were doing when this bug
occurred? Also, can you attach file ~/.netbeans/<version>/var/log/messages.log as an attachment here, so that we see if
some exceptions were thrown before this one, etc.?  Thank you.
Comment 3 gtg 2008-11-12 06:42:39 UTC
I try to reproduce, but I can't. I had some exception before this, and I reported for them.
I did "Single Query: Method whose access can be minimized" from dialog "Query and Refactor" of one of my projects.
Before this I tried other Single Queried and Query Set.
Comment 4 gtg 2008-11-12 06:45:14 UTC
Created attachment 73657 [details]
The message file when exception is thrown.
Comment 5 Jesse Glick 2008-12-09 17:38:07 UTC
NPE is from java.source. I can't locate this line in 081030 sources (it's just a closing brace); as of 081114 sources it
would be

  if (sources.size() == 1) // moved from JavaSourceAccessor.revalidate(Java Source)

Maybe ultimately a bug in Jackpot but the stack trace does not indicate what the cause would be.

java.lang.NullPointerException
	at eu.easyedu.netbeans.svuid.SerialVersionUidHint.run(SerialVersionUidHint.java:74)

in the log file is suspicious. Reporter, please remove this module.

java.lang.NullPointerException
	at org.netbeans.modules.java.source.builder.TreeFactory.QualIdent(TreeFactory.java:548)
	at org.netbeans.api.java.source.TreeMaker.QualIdent(TreeMaker.java:757)
	at org.netbeans.modules.jackpot.cmds.AddOverrides.addOverridesAnnotation(AddOverrides.java:118)

is also thrown earlier.
Comment 6 Jan Lahoda 2008-12-09 19:16:28 UTC
Actually, the version which contains the closing bracket was not part of the build at that time - it was on the Parsing
API branch. The line from which the exception was thrown is 264 in the current sources ("for (Difference diff :
differences) {"). Seems that there are no differences for the file passed into getResultingSource(FileObject). Although
it would be trivial to make this method work also for such files, I do not see a real usecase for it (why would the
client code need to ask for the content of unmodified file? If there are no changes, there is nothing to show to the
user.). I propose to simply add:
if (!getModifiedFileObjects().contains(fileObject) {
    throw new ISE();
}
to getResultingSource(). Any objections?

Anyway, there seems to be a bug in Jackpot that it tries to show diff for unmodified file.

The NPE from QualIdent is IMO caused by passing null Element to the QualIdent method, which is not permitted. The rule
probably tries to add @Override annotation even if the java.lang.Override is not on the classpath (e.g. JDK1.4).

I do not think this is a random bug - most likely, there are (currently unknown) non-random steps to reproduce.
Comment 7 Jesse Glick 2008-12-09 19:28:46 UTC
"there seems to be a bug in Jackpot that it tries to show diff for unmodified file" - if so should go back to jackpot
component. The new ISE sounds reasonable.

Sounds like the NPE from QualIdent may be the root problem.
Comment 8 Jan Lahoda 2008-12-10 12:31:21 UTC
Added the exception to getResultingSource:
http://hg.netbeans.org/main?cmd=changeset;node=a491ae46bb3c

The rest is in Jackpot, IMO.
Comment 9 Quality Engineering 2008-12-11 05:58:42 UTC
Integrated into 'main-golden', will be available in build *200812110201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a491ae46bb3c
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #152941: only modified files are allowed as arguments to getResultingSource, adding an explicit check.
Comment 10 Jesse Glick 2010-04-27 18:42:08 UTC
The old Jackpot module is no longer maintained. There is a rewrite in progress at: http://bitbucket.org/jlahoda/jackpot30/wiki/Home