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 162630 - Invalid code generated when adding property to a class
Summary: Invalid code generated when adding property to a class
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Beans (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jan Pokorsky
URL:
Keywords:
Depends on: 162853
Blocks:
  Show dependency tree
 
Reported: 2009-04-14 20:21 UTC by jcasabla
Modified: 2009-04-20 20:23 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Source file before badly-generated code is added (14.03 KB, text/plain)
2009-04-16 01:40 UTC, jcasabla
Details
Source file after badly-generated code is added (15.21 KB, text/plain)
2009-04-16 01:41 UTC, jcasabla
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jcasabla 2009-04-14 20:21:04 UTC
In the code editor, when you use the wizards to add a property to a class, the "preview" code is ok but the actual 
code inserted into the editor is messed up.

Steps:

1. Create a new source file for a class, name it whatever you want.
2. Inside the code editor, press ALT-Insert, then choose "Add Property..." from the resulting drop-down
3. Give the propery a name, type, and check the checkboxes for "Generate getter and setter" as well as "Generate 
Property Change Support"
4. Look at the code preview - it all look ok
5. Press the "OK" button.
6. The code that gets inserted into yor class is messed up; it doesn't even compile

Workaround: The "preview" code works, you just have to copy it into your clipboard before you press the "OK" button 
(step 5 above). Then you can replace the badly-generated code with the "preview" code.

Other comments:

1. The problem does not seem to happen when the very first property is added to a class, only when subsequent 
properties are added.
2. I first noticed this problem when I was following this tutorial: http://www.netbeans.org/kb/docs/java/gui-db-
custom.html
3. Environment details:
   - Netbeans 6.7 M3
   - Sun JDK 1.6.0_13
   - Windows XP, SP2

Thanks !
Comment 1 Jiri Prox 2009-04-15 14:52:31 UTC
Can you attach the file before/and after the broken code was inserted?
Thanks
Comment 2 jcasabla 2009-04-16 01:36:50 UTC
Attaching following items:

(*) CustomerRecords.zip - contains the final compileable, working project, minus the database (follow instructions in 
the tutorial if you need to get the database running)

(*) OrderEditor_BeforeCodeGen.java - Version of OrderEditor.java prior to generating bad code

(*) OrderEditor_AfterCodeGen.java - Version of OrderEditor.java after generating bad code
Comment 3 jcasabla 2009-04-16 01:40:43 UTC
Created attachment 80204 [details]
Source file before badly-generated code is added
Comment 4 jcasabla 2009-04-16 01:41:19 UTC
Created attachment 80205 [details]
Source file after badly-generated code is added
Comment 5 jcasabla 2009-04-16 01:43:26 UTC
Unable to attach CustomerRecords.zip, it is 11 MB and the upload only allows 1 MB max. I believe the final source code 
for the project can be downloaded directly from the referenced tutorial.
Comment 6 Jiri Prox 2009-04-16 11:06:18 UTC
reproducible, thanks for the attached files
Comment 7 Jan Pokorsky 2009-04-16 14:58:36 UTC
jcasabla: Thank you for additional details. I can reproduce it too now.

It seems to be caused by rewrite of java.source to the new Parsing API. Nested java source tasks do not see changes made
in outer tasks. As it is unlikely that the java.source will fix it in NB 6.7 I will attempt to work around it in the
beans module.
Comment 8 Jan Pokorsky 2009-04-17 10:01:58 UTC
It should work now. http://hg.netbeans.org/jet-main/rev/3f9f8a8e6bc1
Comment 9 Quality Engineering 2009-04-18 07:25:43 UTC
Integrated into 'main-golden', will be available in build *200904180201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/3f9f8a8e6bc1
User: Jan Pokorsky <jpokorsky@netbeans.org>
Log: #162630: work around for broken nesting of JavaSource tasks
Comment 10 Quality Engineering 2009-04-20 20:23:54 UTC
Integrated into 'main-golden', will be available in build *200904201507* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/3f9f8a8e6bc1
User: Jan Pokorsky <jpokorsky@netbeans.org>
Log: #162630: work around for broken nesting of JavaSource tasks