## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
##
-## $Id: Makefile.am 7596 2007-03-28 21:05:53Z twisti $
+## $Id: Makefile.am 8347 2007-08-18 13:04:59Z twisti $
## Process this file with automake to produce Makefile.in
vm \
vmcore
-if WITH_CLASSPATH_GNU
-VM_DIR = \
- lib
-endif
-
if ENABLE_THREADS
THREADS_DIR = \
threads
toolbox \
vmcore \
$(CACAOH_DIR) \
- $(VM_DIR) \
+ lib \
native \
fdlibm \
mm \
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
##
-## $Id: Makefile.am 8262 2007-08-06 12:44:01Z panzi $
+## $Id: Makefile.am 8347 2007-08-18 13:04:59Z twisti $
## Process this file with automake to produce Makefile.in
CLEANFILES = vm.zip
+if WITH_CLASSPATH_GNU
VM_JAVA_FILES = \
$(top_srcdir)/src/lib/gnu/gnu/classpath/VMStackWalker.java \
$(top_srcdir)/src/lib/gnu/gnu/classpath/VMSystemProperties.java \
classes/java/security/VMAccessController.class \
classes/sun/misc/Unsafe.class
-if WITH_CLASSPATH_GNU
if ENABLE_ANNOTATIONS
VM_JAVA_FILES += \
$(top_srcdir)/src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java \
classes/sun/reflect/annotation/AnnotationType.class \
classes/sun/reflect/annotation/AnnotationParser.class
endif
+
+if ENABLE_ZLIB
+pkgdata_DATA = vm.zip
+else
+pkgdata_DATA = nozip
+endif
endif
+if WITH_CLASSPATH_CLDC1_1
+VM_JAVA_FILES = \
+ $(top_srcdir)/src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java
+
+VM_CLASS_FILES = \
+ classes/com/sun/cldchi/jvm/FileDescriptor.class
if ENABLE_ZLIB
pkgdata_DATA = vm.zip
+else
+pkgdata_DATA = nozip
+endif
+endif
+if ENABLE_ZLIB
VM_ZIP = ../vm.zip
vm.zip: $(VM_JAVA_FILES)
cd classes && $(JAR) cvf $(VM_ZIP) .; \
fi
else
-pkgdata_DATA = nozip
-
nozip: $(VM_JAVA_FILES)
$(mkdir_p) classes
- $(JAVAC) -d classes $(VM_JAVA_FILES)
+ $(JAVAC) -source 1.5 -target 1.5 -d classes $(VM_JAVA_FILES)
endif
clean-local:
--- /dev/null
+/* src/lib/com/sun/cldchi/jvm/FileDescriptor.java
+
+ Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+ R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+ C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+ Institut f. Computersprachen - TU Wien
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+package com.sun.cldchi.jvm;
+
+class FileDescriptor {
+ long pointer;
+ int position;
+ int length;
+}
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
##
-## $Id: Makefile.am 8249 2007-07-31 12:59:03Z panzi $
+## $Id: Makefile.am 8347 2007-08-18 13:04:59Z twisti $
## Process this file with automake to produce Makefile.in
com_sun_cldc_io_ResourceInputStream.h \
com_sun_cldc_io_j2me_socket_Protocol.h \
com_sun_cldchi_io_ConsoleOutputStream.h \
+ com_sun_cldchi_jvm_FileDescriptor.h \
com_sun_cldchi_jvm_JVM.h \
java_lang_Math.h \
java_lang_Runtime.h \
if WITH_CLASSPATH_GNU
CLASSPATH = $(top_builddir)/src/lib/classes/:$(CLASSPATH_CLASSES)
VM_ZIP = $(top_builddir)/src/lib/vm.zip
-else
+endif
+
+if WITH_CLASSPATH_SUN
CLASSPATH = $(CLASSPATH_CLASSES)
endif
+if WITH_CLASSPATH_CLDC1_1
+CLASSPATH = $(top_builddir)/src/lib/classes/:$(CLASSPATH_CLASSES)
+VM_ZIP = $(top_builddir)/src/lib/vm.zip
+endif
+
noinst_DATA = $(DO_HEADER_FILES)
$(DO_HEADER_FILES): $(CACAOH) $(VM_ZIP) $(CLASSPATH_CLASSES)
*/
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <zlib.h>
#include "config.h"
-#include "vm/types.h"
+
+#include "mm/memory.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_Object.h"
#include "native/include/java_lang_String.h"
-
#include "native/include/com_sun_cldc_io_ResourceInputStream.h"
+#include "native/include/com_sun_cldchi_jvm_FileDescriptor.h"
+#include "vm/types.h"
+#include "vm/builtin.h"
#include "vm/vm.h" /* REMOVE ME: temporarily */
+#include "vm/exceptions.h"
+#include "vm/stringlocal.h"
+
+#include "vmcore/zip.h"
+#include "threads/lock-common.h"
/* native methods implemented by this file ************************************/
static JNINativeMethod methods[] = {
{ "open", "(Ljava/lang/String;)Ljava/lang/Object;", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_open },
+ { "bytesRemain", "(Ljava/lang/Object;)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_bytesRemain },
+ { "readByte", "(Ljava/lang/Object;)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_readByte },
+ { "readBytes", "(Ljava/lang/Object;[BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_readBytes },
+ { "clone", "(Ljava/lang/Object;)Ljava/lang/Object;", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_clone },
};
/* _Jv_com_sun_cldc_io_ResourceInputStream_init ********************************
native_method_register(u, methods, NATIVE_METHODS_COUNT);
}
+static struct com_sun_cldchi_jvm_FileDescriptor* zip_read_resource(list_classpath_entry *lce, utf *name)
+{
+ hashtable_zipfile_entry *htzfe;
+ lfh lfh;
+ u1 *indata;
+ u1 *outdata;
+ z_stream zs;
+ int err;
+
+ classinfo *ci;
+ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor = NULL;
+
+ /* try to find the class in the current archive */
+
+ htzfe = zip_find(lce, name);
+
+ if (htzfe == NULL)
+ return NULL;
+
+ /* read stuff from local file header */
+
+ lfh.filenamelength = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH);
+ lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH);
+
+ indata = htzfe->data +
+ LFH_HEADER_SIZE +
+ lfh.filenamelength +
+ lfh.extrafieldlength;
+
+ /* allocate buffer for uncompressed data */
+
+ outdata = MNEW(u1, htzfe->uncompressedsize);
+
+ /* how is the file stored? */
+
+ switch (htzfe->compressionmethod) {
+ case Z_DEFLATED:
+ /* fill z_stream structure */
+
+ zs.next_in = indata;
+ zs.avail_in = htzfe->compressedsize;
+ zs.next_out = outdata;
+ zs.avail_out = htzfe->uncompressedsize;
+
+ zs.zalloc = Z_NULL;
+ zs.zfree = Z_NULL;
+ zs.opaque = Z_NULL;
+
+ /* initialize this inflate run */
+
+ if (inflateInit2(&zs, -MAX_WBITS) != Z_OK)
+ vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno));
+
+ /* decompress the file into buffer */
+
+ err = inflate(&zs, Z_SYNC_FLUSH);
+
+ if ((err != Z_STREAM_END) && (err != Z_OK))
+ vm_abort("zip_get: inflate failed: %s", strerror(errno));
+
+ /* finish this inflate run */
+
+ if (inflateEnd(&zs) != Z_OK)
+ vm_abort("zip_get: inflateEnd failed: %s", strerror(errno));
+ break;
+
+ case 0:
+ /* uncompressed file, just copy the data */
+ MCOPY(outdata, indata, u1, htzfe->compressedsize);
+ break;
+
+ default:
+ vm_abort("zip_get: unknown compression method %d",
+ htzfe->compressionmethod);
+ }
+
+ /* Create a file descriptor object */
+ ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
+ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
+ LLNI_field_set_val(fileDescriptor, pointer, (int)outdata);
+ LLNI_field_set_val(fileDescriptor, length, htzfe->uncompressedsize);
+ LLNI_field_set_val(fileDescriptor, position, 0);
+ return fileDescriptor;
+
+}
+
+static struct com_sun_cldchi_jvm_FileDescriptor* file_read_resource(char *path)
+{
+ int len;
+ struct stat statBuffer;
+ u1 *filep;
+ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor = NULL;
+ classinfo *ci;
+ int fd;
+
+ fd = open(path, O_RDONLY);
+
+ if (fd > 0) {
+
+ if (fstat(fd, &statBuffer) != -1) {
+ len = statBuffer.st_size;
+ } else {
+ return NULL;
+ }
+
+ /* Map file into the memory */
+ filep = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
+
+ /* Create a file descriptor object */
+ ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
+ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
+ LLNI_field_set_val(fileDescriptor, pointer, (int)filep);
+ LLNI_field_set_val(fileDescriptor, length, len);
+ LLNI_field_set_val(fileDescriptor, position, 0);
+
+ return fileDescriptor;
+
+ } else {
+ return NULL;
+ }
+
+}
+
/*
* Class: com/sun/cldc/io/ResourceInputStream
* Method: open
* Signature: (Ljava/lang/String;)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, java_lang_String *name)
+JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, java_lang_String *name)
{
- vm_abort("Java_com_sun_cldc_io_ResourceInputStream_open: IMPLEMENT ME!");
+
+ list_classpath_entry *lce;
+ char *filename;
+ s4 filenamelen;
+ char *path;
+ utf *uname;
+ com_sun_cldchi_jvm_FileDescriptor* descriptor;
+
+ /* get the classname as char string (do it here for the warning at
+ the end of the function) */
+
+ uname = javastring_toutf((java_handle_t *)name, false);
+ filenamelen = utf_bytes(uname) + strlen("0");
+ filename = MNEW(char, filenamelen);
+ utf_copy(filename, uname);
+
+ /* walk through all classpath entries */
+
+ for (lce = list_first(list_classpath_entries); lce != NULL;
+ lce = list_next(list_classpath_entries, lce)) {
+
+#if defined(ENABLE_ZLIB)
+ if (lce->type == CLASSPATH_ARCHIVE) {
+
+ /* enter a monitor on zip/jar archives */
+ LOCK_MONITOR_ENTER(lce);
+
+ /* try to get the file in current archive */
+ descriptor = zip_read_resource(lce, uname);
+
+ /* leave the monitor */
+ LOCK_MONITOR_EXIT(lce);
+
+ if (descriptor != NULL) { /* file exists */
+ break;
+ }
+
+ } else {
+#endif
+
+ path = MNEW(char, lce->pathlen + filenamelen);
+ strcpy(path, lce->path);
+ strcat(path, filename);
+
+ descriptor = file_read_resource(path);
+
+ MFREE(path, char, lce->pathlen + filenamelen);
+
+ if (descriptor != NULL) { /* file exists */
+ break;
+ }
+
+#if defined(ENABLE_ZLIB)
+ }
+#endif
+
+ }
+
+ MFREE(filename, char, filenamelen);
+
+ return (java_lang_Object*) descriptor;
+
+}
+
+
+/*
+ * Class: com_sun_cldc_io_ResourceInputStream
+ * Method: bytesRemain
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_bytesRemain(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
+
+ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
+ int32_t length;
+ int32_t position;
+
+ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
+ LLNI_field_get_val(fileDescriptor, position, position);
+ LLNI_field_get_val(fileDescriptor, length, length);
+
+ return length - position;
+
+}
+
+/*
+ * Class: com_sun_cldc_io_ResourceInputStream
+ * Method: readByte
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readByte(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
+
+ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
+ u1 byte;
+ int32_t length;
+ int32_t position;
+ int64_t filep;
+
+ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
+ LLNI_field_get_val(fileDescriptor, position, position);
+ LLNI_field_get_val(fileDescriptor, length, length);
+ LLNI_field_get_val(fileDescriptor, pointer, filep);
+
+ if (position < length) {
+ byte = ((u1*)(int)filep)[position];
+ position++;
+ } else {
+ return -1; /* EOF */
+ }
+
+ /* Update access position */
+ LLNI_field_set_val(fileDescriptor, position, position);
+
+ return (byte & 0xFF);
+
+}
+
+/*
+ * Class: com_sun_cldc_io_ResourceInputStream
+ * Method: readBytes
+ * Signature: (Ljava/lang/Object;[BII)I
+ */
+JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readBytes(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj, java_handle_bytearray_t* byteArray, s4 off, s4 len) {
+
+ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
+ s4 readBytes = -1;
+ int32_t fileLength;
+ int32_t position;
+ s4 available;
+ int64_t filep;
+ void *buf;
+
+ /* get pointer to the buffer */
+ buf = &(LLNI_array_direct(byteArray, off));
+
+ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
+ LLNI_field_get_val(fileDescriptor, position, position);
+ LLNI_field_get_val(fileDescriptor, length, fileLength);
+ LLNI_field_get_val(fileDescriptor, pointer, filep);
+
+ if (position < fileLength) {
+ available = fileLength - position;
+ if (available < len) {
+ readBytes = available;
+ } else {
+ readBytes = len;
+ }
+ memcpy(buf, ((u1*)(int)filep) + position, readBytes * sizeof(u1));
+ position += readBytes;
+ } else {
+ return -1; /* EOF */
+ }
+
+ /* Update access position */
+ LLNI_field_set_val(fileDescriptor, position, position);
+
+ return readBytes;
+}
+
+/*
+ * Class: com_sun_cldc_io_ResourceInputStream
+ * Method: clone
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_clone(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
+
+ classinfo *ci;
+ com_sun_cldchi_jvm_FileDescriptor *srcFileDescriptor;
+ com_sun_cldchi_jvm_FileDescriptor *dstFileDescriptor;
+ int32_t srcLength;
+ int32_t srcPosition;
+ int64_t srcFilePointer;
+
+ srcFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
+ LLNI_field_get_val(srcFileDescriptor, position, srcPosition);
+ LLNI_field_get_val(srcFileDescriptor, length, srcLength);
+ LLNI_field_get_val(srcFileDescriptor, pointer, srcFilePointer);
+
+ ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
+ dstFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
+ LLNI_field_set_val(dstFileDescriptor, position, srcPosition);
+ LLNI_field_set_val(dstFileDescriptor, length, srcLength);
+ LLNI_field_set_val(dstFileDescriptor, pointer, srcFilePointer);
+
+ return (java_lang_Object*) dstFileDescriptor;
- return NULL;
}
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/com_sun_cldc_io_j2me_socket_Protocol.h"
* Method: open0
* Signature: ([BII)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_open0(JNIEnv *env, jclass clazz, java_bytearray *hostname, s4 port, s4 mode)
+JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_open0(JNIEnv *env, jclass clazz, java_handle_bytearray_t *hostname, s4 port, s4 mode)
{
struct hostent *phostent;
struct sockaddr_in serv_addr;
/* The hostname byte-array is a NULL terminated C-string. */
- name = (char *) &(hostname->data);
+ name = (char *) &(LLNI_array_data(hostname));
/* get the host */
* Method: readBuf
* Signature: (I[BII)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv *env, jclass clazz, s4 handle, java_bytearray *b, s4 off, s4 len)
+JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv *env, jclass clazz, s4 handle, java_handle_bytearray_t *b, s4 off, s4 len)
{
void *buf;
ssize_t result;
/* get pointer to the buffer */
- buf = &(b->data[off]);
+ buf = &(LLNI_array_direct(b, off));
/* receive from the socket */
* Method: writeBuf
* Signature: (I[BII)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv *env, jclass clazz, s4 handle, java_bytearray* b, s4 off, s4 len) {
+JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv *env, jclass clazz, s4 handle, java_handle_bytearray_t * b, s4 off, s4 len) {
void *buf;
ssize_t result;
/* get pointer to the buffer */
- buf = &(b->data[off]);
+ buf = &(LLNI_array_direct(b, off));
/* send the given byte to the socket */
#include "vm/types.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_String.h" /* required by j.l.C */
#include "vm/types.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_String.h" /* required by j.l.C */
#include "vm/types.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_Object.h"
*/
JNIEXPORT s4 JNICALL Java_java_lang_String_hashCode(JNIEnv *env, java_lang_String *this)
{
- java_chararray *value;
- s4 offset;
- s4 count;
- s4 hash;
- s4 i;
+ java_handle_chararray_t *value;
+ int32_t offset;
+ int32_t count;
+ s4 hash;
+ s4 i;
/* get values from Java object */
-
- offset = this->offset;
- count = this->count;
- value = this->value;
+
+ LLNI_field_get_val(this, offset, offset);
+ LLNI_field_get_val(this, count, count);
+ LLNI_field_get_ref(this, value, value);
hash = 0;
for (i = 0; i < count; i++) {
- hash = (31 * hash) + value->data[offset + i];
+ hash = (31 * hash) + LLNI_array_direct(value, offset + i);
}
return hash;
*/
JNIEXPORT s4 JNICALL Java_java_lang_String_indexOf__I(JNIEnv *env, java_lang_String *this, s4 ch)
{
- java_chararray *value;
- s4 offset;
- s4 count;
- s4 i;
+ java_handle_chararray_t *value;
+ int32_t offset;
+ int32_t count;
+ s4 i;
/* get values from Java object */
- offset = this->offset;
- count = this->count;
- value = this->value;
+ LLNI_field_get_val(this, offset, offset);
+ LLNI_field_get_val(this, count, count);
+ LLNI_field_get_ref(this, value, value);
for (i = 0; i < count; i++) {
- if (value->data[offset + i] == ch) {
+ if (LLNI_array_direct(value, offset + i) == ch) {
return i;
}
}
*/
JNIEXPORT s4 JNICALL Java_java_lang_String_indexOf__II(JNIEnv *env, java_lang_String *this, s4 ch, s4 fromIndex)
{
- java_chararray *value;
- s4 offset;
- s4 count;
- s4 i;
+ java_handle_chararray_t *value;
+ int32_t offset;
+ int32_t count;
+ s4 i;
/* get values from Java object */
- offset = this->offset;
- count = this->count;
- value = this->value;
+ LLNI_field_get_val(this, offset, offset);
+ LLNI_field_get_val(this, count, count);
+ LLNI_field_get_ref(this, value, value);
if (fromIndex < 0) {
fromIndex = 0;
}
for (i = fromIndex ; i < count ; i++) {
- if (value->data[offset + i] == ch) {
+ if (LLNI_array_direct(value, offset + i) == ch) {
return i;
}
}
*/
JNIEXPORT s4 JNICALL Java_java_lang_String_lastIndexOf__I(JNIEnv *env, java_lang_String *this, s4 ch)
{
- return Java_java_lang_String_lastIndexOf__II(env, this, ch, this->count - 1);
+ int32_t count;
+
+ LLNI_field_get_val(this, count, count);
+
+ return Java_java_lang_String_lastIndexOf__II(env, this, ch, count - 1);
}
*/
JNIEXPORT s4 JNICALL Java_java_lang_String_lastIndexOf__II(JNIEnv *env, java_lang_String *this, s4 ch, s4 fromIndex)
{
- java_chararray *value;
- s4 offset;
- s4 count;
- s4 start;
- s4 i;
+ java_handle_chararray_t *value;
+ int32_t offset;
+ int32_t count;
+ s4 start;
+ s4 i;
/* get values from Java object */
- offset = this->offset;
- count = this->count;
- value = this->value;
+ LLNI_field_get_val(this, offset, offset);
+ LLNI_field_get_val(this, count, count);
+ LLNI_field_get_ref(this, value, value);
start = ((fromIndex >= count) ? count - 1 : fromIndex);
for (i = start; i >= 0; i--) {
- if (value->data[offset + i] == ch) {
+ if (LLNI_array_direct(value, offset + i) == ch) {
return i;
}
}
*/
JNIEXPORT s4 JNICALL Java_java_lang_String_equals(JNIEnv *env, java_lang_String* this, java_lang_Object *o)
{
- java_lang_String* s;
+ java_lang_String* s;
+ java_handle_chararray_t *value;
+ int32_t offset;
+ int32_t count;
+ java_handle_chararray_t *dvalue;
+ int32_t doffset;
+ int32_t dcount;
+ classinfo *c;
+
+ LLNI_field_get_val(this, offset, offset);
+ LLNI_field_get_val(this, count, count);
+ LLNI_field_get_ref(this, value, value);
+ LLNI_class_get(o, c);
/* TODO: is this the correct implementation for short-circuiting on object identity? */
if ((java_lang_Object*)this == o)
return 1;
-
- if (o->header.vftbl->class != class_java_lang_String)
+
+ if (c != class_java_lang_String)
return 0;
s = (java_lang_String *) o;
+ LLNI_field_get_val(this, offset, doffset);
+ LLNI_field_get_val(this, count, dcount);
+ LLNI_field_get_ref(this, value, dvalue);
- if (this->count != s->count)
+ if (count != dcount)
return 0;
- return ( 0 == memcmp((void*)(this->value->data + this->offset),
- (void*)(s->value->data + s->offset),
- this->count) );
+ return ( 0 == memcmp((void*)(LLNI_array_direct(value, offset)),
+ (void*)(LLNI_array_direct(dvalue, doffset),
+ count) );
+
}
#endif
JNIEXPORT java_lang_String* JNICALL Java_java_lang_String_intern(JNIEnv *env, java_lang_String *this)
{
java_handle_t *o;
+ java_handle_chararray_t *value;
+ int32_t offset;
+ int32_t count;
if (this == NULL)
return NULL;
+
+ LLNI_field_get_val(this, offset, offset);
+ LLNI_field_get_val(this, count, count);
+ LLNI_field_get_ref(this, value, value);
/* search table so identical strings will get identical pointers */
- o = literalstring_u2(this->value, this->count, this->offset, true);
+ o = literalstring_u2(value, count, offset, true);
return (java_lang_String *) o;
}
*/
JNIEXPORT void JNICALL Java_java_lang_System_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, s4 srcStart, java_lang_Object *dest, s4 destStart, s4 len)
{
- (void) builtin_arraycopy((java_arrayheader *) src, srcStart,
- (java_arrayheader *) dest, destStart, len);
+ (void) builtin_arraycopy((java_handle_t *) src, srcStart,
+ (java_handle_t *) dest, destStart, len);
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: zip.c 7548 2007-03-21 13:19:44Z twisti $
+ $Id: zip.c 8347 2007-08-18 13:04:59Z twisti $
*/
#define SIGNATURE_LENGTH 4
-
-/* Local file header ***********************************************************
-
- local file header signature 4 bytes (0x04034b50)
- version needed to extract 2 bytes
- general purpose bit flag 2 bytes
- compression method 2 bytes
- last mod file time 2 bytes
- last mod file date 2 bytes
- crc-32 4 bytes
- compressed size 4 bytes
- uncompressed size 4 bytes
- file name length 2 bytes
- extra field length 2 bytes
-
- file name (variable size)
- extra field (variable size)
-
-*******************************************************************************/
-
-#define LFH_HEADER_SIZE 30
-
-#define LFH_SIGNATURE 0x04034b50
-#define LFH_FILE_NAME_LENGTH 26
-#define LFH_EXTRA_FIELD_LENGTH 28
-
-typedef struct lfh lfh;
-
-struct lfh {
- u2 compressionmethod;
- u4 compressedsize;
- u4 uncompressedsize;
- u2 filenamelength;
- u2 extrafieldlength;
-};
-
-
/* Central directory structure *************************************************
[file header 1]
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: zip.h 7246 2007-01-29 18:49:05Z twisti $
+ $Id: zip.h 8347 2007-08-18 13:04:59Z twisti $
*/
#include "vmcore/utf8.h"
+/* Local file header ***********************************************************
+
+ local file header signature 4 bytes (0x04034b50)
+ version needed to extract 2 bytes
+ general purpose bit flag 2 bytes
+ compression method 2 bytes
+ last mod file time 2 bytes
+ last mod file date 2 bytes
+ crc-32 4 bytes
+ compressed size 4 bytes
+ uncompressed size 4 bytes
+ file name length 2 bytes
+ extra field length 2 bytes
+
+ file name (variable size)
+ extra field (variable size)
+
+*******************************************************************************/
+
+#define LFH_HEADER_SIZE 30
+
+#define LFH_SIGNATURE 0x04034b50
+#define LFH_FILE_NAME_LENGTH 26
+#define LFH_EXTRA_FIELD_LENGTH 28
+
+typedef struct lfh lfh;
+
+struct lfh {
+ u2 compressionmethod;
+ u4 compressedsize;
+ u4 uncompressedsize;
+ u2 filenamelength;
+ u2 extrafieldlength;
+};
+
/* hashtable_zipfile_entry ****************************************************/
typedef struct hashtable_zipfile_entry hashtable_zipfile_entry;