I'm refactoring an android project which is getting to big. Running lint gives me the JSME issue Private member access between outer and inner classes. Considering the following example
public class Outer {
private Inner mInner = new Inner();
private class Inner {}
}
I get the information
Name
private field Inner mInner
Location
class Outer (default package)
Problem synopsis
Access to private member of class 'Inner' at line 2
Problem resolution
Make 'Inner' constructor package-local
Applying the problem resolution changes the source to
public class Outer {
private Inner mInner = new Inner();
private class Inner {
Inner() {}
}
}
I'm a little confused at the moment. Until now I thought the example would be equivalent to
public class Outer {
private Inner mInner = new Inner();
private class Inner {
public Inner() {}
}
}
Am I wrong in this case or is it an issue of lint?
Section 8.8.9 of the Java language specification, "Default constructor" says:
In a class type, if the class is declared public, then the default constructor is implicitly given the access modifier public (§6.6); if the class is declared protected, then the default constructor is implicitly given the access modifier protected (§6.6); if the class is declared private, then the default constructor is implicitly given the access modifier private (§6.6); otherwise, the default constructor has the default access implied by no access modifier.