Skip to content

Instantly share code, notes, and snippets.

@vadosnaprimer
Created May 14, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadosnaprimer/53cd13f00ef32167fea8d3370ca9f3f5 to your computer and use it in GitHub Desktop.
Save vadosnaprimer/53cd13f00ef32167fea8d3370ca9f3f5 to your computer and use it in GitHub Desktop.
#enables cldc 1.1 in midp 2.0
diff -ru midp2.0fcs/build/share/config/system.config midp2.0fcs/build/share/config/system.config
--- midp2.0fcs/build/share/config/system.config 2016-05-14 22:53:24.234375000 +0300
+++ midp2.0fcs/build/share/config/system.config 2016-05-14 22:53:15.812500000 +0300
@@ -1,5 +1,5 @@
# Properties visible from System.getProperty()
-microedition.configuration: CLDC-1.0
+microedition.configuration: CLDC-1.1
microedition.profiles: MIDP-2.0
microedition.locale: en-US
microedition.platform: j2me
diff -ru midp2.0fcs/build/share/makefiles/kvm/Defs.gmk midp2.0fcs/build/share/makefiles/kvm/Defs.gmk
--- midp2.0fcs/build/share/makefiles/kvm/Defs.gmk 2002-11-08 00:02:05.000000000 +0300
+++ midp2.0fcs/build/share/makefiles/kvm/Defs.gmk 2016-05-14 20:45:42.718750000 +0300
@@ -152,6 +152,14 @@
KVM_SRC_FILES += $(KVM_INCLUDE_SRC)
KVM_OBJ_FILES = $(patsubst %.c,$(OBJ_DIR)/%.o,$(KVM_SRC_FILES))
+KVM_DEF_SRC += resource.c
+KVM_FP_FILES = fp_math.c fp_bytecodes.c k_cos.c k_rem_pio2.c \
+ k_sin.c k_tan.c s_ceil.c s_copysign.c \
+ s_cos.c s_floor.c s_scalbn.c \
+ s_sin.c s_tan.c e_rem_pio2.c \
+ w_sqrt.c e_sqrt.c s_fabs.c
+KVM_OBJ_FILES += $(patsubst %.c,$(OBJ_DIR)/%.o,$(KVM_FP_FILES))
+
# java source
#
KVM_EXCLUDE_CLASSES := $(KVM_EXCLUDE_CLASSES)|j2se
diff -ru midp2.0fcs/build/share/makefiles/kvm/VM.gmk midp2.0fcs/build/share/makefiles/kvm/VM.gmk
--- midp2.0fcs/build/share/makefiles/kvm/VM.gmk 2016-05-14 16:38:10.781250000 +0300
+++ midp2.0fcs/build/share/makefiles/kvm/VM.gmk 2016-05-14 19:25:05.625000000 +0300
@@ -15,6 +15,7 @@
#
vpath %.c $(KVM_DIR)/kvm/VmCommon/src
vpath %.c $(KVM_DIR)/kvm/VmExtra/src
+vpath %.c $(KVM_DIR)/kvm/VmExtra/src/fp
PREVERIFY_OBJ_DIR = kvm_obj$(g)$(ARCH_DIR)
PREVERIFY_SRC_DIR = $(KVM_DIR)/tools/preverifier/src
diff -ru midp2.0fcs/src/share/classes/com/sun/midp/io/ConnectionBaseAdapter.java midp2.0fcs/src/share/classes/com/sun/midp/io/ConnectionBaseAdapter.java
--- midp2.0fcs/src/share/classes/com/sun/midp/io/ConnectionBaseAdapter.java 2002-11-08 00:02:20.000000000 +0300
+++ midp2.0fcs/src/share/classes/com/sun/midp/io/ConnectionBaseAdapter.java 2016-05-14 19:30:12.312500000 +0300
@@ -9,7 +9,8 @@
package com.sun.midp.io;
import com.sun.cldc.io.ConnectionBaseInterface;
-import com.sun.cldc.io.GeneralBase;
+//import com.sun.cldc.io.GeneralBase;
+import com.sun.cldc.io.Waiter;
import com.sun.midp.midlet.*;
@@ -700,7 +701,8 @@
break;
}
- GeneralBase.iowait();
+ //GeneralBase.iowait();
+ Waiter.waitForIO();
}
}
diff -ru midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/comm/Protocol.java midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/comm/Protocol.java
--- midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/comm/Protocol.java 2002-11-08 00:02:21.000000000 +0300
+++ midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/comm/Protocol.java 2016-05-14 19:31:05.062500000 +0300
@@ -12,7 +12,8 @@
import javax.microedition.io.*;
-import com.sun.cldc.io.GeneralBase;
+//import com.sun.cldc.io.GeneralBase;
+import com.sun.cldc.io.Waiter;
import com.sun.midp.main.Configuration;
@@ -403,7 +404,8 @@
}
/* Wait a while for I/O to become ready */
- GeneralBase.iowait();
+ //GeneralBase.iowait();
+ Waiter.waitForIO();
}
}
diff -ru midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/datagram/DatagramObject.java midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/datagram/DatagramObject.java
--- midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/datagram/DatagramObject.java 2002-11-08 00:02:21.000000000 +0300
+++ midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/datagram/DatagramObject.java 2016-05-14 20:24:49.296875000 +0300
@@ -12,7 +12,7 @@
import javax.microedition.io.*;
-import com.sun.cldc.io.GeneralBase;
+//import com.sun.cldc.io.GeneralBase;
import com.sun.midp.io.HttpUrl;
import com.sun.midp.io.Util;
@@ -20,7 +20,7 @@
/**
* Implements a UDP datagram for the UDP datagram connection.
*/
-public class DatagramObject extends GeneralBase implements Datagram {
+public class DatagramObject implements Datagram {// extends GeneralBase
/** Length of the hostname buffer. */
private static final int MAX_HOST_LENGTH = 256;
@@ -286,6 +286,267 @@
buffer[offset + readWritePosition++] = (byte)ch;
length = readWritePosition;
}
+
+ public final void write(byte b[])
+ throws IOException
+ {
+ write(b, 0, b.length);
+ }
+
+ public void write(byte b[], int off, int len)
+ throws IOException
+ {
+ if(b == null)
+ throw new NullPointerException();
+ if(off < 0 || off > b.length || len < 0 || off + len > b.length || off + len < 0)
+ throw new IndexOutOfBoundsException();
+ if(len == 0)
+ return;
+ for(int i = 0; i < len; i++)
+ write(b[off + i]);
+ }
+
+ public void writeBoolean(boolean v)
+ throws IOException
+ {
+ write(v ? 1 : 0);
+ }
+
+ public void writeByte(int v)
+ throws IOException
+ {
+ write(v);
+ }
+
+ public void writeShort(int v)
+ throws IOException
+ {
+ write(v >>> 8 & 0xff);
+ write(v >>> 0 & 0xff);
+ }
+
+ public void writeChar(int v)
+ throws IOException
+ {
+ write(v >>> 8 & 0xff);
+ write(v >>> 0 & 0xff);
+ }
+
+ public void writeInt(int v)
+ throws IOException
+ {
+ write(v >>> 24 & 0xff);
+ write(v >>> 16 & 0xff);
+ write(v >>> 8 & 0xff);
+ write(v >>> 0 & 0xff);
+ }
+
+ public void writeLong(long v)
+ throws IOException
+ {
+ write((int)(v >>> 56) & 0xff);
+ write((int)(v >>> 48) & 0xff);
+ write((int)(v >>> 40) & 0xff);
+ write((int)(v >>> 32) & 0xff);
+ write((int)(v >>> 24) & 0xff);
+ write((int)(v >>> 16) & 0xff);
+ write((int)(v >>> 8) & 0xff);
+ write((int)(v >>> 0) & 0xff);
+ }
+
+ public void writeChars(String s)
+ throws IOException
+ {
+ int len = s.length();
+ for(int i = 0; i < len; i++)
+ {
+ int v = s.charAt(i);
+ write(v >>> 8 & 0xff);
+ write(v >>> 0 & 0xff);
+ }
+ }
+
+ public void writeUTF(String str)
+ throws IOException
+ {
+ int strlen = str.length();
+ int utflen = 0;
+ char charr[] = new char[strlen];
+ int count = 0;
+ str.getChars(0, strlen, charr, 0);
+ for(int i = 0; i < strlen; i++)
+ {
+ int c = charr[i];
+ if(c >= 1 && c <= 127)
+ {
+ utflen++;
+ continue;
+ }
+ if(c > 2047)
+ utflen += 3;
+ else
+ utflen += 2;
+ }
+
+ if(utflen > 65535)
+ throw new UTFDataFormatException();
+ byte bytearr[] = new byte[utflen + 2];
+ bytearr[count++] = (byte)(utflen >>> 8 & 0xff);
+ bytearr[count++] = (byte)(utflen >>> 0 & 0xff);
+ for(int i = 0; i < strlen; i++)
+ {
+ int c = charr[i];
+ if(c >= 1 && c <= 127)
+ {
+ bytearr[count++] = (byte)c;
+ continue;
+ }
+ if(c > 2047)
+ {
+ bytearr[count++] = (byte)(0xe0 | c >> 12 & 0xf);
+ bytearr[count++] = (byte)(0x80 | c >> 6 & 0x3f);
+ bytearr[count++] = (byte)(0x80 | c >> 0 & 0x3f);
+ } else
+ {
+ bytearr[count++] = (byte)(0xc0 | c >> 6 & 0x1f);
+ bytearr[count++] = (byte)(0x80 | c >> 0 & 0x3f);
+ }
+ }
+
+ write(bytearr);
+ }
+
+ public void writeFloat(float f1)
+ {
+ }
+
+ public void writeDouble(double d1)
+ {
+ }
+
+ public void readFully(byte b[])
+ throws IOException
+ {
+ readFully(b, 0, b.length);
+ }
+
+ public void readFully(byte b[], int off, int len)
+ throws IOException
+ {
+ if(len < 0)
+ throw new IndexOutOfBoundsException();
+ for(int n = 0; n < len;)
+ {
+ int ch = read();
+ if(ch < 0)
+ throw new EOFException();
+ b[off + n++] = (byte)ch;
+ }
+ }
+
+ public int skipBytes(int n)
+ throws IOException
+ {
+ int total = 0;
+ for(int cur = 0; total < n && (cur = (int)skip(n - total)) > 0; total += cur);
+ return total;
+ }
+
+ public boolean readBoolean()
+ throws IOException
+ {
+ int ch = read();
+ if(ch < 0)
+ throw new EOFException();
+ else
+ return ch != 0;
+ }
+
+ public byte readByte()
+ throws IOException
+ {
+ int ch = read();
+ if(ch < 0)
+ throw new EOFException();
+ else
+ return (byte)ch;
+ }
+
+ public int readUnsignedByte()
+ throws IOException
+ {
+ int ch = read();
+ if(ch < 0)
+ throw new EOFException();
+ else
+ return ch;
+ }
+
+ public short readShort()
+ throws IOException
+ {
+ int ch1 = read();
+ int ch2 = read();
+ if((ch1 | ch2) < 0)
+ throw new EOFException();
+ else
+ return (short)((ch1 << 8) + (ch2 << 0));
+ }
+
+ public int readUnsignedShort()
+ throws IOException
+ {
+ int ch1 = read();
+ int ch2 = read();
+ if((ch1 | ch2) < 0)
+ throw new EOFException();
+ else
+ return (ch1 << 8) + (ch2 << 0);
+ }
+
+ public char readChar()
+ throws IOException
+ {
+ int ch1 = read();
+ int ch2 = read();
+ if((ch1 | ch2) < 0)
+ throw new EOFException();
+ else
+ return (char)((ch1 << 8) + (ch2 << 0));
+ }
+
+ public int readInt()
+ throws IOException
+ {
+ int ch1 = read();
+ int ch2 = read();
+ int ch3 = read();
+ int ch4 = read();
+ if((ch1 | ch2 | ch3 | ch4) < 0)
+ throw new EOFException();
+ else
+ return (ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0);
+ }
+
+ public long readLong()
+ throws IOException
+ {
+ return ((long)readInt() << 32) + ((long)readInt() & 0xffffffffL);
+ }
+
+ public String readUTF()
+ throws IOException
+ {
+ return DataInputStream.readUTF(this);
+ }
+
+ public float readFloat()
+ {
+ return 0.0F;
+ }
+
+ public double readDouble()
+ {
+ return 0.0D;
+ }
}
-
-
diff -ru midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/datagram/Protocol.java midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/datagram/Protocol.java
--- midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/datagram/Protocol.java 2002-11-08 00:02:21.000000000 +0300
+++ midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/datagram/Protocol.java 2016-05-14 20:09:38.984375000 +0300
@@ -13,7 +13,8 @@
import javax.microedition.io.*;
import com.sun.cldc.io.ConnectionBaseInterface;
-import com.sun.cldc.io.GeneralBase;
+//import com.sun.cldc.io.GeneralBase;
+import com.sun.cldc.io.Waiter;
import com.sun.midp.io.*;
@@ -291,7 +292,8 @@
}
/* Wait a while for I/O to become ready */
- GeneralBase.iowait();
+ //GeneralBase.iowait();
+ Waiter.waitForIO();
}
}
}
@@ -338,7 +340,8 @@
}
/* Wait a while for I/O to become ready */
- GeneralBase.iowait();
+ //GeneralBase.iowait();
+ Waiter.waitForIO();
}
count = ((int)res) & 0xffff;
diff -ru midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/serversocket/Socket.java midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/serversocket/Socket.java
--- midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/serversocket/Socket.java 2002-11-08 00:02:21.000000000 +0300
+++ midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/serversocket/Socket.java 2016-05-14 20:20:35.359375000 +0300
@@ -13,7 +13,8 @@
import javax.microedition.io.*;
import com.sun.cldc.io.ConnectionBaseInterface;
-import com.sun.cldc.io.GeneralBase;
+//import com.sun.cldc.io.GeneralBase;
+import com.sun.cldc.io.Waiter;
import com.sun.midp.io.*;
@@ -131,7 +132,8 @@
}
/* Wait a while for I/O to become ready */
- GeneralBase.iowait();
+ //GeneralBase.iowait();
+ Waiter.waitForIO();
}
return con;
diff -ru midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/socket/Protocol.java midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/socket/Protocol.java
--- midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/socket/Protocol.java 2002-11-08 00:02:21.000000000 +0300
+++ midp2.0fcs/src/share/classes/com/sun/midp/io/j2me/socket/Protocol.java 2016-05-14 20:20:59.906250000 +0300
@@ -12,7 +12,8 @@
import javax.microedition.io.*;
-import com.sun.cldc.io.GeneralBase;
+//import com.sun.cldc.io.GeneralBase;
+import com.sun.cldc.io.Waiter;
import com.sun.midp.main.Configuration;
@@ -252,7 +253,8 @@
}
/* Wait a while for I/O to become ready */
- GeneralBase.iowait();
+ //GeneralBase.iowait();
+ Waiter.waitForIO();
}
}
diff -ru midp2.0fcs/src/share/classes/com/sun/midp/main/Main.java midp2.0fcs/src/share/classes/com/sun/midp/main/Main.java
--- midp2.0fcs/src/share/classes/com/sun/midp/main/Main.java 2016-05-14 23:43:39.281250000 +0300
+++ midp2.0fcs/src/share/classes/com/sun/midp/main/Main.java 2002-11-08 00:02:25.000000000 +0300
@@ -126,7 +126,7 @@
} catch (InvalidJadException ije) {
System.out.println("** Error installing suite (" +
ije.getReason() + "): " +
- messageForInvalidJadException(ije));
+ messageForInvalidJadException(ije));
} catch (IOException ioe) {
System.out.println("** Error installing suite: " +
ioe.getMessage());
diff -ru midp2.0fcs/src/share/native/configuration.c midp2.0fcs/src/share/native/configuration.c
--- midp2.0fcs/src/share/native/configuration.c 2016-05-14 22:53:49.640625000 +0300
+++ midp2.0fcs/src/share/native/configuration.c 2016-05-14 22:54:22.531250000 +0300
@@ -103,7 +103,7 @@
*=======================================================================*/
/* a default for the configuration property is required by the CLDC spec */
#define DEFAULT_CONFIGURATION "microedition.configuration"
-#define DEFAULT_CLDC "CLDC-1.0"
+#define DEFAULT_CLDC "CLDC-1.1"
/* a default for the encoding property is required by the CLDC spec */
#define ENCODING_PROP_NAME "microedition.encoding"
diff -ru midp2.0fcs/src/share/native/kvm/midpEvents.c midp2.0fcs/src/share/native/kvm/midpEvents.c
--- midp2.0fcs/src/share/native/kvm/midpEvents.c 2002-11-08 00:02:31.000000000 +0300
+++ midp2.0fcs/src/share/native/kvm/midpEvents.c 2016-05-14 20:12:58.093750000 +0300
@@ -166,14 +166,14 @@
*=======================================================================*/
void Java_com_sun_midp_lcdui_Events_open(void) {
- Java_com_sun_cldc_io_j2me_events_PrivateInputStream_open();
+
}
void Java_com_sun_midp_lcdui_Events_readInt(void) {
- Java_com_sun_cldc_io_j2me_events_PrivateInputStream_readInt();
+ JVM_EventsReadInt();
}
void Java_com_sun_midp_lcdui_Events_readUTF(void) {
- Java_com_sun_cldc_io_j2me_events_PrivateInputStream_readUTF();
+ JVM_EventsReadUTF();
}
diff -ru midp2.0fcs/src/win32/native/machine_md.h midp2.0fcs/src/win32/native/machine_md.h
--- midp2.0fcs/src/win32/native/machine_md.h 2002-11-08 00:02:34.000000000 +0300
+++ midp2.0fcs/src/win32/native/machine_md.h 2016-05-14 20:14:36.578125000 +0300
@@ -89,6 +89,11 @@
{ long delta = (long)(wakeupTime - CurrentTime_md()); \
Sleep(delta); \
}
+
+#define SLEEP_FOR(delta) Sleep((long)delta)
+
+#define ERROR_THROW(status) VM_EXIT(status);
+#include<setjmp.h>
/*=========================================================================
* Platform-specific macros and function prototypes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment