public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Eww: Modifier.INTERPRETED overload
@ 2007-05-30 17:21 Andrew Haley
  2007-05-30 17:30 ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Haley @ 2007-05-30 17:21 UTC (permalink / raw)
  To: java-patches

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;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Eww: Modifier.INTERPRETED overload
  2007-05-30 17:21 Eww: Modifier.INTERPRETED overload Andrew Haley
@ 2007-05-30 17:30 ` Tom Tromey
  2007-05-30 17:37   ` David Daney
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2007-05-30 17:30 UTC (permalink / raw)
  To: Andrew Haley; +Cc: java-patches

>>>>> "Andrew" == Andrew Haley <aph-gcc@littlepinkcloud.COM> writes:

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

I'm sure this is my fault but I don't remember what I was thinking.

Andrew> We really need to find another way of marking classes as interpreted,

Yeah.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Eww: Modifier.INTERPRETED overload
  2007-05-30 17:30 ` Tom Tromey
@ 2007-05-30 17:37   ` David Daney
  2007-05-30 17:44     ` Andrew Haley
  0 siblings, 1 reply; 7+ messages in thread
From: David Daney @ 2007-05-30 17:37 UTC (permalink / raw)
  To: tromey; +Cc: Andrew Haley, java-patches

Tom Tromey wrote:
>>>>>> "Andrew" == Andrew Haley <aph-gcc@littlepinkcloud.COM> writes:
> 
> Andrew> This should, perhaps, ring an alarm bell.  Way back when this code was
> Andrew> written, classes weren't marked synthetic, but they are now!
> Andrew> So, any compiled class that is marked as SYNTHETIC is treated as
> Andrew> INTERPRETED by libgcj.  Bad Things Happen.
> 
> I'm sure this is my fault but I don't remember what I was thinking.
> 
> Andrew> We really need to find another way of marking classes as interpreted,
> 
> Yeah.

It's probably obvious, but why can't the value of the constant be changed?

David Daney.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Eww: Modifier.INTERPRETED overload
  2007-05-30 17:37   ` David Daney
@ 2007-05-30 17:44     ` Andrew Haley
  2007-05-30 17:46       ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Haley @ 2007-05-30 17:44 UTC (permalink / raw)
  To: David Daney; +Cc: tromey, java-patches

David Daney writes:
 > Tom Tromey wrote:
 > >>>>>> "Andrew" == Andrew Haley <aph-gcc@littlepinkcloud.COM> writes:
 > > 
 > > Andrew> This should, perhaps, ring an alarm bell.  Way back when this code was
 > > Andrew> written, classes weren't marked synthetic, but they are now!
 > > Andrew> So, any compiled class that is marked as SYNTHETIC is treated as
 > > Andrew> INTERPRETED by libgcj.  Bad Things Happen.
 > > 
 > > I'm sure this is my fault but I don't remember what I was thinking.
 > > 
 > > Andrew> We really need to find another way of marking classes as interpreted,
 > > 
 > > Yeah.
 > 
 > It's probably obvious, but why can't the value of the constant be changed?

Maybe, but access_flags is a u2, and there aren't many bits left.
0x80, perhaps?  It's used for VARARGS at the moment.

Andrew.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Eww: Modifier.INTERPRETED overload
  2007-05-30 17:44     ` Andrew Haley
@ 2007-05-30 17:46       ` Tom Tromey
  2007-05-30 18:08         ` Andrew Haley
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2007-05-30 17:46 UTC (permalink / raw)
  To: Andrew Haley; +Cc: David Daney, java-patches

>>>>> "Andrew" == Andrew Haley <aph-gcc@littlepinkcloud.COM> writes:

Andrew> Maybe, but access_flags is a u2, and there aren't many bits left.
Andrew> 0x80, perhaps?  It's used for VARARGS at the moment.

It seems that whatever we pick may be overloaded by the JVM at some
later date.

Maybe instead we can find a hole in Class and stuff a byte field of
gcj-local flags there.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Eww: Modifier.INTERPRETED overload
  2007-05-30 17:46       ` Tom Tromey
@ 2007-05-30 18:08         ` Andrew Haley
  2007-05-30 19:32           ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Haley @ 2007-05-30 18:08 UTC (permalink / raw)
  To: Tom Tromey; +Cc: David Daney, java-patches

Tom Tromey writes:
 > >>>>> "Andrew" == Andrew Haley <aph-gcc@littlepinkcloud.COM> writes:
 > 
 > Andrew> Maybe, but access_flags is a u2, and there aren't many bits left.
 > Andrew> 0x80, perhaps?  It's used for VARARGS at the moment.
 > 
 > It seems that whatever we pick may be overloaded by the JVM at some
 > later date.

Right.  That's why my patch didn't choose another bit.

 > Maybe instead we can find a hole in Class and stuff a byte field of
 > gcj-local flags there.
 
That sounds like a Much Better Plan.  We can even add a field.

I'm still minded to use my patch on active branches, though.

Andrew.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Eww: Modifier.INTERPRETED overload
  2007-05-30 18:08         ` Andrew Haley
@ 2007-05-30 19:32           ` Tom Tromey
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2007-05-30 19:32 UTC (permalink / raw)
  To: Andrew Haley; +Cc: David Daney, java-patches

Andrew> I'm still minded to use my patch on active branches, though.

Yeah, I think we have to, since a change in Class requires an ABI bump.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-05-30 18:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-30 17:21 Eww: Modifier.INTERPRETED overload Andrew Haley
2007-05-30 17:30 ` Tom Tromey
2007-05-30 17:37   ` David Daney
2007-05-30 17:44     ` Andrew Haley
2007-05-30 17:46       ` Tom Tromey
2007-05-30 18:08         ` Andrew Haley
2007-05-30 19:32           ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).