I am migrating my application from JDK 7 to JDK 8. While doing, I am facing an exception com.sun.jdi.InvocationException occurred invoking method
when an instance of TestField
as shown below is created. I am getting the exception while debugging and could not find the reason for it. I suspect NullPointerException occurs and InvocationException masks it. I have the below Object methods overridden in TestField
.
Below utility classes are a part of commons-lang
jar.
HashCodeBuilder
EqualsBuilder
ToStringBuilder
public class TestField {
private String name;
private Rules rules;
public TestField(String name, Rules rules)
{ this.name = name;
this.rules = rules;
}
public String toString() {
return new ToStringBuilder(this)
.append("\n name", this.getName())
.append("\n Rules", this.getRules())
.append("\n ")
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof TestField) ) return false;
TestField castOther = (TestField) other;
return new EqualsBuilder()
.append(this.getName(), castOther.getName())
.append(this.getRules(), castOther.getRules())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(this.getName())
.append(this.getRules())
.toHashCode();
}
}
Have anyone faced such an issue. Could anyone please help me to resolve the same. Thanks.