Patch for correctly intializing interface class on Method.invoke() (Was: Line number support for interpreter)
Mark Wielaard
mark@klomp.org
Thu May 20 12:11:00 GMT 2004
Hi,
On Wed, 2004-05-19 at 23:47, Mark Wielaard wrote:
> What was happening was that jikes cleverly makes sure that the interface
> is never initialized. While gcj -C just gets us a initialized class when
> using the I.class construct.
>
> The attached Test program does the same. And does fail with gij (CVS),
> but not with gij 3.4 (which wrongly initializes the interface I when the
> array is created). I'll add something like this to Mauve since I saw
> that more runtimes get this wrong.
Did some more reading about this issue and concluded that this is only
possible with interface classes since those are not initialized when
creating an object of a class that implements the interface. Only super
classes of a class must explicitly be initialized when a instance is
created. (See VM Spec 2.17.4)
The following patch adds explicit initialization of interface classes to
Method.invoke() and also does the test whether the declaringClass is an
interface only when the method involved isn't a static method since
interfaces cannot contain static methods.
2004-05-20 Mark Wielaard <mark@klomp.org>
* java/lang/reflect/natMethod.cc (invoke): Only check isInterface()
and set iface when method is non-static. Always initialize interface
classes.
There is now a gnu.testlet.java.lang.Class.init test in Mauve.
gij-3.3 gives a couple of failures since it initializes the interface
class much too early. gij-3.4 (and gij CVS) crashes as soon as invoke()
is called on the interface method (but correctly delay initializing the
interface class). And with this patch gij CVS gives all PASSes for this
test. All regression tests in libjava/testsuite also still PASS.
OK to commit?
Cheers,
Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: natMethod.patch
Type: text/x-patch
Size: 1299 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040520/4f78b9c1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040520/4f78b9c1/attachment.sig>
More information about the Java-patches
mailing list