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 247462 - Generic type information lost when using Refactor => Move for a Java method
Summary: Generic type information lost when using Refactor => Move for a Java method
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 8.0.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-25 05:09 UTC by skomisa
Modified: 2014-11-11 12:33 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 skomisa 2014-09-25 05:09:18 UTC
Summary 
=======
When using Refactor => Move to relocate a method to another class, the return type of that method is changed from List<String> to List.


Steps to reproduce
==================
[1] Create a trivial Java application named TestRefactorMove with two classes in file TestRefactorMove.java as follows:

package testrefactormove;
import java.util.ArrayList;
import java.util.List;

public class TestRefactorMove {
    public static void main(String[] args) {
        List<String> list1 = new ArrayList<>();
        list1.add("AAA");
        list1.add("BBB");
        List<String> list2 = lowerMembers(list1);
        System.out.println("Before: " + list1.toString());
        System.out.println("After:  " + list2.toString());
    }

    public static List<String> lowerMembers(List<String> list) {
        List<String> lower = new ArrayList<>();
        for (String s : list) {
            lower.add(s.toLowerCase());
        }
        return lower;
    }
}    

class SomethingElse {
}

[2] Build and run the app to verify that it works.

[3] Place the cursor on the static method named "lowerMembers", right-click, then select Refactor => Move.

[4] In the "Move Members" dialog select "SomethingElse" from the "To class" drop list, then click the "Refactor" button.

[5] The method is moved, but note that the return type of the moved method SomethingElse.lowerMembers() has been changed from "List<String>" to a raw "List". This example moves a static method, but the problem can be reproduced with non-static methods.


Environment
===========
Product Version: NetBeans IDE 8.0.1 (Build 201408251540)
Java: 1.8.0_20-ea; Java HotSpot(TM) 64-Bit Server VM 25.20-b22
Runtime: Java(TM) SE Runtime Environment 1.8.0_20-ea-b23
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\JohnDoe\AppData\Roaming\NetBeans\8.0.1
Cache directory: C:\Users\JohnDoe\AppData\Local\NetBeans\Cache\8.0.1
Comment 1 Jiri Prox 2014-09-25 10:05:31 UTC
reproducible
Comment 2 Ralph Ruijs 2014-10-08 14:36:39 UTC
changeset:   fa02f2f1d0fd
user:        Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
date:        Wed Oct 08 16:16:33 2014 +0200
summary:     #247462 - Generic type information lost when using Refactor => Move for a Java method
Comment 3 Quality Engineering 2014-10-18 05:10:53 UTC
Integrated into 'main-silver', will be available in build *201410180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/fa02f2f1d0fd
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: #247462 - Generic type information lost when using Refactor => Move for a Java method
Comment 4 skomisa 2014-10-20 01:26:48 UTC
FYI, I retested and I confirm that the fix works in the following environment:

Product Version: NetBeans IDE Dev (Build 201410190001)
Updates: Updates available
Java: 1.8.0_25; Java HotSpot(TM) 64-Bit Server VM 25.25-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_25-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\JohnDoe\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\JohnDoe\AppData\Local\NetBeans\Cache\dev

Thanks.
Comment 5 Jiri Prox 2014-11-04 09:57:51 UTC
thanks for verification
Comment 6 Quality Engineering 2014-11-10 23:21:08 UTC
Integrated into 'releases/release801', will be available in build *201411102027* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/7fae5b41f131
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: #247462 - Generic type information lost when using Refactor => Move for a Java method