-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
None
-
rc3
-
generic
-
generic
The inner classes spec does not specify the access modifiers to
be used for the default constructor of a protected or private
inner class. JLS 8.6.7 specifies that the default constructor
recieves the 'public' modifier if its class is public, else it
receives default access (which is the only other access permitted
for a class in the pre-1.1 language). The program below is thus
illegal.
It is highly counterintuitive that a default constructor for a class
should be inaccessible at any point at which the class might be
subclassed or instantiated.
This appears to be an oversight in the inner classes spec.
-------------------
package p1;
public class ProtectedInnerClass1 {
protected class Foo {
//OK if constructor is explicitly declared
//protected Foo() {}
public String getBar() { return "bar"; }
}
}
-------------------
package p2;
public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1
{
class Bug extends Foo {
String getBug() { return getBar(); }
}
}
-------------------
be used for the default constructor of a protected or private
inner class. JLS 8.6.7 specifies that the default constructor
recieves the 'public' modifier if its class is public, else it
receives default access (which is the only other access permitted
for a class in the pre-1.1 language). The program below is thus
illegal.
It is highly counterintuitive that a default constructor for a class
should be inaccessible at any point at which the class might be
subclassed or instantiated.
This appears to be an oversight in the inner classes spec.
-------------------
package p1;
public class ProtectedInnerClass1 {
protected class Foo {
//OK if constructor is explicitly declared
//protected Foo() {}
public String getBar() { return "bar"; }
}
}
-------------------
package p2;
public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1
{
class Bug extends Foo {
String getBug() { return getBar(); }
}
}
-------------------
- relates to
-
JDK-4117070 error accessing field of protected inner class inherited from different package
-
- Closed
-