【问题标题】:java.lang.ClassFormatError while loading class加载类时出现 java.lang.ClassFormatError
【发布时间】:2012-09-21 22:53:51
【问题描述】:

我正在实现 AbstractFactory 模式,允许外部人员创建工厂。我正在从属性文件中读取工厂实现名称,加载工厂类并使用它来构造对象。问题是,当我尝试创建任务对象时,在我的工厂实现中的某个地方出现以下错误:

线程“Thread-1”java.lang.ClassFormatError 中的异常:代码 类文件中的段长度错误 com/testsuite/loadperformancetesterusage/tasks/GetUrl

下面是 GetUrl 构造函数,没什么花哨的!

public GetUrl( String protocol, String port, String hostname, String path, String producerClassName ) {
    super(producerClassName);
    this.protocol = protocol;
    this.hostname = hostname;
    this.port = port;
    this.path = path;
}

对这里可能发生的事情有任何反馈吗?交叉发帖here

【问题讨论】:

    标签: classloader abstract-factory classformaterror


    【解决方案1】:

    我使用的类的版本有些不匹配。现在可以了。

    【讨论】:

    • 不匹配是什么意思?
    • 这已经有一段时间了,但据我所知,我已经使用一些 java 版本编译了该类,并试图使用另一个版本来加载它。
    猜你喜欢
    • 2019-09-08
    • 1970-01-01
    • 1970-01-01
    • 2012-09-05
    • 2017-05-24
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    • 2020-11-20
    相关资源
    最近更新 更多