[kaffe] CVS kaffe (robilad): Fixed build by adding the missing includes and removing no longer necessary ones
Kaffe CVS
cvs-commits at kaffe.org
Fri Apr 22 14:25:31 PDT 2005
PatchSet 5729
Date: 2005/04/22 21:20:41
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Fixed build by adding the missing includes and removing no longer necessary ones
2005-04-22 Dalibor Topic <robilad at kaffe.org>
* include/Makefile.am (NOINSTALL_DERIVED_HDRS):
Added java_net_InetAddress.h and java_net_NetworkInterface.h.
Reported by: Ito Kazumitsu <kaz at maczuka.gcd.org>
* libraries/clib/native/Array.c,
libraries/clib/native/Field.c,
libraries/clib/native/Method.c:
Fixed includes.
Members:
ChangeLog:1.3897->1.3898
include/Makefile.am:1.95->1.96
include/Makefile.in:1.223->1.224
libraries/clib/native/Array.c:INITIAL->1.23
libraries/clib/native/Field.c:INITIAL->1.19
libraries/clib/native/Method.c:INITIAL->1.41
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3897 kaffe/ChangeLog:1.3898
--- kaffe/ChangeLog:1.3897 Fri Apr 22 17:03:36 2005
+++ kaffe/ChangeLog Fri Apr 22 21:20:41 2005
@@ -1,5 +1,17 @@
2005-04-22 Dalibor Topic <robilad at kaffe.org>
+ * include/Makefile.am (NOINSTALL_DERIVED_HDRS):
+ Added java_net_InetAddress.h and java_net_NetworkInterface.h.
+
+ Reported by: Ito Kazumitsu <kaz at maczuka.gcd.org>
+
+ * libraries/clib/native/Array.c,
+ libraries/clib/native/Field.c,
+ libraries/clib/native/Method.c:
+ Fixed includes.
+
+2005-04-22 Dalibor Topic <robilad at kaffe.org>
+
* libraries/clib/native/java_lang_VMDouble.c:
(parseDoubleFromChars) New function. Factored out from ...
(Java_java_lang_VMDouble_parseDouble): Factored out the parsing.
Index: kaffe/include/Makefile.am
diff -u kaffe/include/Makefile.am:1.95 kaffe/include/Makefile.am:1.96
--- kaffe/include/Makefile.am:1.95 Fri Apr 22 17:03:47 2005
+++ kaffe/include/Makefile.am Fri Apr 22 21:20:44 2005
@@ -67,8 +67,10 @@
java_lang_reflect_Field.h \
java_lang_reflect_Method.h \
java_net_DatagramPacket.h \
+ java_net_InetAddress.h \
java_net_VMInetAddress.h \
java_net_InetSocketAddress.h \
+ java_net_NetworkInterface.h \
java_net_VMNetworkInterface.h \
gnu_java_net_PlainDatagramSocketImpl.h \
gnu_java_net_PlainSocketImpl.h \
Index: kaffe/include/Makefile.in
diff -u kaffe/include/Makefile.in:1.223 kaffe/include/Makefile.in:1.224
--- kaffe/include/Makefile.in:1.223 Fri Apr 22 17:03:47 2005
+++ kaffe/include/Makefile.in Fri Apr 22 21:20:44 2005
@@ -430,8 +430,10 @@
java_lang_reflect_Field.h \
java_lang_reflect_Method.h \
java_net_DatagramPacket.h \
+ java_net_InetAddress.h \
java_net_VMInetAddress.h \
java_net_InetSocketAddress.h \
+ java_net_NetworkInterface.h \
java_net_VMNetworkInterface.h \
gnu_java_net_PlainDatagramSocketImpl.h \
gnu_java_net_PlainSocketImpl.h \
===================================================================
Checking out kaffe/libraries/clib/native/Array.c
RCS: /home/cvs/kaffe/kaffe/libraries/clib/native/Array.c,v
VERS: 1.23
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/native/Array.c Fri Apr 22 21:25:31 2005
@@ -0,0 +1,42 @@
+/*
+ * java.lang.reflect.Array.c
+ *
+ * Copyright (c) 1996, 1997
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#include "config.h"
+#include "config-std.h"
+#include "config-mem.h"
+#include "object.h"
+#include "classMethod.h"
+#include "baseClasses.h"
+#include "itypes.h"
+#include "soft.h"
+#include "exception.h"
+#include "java_lang_reflect_Array.h"
+#include <native.h>
+#include "defs.h"
+
+jint
+java_lang_reflect_Array_getLength(struct Hjava_lang_Object* obj)
+{
+ if (!CLASS_IS_ARRAY(OBJECT_CLASS(obj)))
+ SignalError("java.lang.IllegalArgumentException", "");
+
+ return (obj_length((HArrayOfObject*)obj));
+}
+
+struct Hjava_lang_Object*
+java_lang_reflect_Array_newArray(struct Hjava_lang_Class* clazz, jint size)
+{
+ if (size < 0) {
+ SignalError("java.lang.NegativeArraySizeException", "");
+ }
+
+ return (newArray(clazz, (jsize) size));
+}
+
===================================================================
Checking out kaffe/libraries/clib/native/Field.c
RCS: /home/cvs/kaffe/kaffe/libraries/clib/native/Field.c,v
VERS: 1.19
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/native/Field.c Fri Apr 22 21:25:31 2005
@@ -0,0 +1,183 @@
+/*
+ * java.lang.reflect.Field.c
+ *
+ * Copyright (c) 1996,97 T. J. Wilkinson & Associates, London, UK.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * Written by Tim Wilkinson <tim at tjwassoc.co.uk>
+ */
+
+#include "config.h"
+#include "config-std.h"
+#include "config-mem.h"
+#include "gtypes.h"
+#include "access.h"
+#include "constants.h"
+#include "object.h"
+#include "classMethod.h"
+#include "itypes.h"
+#include "support.h"
+#include "soft.h"
+#include "baseClasses.h"
+#include "exception.h"
+#include "java_io_InputStream.h"
+#include "java_io_PrintStream.h"
+#include "java_lang_System.h"
+#include "java_lang_reflect_Field.h"
+#include <native.h>
+#include "defs.h"
+
+static
+void*
+getFieldAddress(Hjava_lang_reflect_Field* this, struct Hjava_lang_Object* obj)
+{
+ Hjava_lang_Class* clas;
+ Field* fld;
+
+ clas = (Hjava_lang_Class*)unhand(this)->clazz;
+ fld = CLASS_FIELDS(clas) + unhand(this)->slot;
+
+ if (unhand(this)->slot < CLASS_NSFIELDS(clas)) {
+ errorInfo einfo;
+ if (!processClass(clas, CSTATE_COMPLETE, &einfo)) {
+ throwError(&einfo);
+ }
+ return (FIELD_ADDRESS(fld));
+ }
+ else {
+ if (obj == NULL) {
+ SignalError("java.lang.NullPointerException", "");
+ }
+ if (!soft_instanceof(clas, obj)) {
+ SignalError("java.lang.IllegalArgumentException","");
+ }
+ return ((void*)(((char*)(obj)) + FIELD_BOFFSET(fld)));
+ }
+}
+
+/* WHAT WITH SECURITY RESTRICTIONS !!!??? */
+
+
+jint
+java_lang_reflect_Field_getModifiers(struct Hjava_lang_reflect_Field * this)
+{
+ Hjava_lang_Class* clas;
+ Field* fld;
+
+ clas = (Hjava_lang_Class*) unhand(this)->clazz;
+ fld = CLASS_FIELDS(clas) + unhand(this)->slot;
+
+ return ((jint)(fld->accflags & ACC_MASK));
+}
+
+struct Hjava_lang_Object*
+java_lang_reflect_Field_getObject0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(struct Hjava_lang_Object**)getFieldAddress(this, obj));
+}
+
+jboolean
+java_lang_reflect_Field_getBoolean0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(jboolean*)getFieldAddress(this, obj));
+}
+
+jbyte
+java_lang_reflect_Field_getByte0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(jbyte*)getFieldAddress(this, obj));
+}
+
+jchar
+java_lang_reflect_Field_getChar0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(jchar*)getFieldAddress(this, obj));
+}
+
+
+jshort
+java_lang_reflect_Field_getShort0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(jshort*)getFieldAddress(this, obj));
+}
+
+jint
+java_lang_reflect_Field_getInt0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(jint*)getFieldAddress(this, obj));
+}
+
+jlong
+java_lang_reflect_Field_getLong0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(jlong*)getFieldAddress(this, obj));
+}
+
+jfloat
+java_lang_reflect_Field_getFloat0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(jfloat*)getFieldAddress(this, obj));
+}
+
+jdouble
+java_lang_reflect_Field_getDouble0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+{
+ return (*(jdouble*)getFieldAddress(this, obj));
+}
+
+
+void
+java_lang_reflect_Field_setBoolean0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jboolean val)
+{
+ *(jboolean*)getFieldAddress(this, obj) = val;
+}
+
+void
+java_lang_reflect_Field_setByte0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jbyte val)
+{
+ *(jbyte*)getFieldAddress(this, obj) = val;
+}
+
+void
+java_lang_reflect_Field_setChar0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jchar val)
+{
+ *(jchar*)getFieldAddress(this, obj) = val;
+}
+
+void
+java_lang_reflect_Field_setShort0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jshort val)
+{
+ *(jshort*)getFieldAddress(this, obj) = val;
+}
+
+void
+java_lang_reflect_Field_setInt0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jint val)
+{
+ *(jint*)getFieldAddress(this, obj) = val;
+}
+
+void
+java_lang_reflect_Field_setLong0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jlong val)
+{
+ *(jlong*)getFieldAddress(this, obj) = val;
+}
+
+void
+java_lang_reflect_Field_setFloat0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jfloat val)
+{
+ *(jfloat*)getFieldAddress(this, obj) = val;
+}
+
+void
+java_lang_reflect_Field_setDouble0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jdouble val)
+{
+ *(jdouble*)getFieldAddress(this, obj) = val;
+}
+
+void
+java_lang_reflect_Field_setObject0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, struct Hjava_lang_Object* val)
+{
+ *(jobject*)getFieldAddress(this, obj) = val;
+}
===================================================================
Checking out kaffe/libraries/clib/native/Method.c
RCS: /home/cvs/kaffe/kaffe/libraries/clib/native/Method.c,v
VERS: 1.41
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/native/Method.c Fri Apr 22 21:25:31 2005
@@ -0,0 +1,309 @@
+/*
+ * java.lang.reflect.Method.c
+ *
+ * Copyright (c) 1996, 1997, 2004
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#include "config.h"
+#include "config-std.h"
+#include "config-mem.h"
+#include "gtypes.h"
+#include "access.h"
+#include "constants.h"
+#include "object.h"
+#include "classMethod.h"
+#include "itypes.h"
+#include "support.h"
+#include "soft.h"
+#include "exception.h"
+#include "baseClasses.h"
+#include "java_lang_reflect_Method.h"
+#include <native.h>
+#include "jni.h"
+#include "defs.h"
+
+static jclass Zclass;
+static jclass Bclass;
+static jclass Sclass;
+static jclass Cclass;
+static jclass Iclass;
+static jclass Jclass;
+static jclass Fclass;
+static jclass Dclass;
+static jfieldID Zvalue;
+static jfieldID Bvalue;
+static jfieldID Svalue;
+static jfieldID Cvalue;
+static jfieldID Ivalue;
+static jfieldID Jvalue;
+static jfieldID Fvalue;
+static jfieldID Dvalue;
+static jmethodID Zmeth;
+static jmethodID Bmeth;
+static jmethodID Smeth;
+static jmethodID Cmeth;
+static jmethodID Imeth;
+static jmethodID Jmeth;
+static jmethodID Fmeth;
+static jmethodID Dmeth;
+
+JNIEXPORT void JNICALL
+Java_java_lang_reflect_Method_init0(JNIEnv* env)
+{
+ Zclass = (*env)->FindClass(env, "java.lang.Boolean");
+ Zvalue = (*env)->GetFieldID(env, Zclass, "value", "Z");
+ Zmeth = (*env)->GetMethodID(env, Zclass, "<init>", "(Z)V");
+
+ Bclass = (*env)->FindClass(env, "java.lang.Byte");
+ Bvalue = (*env)->GetFieldID(env, Bclass, "value", "B");
+ Bmeth = (*env)->GetMethodID(env, Bclass, "<init>", "(B)V");
+
+ Sclass = (*env)->FindClass(env, "java.lang.Short");
+ Svalue = (*env)->GetFieldID(env, Sclass, "value", "S");
+ Smeth = (*env)->GetMethodID(env, Sclass, "<init>", "(S)V");
+
+ Cclass = (*env)->FindClass(env, "java.lang.Character");
+ Cvalue = (*env)->GetFieldID(env, Cclass, "value", "C");
+ Cmeth = (*env)->GetMethodID(env, Cclass, "<init>", "(C)V");
+
+ Iclass = (*env)->FindClass(env, "java.lang.Integer");
+ Ivalue = (*env)->GetFieldID(env, Iclass, "value", "I");
+ Imeth = (*env)->GetMethodID(env, Iclass, "<init>", "(I)V");
+
+ Jclass = (*env)->FindClass(env, "java.lang.Long");
+ Jvalue = (*env)->GetFieldID(env, Jclass, "value", "J");
+ Jmeth = (*env)->GetMethodID(env, Jclass, "<init>", "(J)V");
+
+ Fclass = (*env)->FindClass(env, "java.lang.Float");
+ Fvalue = (*env)->GetFieldID(env, Fclass, "value", "F");
+ Fmeth = (*env)->GetMethodID(env, Fclass, "<init>", "(F)V");
+
+ Dclass = (*env)->FindClass(env, "java.lang.Double");
+ Dvalue = (*env)->GetFieldID(env, Dclass, "value", "D");
+ Dmeth = (*env)->GetMethodID(env, Dclass, "<init>", "(D)V");
+}
+
+jint
+java_lang_reflect_Method_getModifiers(struct Hjava_lang_reflect_Method* this)
+{
+ Hjava_lang_Class* clazz;
+ jint slot;
+ int flags;
+
+ clazz = unhand(this)->clazz;
+ slot = unhand(this)->slot;
+
+ assert(slot < CLASS_NMETHODS(clazz));
+
+ flags = clazz->methods[slot].accflags;
+ if (flags & ACC_ABSTRACT)
+ /* If an abstract method is ever referenced,
+ * it's native code is throwAbstractMethodError, and
+ * ACC_NATIVE is set in findLocalMethod.
+ */
+ return (flags & (ACC_MASK-ACC_NATIVE));
+ else
+ return (flags & ACC_MASK);
+}
+
+JNIEXPORT jobject JNICALL
+Java_java_lang_reflect_Method_invoke0(JNIEnv* env, jobject _this, jobject _obj, jobjectArray _argobj)
+{
+ Hjava_lang_Class* clazz;
+ jarray paramtypes;
+ jobject arg;
+ jclass argc;
+ Method* meth;
+ jmethodID methID;
+ jint slot;
+ jvalue args[255]; /* should this be allocated dynamically? */
+ jvalue ret;
+ int len;
+ int i;
+ char rettype;
+ errorInfo info;
+
+ /* Bit of a hack this */
+ Hjava_lang_Object* obj = (Hjava_lang_Object*)_obj;
+ Hjava_lang_reflect_Method* this = (Hjava_lang_reflect_Method*)_this;
+ HArrayOfObject* argobj = (HArrayOfObject*)_argobj;
+ jthrowable targetexc;
+
+ clazz = unhand(this)->clazz;
+ paramtypes = unhand(this)->parameterTypes;
+
+ /*
+ * A method invocation via reflection is a first active use, so
+ * initialize the class object. (XXX: check whether that's true.)
+ */
+ /* XXX use JNI here XXX */
+ if (clazz->state < CSTATE_USABLE || (_this == NULL)) {
+ if (processClass(clazz, CSTATE_COMPLETE, &info) == false) {
+ throwError(&info);
+ }
+ }
+
+ slot = unhand(this)->slot;
+
+ assert(slot < CLASS_NMETHODS(clazz));
+
+ /* Note: we assume here that `meth' is identical to the jmethodID which
+ * would be returned by JNIEnv::GetMethodID for this method.
+ */
+ meth = &CLASS_METHODS(clazz)[slot];
+ methID = (*env)->FromReflectedMethod(env, _this);
+
+ len = argobj ? obj_length(argobj) : 0;
+
+ rettype = *METHOD_RET_TYPE(meth);
+
+ for (i = len - 1; i >= 0; i--) {
+ arg = (*env)->GetObjectArrayElement(env, argobj, (unsigned int)i);
+ argc = (*env)->GetObjectArrayElement(env, paramtypes, (unsigned int)i);
+ if (!CLASS_IS_PRIMITIVE((Hjava_lang_Class*)argc)) {
+ args[i].l = arg;
+ }
+ else switch (CLASS_PRIM_SIG((Hjava_lang_Class*)argc)) {
+ case 'I':
+ args[i].i = (*env)->GetIntField(env, arg, Ivalue);
+ break;
+ case 'Z':
+ args[i].z = (*env)->GetBooleanField(env, arg, Zvalue);
+ break;
+ case 'S':
+ args[i].s = (*env)->GetShortField(env, arg, Svalue);
+ break;
+ case 'B':
+ args[i].b = (*env)->GetByteField(env, arg, Bvalue);
+ break;
+ case 'C':
+ args[i].c = (*env)->GetCharField(env, arg, Cvalue);
+ break;
+ case 'F':
+ args[i].f = (*env)->GetFloatField(env, arg, Fvalue);
+ break;
+ case 'D':
+ args[i].d = (*env)->GetDoubleField(env, arg, Dvalue);
+ break;
+ case 'J':
+ args[i].j = (*env)->GetLongField(env, arg, Jvalue);
+ break;
+ }
+ }
+
+ /* Select which method to really call, and call it */
+ if (METHOD_IS_STATIC(meth)) { /* static method */
+
+ switch (rettype) {
+
+ /* invoke proper method via JNI CallStatic<Type>MethodA */
+#define CallStaticTypeMethodA(type) \
+ (*env)->CallStatic##type##MethodA(env, clazz, methID, args)
+
+ case 'V': CallStaticTypeMethodA(Void); break;
+ case 'J': ret.j = CallStaticTypeMethodA(Long); break;
+ case 'F': ret.f = CallStaticTypeMethodA(Float); break;
+ case 'D': ret.d = CallStaticTypeMethodA(Double); break;
+ case 'I': ret.i = CallStaticTypeMethodA(Int); break;
+ case 'S': ret.s = CallStaticTypeMethodA(Short); break;
+ case 'B': ret.b = CallStaticTypeMethodA(Byte); break;
+ case 'Z': ret.z = CallStaticTypeMethodA(Boolean); break;
+ case 'C': ret.c = CallStaticTypeMethodA(Char); break;
+ case 'L':
+ case '[': ret.l = CallStaticTypeMethodA(Object); break;
+#undef CallStaticTypeMethodA
+ default:
+ ABORT();
+ }
+ }
+ else if (METHOD_IS_CONSTRUCTOR(meth)) { /* a constructor */
+ /*
+ * This if applies if we are called from Constructor.newInstance
+ */
+ ret.l = (*env)->NewObjectA(env, clazz, methID, args);
+ /* override return type parsed from signature */
+ rettype = 'L';
+ }
+ else { /* nonstatic method */
+ switch (rettype) {
+
+ /* Why Call<Type>MethodA and not CallNonvirtual<Type>MethodA?
+ *
+ * Because the spec says:
+ * If the underlying method is an instance method, it is
+ * invoked using dynamic method lookup as documented in The
+ * Java Language Specification, section 15.11.4.4; in
+ * particular, overriding based on the runtime type of the
+ * target object will occur.
+ */
+#define CallTypeMethodA(type) \
+ (*env)->Call##type##MethodA(env, obj, methID, args)
+
+ case 'V': CallTypeMethodA(Void); break;
+ case 'J': ret.j = CallTypeMethodA(Long); break;
+ case 'F': ret.f = CallTypeMethodA(Float); break;
+ case 'D': ret.d = CallTypeMethodA(Double); break;
+ case 'I': ret.i = CallTypeMethodA(Int); break;
+ case 'S': ret.s = CallTypeMethodA(Short); break;
+ case 'B': ret.b = CallTypeMethodA(Byte); break;
+ case 'Z': ret.z = CallTypeMethodA(Boolean); break;
+ case 'C': ret.c = CallTypeMethodA(Char); break;
+ case 'L':
+ case '[': ret.l = CallTypeMethodA(Object); break;
+#undef CallTypeMethodA
+ default:
+ ABORT();
+ }
+ }
+
+ /* If the method completes abruptly by throwing an exception, the
+ * exception is placed in an InvocationTargetException and thrown
+ * in turn to the caller of invoke.
+ */
+ targetexc = (*env)->ExceptionOccurred(env);
+ if (targetexc != 0) {
+ struct Hjava_lang_Throwable* e;
+
+ (*env)->ExceptionClear(env);
+ e = (struct Hjava_lang_Throwable *)execute_java_constructor(
+ "java.lang.reflect.InvocationTargetException", NULL, NULL,
+ "(Ljava/lang/Throwable;)V", targetexc);
+ throwException(e);
+ assert(!"Not here");
+ }
+ else switch (rettype) {
+ case 'I':
+ return ((*env)->NewObject(env, Iclass, Imeth, ret.i));
+ break;
+ case 'Z':
+ return ((*env)->NewObject(env, Zclass, Zmeth, ret.z));
+ break;
+ case 'S':
+ return ((*env)->NewObject(env, Sclass, Smeth, ret.s));
+ break;
+ case 'B':
+ return ((*env)->NewObject(env, Bclass, Bmeth, ret.b));
+ break;
+ case 'C':
+ return ((*env)->NewObject(env, Cclass, Cmeth, ret.c));
+ break;
+ case 'F':
+ return ((*env)->NewObject(env, Fclass, Fmeth, ret.f));
+ break;
+ case 'D':
+ return ((*env)->NewObject(env, Dclass, Dmeth, ret.d));
+ break;
+ case 'J':
+ return ((*env)->NewObject(env, Jclass, Jmeth, ret.j));
+ break;
+ case 'L':
+ case '[':
+ return (ret.l);
+ }
+
+ return (NULL);
+}
More information about the kaffe
mailing list