classpath-patches
[Top][All Lists]
Advanced

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

Re: [cp-patches] Re: RFC: Patch for duplicate entries in serialPersisten


From: Stuart Ballard
Subject: Re: [cp-patches] Re: RFC: Patch for duplicate entries in serialPersistentFields
Date: Sun, 11 Dec 2005 21:42:13 -0500

On 12/11/05, Guilhem Lavaux <address@hidden> wrote:
> Bah ! I would rather use a native function that will throw directly
> InvalidClassException. The problem is that's will be anyway hidden to
> the general user and that he/she may be surprised getting that sort of
> exception.

I dunno, this seems pretty clean if it works:

public class Throw {
  private static Throwable t;
  public Throw() throws Throwable {throw t;}
  public static synchronized void uncheckedThrow(Throwable t) {
    Throw.t = t;
    try {
      Throw.class.newInstance();
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    }
  }
}

Throw.uncheckedThrow(new InvalidClassException("..."));

A perfectly portable illegal-exception-thrower :)
--
http://sab39.dev.netreach.com/




reply via email to

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