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.
Overview: Object can use a protected method from another class when it is not a subclass. Steps to Reproduce: 1) Make three Java class files. Name them Example, Example2, and Example3. 2) Type each of these classes into the corresponding files: public class Example { public static void main(String[] args) { Example2 b = new Example2(); Example2.a c = new Example2.a(); Example3 d = new Example3(); b.ddp(); c.ddp(); d.ddp(); } } public class Example2 { protected void ddp() { System.out.println("ohio"); } public static class a { public void ddp() { System.out.println("ohio"); } } } public class Example3 extends Example2 { } 3) Run the code. Actual Results: The console prints out 3 ohios. Expected Results: There should be a compiler error since the method Example2.ddp() is protected and object b should not be able to use it since Example is not a subclass of Example2. Build Date & Platform: Build 2013-05-06 on Windows 8
The classes are in the same package http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html