java.lang.VerifyError: Bad type on operand stack in method com.sun.net.httpserver.spi.HttpServerProvider
Solution 1
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?
Solution 2
Well, most likely, it just is a compiler bug, see 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.
Marcus Junius Brutus
Updated on June 04, 2022Comments
-
Marcus Junius Brutus almost 2 years
I have been plagued by this problem and managed to narrow it down to a small file that fails throwing the
java.lang.VerifyError
when invoked from Ant withfork
set tofalse
in the<java>
task but succeeds whenfork
is set totrue
.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 tofalse
it throws:[java] java.lang.VerifyError: Bad type on operand stack [java] Exception Details: [java] Location: [java] com/sun/net/httpserver/spi/HttpServerProvider$1.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$1' } [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 totrue
it succeeds. The specific exceptionVerifyError
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 thefork
attribute of the<java>
Ant task is beyond me. Any thoughts? I am runningUbuntu 12.04
with the following java tools:$ 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 tofalse
I also have to explicitly add/usr/lib/jvm/jdk1.7.0/jre/lib/rt.jar
to the CLASSPATH in order to trigger theVerifyError
exception. Otherwise it fails before reaching that point with: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 thert.jar
of thejava
version I am using.