I port my application from JDK 7 to JDK 8. At runtime, I encounter an exception com.sun.jdi.InvocationException occurred invoking methodwhen an instance is created TestField, as shown below. I get an exception during debugging and cannot find the reason for this. I suspect that a NullPointerException is occurring, and an InvocationException is masking it. I have Object methods overridden in TestField.
The utility classes below are part of the commons-langjar.
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();
}
}
Has anyone encountered such a problem. Can someone help me solve the same thing. Thank.
source
share