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 148805 - Wrong code generated for initialize() method when some visual elements are not lazy initialized
Summary: Wrong code generated for initialize() method when some visual elements are no...
Status: RESOLVED FIXED
Alias: None
Product: javame
Classification: Unclassified
Component: Visual Designer (show other bugs)
Version: 6.x
Hardware: Sun Windows XP
: P2 blocker with 1 vote (vote)
Assignee: David Kaspar
URL:
Keywords: RANDOM
Depends on:
Blocks:
 
Reported: 2008-10-01 07:55 UTC by gbadoi
Modified: 2010-10-15 02:56 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch (4.67 KB, patch)
2010-10-14 13:12 UTC, David Kaspar
Details | Diff
Patch (16.66 KB, patch)
2010-10-14 17:56 UTC, David Kaspar
Details | Diff
Patch (16.66 KB, patch)
2010-10-14 17:58 UTC, David Kaspar
Details | Diff
Patch (16.66 KB, patch)
2010-10-14 17:59 UTC, David Kaspar
Details | Diff
Patch (16.66 KB, patch)
2010-10-14 17:59 UTC, David Kaspar
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description gbadoi 2008-10-01 07:55:41 UTC
NetBeans generates wrong code for initialize() method when some visual elements are not lazy initialized.
Example:

private void initialize () {
        // write pre-initialize user code here
form = new Form ("form");
form.addCommand (exitCommand);
form.setCommandListener (this);
exitCommand = new Command ("Exit", Command.EXIT, 0);
        // write post-initialize user code here
}

Notice "exitCommand" is added to form BEFORE it's creation.

Steps to reproduce:
1. Create a new mobility project but do not create default midlet.
2. Create a new visual midlet
3. Add a new form to midlet.
4. Add exitCommand command to form.
5. Edit form's properrties
6. Set "Is lazy Initialized" to false
7. Close properties
8. Open exitCommand's properties
9. Set "Is lazy Initialized" to false
10. Close properties.
11. Run middlet in the emulator. An exception is raised:

java.lang.NullPointerException
        at javax.microedition.lcdui.Displayable.addCommand(Displayable.java:300)
        at VisualMIDlet.initialize(+24)

Note:
Same behavior found in NetBeans 6.5
Comment 1 Karol Harezlak 2009-02-05 13:20:24 UTC
Couldn't reproduce it in:

Product Version: NetBeans IDE Dev (Build 090204)
Java: 1.5.0_16; Java HotSpot(TM) Client VM 1.5.0_16-133
System: Mac OS X version 10.5.6 running on i386; MacRoman; en_US (nb)
Userdir: /Volumes/trunk2/main/nbbuild/testuserdir

I think this issues was fixed in Patch 1 for 6.5 (I may be wrong).
Comment 2 gbadoi 2009-02-06 06:53:36 UTC
Reproduced today several times (Mobile application, CLDC 1.1), same wrong code was generated for initialize().
Emulator starts, exception is raised after pushing Launch button.


Product Version: NetBeans IDE 6.5 (Build 200811100001)
Java: 1.6.0_11; Java HotSpot(TM) Client VM 11.0-b16
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)
Comment 3 Karol Harezlak 2009-02-06 07:50:50 UTC
Could you provide information about version of Netbeans you are using (Copy past from Netbeans About window)
Comment 4 gbadoi 2009-02-07 06:38:21 UTC
NetBeans info (already sent!):

Product Version: NetBeans IDE 6.5 (Build 200811100001)
Java: 1.6.0_11; Java HotSpot(TM) Client VM 11.0-b16
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)
Userdir: C:\Users\gigi\.netbeans\6.5
Comment 5 Adam Sotona 2010-09-15 07:42:56 UTC
I can always reproduce it in NB 6.9.1.
Comment 6 David Kaspar 2010-10-14 13:11:56 UTC
The issue was that FormCD is dependent on all its CommandEventSourceCDs but the CommandEventSourceCD is not ClassCD and therefore not included into the dependency-map of the topological sort...
Attaching a patch for the issue. It contains:
1) CommandEventSourceCD is dependency on its Command
2) RootCode class with topological sort is gathering dependency map using all components in the document
Comment 7 David Kaspar 2010-10-14 13:12:31 UTC
Created attachment 102408 [details]
Patch
Comment 8 David Kaspar 2010-10-14 17:56:34 UTC
Created attachment 102411 [details]
Patch

A new patch that included the same fix even for ChoiceGroupCD.
Comment 9 David Kaspar 2010-10-14 17:58:17 UTC
Created attachment 102412 [details]
Patch

A new patch that included the same fix even for ChoiceGroupCD.
Comment 10 David Kaspar 2010-10-14 17:59:10 UTC
Created attachment 102413 [details]
Patch

A new patch that included the same fix even for ChoiceGroupCD.
Comment 11 David Kaspar 2010-10-14 17:59:34 UTC
Created attachment 102414 [details]
Patch

A new patch that included the same fix even for ChoiceGroupCD.
Comment 12 David Kaspar 2010-10-14 18:01:15 UTC
Committed and pushed as:
changeset:   179678:f319d413228a
tag:         tip
user:        David Kaspar <dkaspar@netbeans.org>
date:        Thu Oct 14 19:57:42 2010 +0200
summary:     #148805: Fix for correct topological sort of non-lazy-initialized components
Comment 13 Quality Engineering 2010-10-15 02:56:03 UTC
Integrated into 'main-golden', will be available in build *201010150000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/f319d413228a
User: David Kaspar <dkaspar@netbeans.org>
Log: #148805: Fix for correct topological sort of non-lazy-initialized components