This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Serious bug in _Jv_InitPrimClass (I think)


Peter Blemel wrote:

if (sig != 'V')
   _Jv_NewArrayClass (cl, NULL, (_Jv_VTable *) array_vtable);

which is the root of all evil in that it starts the chain of events leading to my doom. In effect, I propose to initialize all non-array primitives first and then come back and call _Jv_NewArrayClass for everything but the void class.

What do you think?

Nasty. Thanks for the detailed bug report.


I'm pretty sure it is redundant, as well as dangerous, to create the array classes here, we can just get rid of this code and let _Jv_NewPrimArray take care of creating them on demand. I'm going to check in the attached patch - please let me know if this fixes your problem.

Regards

Bryce

2004-07-23  Bryce McKinlay  <mckinlay@redhat.com>

	* prims.cc (_Jv_InitPrimClass): Don't create an array class.
	(_Jv_CreateJavaVM): Don't pass array vtable parameter to
	_Jv_InitPrimClass.
	(DECLARE_PRIM_TYPE): Don't declare array vtables.
	* include/jvm.h (struct _Jv_ArrayVTable): Removed.
	* java/lang/Class.h (_Jv_InitPrimClass): Update friend declaration.

Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.94
diff -u -r1.94 prims.cc
--- prims.cc	20 Jul 2004 17:57:58 -0000	1.94
+++ prims.cc	24 Jul 2004 01:03:36 -0000
@@ -670,7 +670,6 @@
 
 // Ensure 8-byte alignment, for hash synchronization.
 #define DECLARE_PRIM_TYPE(NAME)			\
-  _Jv_ArrayVTable _Jv_##NAME##VTable;		\
   java::lang::Class _Jv_##NAME##Class __attribute__ ((aligned (8)));
 
 DECLARE_PRIM_TYPE(byte)
@@ -684,8 +683,7 @@
 DECLARE_PRIM_TYPE(void)
 
 void
-_Jv_InitPrimClass (jclass cl, char *cname, char sig, int len, 
-                   _Jv_ArrayVTable *array_vtable)
+_Jv_InitPrimClass (jclass cl, char *cname, char sig, int len)
 {    
   using namespace java::lang::reflect;
 
@@ -702,8 +700,6 @@
   cl->vtable = JV_PRIMITIVE_VTABLE;
   cl->state = JV_STATE_DONE;
   cl->depth = -1;
-  if (sig != 'V')
-    _Jv_NewArrayClass (cl, NULL, (_Jv_VTable *) array_vtable);
 }
 
 jclass
@@ -976,15 +972,15 @@
   finit_name = _Jv_makeUtf8Const ("finit$", 6);
 
   /* Initialize built-in classes to represent primitive TYPEs. */
-  _Jv_InitPrimClass (&_Jv_byteClass,    "byte",    'B', 1, &_Jv_byteVTable);
-  _Jv_InitPrimClass (&_Jv_shortClass,   "short",   'S', 2, &_Jv_shortVTable);
-  _Jv_InitPrimClass (&_Jv_intClass,     "int",     'I', 4, &_Jv_intVTable);
-  _Jv_InitPrimClass (&_Jv_longClass,    "long",    'J', 8, &_Jv_longVTable);
-  _Jv_InitPrimClass (&_Jv_booleanClass, "boolean", 'Z', 1, &_Jv_booleanVTable);
-  _Jv_InitPrimClass (&_Jv_charClass,    "char",    'C', 2, &_Jv_charVTable);
-  _Jv_InitPrimClass (&_Jv_floatClass,   "float",   'F', 4, &_Jv_floatVTable);
-  _Jv_InitPrimClass (&_Jv_doubleClass,  "double",  'D', 8, &_Jv_doubleVTable);
-  _Jv_InitPrimClass (&_Jv_voidClass,    "void",    'V', 0, &_Jv_voidVTable);
+  _Jv_InitPrimClass (&_Jv_byteClass,    "byte",    'B', 1);
+  _Jv_InitPrimClass (&_Jv_shortClass,   "short",   'S', 2);
+  _Jv_InitPrimClass (&_Jv_intClass,     "int",     'I', 4);
+  _Jv_InitPrimClass (&_Jv_longClass,    "long",    'J', 8);
+  _Jv_InitPrimClass (&_Jv_booleanClass, "boolean", 'Z', 1);
+  _Jv_InitPrimClass (&_Jv_charClass,    "char",    'C', 2);
+  _Jv_InitPrimClass (&_Jv_floatClass,   "float",   'F', 4);
+  _Jv_InitPrimClass (&_Jv_doubleClass,  "double",  'D', 8);
+  _Jv_InitPrimClass (&_Jv_voidClass,    "void",    'V', 0);
 
   // Turn stack trace generation off while creating exception objects.
   _Jv_InitClass (&java::lang::VMThrowable::class$);
Index: include/jvm.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/jvm.h,v
retrieving revision 1.66
diff -u -r1.66 jvm.h
--- include/jvm.h	13 Jul 2004 01:04:47 -0000	1.66
+++ include/jvm.h	24 Jul 2004 01:03:36 -0000
@@ -79,12 +79,6 @@
 // to keep this up to date by hand.
 #define NUM_OBJECT_METHODS 5
 
-// This structure is the type of an array's vtable.
-struct _Jv_ArrayVTable : public _Jv_VTable
-{
-  vtable_elt extra_method[NUM_OBJECT_METHODS - 1];
-};
-
 union _Jv_word
 {
   jobject o;
Index: java/lang/Class.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Class.h,v
retrieving revision 1.67
diff -u -r1.67 Class.h
--- java/lang/Class.h	19 Jul 2004 18:29:30 -0000	1.67
+++ java/lang/Class.h	24 Jul 2004 01:03:36 -0000
@@ -328,7 +328,7 @@
   friend void _Jv_InitNewClassFields (jclass klass);
 
   // in prims.cc
-  friend void _Jv_InitPrimClass (jclass, char *, char, int, _Jv_ArrayVTable *);
+  friend void _Jv_InitPrimClass (jclass, char *, char, int);
 
   friend void _Jv_PrepareCompiledClass (jclass);
   friend void _Jv_PrepareConstantTimeTables (jclass);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]