Skip to content

JimpleUpType missing equals and hashCode overrides, causes faulty exceptions #135

@Hazem-Gamall

Description

@Hazem-Gamall

The JimpleUpType class is missing overridden implementations of both equals and hashCode. This results in logical errors and can cause unexpected exceptions when instances are used in collections or other contexts where proper equality and hashing behavior is required.

Since JimpleUpType wraps a delegate type, both equals and hashCode should operate based on the delegate, similar to how it's done in JimpleType.

Suggested Fix:
Copy the implementation for both methods from JimpleType as follows:

@Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (o != null && this.getClass() == o.getClass()) {
            JimpleUpType that = (JimpleUpType)o;
            return Objects.equals(this.delegate, that.delegate);
        } else {
            return false;
        }
    }

@Override
    public int hashCode() {
        return Objects.hash(new Object[]{this.delegate});
    }

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