[kaffe] CVS kaffe (guilhem): Added some Java 1.5 support in kaffe.

Kaffe CVS cvs-commits at kaffe.org
Thu Mar 30 09:52:29 PST 2006


PatchSet 7202 
Date: 2006/03/30 17:39:12
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Added some Java 1.5 support in kaffe.

        * kaffe/kaffeh/main.c

        * kaffe/kaffevm/access.h: Moved kaffe flags on class members into
        its own namespace. Added Java 1.5 accessibility flags.

        * kaffe/kaffevm/baseClasses.c
        (initialiseKaffe): Added support for Signature and Synthetic
        keywords.

        * kaffe/kaffevm/classMethod.c
        (addInnerClasses): Copy accessibility flags.
        (addMethod): put kaffe flags into its own variable.

        * kaffe/kaffevm/classMethod.h
        (Hjava_lang_Class): Added fields to support kaffe flags and
        extended Java 1.5 signature.
        Kaffe Flags are in their own variable now.

        * kaffe/kaffevm/code-analyse.c: Likewise.

        * kaffe/kaffevm/code-analyse.h
        (CONSTANTTYPE): Added support for CONSTANT_Class and
        CONSTANT_ResolvedClass.
        (SET_NEWFRAME): Updated kaffe flags.

        * kaffe/kaffevm/external.c: Updated kaffe flags.

        * kaffe/kaffevm/gtypes.h: Introduced a new type for kaffe flags.

        * kaffe/kaffevm/kaffe.def
        (LDC): Class can be loaded directly now as of Java 1.5.
        (PUTFIELD, PUTSTATIC): Updated checking of accessibility to Java
        1.5 standard.

        * kaffe/kaffevm/readClass.c
        (readSignatureAttribute): New function.
        (readAttributes): Added support for Synthetic and Signature.

        * kaffe/kaffevm/readClass.h: Added support for Java 1.5 classes.

        * kaffe/kaffevm/gcj/gcj-glue.c,
        kaffe/kaffevm/intrp/machine.c,
        kaffe/kaffevm/jit/native-wrapper.c,
        kaffe/kaffevm/jni/jni.c,
        kaffe/kaffevm/intrp/methodcalls.c,
        libraries/clib/native/Class.c: Updated kaffe flags.

        * kaffe/kaffevm/intrp/machine.h,
        kaffe/kaffevm/jit3/machine.h,
        kaffe/kaffevm/jit/machine.h
        (current_method): New icode.

        * test/internal/jit_stub.c: Updated to new internal API.

Members: 
	ChangeLog:1.4709->1.4710 
	kaffe/kaffeh/main.c:1.22->1.23 
	kaffe/kaffevm/access.h:INITIAL->1.12 
	kaffe/kaffevm/baseClasses.c:1.72->1.73 
	kaffe/kaffevm/classMethod.c:1.152->1.153 
	kaffe/kaffevm/classMethod.h:1.86->1.87 
	kaffe/kaffevm/code-analyse.c:1.47->1.48 
	kaffe/kaffevm/code-analyse.h:1.21->1.22 
	kaffe/kaffevm/external.c:1.84->1.85 
	kaffe/kaffevm/gtypes.h:1.19->1.20 
	kaffe/kaffevm/kaffe.def:1.43->1.44 
	kaffe/kaffevm/readClass.c:1.25->1.26 
	kaffe/kaffevm/readClass.h:1.7->1.8 
	kaffe/kaffevm/gcj/gcj-glue.c:1.9->1.10 
	kaffe/kaffevm/intrp/machine.c:1.55->1.56 
	kaffe/kaffevm/intrp/machine.h:1.12->1.13 
	kaffe/kaffevm/intrp/methodcalls.c:1.12->1.13 
	kaffe/kaffevm/jit/machine.h:1.25->1.26 
	kaffe/kaffevm/jit/native-wrapper.c:1.13->1.14 
	kaffe/kaffevm/jit3/machine.h:1.28->1.29 
	kaffe/kaffevm/jni/jni.c:1.41->1.42 
	libraries/clib/native/Class.c:1.89->1.90 
	test/internal/jit_stub.c:1.11->1.12 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4709 kaffe/ChangeLog:1.4710
--- kaffe/ChangeLog:1.4709	Wed Mar 29 18:51:36 2006
+++ kaffe/ChangeLog	Thu Mar 30 17:39:12 2006
@@ -1,3 +1,59 @@
+2006-03-28  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* kaffe/kaffeh/main.c
+
+	* kaffe/kaffevm/access.h: Moved kaffe flags on class members into
+	its own namespace. Added Java 1.5 accessibility flags.
+
+	* kaffe/kaffevm/baseClasses.c
+	(initialiseKaffe): Added support for Signature and Synthetic
+	keywords.
+
+	* kaffe/kaffevm/classMethod.c
+	(addInnerClasses): Copy accessibility flags.
+	(addMethod): put kaffe flags into its own variable. 
+
+	* kaffe/kaffevm/classMethod.h
+	(Hjava_lang_Class): Added fields to support kaffe flags and
+	extended Java 1.5 signature.
+	Kaffe Flags are in their own variable now.
+
+	* kaffe/kaffevm/code-analyse.c: Likewise.
+
+	* kaffe/kaffevm/code-analyse.h
+	(CONSTANTTYPE): Added support for CONSTANT_Class and
+	CONSTANT_ResolvedClass.
+	(SET_NEWFRAME): Updated kaffe flags.
+
+	* kaffe/kaffevm/external.c: Updated kaffe flags.
+
+	* kaffe/kaffevm/gtypes.h: Introduced a new type for kaffe flags.
+
+	* kaffe/kaffevm/kaffe.def
+	(LDC): Class can be loaded directly now as of Java 1.5.
+	(PUTFIELD, PUTSTATIC): Updated checking of accessibility to Java
+	1.5 standard.
+	
+	* kaffe/kaffevm/readClass.c
+	(readSignatureAttribute): New function.
+	(readAttributes): Added support for Synthetic and Signature.
+
+	* kaffe/kaffevm/readClass.h: Added support for Java 1.5 classes.
+
+	* kaffe/kaffevm/gcj/gcj-glue.c,
+	kaffe/kaffevm/intrp/machine.c,
+	kaffe/kaffevm/jit/native-wrapper.c,
+	kaffe/kaffevm/jni/jni.c,
+	kaffe/kaffevm/intrp/methodcalls.c,
+	libraries/clib/native/Class.c: Updated kaffe flags.
+	
+	* kaffe/kaffevm/intrp/machine.h,
+	kaffe/kaffevm/jit3/machine.h,
+	kaffe/kaffevm/jit/machine.h
+	(current_method): New icode.
+
+	* test/internal/jit_stub.c: Updated to new internal API.
+	
 2006-03-29  Dalibor Topic  <robilad at kaffe.org>
 
 	Fix for #31.
Index: kaffe/kaffe/kaffeh/main.c
diff -u kaffe/kaffe/kaffeh/main.c:1.22 kaffe/kaffe/kaffeh/main.c:1.23
--- kaffe/kaffe/kaffeh/main.c:1.22	Tue Mar 28 23:38:14 2006
+++ kaffe/kaffe/kaffeh/main.c	Thu Mar 30 17:39:15 2006
@@ -54,6 +54,8 @@
 Utf8Const* Exceptions_name;
 Utf8Const* SourceFile_name;
 Utf8Const* InnerClasses_name;
+Utf8Const* Signature_name;
+Utf8Const* Synthetic_name;
 
 FILE* include;
 FILE* jni_include;
@@ -110,6 +112,8 @@
 	Exceptions_name = utf8ConstNew("Exceptions", -1);
 	SourceFile_name = utf8ConstNew("SourceFile", -1);
 	InnerClasses_name = utf8ConstNew("InnerClasses", -1);
+	Synthetic_name = utf8ConstNew("Synthetic", -1);
+	Signature_name = utf8ConstNew("Signature", -1);
 
 	/* Process each class */
 	for (nm = argv[farg]; nm != 0; nm = argv[++farg]) {
===================================================================
Checking out kaffe/kaffe/kaffevm/access.h
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/access.h,v
VERS: 1.12
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/access.h	Thu Mar 30 17:52:27 2006
@@ -0,0 +1,124 @@
+/*
+ * access.h
+ * Access flags.
+ *
+ * Copyright (c) 1996, 1997
+ *	Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * Copyright (c) 2004
+ *	Kaffe.org contributors, see ChangeLogs for details.  All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#ifndef __access_h
+#define __access_h
+
+#include "gtypes.h"
+
+#define	ACC_PUBLIC		0x0001
+#define	ACC_PRIVATE		0x0002
+#define	ACC_PROTECTED		0x0004
+#define	ACC_STATIC		0x0008
+#define	ACC_FINAL		0x0010
+#define	ACC_SYNCHRONISED	0x0020
+#define	ACC_VOLATILE		0x0040
+#define ACC_BRIDGE              0x0040
+#define	ACC_TRANSIENT		0x0080
+#define ACC_VARARGS		0x0080
+#define	ACC_NATIVE		0x0100
+#define	ACC_INTERFACE		0x0200
+#define	ACC_ABSTRACT		0x0400
+#define	ACC_STRICT		0x0800
+#define ACC_SYNTHETIC		0x1000
+#define ACC_ANNOTATION		0x2000
+#define ACC_ENUM		0x4000
+
+#define	ACC_MASK		0x0FFF
+
+/* Warning: strictfp aka ACC_STRICT is also 0x0800 and used for
+   classes and methods */
+#define	KFLAG_CONSTRUCTOR	0x01
+
+/* only for class */
+#define	KFLAG_GCJ		0x02
+/* only for method: method was jitted */
+#define	KFLAG_JITTED		0x02
+#define KFLAG_JNI               0x04
+/* either jitted or native method was found */
+#define	KFLAG_TRANSLATED	0x08
+#define	KFLAG_VERIFIED		0x10
+
+typedef enum {
+	ACC_TYPE_CLASS,
+	ACC_TYPE_INNER_CLASS,
+	ACC_TYPE_METHOD,
+	ACC_TYPE_INTERFACE_METHOD,
+	ACC_TYPE_FIELD,
+	ACC_TYPE_INTERFACE_FIELD
+} access_type_t;
+
+struct Hjava_lang_Class;
+
+/*
+ * Check the validity of the given flags.
+ *
+ * @param type Type of access.
+ * @param access_flags The flag set to check.
+ * @return NULL if the flags are valid, otherwise it returns a description
+ * of the problem.
+ */
+const char *checkAccessFlags(access_type_t type, accessFlags access_flags);
+
+/*
+ * Check the accessibility of a slot from a specific context.
+ *
+ * context - The class that wishes to access another class' method/field.
+ * target - The class being accessed.
+ * target_flags - The access flags for the method/field being accessed in
+ *   target.
+ * returns - True if the slot is accessible.
+ */
+int checkAccess(struct Hjava_lang_Class *context,
+		struct Hjava_lang_Class *target,
+		accessFlags target_flags);
+/*
+ * Separate method for checking virtual method accessibility.  This is used to
+ * check the accessibility when inheritance matters.  For example:
+ *
+ * package one;
+ *
+ * class A
+ * {
+ *   public void foo(B b) { b.foo(); }
+ * }
+ *
+ * abstract class B
+ * {
+ *   protected abstract void foo();
+ * }
+ *
+ * package two;
+ *
+ * class C
+ *   extends C
+ * {
+ *   protected void foo() { }
+ * }
+ *
+ * context - The class that wishes to access another class' method.
+ * target - The original object class.  This must be specified since public
+ *   methods contained within package private classes become public when
+ *   inherited by public classes.
+ * meth - The method to check for accessibility.
+ * returns - True if the method is accessible.
+ */
+int checkMethodAccess(struct Hjava_lang_Class *context,
+		      struct Hjava_lang_Class *target,
+		      Method *meth);
+int checkFieldAccess(struct Hjava_lang_Class *context,
+		     struct Hjava_lang_Class *target,
+		     Field *field);
+
+#endif
Index: kaffe/kaffe/kaffevm/baseClasses.c
diff -u kaffe/kaffe/kaffevm/baseClasses.c:1.72 kaffe/kaffe/kaffevm/baseClasses.c:1.73
--- kaffe/kaffe/kaffevm/baseClasses.c:1.72	Sat Dec 24 01:41:50 2005
+++ kaffe/kaffe/kaffevm/baseClasses.c	Thu Mar 30 17:39:16 2006
@@ -59,6 +59,8 @@
 Utf8Const* Exceptions_name;
 Utf8Const* SourceFile_name;
 Utf8Const* InnerClasses_name;
+Utf8Const* Signature_name;
+Utf8Const* Synthetic_name;
 
 static struct _dispatchTable *ClassClass_vtable;
 static Hjava_lang_Class*	ClassClass;
@@ -255,11 +257,14 @@
 	Exceptions_name = utf8ConstNew("Exceptions", -1);
 	SourceFile_name = utf8ConstNew("SourceFile", -1);
 	InnerClasses_name = utf8ConstNew("InnerClasses", -1);
+	Signature_name = utf8ConstNew("Signature", -1);
+	Synthetic_name = utf8ConstNew("Synthetic", -1);
 
 	if (!(init_name && final_name && void_signature &&
 	      constructor_name && Code_name && LineNumberTable_name &&
 	      LocalVariableTable_name && ConstantValue_name &&
-	      Exceptions_name && SourceFile_name && InnerClasses_name)) {
+	      Exceptions_name && SourceFile_name && InnerClasses_name && 
+	      Signature_name && Synthetic_name)) {
 		DBG(INIT, dprintf("not enough memory to run kaffe\n"); );
 		KAFFEVM_ABORT();
 	}
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.152 kaffe/kaffe/kaffevm/classMethod.c:1.153
--- kaffe/kaffe/kaffevm/classMethod.c:1.152	Sun Mar 19 16:16:21 2006
+++ kaffe/kaffe/kaffevm/classMethod.c	Thu Mar 30 17:39:16 2006
@@ -1072,6 +1072,11 @@
 	return (success);
 }
 
+
+/*
+ * Add a Java 1.5 signature to the class descriptor.
+ */
+
 /*
  * Read in InnerClasses declares for a class
  */
@@ -1112,6 +1117,7 @@
 		readu2(&ic->inner_class_accflags, fp);
 
 		if (c->this_index && ic->inner_class == c->this_index) {
+//		    c->accflags = (ic->inner_class_accflags & ACC_MASK);
 		    c->this_inner_index = i;
 		}
 	}
@@ -1200,8 +1206,7 @@
 		return NULL;
 	}
 	mt->class = c;
-	/* Warning: ACC_CONSTRUCTION match ACC_STRICT */
-	mt->accflags = access_flags & ACC_MASK;
+	mt->accflags = access_flags;
 	mt->c.bcode.code = NULL;
 	mt->stacksz = 0;
 	mt->localsz = 0;
@@ -1210,7 +1215,7 @@
 
 	/* Mark constructors as such */
 	if (utf8ConstEqual (name, constructor_name)) {
-		mt->accflags |= ACC_CONSTRUCTOR;
+		mt->kFlags |= KFLAG_CONSTRUCTOR;
 	}
 
 	CLASS_NMETHODS(c)++;
Index: kaffe/kaffe/kaffevm/classMethod.h
diff -u kaffe/kaffe/kaffevm/classMethod.h:1.86 kaffe/kaffe/kaffevm/classMethod.h:1.87
--- kaffe/kaffe/kaffevm/classMethod.h:1.86	Fri Sep  9 14:41:45 2005
+++ kaffe/kaffe/kaffevm/classMethod.h	Thu Mar 30 17:39:16 2006
@@ -99,9 +99,11 @@
 	struct _classEntry*	centry;
 
 	Utf8Const*		name;
+        Utf8Const*              extSignature;
 	unsigned int		packageLength;
 	char*			sourcefile;	/* source file name if known */
 	accessFlags		accflags;
+        kaffeClassFlags         kFlags;
 
 	/* If non-NULL, a pointer to the superclass.
 	 * However, if state < CSTATE_DOING_PREPARE, then
@@ -197,8 +199,8 @@
 #define signalOnClass(C) signalCond(((C)))
 #define broadcastOnClass(C) broadcastCond(((C)))
 
-#define METHOD_TRANSLATED(M)		((M)->accflags & ACC_TRANSLATED)
-#define METHOD_JITTED(M)		((M)->accflags & ACC_JITTED)
+#define METHOD_TRANSLATED(M)		((M)->kFlags & KFLAG_TRANSLATED)
+#define METHOD_JITTED(M)		((M)->kFlags & KFLAG_JITTED)
 
 #define	METHOD_NATIVECODE(M)		(((M)->idx == -1) ? \
 		((M)->ncode) : \
@@ -235,9 +237,9 @@
 	} \
 } while (0)
 #define	SET_METHOD_NATIVECODE(M, C)	_SET_METHOD_NATIVECODE(M, C); \
-					(M)->accflags |= ACC_TRANSLATED
+					(M)->kFlags |= KFLAG_TRANSLATED
 #define	SET_METHOD_JITCODE(M, C)	_SET_METHOD_NATIVECODE(M, C); \
-					(M)->accflags |= ACC_TRANSLATED|ACC_JITTED
+					(M)->kFlags |= KFLAG_TRANSLATED|KFLAG_JITTED;
 
 /*
  * Stats for the nameMapping object.
@@ -306,7 +308,9 @@
 typedef struct _jmethodID {
 	Utf8Const*		name;
 	parsed_signature_t*	parsed_sig;
+        Utf8Const*              extSignature;
 	accessFlags		accflags;
+        kaffeClassFlags         kFlags;
 	long			idx;	/* Index into class->vtable */
 	u2			stacksz;
 	u2			localsz;
@@ -376,6 +380,7 @@
 	Hjava_lang_Class*	clazz;
 	Utf8Const*		name;
 	Utf8Const*		signature;
+        Utf8Const*              extSignature;
 	Hjava_lang_Class*	type;
 	accessFlags		accflags;
 	u2			bsize;		/* in bytes */
@@ -475,7 +480,7 @@
 #define METHOD_IS_PROTECTED(METH)    ((METH)->accflags & ACC_PROTECTED)
 #define METHOD_IS_PRIVATE(METH)      ((METH)->accflags & ACC_PRIVATE)
 
-#define METHOD_IS_CONSTRUCTOR(METH)  ((METH)->accflags & ACC_CONSTRUCTOR)
+#define METHOD_IS_CONSTRUCTOR(METH)  ((METH)->kFlags & KFLAG_CONSTRUCTOR)
 #define METHOD_IS_STATIC(METH)       ((METH)->accflags & ACC_STATIC)
 
 #define METHOD_IS_ABSTRACT(METH)     ((METH)->accflags & ACC_ABSTRACT)
@@ -486,8 +491,8 @@
 #define METHOD_IS_SYNCHRONISED(METH) ((METH)->accflags & ACC_SYNCHRONISED)
 
 
-#define CLASS_GCJ(C)		((C)->accflags & ACC_GCJ)
-#define SET_CLASS_GCJ(C)	(C)->accflags |= ACC_GCJ
+#define CLASS_GCJ(C)		((C)->kFlags & KFLAG_GCJ)
+#define SET_CLASS_GCJ(C)	(C)->kFlags |= KFLAG_GCJ
 
 /* For manipulating the constant pool in a class */
 #define CLASS_CONSTANTS(CL) (&(CL)->constants)
@@ -691,6 +696,8 @@
 extern Utf8Const* Exceptions_name;	/* "Exceptions" */
 extern Utf8Const* SourceFile_name;	/* "SourceFile" */
 extern Utf8Const* InnerClasses_name;	/* "InnerClasses" */
+extern Utf8Const* Signature_name;       /* "Signature" */
+extern Utf8Const* Synthetic_name;       /* "Synthetic" */
 
 void initialiseSecurity (void);
 
Index: kaffe/kaffe/kaffevm/code-analyse.c
diff -u kaffe/kaffe/kaffevm/code-analyse.c:1.47 kaffe/kaffe/kaffevm/code-analyse.c:1.48
--- kaffe/kaffe/kaffevm/code-analyse.c:1.47	Sat Jan 14 09:11:35 2006
+++ kaffe/kaffe/kaffevm/code-analyse.c	Thu Mar 30 17:39:16 2006
@@ -89,7 +89,7 @@
 	codeInfo->localuse = localuse;
 
 	/* We don't need to do this twice */
-	meth->accflags |= ACC_VERIFIED;
+	meth->kFlags |= KFLAG_VERIFIED;
 
 	for (lcl = 0; lcl < meth->localsz; lcl++) {
 		localuse = codeInfo->localuse;
Index: kaffe/kaffe/kaffevm/code-analyse.h
diff -u kaffe/kaffe/kaffevm/code-analyse.h:1.21 kaffe/kaffe/kaffevm/code-analyse.h:1.22
--- kaffe/kaffe/kaffevm/code-analyse.h:1.21	Wed Aug 10 21:17:48 2005
+++ kaffe/kaffe/kaffevm/code-analyse.h	Thu Mar 30 17:39:16 2006
@@ -73,6 +73,10 @@
 	case CONSTANT_ResolvedString:				\
 		VAL = TOBJ;					\
 		break;						\
+        case CONSTANT_Class:                                    \
+	case CONSTANT_ResolvedClass:                            \
+                VAL = TOBJ;                                     \
+                break;                                          \
 	default:						\
 		VAL = TUNSTABLE;				\
 		break;						\
@@ -162,7 +166,7 @@
 	if (FRAME(pc) == 0) {					\
 		FRAME(pc) = ALLOCFRAME();			\
 		if (!FRAME(pc)) {				\
-			meth->accflags &= ~ACC_VERIFIED;	\
+			meth->kFlags &= ~KFLAG_VERIFIED;	\
 			tidyAnalyzeMethod(&codeInfo);		\
 			postOutOfMemory(einfo);			\
 			return false;				\
Index: kaffe/kaffe/kaffevm/external.c
diff -u kaffe/kaffe/kaffevm/external.c:1.84 kaffe/kaffe/kaffevm/external.c:1.85
--- kaffe/kaffe/kaffevm/external.c:1.84	Mon Oct  3 19:36:00 2005
+++ kaffe/kaffe/kaffevm/external.c	Thu Mar 30 17:39:16 2006
@@ -440,7 +440,7 @@
 	}
 
 	if (func != NULL) {
-		meth->accflags |= ACC_JNI;
+		meth->kFlags |= KFLAG_JNI;
 	}
 
 	return (func);
Index: kaffe/kaffe/kaffevm/gtypes.h
diff -u kaffe/kaffe/kaffevm/gtypes.h:1.19 kaffe/kaffe/kaffevm/gtypes.h:1.20
--- kaffe/kaffe/kaffevm/gtypes.h:1.19	Wed Aug 10 21:17:49 2005
+++ kaffe/kaffe/kaffevm/gtypes.h	Thu Mar 30 17:39:16 2006
@@ -55,6 +55,7 @@
 
 typedef	u1		nativecode;
 typedef u2		accessFlags;
+typedef u1              kaffeClassFlags;
 typedef u2		constIndex;
 
 typedef struct _jfieldID Field;
Index: kaffe/kaffe/kaffevm/kaffe.def
diff -u kaffe/kaffe/kaffevm/kaffe.def:1.43 kaffe/kaffe/kaffevm/kaffe.def:1.44
--- kaffe/kaffe/kaffevm/kaffe.def:1.43	Sun Mar  5 14:35:26 2006
+++ kaffe/kaffe/kaffevm/kaffe.def	Thu Mar 30 17:39:16 2006
@@ -148,6 +148,21 @@
 	case CONSTANT_ResolvedString:
 		move_string_const(stack(0), (void*)CLASS_CONST_DATA(current_class(),idx));
 		break;
+	case CONSTANT_Class:
+	        {
+		        errorInfo ei;
+			void *s;
+	    
+			s = getClass(idx, current_class(), &ei);
+			if (s == 0) {
+			  compile_time_error(ei);	      
+			}
+			move_string_const(stack(0), s);
+		}
+		break;
+	case CONSTANT_ResolvedClass:
+	        move_ref_const(stack(0), (void*)CLASS_CONST_DATA(current_class(), idx));
+		break;
 	case CONSTANT_Float:
 		move_float_const(stack(0), *(float*)&CLASS_CONST_DATA(current_class(),idx));
 		break;
@@ -188,6 +203,21 @@
 	case CONSTANT_ResolvedString:
 		move_string_const(stack(0), (void*)CLASS_CONST_DATA(current_class(),idx));
 		break;
+	case CONSTANT_Class:
+	        {
+		        errorInfo ei;
+			void *s;
+	    
+			s = getClass(idx, current_class(), &ei);
+			if (s == 0) {
+			  compile_time_error(ei);	      
+			}
+			move_string_const(stack(0), s);
+		}
+		break;
+	case CONSTANT_ResolvedClass:
+	        move_ref_const(stack(0), (void*)CLASS_CONST_DATA(current_class(), idx));
+		break;
 	case CONSTANT_Float:
 		move_float_const(stack(0), *(jfloat*)&CLASS_CONST_DATA(current_class(),idx));
 		break;
@@ -2523,7 +2553,8 @@
 		}
 	}
 	else if (((field_field()->accflags & ACC_FINAL) &&
-		  ((field_class() != current_class()))) ||
+		  (field_class() != current_class() ||
+		  !utf8ConstEqual(METHOD_NAME(current_method()), init_name))) ||
 		 !checkFieldAccess(current_class(),
 				   field_class(),
 				   field_field())) {
@@ -2705,7 +2736,8 @@
 		}
 	}
 	else if (((field_field()->accflags & ACC_FINAL) &&
-		  ((field_class() != current_class()))) ||
+		  (field_class() != current_class() )) ||
+//		   !utf8ConstEqual(METHOD_NAME(current_method()), constructor_name) )) ||
 		 !checkFieldAccess(current_class(),
 				   field_class(),
 				   field_field())) {
@@ -2977,7 +3009,7 @@
 		pop(method_nargs() + 1);
 		METHOD_RETURN_VALUE();
 	}
-	else if ((method_method()->accflags & ACC_CONSTRUCTOR) &&
+	else if ((method_method()->kFlags & KFLAG_CONSTRUCTOR) &&
 		 (method_method()->class != method_class())) {
 		/* XXX I think this test is wrong. */
 		softcall_nosuchmethod(method_class(), method_name(), method_sig());
Index: kaffe/kaffe/kaffevm/readClass.c
diff -u kaffe/kaffe/kaffevm/readClass.c:1.25 kaffe/kaffe/kaffevm/readClass.c:1.26
--- kaffe/kaffe/kaffevm/readClass.c:1.25	Fri May  6 15:24:28 2005
+++ kaffe/kaffe/kaffevm/readClass.c	Thu Mar 30 17:39:16 2006
@@ -196,6 +196,24 @@
 	return (true);
 }
 
+static bool
+readSignatureAttribute(Hjava_lang_Class* this, u2 idx, Utf8Const **signature, errorInfo *einfo)
+{
+  constants* pool;
+  
+  pool = CLASS_CONSTANTS (this);
+  
+  if (pool->tags[idx] != CONSTANT_Utf8) {
+    postExceptionMessage(einfo, JAVA_LANG(ClassFormatError),
+			 "invalid signature index: %d",
+			 idx);
+    return false;
+  }
+  
+  *signature = WORD2UTF (pool->data[idx]);
+  return true;
+}
+
 /*
  * Read in attributes.
  */
@@ -285,6 +303,41 @@
 					return false;
 				}
 			}
+#if !defined(KAFFEH)
+			else if (utf8ConstEqual(name, Synthetic_name)) {
+			  switch (thingType)
+			    {
+			    case READATTR_CLASS:
+			      ((Hjava_lang_Class *)thing)->accflags |= ACC_SYNTHETIC;
+			      break;
+			    case READATTR_METHOD:
+			      ((Method *)thing)->accflags |= ACC_SYNTHETIC;
+			      break;
+			    case READATTR_FIELD:
+			      ((Field *)thing)->accflags |= ACC_SYNTHETIC;
+			      break;
+			    }
+			}
+			else if (utf8ConstEqual(name, Signature_name)) {
+			  Utf8Const *signature;
+			  readu2(&idx, fp);
+			  if (!readSignatureAttribute(this, idx, &signature, einfo))
+			    return false;
+			  
+			  switch (thingType)
+			    {
+			    case READATTR_CLASS:
+			      ((Hjava_lang_Class *)thing)->extSignature = signature;
+			      break;
+			    case READATTR_METHOD:
+			      ((Method *)thing)->extSignature = signature;
+			      break;
+			    case READATTR_FIELD:
+			      ((Field *)thing)->extSignature = signature;
+			      break;
+			    }
+			}
+#endif
 			else {
 				DBG(READCLASS,
 				    dprintf("%s: don't know how to parse %s on %s\n",
Index: kaffe/kaffe/kaffevm/readClass.h
diff -u kaffe/kaffe/kaffevm/readClass.h:1.7 kaffe/kaffe/kaffevm/readClass.h:1.8
--- kaffe/kaffe/kaffevm/readClass.h:1.7	Sun May 11 18:42:42 2003
+++ kaffe/kaffe/kaffevm/readClass.h	Thu Mar 30 17:39:16 2006
@@ -5,6 +5,10 @@
  * Copyright (c) 1996, 1997
  *	Transvirtual Technologies, Inc.  All rights reserved.
  *
+ * Copyright(c) 2005
+ * 	The Kaffe.org's developers. All Rights reserved.
+ * 	See ChangeLog for details.
+ *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
  */
@@ -25,6 +29,8 @@
 #define	MINOR_VERSION_V1_3	0
 #define	MAJOR_VERSION_V1_4	48
 #define	MINOR_VERSION_V1_4	0
+#define MAJOR_VERSION_V1_5	49
+#define MINOR_VERSION_V1_5	0
 
 typedef enum ReadAttrType {
 	READATTR_METHOD = 11,
Index: kaffe/kaffe/kaffevm/gcj/gcj-glue.c
diff -u kaffe/kaffe/kaffevm/gcj/gcj-glue.c:1.9 kaffe/kaffe/kaffevm/gcj/gcj-glue.c:1.10
--- kaffe/kaffe/kaffevm/gcj/gcj-glue.c:1.9	Fri Apr 12 21:13:59 2002
+++ kaffe/kaffe/kaffevm/gcj/gcj-glue.c	Thu Mar 30 17:39:16 2006
@@ -290,20 +290,20 @@
 
         /* Mark constructors as such */
         if (utf8ConstEqual (mt->name, constructor_name)) {
-                mt->accflags |= ACC_CONSTRUCTOR;
+                mt->kFlags |= KFLAG_CONSTRUCTOR;
         }
 
 	/* Assumption 1: gcj always sets the 0x4000 ACC_TRANSLATED flag, 
 	 * even in abstract methods.
 	 */
-	assert(mt->accflags & ACC_TRANSLATED);
+	assert(mt->accflags & KFLAG_TRANSLATED);
 
 	/*
 	 * We clear ACC_TRANSLATED flags for methods with no code, such as
 	 * abstract methods.
 	 */
 	if (info->ncode == 0 || (info->accflags & ACC_NATIVE)) {
-		mt->accflags &= ~ACC_TRANSLATED;
+		mt->kFlags &= ~KFLAG_TRANSLATED;
 	}
 
         CLASS_NMETHODS(c)++;
Index: kaffe/kaffe/kaffevm/intrp/machine.c
diff -u kaffe/kaffe/kaffevm/intrp/machine.c:1.55 kaffe/kaffe/kaffevm/intrp/machine.c:1.56
--- kaffe/kaffe/kaffevm/intrp/machine.c:1.55	Sat Mar  4 17:51:04 2006
+++ kaffe/kaffe/kaffevm/intrp/machine.c	Thu Mar 30 17:39:17 2006
@@ -138,6 +138,7 @@
 	Hjava_lang_Object* volatile mobj;
 	VmExceptHandler mjbuf;
 	accessFlags methaccflags;
+	kaffeClassFlags methkflags;
 
 	slots* volatile lcl;
 	slots* volatile sp;
@@ -174,6 +175,7 @@
 
 	/* If this is native, then call the real function */
 	methaccflags = meth->accflags;
+	methkflags = meth->kFlags;
 
 #if defined(ENABLE_JVMPI)
 	if (methaccflags & ACC_STATIC)
@@ -199,7 +201,7 @@
 	}
 
 	/* Analyze method if required */
-	if ((methaccflags & ACC_VERIFIED) == 0) {
+	if ((methkflags & KFLAG_VERIFIED) == 0) {
 		codeinfo* codeInfo;
 		bool success = analyzeMethod(meth, &codeInfo, &einfo);
 		tidyAnalyzeMethod(&codeInfo);
Index: kaffe/kaffe/kaffevm/intrp/machine.h
diff -u kaffe/kaffe/kaffevm/intrp/machine.h:1.12 kaffe/kaffe/kaffevm/intrp/machine.h:1.13
--- kaffe/kaffe/kaffevm/intrp/machine.h:1.12	Wed Aug 10 21:17:52 2005
+++ kaffe/kaffe/kaffevm/intrp/machine.h	Thu Mar 30 17:39:17 2006
@@ -44,6 +44,7 @@
   if (getMethodSignatureClass(idx, meth->class, true, 2, &cinfo, &einfo) \
         == false) { throwError(&einfo); }
 
+#define current_method()        (meth)
 #define	method_name()		(cinfo.name)
 #define	method_sig()		(cinfo.signature)
 #define method_idx()		(cinfo.method->idx)
Index: kaffe/kaffe/kaffevm/intrp/methodcalls.c
diff -u kaffe/kaffe/kaffevm/intrp/methodcalls.c:1.12 kaffe/kaffe/kaffevm/intrp/methodcalls.c:1.13
--- kaffe/kaffe/kaffevm/intrp/methodcalls.c:1.12	Wed Mar 29 18:51:37 2006
+++ kaffe/kaffe/kaffevm/intrp/methodcalls.c	Thu Mar 30 17:39:17 2006
@@ -130,12 +130,12 @@
 				throwError(&einfo);
 			}
 			setMethodCodeStart(meth, func);
-			meth->accflags |= ACC_TRANSLATED;
+			meth->kFlags |= KFLAG_TRANSLATED;
 		}
 
 		call->function = getMethodCodeStart(meth);
 
-		if (meth->accflags & ACC_JNI)
+		if (meth->kFlags & KFLAG_JNI)
 		{
 			if (meth->accflags & ACC_STATIC)
 			{
@@ -170,7 +170,7 @@
 			if (meth->accflags & ACC_STATIC) {
 				syncobj = &meth->class->head;
 			}
-			else if (meth->accflags & ACC_JNI) {
+			else if (meth->kFlags & KFLAG_JNI) {
 				syncobj = (Hjava_lang_Object*)call->args[1].l;
 			}
 			else {
@@ -192,7 +192,7 @@
 		 * that JNI call we're cleaning up the pointer and we will
 		 * put it again to the value afterward.
 		 */
-		if ((meth->accflags & ACC_JNI) != 0) {
+		if ((meth->kFlags & KFLAG_JNI) != 0) {
 			if (thread_data->exceptObj != NULL)
 				save_except = thread_data->exceptObj;
 			else
@@ -208,7 +208,7 @@
 		}
 
 		/* If we have a pending exception and this is JNI, throw it */
-		if ((meth->accflags & ACC_JNI) != 0) {
+		if ((meth->kFlags & KFLAG_JNI) != 0) {
 		        if (call->rettype == 'L')
 			        call->ret->l = unveil(call->ret->l);
 		        finishJNIcall();
Index: kaffe/kaffe/kaffevm/jit/machine.h
diff -u kaffe/kaffe/kaffevm/jit/machine.h:1.25 kaffe/kaffe/kaffevm/jit/machine.h:1.26
--- kaffe/kaffe/kaffevm/jit/machine.h:1.25	Mon Dec 26 18:01:47 2005
+++ kaffe/kaffe/kaffevm/jit/machine.h	Thu Mar 30 17:39:17 2006
@@ -73,6 +73,7 @@
 #define	method_nargs()		(cinfo.in)
 #define	method_dtable_offset	(OBJECT_DTABLE_OFFSET)
 #define	method_returntype()	(cinfo.rettype)
+#define current_method() (meth)
 
 /* -------------------------------------------------------------------- */
 /* Fields */
Index: kaffe/kaffe/kaffevm/jit/native-wrapper.c
diff -u kaffe/kaffe/kaffevm/jit/native-wrapper.c:1.13 kaffe/kaffe/kaffevm/jit/native-wrapper.c:1.14
--- kaffe/kaffe/kaffevm/jit/native-wrapper.c:1.13	Mon Dec 26 18:01:47 2005
+++ kaffe/kaffe/kaffevm/jit/native-wrapper.c	Thu Mar 30 17:39:17 2006
@@ -456,7 +456,7 @@
 	installMethodCode(NULL, xmeth, &ncode);
 
 	if (use_JNI)
-		xmeth->accflags |= ACC_JNI;
+		xmeth->kFlags |= KFLAG_JNI;
 
 	goto done;
 exitOOM:
@@ -490,5 +490,5 @@
 void
 engine_create_wrapper (Method *meth, void *func)
 {
-	Kaffe_wrapper (meth, func, (meth->accflags&ACC_JNI)!=0);
+	Kaffe_wrapper (meth, func, (meth->kFlags & KFLAG_JNI)!=0);
 }
Index: kaffe/kaffe/kaffevm/jit3/machine.h
diff -u kaffe/kaffe/kaffevm/jit3/machine.h:1.28 kaffe/kaffe/kaffevm/jit3/machine.h:1.29
--- kaffe/kaffe/kaffevm/jit3/machine.h:1.28	Mon Dec 26 18:01:47 2005
+++ kaffe/kaffe/kaffevm/jit3/machine.h	Thu Mar 30 17:39:17 2006
@@ -61,6 +61,7 @@
 #define	get_interface_method_info(IDX) \
 	if (getMethodSignatureClass(IDX, xmeth->class, true, 2, &cinfo, einfo) == false) { success = false; goto done; }
 
+#define current_method()  (xmeth)
 #define	method_name()	(cinfo.name)
 #define	method_sig()	(cinfo.signature)
 #define	method_idx()	(cinfo.method->idx)
Index: kaffe/kaffe/kaffevm/jni/jni.c
diff -u kaffe/kaffe/kaffevm/jni/jni.c:1.41 kaffe/kaffe/kaffevm/jni/jni.c:1.42
--- kaffe/kaffe/kaffevm/jni/jni.c:1.41	Sun Mar 19 16:16:22 2006
+++ kaffe/kaffe/kaffevm/jni/jni.c	Thu Mar 30 17:39:18 2006
@@ -654,7 +654,7 @@
 			if (strcmp(meth[i].name->data, methodArray[j].name) == 0 &&
 			    strcmp(METHOD_SIGD(&meth[i]), methodArray[j].signature) == 0 &&
 			    (meth[i].accflags & ACC_NATIVE) != 0) {
-				meth[i].accflags |= ACC_JNI;
+				meth[i].kFlags |= KFLAG_JNI;
 				engine_create_wrapper(&meth[i], methodArray[j].fnPtr); 
 				goto found;
 			}
Index: kaffe/libraries/clib/native/Class.c
diff -u kaffe/libraries/clib/native/Class.c:1.89 kaffe/libraries/clib/native/Class.c:1.90
--- kaffe/libraries/clib/native/Class.c:1.89	Fri Dec 23 21:13:54 2005
+++ kaffe/libraries/clib/native/Class.c	Thu Mar 30 17:39:18 2006
@@ -318,7 +318,7 @@
 		if (publicOnly && ((mth[i].accflags&ACC_PUBLIC)==0))
 			continue;
 		
-		if ((mth[i].accflags & ACC_CONSTRUCTOR)!=0)
+		if ((mth[i].kFlags & KFLAG_CONSTRUCTOR)!=0)
 			continue;
 
 		if (utf8ConstEqual(init_name, mth[i].name))
@@ -335,7 +335,7 @@
 		if (publicOnly && ((mth[i].accflags&ACC_PUBLIC)==0))
 			continue;
 
-		if ((mth[i].accflags & ACC_CONSTRUCTOR)!=0)
+		if ((mth[i].kFlags & KFLAG_CONSTRUCTOR)!=0)
 			continue;
 
 		if (utf8ConstEqual(init_name, mth[i].name))
@@ -359,7 +359,7 @@
 
 	count = 0;
 	for (i = CLASS_NMETHODS(clas)-1; i >= 0;  i--) {
-		if ((mth[i].accflags & ACC_CONSTRUCTOR) == 0)
+		if ((mth[i].kFlags & KFLAG_CONSTRUCTOR) == 0)
 			continue;
 
 		if (publicOnly && ((mth[i].accflags&ACC_PUBLIC)==0))
@@ -372,7 +372,7 @@
 	ptr = (Hjava_lang_reflect_Constructor**)&unhand_array(array)->body[0];
 
 	for (i = CLASS_NMETHODS(clas)-1; i >= 0;  i--) {
-		if ((mth[i].accflags & ACC_CONSTRUCTOR) == 0)
+		if ((mth[i].kFlags & KFLAG_CONSTRUCTOR) == 0)
 			continue;
 
 		if (publicOnly && ((mth[i].accflags&ACC_PUBLIC)==0))
Index: kaffe/test/internal/jit_stub.c
diff -u kaffe/test/internal/jit_stub.c:1.11 kaffe/test/internal/jit_stub.c:1.12
--- kaffe/test/internal/jit_stub.c:1.11	Sat May  7 03:56:59 2005
+++ kaffe/test/internal/jit_stub.c	Thu Mar 30 17:39:19 2006
@@ -135,11 +135,14 @@
 	Exceptions_name = utf8ConstNew("Exceptions", -1);
 	SourceFile_name = utf8ConstNew("SourceFile", -1);
 	InnerClasses_name = utf8ConstNew("InnerClasses", -1);
+	Synthetic_name = utf8ConstNew("Synthetic", -1);
+	Signature_name = utf8ConstNew("Signature", -1);
 
 	if (!(init_name && final_name && void_signature &&
 	      constructor_name && Code_name && LineNumberTable_name &&
 	      LocalVariableTable_name && ConstantValue_name &&
-	      Exceptions_name && SourceFile_name && InnerClasses_name)) {
+	      Exceptions_name && SourceFile_name && InnerClasses_name &&
+	      Synthetic_name && Signature_name)) {
 		dprintf("not enough memory to run kaffe\n");
 		KAFFEVM_ABORT();
 	}




More information about the kaffe mailing list