Bug 319069

Summary: [move member type] Convert to top level looses literal initializers when changing visibility
Product: [Eclipse Project] JDT Reporter: Luke Hutchison <luke.hutch>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: daniel_megert, deepakazad, markus.kell.r
Version: 3.7   
Target Milestone: 3.7 M3   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 325131    
Bug Blocks:    
Attachments:
Description Flags
First stab
none
Fix
none
Fix 2 none

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.