java.lang.VerifyError: Expecting to find object/array on stack

P

pcouas

Hi,

I have folliwing error on JDK 1.3.1, that's was ok before ?
Where is my Mistake ?

Regards
Philippe


java.lang.VerifyError: (class: util/generic/URLConnectionT$MTimer,
method: <init

signature: (Lutil/generic/URLConnectionT;JLutil/generic/TimeOutListener;)V) Expecting to find object/array on stack

at
util.generic.URLConnectionT.connectToHere(URLConnectionT.java(Compile
d Code))


at
util.generic.URLConnectionT.connectToHere(URLConnectionT.java(Compile
d Code))


at
servlet24.TestServlet.setFixPostsBean(TestServlet.java(Compiled Code)
)


package util.generic;


//Sert a tester,


import java.net.*;
import java.io.*;


public class URLConnectionT implements TimeOutListener,
URLResponseListener
{


class MTimer extends Thread
{
private long timeOutInterval = 3000L;
TimeOutListener listener = null;
boolean continueThread = true;
boolean debug = false;


public MTimer(long timeOut, TimeOutListener l)
{
super("Time Out Thread");
System.out.println("Tmier apsuper");
timeOutInterval = timeOut;
listener = l;
}


public void stopTimer()
{
if(debug)System.out.println("Timer stopped");
continueThread = false;
}


public void run()
{
if(debug)System.out.println("Running Timer");
long actualTimeSlept = 0L;


while( (actualTimeSlept < timeOutInterval) &&
continueThread)
{
long l1 = System.currentTimeMillis();
try
{
sleep(timeOutInterval);
}
catch(Exception e) // InterruptedException
{
continueThread = false;
}
long l2 = System.currentTimeMillis();
actualTimeSlept += l2 - l1;
}
if(continueThread)
listener.timedOut(timeOutInterval);
if(debug)System.out.println("Running Compete");
} // fin run



} //fin class Thread MTimer


static boolean responseAvailable = false; //permet de mettre
fin au Thread
public URLRequester uR;
private long timeSleep = 1000L;
MTimer timer;
boolean debug = false;
private boolean isok = false;

public URLConnectionT()
{
super();
}


public URLConnectionT(boolean d)
{
this();
debug=d;
}


public synchronized void error(String s)
{
System.out.println(s);
}


public synchronized void timedOut(long mtimeOutInterval)
{
if(debug)System.out.println("Connection timedOut1");
uR.stopRequest();
timer.stopTimer();


if(debug)System.out.println("Connection timedOut2");
responseAvailable = true;
}


public synchronized void done()
{
isok = true;
timer.stopTimer();
uR.stopRequest();


if(debug)System.out.println("Success");
responseAvailable = true; // met fin du
Thread
// isok = true;
}


// other methods for various HTTP Response Types..
public boolean connectToHere(String sURL)
{
return this.connectToHere(sURL,null);
}


public boolean connectToHere(String sURL,OutputStream mout)
{
isok = false;
if(debug)System.out.println("Starting to connect to : "

+ sURL);
System.out.println("URLConnection AvTimer");
timer = new MTimer(100, this);


try
{
uR = new URLRequester(new URL(sURL),
this,debug,mout); //creation du Thread
/* }
catch (MalformedURLException e)
{}*/


responseAvailable = false;
timer.start(); //demmarrage timeout
uR.start(); //demmarrage thread de test


while(!responseAvailable)
{
try
{
Thread.sleep(timeSleep);
}
catch(InterruptedException e)
{
}
} // fin while
if(debug)System.out.println("Done");


}
catch (Exception e)
{}


return isok;
} // fin methode connectToHere


class URLRequester extends Thread
{
URL urlToOpen;
URLResponseListener listener;
BufferedInputStream dis = null;
OutputStream out=null;


URLRequester(URL urlToRead, URLResponseListener ul,boolean
mdebug, OutputStream mout)
{
urlToOpen = urlToRead;
listener = ul;
debug=mdebug;
out=mout;
}


URLRequester(URL urlToRead, URLResponseListener ul)
{
urlToOpen = urlToRead;
listener = ul;
debug=false;
}


boolean continueThread = true;


public void stopRequest()
{
if(debug)System.out.println("Request Stopped");
continueThread = false;
}


public void run()
{
if(debug)System.out.println("Starting request.");
dis = null;
while( continueThread )
{
try
{
URLConnection uc =
urlToOpen.openConnection(); // no connection yet
uc.setUseCaches(false); //

possibly user specified.


if(debug)System.out.println("Connecting....");
uc.connect(); // request for
connection now!!! throws IOException here ,


if(debug)System.out.println("Opening....");
dis = new
BufferedInputStream(uc.getInputStream()); // throws IOException

here .try again


if(debug)System.out.println("DoneStream.");
// read the data in a loop


if(out!=null)
{
byte buf[] = new byte[2048];
int len;


if(debug)System.out.println("DoneStream out.");
while (true)
{
try
{
len = dis.read(buf);


if(debug)System.out.println("WriteStream01. "+len);
if (len<1)//done?
{
out.flush();
break;
}
}
catch (Exception e)
{
System.out.println("Err run
Stream. ");
break;
}
try
{


if(debug)System.out.println("WriteStream02. "+len);
out.write(buf,0,len);


if(debug)System.out.println("WriteStream03. "+len);
}
catch (Exception e)
{
System.out.println("Err run
Stream02. "+e.getMessage());
}
}//while


if(debug)System.out.println("WriteStream End. ");
}


dis.close(); // throws an exception
continueThread = false; // because we
are done.


listener.done();
}
catch(IOException e) // catch errors while
connecting and reading from the input stream.
{
// notify the user that the HTTP Reqest

failed using the HTTPResponseListener
listener.error(e.toString());
continueThread = false;
return;
}


}


if(dis!=null)
{
try { dis.close(); }
catch (IOException e) {}
dis = null;
}
if(debug)System.out.println("Request Complete.");
}
}



}


package util.generic;

public interface TimeOutListener
{
public void timedOut(long l);
}
 
P

pcouas

$ ./java -fullversion
java full version "J2RE 1.3.1 IBM AIX build ca131-20040517"

How could i avoid this Compiler Bug ?
 
C

Chris Uppal

pcouas said:
I have folliwing error on JDK 1.3.1, that's was ok before ? [...]

java.lang.VerifyError: (class: util/generic/URLConnectionT$MTimer,
method: <init>
signature: (Lutil/generic/URLConnectionT;JLutil/generic/TimeOutListener;)V)
Expecting to find object/array on stack

That looks like what you'd expect if you compiled your code (with the nested
class MTimer) under a 1.4 or 1.5 compiler, but ran it on a 1.3 JVM.

I don't know how that could happen, because the compiler /should/ either
generate code for a 1.4 JVM and include a version number requiring a 1.4 JVM,
or (depending on what it's been told to do so) generate code which is
acceptable to a 1.3 JVM and only include a 1.3 version number.

The technical explanation (if my guess is correct) is that before 1.4 the
verifier would not allow (non-static) nested classes to be compiled correctly.
The reference to the outer object should be set before the nested class's
constructor is called (and hence before its inherited constructors are called),
but the verifier would not allow fields to be set before the superclass's
constructor was called. Hence 1.3 compilers (and later ones with the -target
1.3) will generate technically incorrect code (where the outer reference is set
/after/ the superclass's constructor has returned) that will run on a 1.3 JVM.
Later compilers, when generating code for later JVMs, "know" that the verifier
has been fixed, so they can generate correct code. If you somehow feed code
for a 1.4 JVM to a 1.3 JVM then it will fail verification. But that classfile
/shouldn't/ even load because the it should be marked (as it were) "1.4 JVMs
only".

To check the version numbers, you can use:
javap -verbose <classname>
which will print tons of garbage, most of which you can ignore. The third line
gives the major version numbers embedded in the class file. For code intended
to run on a 1.3 (or later) JVM, that should be 47. For classfiles which
require a 1.4 JVM (or later) it should be 48. (And for 1.5 its 49)

-- chris
 
R

Roedy Green

public class URLConnectionT implements TimeOutListener,
URLResponseListener

to understand your code I need to see the code for TimeOutListener and
URLResponseListener.


I note that URLConnectionT does not appear to implement
TimeOutListener.timedOut.

It also needs a main method or test harness so I can at least load the
class too.

see http://mindprod.com/jgloss/sscce.html
 
P

pcouas

Yes on my PC, have some common Library and theses library could be
compiler with JDK1.4
I have tried to erase all my classes and recompile with an JDK1.3 but
Without Result

package util.generic;


public interface TimeOutListener
{
public void timedOut(long l);
}

package util.generic;


public interface URLResponseListener
{
public void error(String message);
public void done(); //fin
}
 
R

Roedy Green

I have tried to erase all my classes and recompile with an JDK1.3 but
Without Result

I don't think you mean that literally. Something happened, but it was
not what you wanted. To help others diagnose, describe that unwanted
behaviour in more detail
 
P

pcouas

package util.generic;


//Sert a tester, mais pas a lire les donnees A PRIORI

import java.net.*;
import java.io.*;

public class URLConnectionT implements TimeOutListener,
URLResponseListener
{

public static void main(String[] args)
{
URLConnectionT u = new URLConnectionT();
u.connectToHere("http://172.16.1.8:8080");
}

class MTimer extends Thread
{
// private long timeOutInterval = 10L; //0,01 secondes de
timeout, en milisecondes pour le timer
private long timeOutInterval = 3000L;
TimeOutListener listener = null;
boolean continueThread = true;
boolean debug = false;

public MTimer(long timeOut, TimeOutListener l)
{
super("Time Out Thread");
//System.out.println("Tmier apsuper");
timeOutInterval = timeOut;
listener = l;
}


public void stopTimer()
{
if(debug)System.out.println("Timer stopped");
continueThread = false;
}

public void run()
{
if(debug)System.out.println("Running Timer");
long actualTimeSlept = 0L;


while( (actualTimeSlept < timeOutInterval) &&
continueThread)
{
long l1 = System.currentTimeMillis();
try
{
sleep(timeOutInterval);
}
catch(Exception e) // InterruptedException
{
continueThread = false;
}
long l2 = System.currentTimeMillis();
actualTimeSlept += l2 - l1;
}
if(continueThread)
listener.timedOut(timeOutInterval);
if(debug)System.out.println("Running Compete");
} // fin run
} //fin class Thread MTimer



static boolean responseAvailable = false; //permet de mettre
fin au Thread
public URLRequester uR;
// private long timeSleep = 10L;
private long timeSleep = 1000L;
MTimer timer;
boolean debug = false;
private boolean isok = false;

public URLConnectionT()
{
super();
}


public URLConnectionT(boolean d)
{
this();
debug=d;
}


public synchronized void error(String s)
{
System.out.println(s);
}

public synchronized void timedOut(long mtimeOutInterval)
{
if(debug)System.out.println("Connection timedOut1");
uR.stopRequest();
timer.stopTimer();

if(debug)System.out.println("Connection timedOut2");
responseAvailable = true;
}

public synchronized void done()
{
isok = true;
timer.stopTimer();
uR.stopRequest();

if(debug)System.out.println("Success");
responseAvailable = true; // met fin du
Thread
// isok = true;
}

// other methods for various HTTP Response Types..
public boolean connectToHere(String sURL)
{
return this.connectToHere(sURL,null);
}

public boolean connectToHere(String sURL,OutputStream mout)
{
isok = false;
if(debug)System.out.println("Starting to connect to : "
+ sURL);
System.out.println("URLConnection AvTimer *"+sURL+"*");
timer = new MTimer(100, this);

try
{
uR = new URLRequester(new URL(sURL),
this,debug,mout); //creation du Thread
/* }
catch (MalformedURLException e)
{}*/

responseAvailable = false;
timer.start(); //demmarrage timeout
uR.start(); //demmarrage thread de test

while(!responseAvailable)
{
try
{
Thread.sleep(timeSleep);
}
catch(InterruptedException e)
{
}
} // fin while
if(debug)System.out.println("Done");

}
catch (Exception e)
{}

return isok;
} // fin methode connectToHere
/*}

URLRequester.java


import java.net.*;

*/
class URLRequester extends Thread
{
URL urlToOpen;
URLResponseListener listener;
// DataInputStream dis = null;
BufferedInputStream dis = null;
OutputStream out=null;

URLRequester(URL urlToRead, URLResponseListener ul,boolean
mdebug, OutputStream mout)
{
urlToOpen = urlToRead;
listener = ul;
debug=mdebug;
out=mout;
}

URLRequester(URL urlToRead, URLResponseListener ul)
{
urlToOpen = urlToRead;
listener = ul;
debug=false;
}


boolean continueThread = true;

public void stopRequest()
{
if(debug)System.out.println("Request Stopped");
continueThread = false;
}


public void run()
{
if(debug)System.out.println("Starting request.");
dis = null;
while( continueThread )
{
try
{
URLConnection uc =
urlToOpen.openConnection(); // no connection yet
uc.setUseCaches(false); //
possibly user specified.

if(debug)System.out.println("Connecting....");
uc.connect(); // request for
connection now!!! throws IOException here ,

if(debug)System.out.println("Opening....");
//dis = new
DataInputStream(uc.getInputStream()); // throws IOException
here .try again
dis = new
BufferedInputStream(uc.getInputStream()); // throws IOException
here .try again

if(debug)System.out.println("DoneStream.");
// read the data in a loop

if(out!=null)
{
byte buf[] = new byte[2048];
int len;

if(debug)System.out.println("DoneStream out.");
while (true)
{
try
{
len = dis.read(buf);

if(debug)System.out.println("WriteStream01. "+len);
if (len<1)//done?
{
out.flush();
break;
}
}
catch (Exception e)
{
System.out.println("Err run
Stream. ");
break;
}
try
{

if(debug)System.out.println("WriteStream02. "+len);
out.write(buf,0,len);

if(debug)System.out.println("WriteStream03. "+len);
}
catch (Exception e)
{
System.out.println("Err run
Stream02. "+e.getMessage());
}
}//while

if(debug)System.out.println("WriteStream End. ");
}


dis.close(); // throws an exception
continueThread = false; // because we
are done.

listener.done();
}
catch(IOException e) // catch errors while
connecting and reading from the input stream.
{
// notify the user that the HTTP Reqest
failed using the HTTPResponseListener
listener.error(e.toString());
continueThread = false;
return;
}
/* catch (InterruptedException e)
{
}*/

}

if(dis!=null)
{
try { dis.close(); }
catch (IOException e) {}
dis = null;
}
if(debug)System.out.println("Request Complete.");
}
}


}

--------------------------------------------
package util.generic;


//Sert a tester,


import java.net.*;
import java.io.*;


public class URLConnectionT implements TimeOutListener,
URLResponseListener
{


class MTimer extends Thread
{
private long timeOutInterval = 3000L;
TimeOutListener listener = null;
boolean continueThread = true;
boolean debug = false;


public MTimer(long timeOut, TimeOutListener l)
{
super("Time Out Thread");
System.out.println("Tmier apsuper");
timeOutInterval = timeOut;
listener = l;
}


public void stopTimer()
{
if(debug)System.out.println("Timer stopped");
continueThread = false;
}


public void run()
{
if(debug)System.out.println("Running Timer");
long actualTimeSlept = 0L;


while( (actualTimeSlept < timeOutInterval) &&
continueThread)
{
long l1 = System.currentTimeMillis();
try
{
sleep(timeOutInterval);
}
catch(Exception e) // InterruptedException
{
continueThread = false;
}
long l2 = System.currentTimeMillis();
actualTimeSlept += l2 - l1;
}
if(continueThread)
listener.timedOut(timeOutInterval);
if(debug)System.out.println("Running Compete");
} // fin run



} //fin class Thread MTimer


static boolean responseAvailable = false; //permet de mettre
fin au Thread
public URLRequester uR;
private long timeSleep = 1000L;
MTimer timer;
boolean debug = false;
private boolean isok = false;

public URLConnectionT()
{
super();
}


public URLConnectionT(boolean d)
{
this();
debug=d;
}


public synchronized void error(String s)
{
System.out.println(s);
}


public synchronized void timedOut(long mtimeOutInterval)
{
if(debug)System.out.println("Connection timedOut1");
uR.stopRequest();
timer.stopTimer();


if(debug)System.out.println("Connection timedOut2");
responseAvailable = true;
}


public synchronized void done()
{
isok = true;
timer.stopTimer();
uR.stopRequest();


if(debug)System.out.println("Success");
responseAvailable = true; // met fin du
Thread
// isok = true;
}


// other methods for various HTTP Response Types..
public boolean connectToHere(String sURL)
{
return this.connectToHere(sURL,null);
}


public boolean connectToHere(String sURL,OutputStream mout)
{
isok = false;
if(debug)System.out.println("Starting to connect to : "



+ sURL);
System.out.println("URLConnection AvTimer");
timer = new MTimer(100, this);


try
{
uR = new URLRequester(new URL(sURL),
this,debug,mout); //creation du Thread
/* }
catch (MalformedURLException e)
{}*/


responseAvailable = false;
timer.start(); //demmarrage timeout
uR.start(); //demmarrage thread de test


while(!responseAvailable)
{
try
{
Thread.sleep(timeSleep);
}
catch(InterruptedException e)
{
}
} // fin while
if(debug)System.out.println("Done");


}
catch (Exception e)
{}


return isok;
} // fin methode connectToHere


class URLRequester extends Thread
{
URL urlToOpen;
URLResponseListener listener;
BufferedInputStream dis = null;
OutputStream out=null;


URLRequester(URL urlToRead, URLResponseListener ul,boolean
mdebug, OutputStream mout)
{
urlToOpen = urlToRead;
listener = ul;
debug=mdebug;
out=mout;
}


URLRequester(URL urlToRead, URLResponseListener ul)
{
urlToOpen = urlToRead;
listener = ul;
debug=false;
}


boolean continueThread = true;


public void stopRequest()
{
if(debug)System.out.println("Request Stopped");
continueThread = false;
}


public void run()
{
if(debug)System.out.println("Starting request.");
dis = null;
while( continueThread )
{
try
{
URLConnection uc =
urlToOpen.openConnection(); // no connection yet
uc.setUseCaches(false); //



possibly user specified.


if(debug)System.out.println("Connecting....");
uc.connect(); // request for
connection now!!! throws IOException here ,


if(debug)System.out.println("Opening....");
dis = new
BufferedInputStream(uc.getInputStream()); // throws IOException



here .try again


if(debug)System.out.println("DoneStream.");
// read the data in a loop


if(out!=null)
{
byte buf[] = new byte[2048];
int len;


if(debug)System.out.println("DoneStream out.");
while (true)
{
try
{
len = dis.read(buf);


if(debug)System.out.println("WriteStream01. "+len);
if (len<1)//done?
{
out.flush();
break;
}
}
catch (Exception e)
{
System.out.println("Err run
Stream. ");
break;
}
try
{


if(debug)System.out.println("WriteStream02. "+len);
out.write(buf,0,len);


if(debug)System.out.println("WriteStream03. "+len);
}
catch (Exception e)
{
System.out.println("Err run
Stream02. "+e.getMessage());
}
}//while


if(debug)System.out.println("WriteStream End. ");
}


dis.close(); // throws an exception
continueThread = false; // because we
are done.


listener.done();
}
catch(IOException e) // catch errors while
connecting and reading from the input stream.
{
// notify the user that the HTTP Reqest



failed using the HTTPResponseListener
listener.error(e.toString());
continueThread = false;
return;
}


}


if(dis!=null)
{
try { dis.close(); }
catch (IOException e) {}
dis = null;
}
if(debug)System.out.println("Request Complete.");
}
}



}

-----------------------------------
package util.generic;

public interface TimeOutListener
{
public void timedOut(long l);
}

---------------------------

-------------------------------------------
Error Message
URLConnection AvTimer *http://172.16.1.8:8080*
java.lang.VerifyError: (class: util/generic/URLConnectionT$MTimer,
method: <init> signature:
(Lutil/generic/URLConnectionT;JLutil/generic/TimeOutListener;)V)
Expecting to find object/array on stack
at util.generic.URLConnectionT.connectToHere(URLConnectionT.java:141)
at util.generic.URLConnectionT.connectToHere(URLConnectionT.java:133)
at util.generic.URLConnectionT.main(URLConnectionT.java:30)
Exception in thread "main" Process exited with exit code 1.
 
P

pcouas

Hi,

When i compile and run Main Method With JDK 1.3.1.17 i have error and
When i Compile and run With Jdk1.4.2 i havent Error Message .

Goal of this class is Testing internet Ip Adress, before an HTTPURL
connection later

Regards
Philippe
 
P

pcouas

Hi,

I have putting two Thread class out of main Class and My Projets don't
Crash

Regards
Philippe
 
P

pcouas

I have error on another class, that's also on Inner classes
I have Upgraded Jdevelopper Tools and Perhaps it's an Compilation
Parameter ?

Regards
Philippe
 
P

pcouas

Sorry,

That'ok with classes compiled with Jdevelopper1012 and JDK 1.3.1
(D:\java\j2sdk1.3.1)
That's crash with classes compiled with Jdevelopper1013 and same
physical Jdk 1.3.1 (D:\java\j2sdk1.3.1)

Regards
Philippe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top