PDA

View Full Version : MidletPascal - library error



mmmnovak
24-10-2006, 03:45 PM
Hello,
i have problem with send mail (over smtp).
I create library(in java for MidletPascal).
Midlet pascal compils program OK, but when I run my program - it shut down and write error:

Running with storage root DefaultColorPhone
Running with locale: Czech_Czech Republic.1250
Error verifying method Lib_mylib sendmail(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/StringI
static Method............: 228ed64 'M.R (static)'
Stack Chunk.......: 20a125c
Frame Pointer.....: 20a1280
Current IP........: 228ec57 = 228ec18 + offset 63
Previous Frame....: 20a1268
Previous IP.......: 228eca7 (offset 3)
Approximate bytecode offset 9: Inconsistent or missing stackmap at target
Frame size........: 0 (0 arguments, 0 local variables)
Operand[1]........: 228ef30
Operand[2]........: 228eee4
Operand[3]........: 228eee4
Operand[4]........: 228eee4
Operand[5]........: 228eee4

Method............: 228ed04 'M.run (virtual)'
Stack Chunk.......: 20a125c
Frame Pointer.....: 20a1268
Current IP........: 228eca7 = 228eca4 + offset 3
Previous Frame....: 0
Previous IP.......: 1
Frame size........: 1 (1 arguments, 0 local variables)
Argument[0].......: 20a2d0c

VM status:
Instruction pointer.: 228ec57 (offset within invoking method: 63)
Next instruction....: 0xb8
Frame pointer.......: 20a1280
Local pointer.......: 20a1280
Stack size..........: 128; sp: 20a12a8; ranges: 20a1264-20a1464;
Contents of the current stack frame:
20a1280: 20a1268 (lp) (fp)
20a1284: 228eca7
20a1288: 20a127c
20a128c: 228ed64
20a1290: 20a125c
20a1294: 0 (end of frame)
20a1298: 228ef30
20a129c: 228eee4
ALERT: java/lang/VerifyError: Lib_mylib.
20a12a0: 228eee4
20a12a4: 228eee4
20a12a8: 228eee4 (sp)
Execution stack contains 72 items:
20a2d0c
0
1
228c318
228ed04
20a125c
0
20a1268
228eca7
20a127c
228ed64
20a125c
0
228ef30
228eee4
228eee4
228eee4
228eee4

Execution completed.
3473177 bytecodes executed
96 thread switches
1622 classes in the system (including system classes)
18222 dynamic objects allocated (555240 bytes)
4 garbage collections (477812 bytes collected)
Execution completed.
3473177 bytecodes executed
96 thread switches
1622 classes in the system (including system classes)
18222 dynamic objects allocated (555240 bytes)
4 garbage collections (477812 bytes collected)

Do you want what it fix the problem?

Sorry for my English, i'am from czech republic.

MidletPascal:

program Test;
uses mylib;

var ok:integer;
begin
ok:=MyLib.sendmail('smtp.etmail.cz','mmm.novak@sez nam.cz','mmm.novak@seznam.cz','mmm.novak@seznam.cz ','mmm.novak@seznam.cz');


drawtext('bbb',50,50);
repaint;

delay(10000);
end.

Library:

import javax.microedition.lcdui.Command.*;
import javax.microedition.lcdui.CommandListener.*;
import javax.microedition.midlet.MIDlet.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import java.io.*;
import java.util.*;

public class Lib_mylib{

public static int sendmail(String smtp, String from, String to, String subject, String msg)
{

SocketConnection sc;
InputStream is;
OutputStream os;

sc=null;
is=null;
os=null;

try {

sc = (SocketConnection) Connector.open("socket://"+smtp+":25");
is = sc.openInputStream();
os = sc.openOutputStream();

os.write(("HELO there" + "\r\n").getBytes());
os.write(("mail FROM: "+ from +"\r\n").getBytes());
os.write(("RCPT TO: "+ to + "\r\n").getBytes());
os.write("DATA\r\n".getBytes());
// stamp the msg with date
os.write(("Date: " + new Date() + "\r\n").getBytes());
os.write(("From: "+from+"\r\n").getBytes());
os.write(("To: "+to+"\r\n").getBytes());
os.write(("Subject: "+subject+"\r\n").getBytes());
os.write((msg+"\r\n").getBytes()); // message body
os.write(".\r\n".getBytes());
os.write("QUIT\r\n".getBytes());

// debug
StringBuffer sb = new StringBuffer();
int c = 0;
while (((c = is.read()) != -1) )
{
sb.append((char) c);
}
}

catch(IOException e)
{return 1;}
finally
{
try
{
if(is != null)
{is.close();}
if(os != null)
{os.close();}
if(sc != null)
{sc.close();}

}
catch(IOException e)
{
e.printStackTrace();
return 0;
}
}
return 1;
}
}

Thank you.