Skip to content

Bad precondition in java.util.HashSet.HashSet(Collection<? extends E> c) #27

@psybers

Description

@psybers

I believe this spec is wrong:

//@ ensures size() == c.size();

Since the collection c can be of any type, it might have duplicates. The resulting set would thus have a smaller size.

Perhaps a spec of:

    //@   ensures c instanceof Set ==> (size() == c.size());
    //@   ensures !(c instanceof Set) ==> (size() <= c.size());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions