Bug 432869 - Path.hashCode() does not represent the actual path
Summary: Path.hashCode() does not represent the actual path
Status: CLOSED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.3.2   Edit
Hardware: All All
: P3 trivial (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, helpwanted
Depends on:
Blocks:
 
Reported: 2014-04-15 20:41 EDT by Colin Haber CLA
Modified: 2015-04-24 22:50 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Haber CLA 2014-04-15 20:41:50 EDT
org.eclipse.core.runtime.Path#hashCode() simply returns ```separators & HASH_MASK```, the first of which doesn't actually contain information on the path segments themselves. Its Javadoc reads "flags indicating separators (has leading, is UNC, has trailing)", and that seems to be the case.

It would make sense for the Object hash to represent the path segments in some way, considering that's what the Path is, semantically.

Eclipse SDK 4.3.2.M20140221-1700
Comment 1 Eclipse Genie CLA 2015-04-24 15:32:36 EDT
New Gerrit change created: https://git.eclipse.org/r/46456
Comment 2 Brian de Alwis CLA 2015-04-24 22:50:25 EDT
The 'separators' field, since renamed to 'flags', contains a hash code as computed in the constructor:

    private Path(String device, String[] segments, int flags) {
        // no segment validations are done for performance reasons      
        this.segments = segments;
        this.device = device;
        //hash code is cached in all but the bottom four bits of the flags field
        this.flags = (computeHashCode() << 4) | (flags & ALL_FLAGS);
    }

Closing as INVALID, since the segments are actually used in computing the hash, but it is deceiving!