Why haven't the *Attributes interfaces been "decorated" with default methods in Java 8?

Francis Galiegue fgaliegue at gmail.com
Mon Nov 30 17:34:41 UTC 2015


Hello,

Just one example, BasicFileAttributes. The contract is clear about
what should be returned whether there is no support for some
attributes; I have written an interface like this:

public interface BasicFileAttributesBase
    extends BasicFileAttributes
{
    @Override
    default FileTime lastModifiedTime()
    {
        return AttributeConstants.EPOCH;
    }

    @Override
    default FileTime lastAccessTime()
    {
        return AttributeConstants.EPOCH;
    }


    @Override
    default FileTime creationTime()
    {
        return AttributeConstants.EPOCH;
    }

    @Override
    default boolean isSymbolicLink()
    {
        return false;
    }

    @Override
    default boolean isOther()
    {
        return false;
    }

    @Override
    default Object fileKey()
    {
        return null;
    }
}

Since default methods in interfaces are backwards compatible with
older versions of Java, why hasn't this been done? Is this an
oversight?

Regards,
-- 
Francis Galiegue, fgaliegue at gmail.com, https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa


More information about the nio-dev mailing list