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 113313 - Regenerating method breaks the code
Summary: Regenerating method breaks the code
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker with 1 vote (vote)
Assignee: Rastislav Komara
URL:
Keywords:
: 113144 (view as bug list)
Depends on:
Blocks: 113143
  Show dependency tree
 
Reported: 2007-08-21 11:36 UTC by luky
Modified: 2009-11-02 10:55 UTC (History)
1 user (show)

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 luky 2007-08-21 11:36:52 UTC
Regenerating a method which includes switch statement results in a broken code which looks like:
public void test(int testNumber) throws Throwable {
        switch (testNumber) {
            default:
        testBl();
                break;
            default:
        testFf1();
                break;
            default:
        testFl();
                break;
            default:

}
To reproduce use mobility pack, create a midlet and try to create a unit test. After test is created add to original 
midlet some other method and try to regenerate unit test (you may need to do it twice as there is another problem - on 
1st attempt regenration doesn't work). After regeneration you should see broken code
Comment 1 Jan Lahoda 2007-08-21 12:27:08 UTC
Well, I see two problems here:
-the mobility's generator generates a class which contains "public void test(int testNumber) throws Throwable" twice. So
exact print of the class is uncompilable anyway.
-the code gen generates broken switch statement. May be caused by the previous problem. Two variants here:
   -if this problem is caused by the duplicated methods, it is a P3 codegen bug, IMO. Not nice that we generate a very
broken code for a slightly broken rewrites, but broken rewrites are the principal problem.
   -if this problem is not caused by the duplicated methods, than this is a P2 in codegen.

Could you please try to fix the mobility's generator not to duplicate the test method? Thanks.
Comment 2 Jan Lahoda 2007-08-21 13:47:15 UTC
Ok, Lukas sent me a prototype version of TestCreator that does not duplicate the test method, and the codegen does not
generate correct code anyway. So we need to investigate this as a P2 in codegen, IMO.
Comment 3 Jan Lahoda 2007-08-27 15:36:00 UTC
I have added a commented-out test case for this (see below). Unfortunately, I do not know how to fix this properly.

Checking in MethodBodyTest.java;
/cvs/java/source/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java,v  <--  MethodBodyTest.java
new revision: 1.6; previous revision: 1.5
done
Comment 4 luky 2007-09-05 16:38:52 UTC
*** Issue 113144 has been marked as a duplicate of this issue. ***
Comment 5 Pavel Flaska 2007-09-10 12:54:05 UTC
Checking in src/org/netbeans/modules/java/source/save/CasualDiff.java;
/cvs/java/source/src/org/netbeans/modules/java/source/save/CasualDiff.java,v  <--  CasualDiff.java
new revision: 1.190; previous revision: 1.189
done
Checking in test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java;
/cvs/java/source/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java,v  <--  MethodBodyTest.java
new revision: 1.8; previous revision: 1.7
done
Comment 6 Pavel Flaska 2007-09-10 13:04:11 UTC
Should work now, but leaving opened until correct solution will be implemented. Decreasing priority. Thanks Honza for
test-case.
Comment 7 luky 2007-09-27 15:21:30 UTC
Confirm, it it working now
Comment 8 Rastislav Komara 2009-02-03 10:52:12 UTC
Overtake.
Comment 9 David Strupl 2009-03-31 15:54:31 UTC
Resolving all issues with milestone "future" as LATER. If you feel strongly that
it should be implemented please reopen and set the target milestone to "next".
Comment 10 Quality Engineering 2009-11-02 10:55:22 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX