This is the mail archive of the java@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: Untimed resolve ?


The initial problem comes from a completely different code. Consider this:

class X extends Exception {}

class Testx
{
public static void main(String args[])
{
try
{
System.out.println("loaded.");
X x = new X();
//new X();
}
catch(NoClassDefFoundError noclass)
{
System.out.println("caught you!");
}
}
}

If you compile Testx.java and then remove X.class, with the above code
the NoClassDefFoundError will not be caught using Sun VM (1.3 or 1.4).
Now if you comment the "X x = new X()" and uncomment "new X()", the error
will be caught. At any rate, this is an obvious bug and other virtual machines do it as well.

The problem with GIJ is that when you run Testx (above), it tries to resolve all entries in the constant pool,
therefore it gives an error before it even runs main (i.e. that X.class is missing), which is not correct.

I tried to see how GIJ behaves on the above code, but it does premature resolving, so it is not possible.
The method in the ClassLoader.java resolveClass() should be called linkClass(), otherwise it confuses alot of
people.

Of course the program of the previous post ran just fine using Sun VM, since it does not do premature resolving of entries
in the pool.

There is no problem with the bug report, but I was not sure if I am missing something, and may be this is not an incorrect
behaviour. I started this discussion on http://forum.java.sun.com/thread.jsp?forum=4&thread=338788, it has some interesting
examples where the various machines do not behave properly.

Thx,
Martin.

t 18:16 27.12.2002 'ã.'Conve -0800, you wrote:
On Fri, 2002-12-27 at 09:39, Martin Vechev wrote:
> At the end of loading the X class it also resolves it, which seems
> incorrect. Shouldn't it rich the actual 'new' bytecode
> and then throw NoClassDefFoundError.

I think you're right.  Did you try it with Sun's or IBM's java?  I saw
something like this a couple of months ago.  gij was reporting an error
like this, but IBM's java could run the code just fine -- even though
the class in question was missing in both cases.

Would you mind filing a bug report for this?

Thanks,

AG


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