Eww: Modifier.INTERPRETED overload

Andrew Haley aph-gcc@littlepinkcloud.COM
Wed May 30 17:21:00 GMT 2007


If you look in java/lang/reflect/Modifier.java you'll see:

  /**
   * Flag indicating a synthetic member.
   */
  static final int SYNTHETIC = 0x1000;

...

  /**
   * GCJ-LOCAL: This access flag is set on interpreted classes.
   */
  static final int INTERPRETED = 0x1000;

This should, perhaps, ring an alarm bell.  Way back when this code was
written, classes weren't marked synthetic, but they are now!
So, any compiled class that is marked as SYNTHETIC is treated as
INTERPRETED by libgcj.  Bad Things Happen.

We really need to find another way of marking classes as interpreted,
but clearing the INTERPRETED flag when loading the class prevents a
crash.

Andrew.



2007-05-30  Andrew Haley  <aph@redhat.com>

	* java/lang/natClassLoader.cc (_Jv_NewClassFromInitializer): Clear
	INTERPRETED access modifier.

Index: natClassLoader.cc
===================================================================
--- natClassLoader.cc	(revision 124185)
+++ natClassLoader.cc	(working copy)
@@ -281,7 +281,16 @@
   memcpy (dst, src, len);
   
   new_class->engine = &_Jv_soleIndirectCompiledEngine;
-  
+
+  /* FIXME:  Way back before the dawn of time, we overloaded the
+     SYNTHETIC class access modifier to mean INTERPRETED.  This was a
+     Bad Thing, but it didn't matter then because classes were never
+     marked synthetic.  However, it is possible to redeem the
+     situation: _Jv_NewClassFromInitializer is only called from
+     compiled classes, so we clear the INTERPRETED flag.  This is a
+     kludge!  */
+  new_class->accflags &= ~java::lang::reflect::Modifier::INTERPRETED;
+
   (*_Jv_RegisterClassHook) (new_class);
   
   return new_class;



More information about the Java-patches mailing list