classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Continuing newInstance saga


From: Patrick Doyle
Subject: Continuing newInstance saga
Date: Tue, 7 Aug 2001 15:01:55 -0400 (EDT)

My appologies; it seems that simply re-throwing the NoSuchMethodException
as a NoSuchMethodError doesn't give the correct results when the class in
question is an interface.  In that case, it's supposed to throw an
InstationException after all.

In my current code, I have this:

    catch(NoSuchMethodException e) {
        //throw new InstantiationException("Method not found");
        if((getModifiers() & Modifier.INTERFACE) != 0)
            throw new InstantiationException("Can't instantiate interface");
        else
            throw new NoSuchMethodError("No-arg constructor not found");
    }

However, this is incomplete because it doesn't properly handle abstract
classes, array classes, or primitive types.

Perhaps it would just be simpler to follow the spec as written, and throw
an InstantiationException in every case.  Since that is how Classpath is
already written, it's not only the cleanest solution: it's also the
easiest.

Sorry for the confusion.

--
Patrick Doyle
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]