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 256101 - [Regression] Refactor > Encapsulate fields is inserting methods at the start of the class when "Default" insertion point is used
Summary: [Regression] Refactor > Encapsulate fields is inserting methods at the start ...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 8.2
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Ralph Ruijs
Depends on:
Reported: 2015-10-22 12:39 UTC by brettryan
Modified: 2015-10-22 12:39 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description brettryan 2015-10-22 12:39:28 UTC
After testing 201510160002 I'm finding that encapsulating fields is now putting the getters above the constructor when the "Default" insertion point is used. My project settings have the default ordering of static, instance variables, constructors then methods.

Steps to reproduce:

1. Create a new class

    public class Teapot {

        double capacity;
        int colour;

2. After the `int colour;' line invoke code completion and choose to generate the constructor with the arguments.
3. Highlight the two instance menbers.
4. Choose Refactor > Encapsulate Fields
5. Click `Select None', then `Select Getters'.
6. Set insertion point to `Default' and click `Refactor'.

Note now that the members are inserted at the top of the class:

    public class Teapot {

        public double getCapacity() {
            return capacity;

        public int getColour() {
            return colour;

        private double capacity;
        private int colour;

        public Teapot(double capacity, int colour) {
            this.capacity = capacity;
            this.colour = colour;


Expected result: methods should be added to the end of the class.
Actual result: methods are inserted at the top of the class.

- If only a single member is in the class, the behaviour is normal.
- If you do not select the members and instead just right click the class, the behaviour is normal.
- It does not matter if you untick the setters, the result is the same.
- It does not matter how many members you tick, the result is the same.

Product Version: NetBeans IDE Dev (Build 201510160002)
Java: 1.8.0_60; Java HotSpot(TM) 64-Bit Server VM 25.60-b23
Runtime: Java(TM) SE Runtime Environment 1.8.0_60-b27
System: Mac OS X version 10.11 running on x86_64; UTF-8; en_AU (nb)
User directory: /Users/bryan/Library/Application Support/NetBeans/dev
Cache directory: /Users/bryan/Library/Caches/NetBeans/dev

I am going to move to the RC soon and will retest.