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: Line number support for interpreter


Hi,

On Wed, 2004-05-19 at 21:34, Bryce McKinlay wrote:
> Mark Wielaard wrote:
> 
> >It might be a good idea to add this small test to testsuite/libjava.lang
> >since it seems a strange corner case that isn't normally tested/used.
> 
> The libjava.lang/InvokeInterface.java test should cover this case 
> already. Does that test not fail for you?

Nope. And I finally found out why. InvokeInterface was compiled by
gcj -C but my test program by jikes (1.18). And when InvokeInterface is
compiled with jikes then it fails also when run with gij!

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.

Cheers,

Mark
import java.lang.reflect.Method;

public class Invoke
{
  interface I
  {
    static long l = Invoke.initI();
    void m();
  }

  static class C implements I
  {
    static long l = Invoke.initC();
    public void m()
    {
      System.out.println("Hello World");
    }
  }

  public static void main(String[] args) throws Exception
  {
    Class c = new I[0].getClass().getComponentType();
    Method m = c.getDeclaredMethod("m", null);
    Object o = new C();
    System.out.println("Invoking...");
    m.invoke(o, null);
    System.out.println("...Invoked");
  }

  static long initI()
  {
    System.err.println("initI");
    return 5;
  }

  static long initC()
  {
    System.err.println("initC");
    return 5;
  }
}

Attachment: signature.asc
Description: This is a digitally signed message part


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