com.sun.jdi.InvocationException在JDK8中调用了方法 [英] com.sun.jdi.InvocationException occurred invoking method in JDK8

查看:978
本文介绍了com.sun.jdi.InvocationException在JDK8中调用了方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的应用程序从JDK 7迁移到JDK 8.在执行操作时,我遇到一个异常 com.sun.jdi.InvocationException调用方法时实例创建了如下所示的 TestField 。我在调试时遇到异常,无法找到原因。我怀疑发生 NullPointerException InvocationException 会掩盖它。我在 TestField 中覆盖了以下Object方法。

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.

以下实用程序类是 commons-lang jar的一部分。

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.

推荐答案

虽然我没有遇到过这个特殊问题,但我已经得到了很少的迁移问题被后续进程掩盖的更改。

Although I have not run into this particular issue I have had my fair share of migration issues that were caused by little changes that got masked by later processes.

我打算建议回溯并查看你的toString方法,但似乎有几个人已经遇到了同样的问题; toString或你的toHashCode是最有可能的罪魁祸首。在坚果shell中,空指针异常很可能被抛出但被com.sun.jdi.InvocationException错误掩盖。因此,如果你得到一个空指针异常,那么在此之前仍然会发生一些事情,但是被掩盖了。只需取出部分代码并逐步处理它们。

I was going to suggest backtracking and looking at your toString method but it seems several people have had this same exact problem already; toString or your toHashCode is the most likely culprits. In a nut shell a null pointer exception is most likely being thrown but masked by the com.sun.jdi.InvocationException error. So if you are getting a Null Pointer Exception chances are there still was something that happened before that but was masked. Just take parts of your code out and work them back in step by step.

以下是我认为可以解决的其他问题和答案(我没有标记为重复的声誉):

Here is the other question and answers that I think will solve this (I do not have the reputation to mark as a duplicate):

com-sun-jdi-invocationexception发生调用方法

另外看看这个问题,特别是Robin Green的评论,你试过这样调试这段代码吗?

Also take a look at this question, particularly the comment by Robin Green, have you tried debugging this code that way?

示例

这篇关于com.sun.jdi.InvocationException在JDK8中调用了方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆