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 122733 - [encapsulate field] wrong accessibility evaluation
Summary: [encapsulate field] wrong accessibility evaluation
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Daniel Prusa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-26 03:55 UTC by Masaki Katakai
Modified: 2008-02-24 19:23 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 Masaki Katakai 2007-11-26 03:55:09 UTC
NetBeans 6.0 RC2:

Try "Encapsulate field" for "h" in the following codes and
uncheck "Use Accessors Even When Field Is Accessible" option
It works in NB5.5.1.

--
public class Main{
    class A{
        int h;
    }

    class B extends A{
        void m(){
            System.out.println(h);
        }
    }
}
--

Result NB6.0:
h should be getH() in method m.
--
public class Main{
    class A{
        private int h;

        public int getH() {
            return h;
        }

        public void setH(int h) {
            this.h = h;
        }
    }

    class B extends A{
        void m(){
            System.out.println(h);
        }
    }
}
--

Result NB5.5.1: it's correct.
--
public class Main {
    class A{
        private int h;

        public int getH() {
            return h;
        }

        public void setH(int h) {
            this.h = h;
        }
    }

    class B extends A{
        void m(){
            System.out.println(getH());
        }
    }
}
--
Comment 1 Jan Pokorsky 2007-11-26 12:22:00 UTC
It fails in case you place everything to one file. If subclasses are placed to separate files or another top level class
the refactoring works as expected. I will improve the checking.
Comment 2 Daniel Prusa 2008-02-24 19:23:38 UTC
Fixed in 1b7d607afa93.