Name: jl125535 Date: 02/25/2004
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b39)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b39, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
public Inner inner;
public void create()
inner = new Inner();
private class Inner
protected int k = 100;
public static void main(String args)
Outer outer = new Outer();
System.out.println("Value of k: " + outer.inner.k);
The code compiles and runs without any errors.
But actually it should'nt because the inner class "Inner" is declared private and is accessed from outside the enclosing class. If the declaration inside the inner class is changed from "protected int k = 100;" to "public int k = 100;" the compiler gives an error because the inner class is declared as being private.
That's what is expected to happen for the "protected int k = 100;" as well.
The same problem occurs if the inner class is declared with default/package
Many users in the forum report the same problem for j2sdk 1.4.1 and j2sdk 1.4.2. See http://forum.java.sun.com/thread.jsp?forum=31&thread=487351&tstart=0&trange=500.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
EXPECTED VERSUS ACTUAL BEHAVIOR :
a compiler error
Value of k: 100
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
---------- END SOURCE ----------
(Incident Review ID: 236850)