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 120599 - Cannot use hints in mobility guarded block
Summary: Cannot use hints in mobility guarded block
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Max Sauer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-31 12:21 UTC by Lukas Hasik
Modified: 2009-11-02 11:00 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample project (18.19 KB, application/x-compressed)
2007-10-31 15:36 UTC, Lukas Hasik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Hasik 2007-10-31 12:21:47 UTC
10/31 build

-I do expect that this is editor issue but I'd like to Visual Designer guys to take care of it and evaluate first

-go to any of the mobility guarded blocks of vmd. Try to add pre-init, post-init code e.g. throw new Exception();
when you wanna invoke "Surrond with try-catch" only a message in status bar appears but no code is added. It used to
throw exception described in issue 112764 before. 

->it works in J2SE code - 
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try {
            throw new Exception();
        } catch (Exception ex) {                                        
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

-> mobility project doesn't work any of Insert Code (Alt+Insert) actions in the GB
Comment 1 Jan Lahoda 2007-10-31 14:52:28 UTC
The surround with try-catch hint is designed to encapsulate whole block into the try-catch. If the block is inside a
guarded block, it currently cannot work. Similar situation for some other hints. This can theoretically be fixed, but
there simply is not enough time for NB6.0.

The Alt-Insert does not work inside the anonymous innerclasses that are inside a guarded block - it obviously cannot
generate the code there, and this cannot fixed, IMO, because the GB is there. The Insert Code should be ideally disabled
in the guarded anonymous innerclasses, but this is like P4. I tried the Alt-Insert in the outer class (where it makes
sense to use it, IMO), and it worked OK to me.

Comment 2 Lukas Hasik 2007-10-31 15:13:24 UTC
I don't agree the code isn't in guarded block. It isn't anonymous inner class. I'm attaching sample project. 

look at the code. The throw new Ex() isn't in guarded block but between two guarded blocks 

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize
">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize

        throw new Exception();

//GEN-LINE:|0-initialize|1|0-postInitialize

        throw new Exception();

    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2| 


note: When I was creating the sample project then it happened to me that the IDE 2 times used the try-catch hint
correctly. In most of cases it ignores it and shows just a warning therefore the functionality doesn't work and users
get confused.

Please, consider to fix it as it highly restricts the editor for mobility visual designer.
Comment 3 Lukas Hasik 2007-10-31 15:36:42 UTC
Created attachment 52130 [details]
sample project
Comment 4 Pavel Flaska 2007-10-31 17:03:24 UTC
Yes, that is a hell of a guards. Not only hints are responsible (use-case described by Honza Lahoda), also generator. In
current design, that is very difficult to provide a "real" fix. I will prepare some hacking stuff which should eliminate
the problem.
Comment 5 Pavel Flaska 2007-10-31 19:00:54 UTC
Should be better. Use-cases described by Honza Lahoda (hint tries to refactor source containing guarded block) will
still not work. IMO now it could be P3.

----------------------------
revision 1.46
date: 2007/10/31 16:17:12;  author: pflaska;  state: Exp;  lines: +3 -0
#120599: It should be possible to use hints in mobility.
----------------------------
Comment 6 Jan Becicka 2008-05-15 13:25:56 UTC
Max volunteered :)
Comment 7 Jan Becicka 2008-11-13 15:04:21 UTC
Will resolve later.
Comment 8 Quality Engineering 2009-11-02 11:00:41 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX