一分钟前工作的方法出现 java.lang.VerifyError

发布于 2024-09-05 22:34:32 字数 2500 浏览 5 评论 0原文

提前致歉,但我以前从未见过这个错误,也不知道该包括什么。我正在使用 NetBeans,突然开始出现此错误:

Exception in thread "AWT-EventQueue-0" java.lang.VerifyError: (class: market/CostOperations, method: <init> signature: ()V) Constructor must call super() or this()
            at Bluebuild.Main.refreshTables(Main.java:748)
            at Bluebuild.Main.formComponentShown(Main.java:649)
            at Bluebuild.Main.access$100(Main.java:28)
            at Bluebuild.Main$2.componentShown(Main.java:374)
            at java.awt.Component.processComponentEvent(Component.java:6095)
            at java.awt.Component.processEvent(Component.java:6043)
            at java.awt.Container.processEvent(Container.java:2041)
            at java.awt.Window.processEvent(Window.java:1836)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Window.dispatchEventImpl(Window.java:2478)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

我不知道发生了什么。我什至没有修改 market/CostOperations。

不过,这是构造函数:

public CostOperations() throws ParserConfigurationException, SAXException, IOException {

        //Open the xml file
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        f = new File(dbName);
        doc = builder.parse(f);
        System.out.println(f.canWrite());

        //Create the XPath
        XPathFactory xpfactory = XPathFactory.newInstance();
        path = xpfactory.newXPath();

    }

在调试模式下,我得到这个:

debug:
Have no FileObject for C:\Program Files (x86)\Java\jdk1.6.0_20\jre\lib\sunrsasign.jar
Have no FileObject for C:\Program Files (x86)\Java\jdk1.6.0_20\jre\classes

我只需要知道导致错误的原因以及如何修复它。谢谢!

Apologies in advance but I have never seen this error before and don't know what to include. I am using NetBeans and suddenly began getting this error:

Exception in thread "AWT-EventQueue-0" java.lang.VerifyError: (class: market/CostOperations, method: <init> signature: ()V) Constructor must call super() or this()
            at Bluebuild.Main.refreshTables(Main.java:748)
            at Bluebuild.Main.formComponentShown(Main.java:649)
            at Bluebuild.Main.access$100(Main.java:28)
            at Bluebuild.Main$2.componentShown(Main.java:374)
            at java.awt.Component.processComponentEvent(Component.java:6095)
            at java.awt.Component.processEvent(Component.java:6043)
            at java.awt.Container.processEvent(Container.java:2041)
            at java.awt.Window.processEvent(Window.java:1836)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Window.dispatchEventImpl(Window.java:2478)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

I have not a clue what happened. I didn't even modify market/CostOperations.

Here's the constructor though:

public CostOperations() throws ParserConfigurationException, SAXException, IOException {

        //Open the xml file
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        f = new File(dbName);
        doc = builder.parse(f);
        System.out.println(f.canWrite());

        //Create the XPath
        XPathFactory xpfactory = XPathFactory.newInstance();
        path = xpfactory.newXPath();

    }

In Debug Mode I get this:

debug:
Have no FileObject for C:\Program Files (x86)\Java\jdk1.6.0_20\jre\lib\sunrsasign.jar
Have no FileObject for C:\Program Files (x86)\Java\jdk1.6.0_20\jre\classes

I just need to know what is causing the error and how to fix it. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

短叹 2024-09-12 22:34:32

VerifyError 表示字节码无效,这表明存在编译器问题。我会尝试重建所有内容,希望它能够消失,但否则你应该提交一个错误。字节码需要通过 invokenonvirtual superclass/()V 手动调用超类构造函数,但不需要在源代码,编译器应该处理它

A VerifyError means the bytecode is invalid, which points to a compiler problem. I would try rebuilding everything in the hopes that it goes away, but otherwise you should file a bug. The bytecode is required to call the superclass constructor manually via invokenonvirtual superclass/<init>()V, but you shouldn't need to add super(); in the source, the compiler should handle that

疯狂的代价 2024-09-12 22:34:32

我严重怀疑这是一个 Java 编译器错误。类似的事情很可能会被其他人注意到并报告为错误。但是您可以通过重新编译文件并使用 javap 反汇编字节码来验证这一点。在构造函数代码中查找以下指令:

    invokespecial #1 <Method java.lang.Object()>

我认为更有可能的是,在编译器编写字节码之后,某些东西正在修改它们。可能性包括一些修改字节码以注入分析挂钩的分析器,或一些注入依赖项、切点等的注释处理器。

I would seriously doubt that this is a Java compiler bug. Something like that would most likely have been noticed by someone else and reported as a bug. But you can verify this by recompiling the file and using javap to disassemble the bytecodes. Look for the the following instruction in the constructor code:

    invokespecial #1 <Method java.lang.Object()>

I think it is more likely that something is modifying the bytecodes after the compiler has written them. Possibilities include some profiler that is modifying the bytecodes to inject profiling hooks, or some annotation processor that is injecting dependencies, cut points, etc.

或十年 2024-09-12 22:34:32

这绝对是一个编译器问题:生成的字节码具有不同的二进制格式。

为了解决这个问题:
右键单击项目->属性->来源->源/二进制格式

将其更改为适合您的代码的任何格式。

It is definitely a compiler issue: the bytecode generated has a different Binary Format.

To solve this:
Right click on the project -> Properties -> Sources -> Source/Binary Format

Change it to whatever format is suitable to your code.

╰◇生如夏花灿烂 2024-09-12 22:34:32

只需尝试在错误状态时将 super() 放在构造函数的开头即可。

我认为它通常是推断和添加的,没有编写它的约束,也许 CostOperations 的超类没有任何空构造函数。

Just try putting a super() at the beginning of your constructor as the error states.

I thought it was usually inferred and added without the constraint to write it, maybe the superclass of CostOperations doesn't have any empty constructor..

原谅我要高飞 2024-09-12 22:34:32

已验证:编译器错误。

Verified: Compiler Bug.

春风十里 2024-09-12 22:34:32

我在 Netbeans 中就遇到过这种情况。在 netbeans 中,当您尝试在同一目录中复制 .java 文件而不使用“重构副本”时,它将新文件放置为“YourJavaFile_1.java”并出现问题。但如果你用“refactor copy”复制那个文件,就没有问题了。

它的名称为“YourJavaFile1.java”,但进行了重构。

This happened to me in Netbeans. In netbeans, when you try to copy a .java file in same directory without "refactor copy", it places the new file as "YourJavaFile_1.java" and problem occures. But if you copy that file with "refactor copy", there is no problem.

It gives the name as "YourJavaFile1.java", but with refactoring.

秋千易 2024-09-12 22:34:32

我认为这可能是由于类/构造函数访问说明符不匹配造成的。我刚刚解决了一个类似的问题,其中该类是使用包访问说明符声明的,但其构造函数被声明为公共。

只需让构造函数也有一个包访问说明符就可以解决这个问题。

class Ngram{

    public Ngram(String str, int count){
        ngram = str;
        freq = count;
    }

    String ngram;
    int freq;
}

I opine it may be caused as a result in class/constructor access specifier mismatch. I just resolved a similar issue where the class was declared with a package access specifier but its constructor was declared public.

Simply making the constructor also have a package access specifier resolved the issue.

class Ngram{

    public Ngram(String str, int count){
        ngram = str;
        freq = count;
    }

    String ngram;
    int freq;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文