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 134143 - Create local variable generates declaration at wrong position
Summary: Create local variable generates declaration at wrong position
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: Max Sauer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-29 10:34 UTC by Jiri Prox
Modified: 2009-11-02 11:01 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 2008-04-29 10:34:29 UTC
Product Version: NetBeans IDE Dev (Build 20080425101413)
Java: 1.6.0_10-beta; Java HotSpot(TM) Client VM 11.0-b11
System: Linux version 2.6.22-14-generic running on i386; UTF-8; en_US (nb)

Create local variable generates declaration at wrong position, if there is variable with the same name in the another block.

Steps to reproduce:
0) configure the hint to create local variable at the place of first usage
1) have a method fragment:
        for (int i = 0; i < childs; i++) {
            Object child = model.getChild(parent, i);
            al.add(child);
        }
        if (level <= sortLevel) {
            sortChilds(al);
        }

        while(!al.isEmpty()) {            
            child = al.remove(0);
            browseChildren(model, child, level + 1);                    
        }

2) in the last block('while') use create local variable,

-> the Object child is created before the first block. This cause error in code, since the redeclaration in the 'for' block

        Object child;
        for (int i = 0; i < childs; i++) {
            Object child = model.getChild(parent, i);
            al.add(child);
        }
        if (level <= sortLevel) {
            sortChilds(al);
        }

        while(!al.isEmpty()) {            
            child = al.remove(0);
            browseChildren(model, child, level + 1);                    
        }
Comment 1 Jan Becicka 2008-05-15 13:26:11 UTC
Max volunteered :)
Comment 2 Max Sauer 2008-11-25 10:23:53 UTC
This will be resolved LATER.
Comment 3 Quality Engineering 2009-11-02 11:01:02 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX