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.
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
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.
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.
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
*** Issue 113144 has been marked as a duplicate of this issue. ***
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
Should work now, but leaving opened until correct solution will be implemented. Decreasing priority. Thanks Honza for test-case.
Confirm, it it working now
Overtake.
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".
NetBeans.org Migration: changing resolution from LATER to WONTFIX