[Top][All Lists]

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

Fw: java.lang.Constructor conformance

From: Dave Roberts
Subject: Fw: java.lang.Constructor conformance
Date: Sun, 12 Aug 2001 23:17:57 -0700

I'm thinking about writing some Mauve tests and so this is a good example of
what can happen...

Basically, this brings up a good point as to procedure when we find things
like this moving forward. It seems like there are two desires:
1. Make a good, free Java library that has high interoperability with Sun's
reference implemention for standard programs.

2. Do the right thing.

In cases where these are in conflict, I would recommend we:
1. Make sure we file the bug on Sun's site to force them to clarify which is
correct, their docs or their code.
2. Implement an environment variable that can be set from the JVM command
line to invoke the desired behavior . I don't know what should be default
behavior, though, Sun's current implementation (e.g., use -DPEDANTIC=true
for the other) or the documented behavior (e.g.,
use -DJDK_COMPATIBILITY=true for Sun compatiblity). Depending on my mood, I
could go either way.

-- Dave

----- Original Message -----
From: "Tom Tromey" <address@hidden>
To: "Patrick Doyle" <address@hidden>
Cc: <address@hidden>
Sent: Wednesday, August 08, 2001 11:20 AM
Subject: Re: java.lang.Constructor conformance

> >>>>> "Patrick" == Patrick Doyle <address@hidden> writes:
> Patrick> When a constructor isn't found, Classpath's
> Patrick> java.lang.Constructor dutifully throws
> Patrick> InstantiationException, as per Sun's library spec.  However,
> Patrick> the JDK itself actually throws NoSuchMethodError (not to be
> Patrick> confused with NoSuchMethodException).  Kaffe also throws
> Patrick> NoSuchMethodError.
> Interesting.
> What version of the JDK are you using?
> JDK 1.2 throws InstantiationException.
> Patrick> Technically, Classpath is right, but I'm not sure whether
> Patrick> that's more important than matching the behaviour of Sun's
> Patrick> JVM.
> Tough call.
> Patrick> The way to fix it is to catch the NoSuchMethodException from
> Patrick> Constructor.newInstance, and (believe it or not) re-throw it as a
> Patrick> NoSuchMethodError.  Then Classpath should act just like the JDK.
> libgcj throws NoSuchMethodException.  I know we didn't just make this
> up, so I tracked it down.  The JCL book says that Class.newInstance
> throws NoSuchMethodException if the class does not have a no-arg
> constructor.
> Oh, well -- another case where Sun's documentation and implementation
> are inconsistent and vary randomly across versions.  Yay.  The upshot
> is that Java programs can't rely on the behavior.
> Tom
> _______________________________________________
> Classpath mailing list
> address@hidden

reply via email to

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