1 /* class: java/lang/System */
5 * Class: java/lang/System
6 * Method: currentTimeMillis
9 JNIEXPORT s8 JNICALL Java_java_lang_VMSystem_currentTimeMillis ( JNIEnv *env )
13 (void) gettimeofday(&tv, NULL);
14 return ((s8) tv.tv_sec) * 1000 + tv.tv_usec / 1000;
19 * Class: java/lang/System
21 * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
23 JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy (JNIEnv *env, jclass clazz,struct java_lang_Object* source, s4 sp, struct java_lang_Object* dest, s4 dp, s4 len)
26 java_arrayheader *s = (java_arrayheader*) source;
27 java_arrayheader *d = (java_arrayheader*) dest;
28 arraydescriptor *sdesc;
29 arraydescriptor *ddesc;
31 /* printf("arraycopy: %p:%x->%p:%x\n",source,sp,dest,dp);
35 exceptionptr = proto_java_lang_NullPointerException;
39 sdesc = s->objheader.vftbl->arraydesc;
40 ddesc = d->objheader.vftbl->arraydesc;
42 if (!sdesc || !ddesc || (sdesc->arraytype != ddesc->arraytype)) {
43 exceptionptr = proto_java_lang_ArrayStoreException;
47 if ((len<0) || (sp<0) || (sp+len > s->size) || (dp<0) || (dp+len > d->size)) {
48 exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
52 if (sdesc->componentvftbl == ddesc->componentvftbl) {
53 /* We copy primitive values or references of exactly the same type */
54 s4 dataoffset = sdesc->dataoffset;
55 s4 componentsize = sdesc->componentsize;
56 memmove(((u1*)d) + dataoffset + componentsize * dp,
57 ((u1*)s) + dataoffset + componentsize * sp,
58 (size_t) len * componentsize);
61 /* We copy references of different type */
62 java_objectarray *oas = (java_objectarray*) s;
63 java_objectarray *oad = (java_objectarray*) d;
66 for (i=0; i<len; i++) {
67 java_objectheader *o = oas->data[sp+i];
68 if (!builtin_canstore(oad, o)) {
69 exceptionptr = proto_java_lang_ArrayStoreException;
75 /* XXX this does not completely obey the specification!
76 * If an exception is thrown only the elements above
77 * the current index have been copied. The
78 * specification requires that only the elements
79 * *below* the current index have been copied before
82 for (i=len-1; i>=0; i--) {
83 java_objectheader *o = oas->data[sp+i];
84 if (!builtin_canstore(oad, o)) {
85 exceptionptr = proto_java_lang_ArrayStoreException;
93 void attach_property (char *name, char *value)
95 log_text("attach_property not supported");
97 if (activeprops >= MAXPROPS) panic ("Too many properties defined");
98 proplist[activeprops][0] = name;
99 proplist[activeprops][1] = value;
105 * Class: java/lang/System
106 * Method: identityHashCode
107 * Signature: (Ljava/lang/Object;)I
109 JNIEXPORT s4 JNICALL Java_java_lang_VMSystem_identityHashCode (JNIEnv *env , jclass clazz, struct java_lang_Object* par1)
111 return ((char*) par1) - ((char*) 0);