JDK-8179311 : Allow private members for interfaces
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2017-04-25
  • Updated: 2017-04-26
  • Resolved: 2017-04-26
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Since Java 8 there are default implementations for interfaces, which is great. But I cannot define private static constants, private member fields or private methods to use from inside these default methods.

There's no obvious reason for not allowing this. I suggest to do it.

public interface I
{
    public static final int foo = 1234;
    
    private void help()
    {
        // Do some internal stuff.
    }
    
    public default void bar()
    {
        help();
        // Do some basic stuff.
    }
}


JUSTIFICATION :
I cannot write reusable, but internal code in an interface.