Bug 319069 - [move member type] Convert to top level looses literal initializers when changing visibility
Summary: [move member type] Convert to top level looses literal initializers when chan...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.7 M3   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 325131
Blocks:
  Show dependency tree
 
Reported: 2010-07-06 20:44 EDT by Luke Hutchison CLA
Modified: 2010-10-26 04:39 EDT (History)
3 users (show)

See Also:


Attachments
First stab (13.85 KB, patch)
2010-09-13 12:36 EDT, Markus Keller CLA
no flags Details | Diff
Fix (19.01 KB, patch)
2010-10-08 12:31 EDT, Markus Keller CLA
no flags Details | Diff
Fix 2 (7.72 KB, patch)
2010-10-14 09:52 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luke Hutchison CLA 2010-07-06 20:44:16 EDT
Build Identifier: 20100218-1602

Given the following code:

class A {
  class B {
    private static final String TAG1 = "tag1", TAG2 = "tag2";
  }
  String X = B.TAG1, Y = B.TAG2;
}

If you convert class B to toplevel, then you are warned about needing to change the visibility of TAG1 and TAG2 to default.  After refactoring you get:

class B {
  static final String TAG1;
  static final String TAG2;
}

which loses the String literal initializer values.


Reproducible: Always

Steps to Reproduce:
(as above)
Comment 1 Markus Keller CLA 2010-09-13 12:36:46 EDT
Created attachment 178759 [details]
First stab

Unfortunately, the patch is too ugly for M2. I tried to use a WeakHashMap, but I had to discover that WHM leaks values, unless the map is used again after a key has been garbage collected... . Waiting for bug 325131 which will make a good fix possible.
Comment 2 Markus Keller CLA 2010-10-08 12:31:33 EDT
Created attachment 180499 [details]
Fix
Comment 3 Markus Keller CLA 2010-10-08 12:33:03 EDT
Fixed in HEAD.
Comment 4 Markus Keller CLA 2010-10-14 09:52:48 EDT
Created attachment 180878 [details]
Fix 2

The original fix didn't work in cases where a multi-field declaration had to be split and the new fragment got touched twice. Fixed in HEAD.
Comment 5 Dani Megert CLA 2010-10-26 04:39:49 EDT
Verified in I20101025-1800.