KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Code I have the following class with a member interface: package com.example.withinterface; public class SomeClass { interface SomeInterface { void doSomething(); } } And another class trying to access it: package com.example.withinterface.main; import com.example.withinterface.SomeClass; public class Main { public static void main(String[] argss) { System.out.println(SomeClass.SomeInterface.class); } } Error In Main I get the following error from javac: SomeInterface is not public in SomeClass; cannot be accessed from outside package . And in Eclipse: SomeInterface is not public in SomeClass; cannot be accessed from outside package . Both compiling as Java 7. Everything compiles fine if I make SomeInterface public . But Spec says The Java Language Specification for Java 7 says this: A member interface is an interface whose declaration is directly enclosed in another class or interface declaration. A member interface in a class declaration is implicitly public (ยง6.6) unless an access modifier is specified. The Java Language Specification for Java 5 doesn't seem to have the second sentence. Question So shouldn't SomeInterface be considered public and shouldn't Main compile? Update As suggested by Ajay George this was indeed <a href="https://bugs.java.com/bugdatabase/view_bug?bug_i
Tags (comma-separated)
Save Edits
Cancel