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 65205 - Options can be set to produce not compilable code
Summary: Options can be set to produce not compilable code
Status: VERIFIED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-27 16:01 UTC by Jiri Prox
Modified: 2005-12-08 10:50 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Prox 2005-09-27 16:01:37 UTC
NB 5.0 dev build 20050927
JDK 1.5.0_05

A certain combination of options can produce uncompilable code.
When components are generated as local variables they are not visible when
Listener Generation Style is set to Main Class or One Inner Class.
Comment 1 Tomas Stupka 2005-11-11 08:34:26 UTC
There is no easy way to check for a conflict every time the user is changing
some of the mentioned properties. To disallow such settings would be laborious
and risky and i am not sure if it's worth the effort. 

in this context i changed the code generator so on each place in the code where
a local variable from initComponents()  is used in a listener method outside the
initComponents() scope will be a comment with a warning and a explanation which
settings could be the cause for the compile error.

Checking in Bundle.properties;
/cvs/form/src/org/netbeans/modules/form/Bundle.properties,v  <--  Bundle.properties
new revision: 1.179; previous revision: 1.178
done
Checking in JavaCodeGenerator.java;
/cvs/form/src/org/netbeans/modules/form/JavaCodeGenerator.java,v  <-- 
JavaCodeGenerator.java
new revision: 1.165; previous revision: 1.164
done
Comment 2 Jiri Prox 2005-11-14 12:25:20 UTC
It looks like this fix has broken code generation of event listeners.
Now it can generates syntaxtic wrong code:

 private class FormListener implements java.awt.event.ActionListener {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (evt.getSource() ==
                // WARNING: Variable jButton1 should not be declared as local in
initComponents() as long as
                // Forms property 'Listener Generation Style' is set to 'Main
Class' or 'One Inner Class'.
                // Check the values set in components 'Use Local Variable' and
                // Forms 'Local Variables' and 'Listener Generation Style'
properties.
                if (evt.getSource() == jButton1) {
                    NewJFrame3.this.jButton1ActionPerformed(evt);
                }
            }
        }// </editor-fold>


It produces wrong code in all cases when Listener Generation Syle is not set do
Annonymous Inner Class
Comment 3 Tomas Stupka 2005-11-14 13:13:05 UTC
oops!
should be ok now...

Checking in JavaCodeGenerator.java;
/cvs/form/src/org/netbeans/modules/form/JavaCodeGenerator.java,v  <-- 
JavaCodeGenerator.java
new revision: 1.166; previous revision: 1.165
done
Comment 4 Jiri Prox 2005-12-08 10:50:34 UTC
verified