java.lang.VerifyError:com.sun.net.httpserver.spi.HttpServerProvider 方法中操作数堆栈上的错误类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18903693/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.VerifyError: Bad type on operand stack in method com.sun.net.httpserver.spi.HttpServerProvider
提问by Marcus Junius Brutus
I have been plagued by this problem and managed to narrow it down to a small file that failsthrowing the java.lang.VerifyError
when invoked from Ant with fork
set to false
in the <java>
task but succeedswhen fork
is set to true
.
我一直在困扰着这个问题,并设法缩小它是一个小文件失败抛java.lang.VerifyError
从蚂蚁与调用时fork
设置为false
在<java>
任务,但成功时fork
被设置为true
。
The self-contained file is:
自包含文件是:
package foo;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
@WebService
class Hello {
public String sayHello() {
return "hello";
}
}
public class FooMain {
public static void main(String args[]) throws Exception {
Object implementor = new Hello();
String address = "http://localhost:9000/SoapContext/SoapPort";
Endpoint.publish(address, implementor);
}
}
When invoked with Ant and fork
set to false
it throws:
当用 Ant 调用并fork
设置为false
它时抛出:
[java] java.lang.VerifyError: Bad type on operand stack
[java] Exception Details:
[java] Location:
[java] com/sun/net/httpserver/spi/HttpServerProvider.run()Ljava/lang/Object; @27: invokestatic
[java] Reason:
[java] Type 'sun/net/httpserver/DefaultHttpServerProvider' (current frame, stack[0]) is not assignable to 'com/sun/net/httpserver/spi/HttpServerProvider'
[java] Current Frame:
[java] bci: @27
[java] flags: { }
[java] locals: { 'com/sun/net/httpserver/spi/HttpServerProvider' }
[java] stack: { 'sun/net/httpserver/DefaultHttpServerProvider' }
[java] Bytecode:
[java] 0000000: b800 2599 0007 b800 27b0 b800 2699 0007
[java] 0000010: b800 27b0 bb00 1a59 b700 2ab8 0028 57b8
[java] 0000020: 0027 b0
[java] Stackmap Table:
[java] same_frame(@10)
When invoked with fork
set to true
it succeeds. The specific exception VerifyError
especially when combined with "Bad type on operand stack
" points to a compiler bug from what I've read but why should it succeed or fail depending on the fork
attribute of the <java>
Ant task is beyond me. Any thoughts? I am running Ubuntu 12.04
with the following java tools:
当使用fork
set调用true
它时成功。特定的异常,VerifyError
尤其是与“ Bad type on operand stack
”结合使用时,从我读过的内容中指出了一个编译器错误,但根据Ant 任务的fork
属性,它为什么会成功或失败,这<java>
超出了我的理解。有什么想法吗?我正在Ubuntu 12.04
使用以下 Java 工具运行:
$ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Server VM (build 24.0-b56, mixed mode)
$ javac -version
javac 1.7.0_40
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
$ ant -diagnostics | grep java.vm
java.vm.version : 24.0-b56
java.vm.vendor : Oracle Corporation
java.vm.name : Java HotSpot(TM) Server VM
java.vm.specification.name : Java Virtual Machine Specification
java.vm.specification.vendor : Oracle Corporation
java.vm.specification.version : 1.7
java.vm.info : mixed mode
important update
重要更新
When invoked from Ant with fork
set to false
I also have to explicitly add /usr/lib/jvm/jdk1.7.0/jre/lib/rt.jar
to the CLASSPATH in order to trigger the VerifyError
exception. Otherwise it fails before reaching that point with:
当从 Ant 调用并fork
设置为时,false
我还必须显式添加/usr/lib/jvm/jdk1.7.0/jre/lib/rt.jar
到 CLASSPATH 以触发VerifyError
异常。否则它会在到达该点之前失败:
javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
Of course having to add rt.jar
in the CLASSPATH is mighty strange especially since it is the rt.jar
of the java
version I am using.
当然,必须添加rt.jar
CLASSPATH 是非常奇怪的,尤其是因为它是我正在使用rt.jar
的java
版本。
回答by disrvptor
This is most likely due to the mismatch between java versions, I see you are running 1.7.0_40 and 1.7.0_24. Ensure JAVA_HOME is set to the 1.7.0_40 JDK prior to invoking Ant. See the following post for additional information on how to do that. How do I change the JAVA_HOME for ant?
这很可能是由于 Java 版本之间的不匹配,我看到您正在运行 1.7.0_40 和 1.7.0_24。确保在调用 Ant 之前将 JAVA_HOME 设置为 1.7.0_40 JDK。有关如何执行此操作的其他信息,请参阅以下帖子。如何更改蚂蚁的 JAVA_HOME ?
回答by user3603546
Well, most likely, it just is a compiler bug, see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8006684
好吧,很可能只是编译器错误,请参阅http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8006684
And it does not really depend on the fork property as per your description, only the classpath does.
根据您的描述,它并不真正依赖于 fork 属性,仅依赖于类路径。
回答by Azee
When the class is loaded some verification procedures are performed. If byte code was generated with errors classloader could raise a VerifyError.
当类加载时,会执行一些验证程序。如果生成的字节码有错误,类加载器可能会引发一个 VerifyError。
I had the same issue. To solve it:
我遇到过同样的问题。要解决它:
- Update Java. On the build environment and on the execution environment. Should be over
1.8.0_75
- Update CGLIB if used in your project dependencies.
2.2
->3.2.4
solved the issue.
- 更新 Java。在构建环境和执行环境上。应该结束
1.8.0_75
- 如果在您的项目依赖项中使用,请更新 CGLIB。
2.2
->3.2.4
解决了这个问题。