Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8359

Re: Thumbs up for suppressable exceptions in JDK 1.7

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Thumbs up for suppressable exceptions in JDK 1.7
Date 2011-09-27 02:28 -0700
Organization Canadian Mind Products
Message-ID <cp5387dadnj2jmuheklm82niu718054nsj@4ax.com> (permalink)
References <j5ru3o$cu7$1@news.albasani.net>

Show all headers | View raw


On Tue, 27 Sep 2011 09:31:03 +0200, Jan Burse <janburse@fastmail.fm>
wrote, quoted or indirectly quoted someone who said :

>Dear All
>
>Was just playing around with suppressable exceptions
>in JDK 1.7. This looks like a great improvement for
>bug hunting!
>
>Best Regards
>
>Manually Suppressed:
>------------------
>
>   public class TestSuppressed {
>
>     public static void main(String[] args) throws Exception {
>         try {
>             throw new IllegalArgumentException("x");
>         } catch (IllegalArgumentException x) {
>             x.addSuppressed(new IllegalArgumentException("y"));
>             throw x;
>         }
>     }
>
>   }
>
>gives:
>
>    Exception in thread "main" java.lang.IllegalArgumentException: x
>     at TestSuppressed.main(TestSuppressed.java:12)
>     Suppressed: java.lang.IllegalArgumentException: y
>         at TestSuppressed.main(TestSuppressed.java:14)
>         ... 5 more
>
>Automatically Suppressed:
>---------------------
>
>    public class TestSuppressed implements AutoCloseable {
>
>       public static void main(String[] args) throws Exception {
>         try (TestSuppressed ts=new TestSuppressed()) {
>             throw new IllegalArgumentException("x");
>         }
>       }
>
>       public void close() throws Exception {
>         throw new IllegalArgumentException("y");
>       }
>
>    }
>
>gives:
>
>    Exception in thread "main" java.lang.IllegalArgumentException: x
>     at TestSuppressed.main(TestSuppressed.java:9)
>     Suppressed: java.lang.IllegalArgumentException: y
>         at TestSuppressed.close(TestSuppressed.java:20)
>         at TestSuppressed.main(TestSuppressed.java:10)
>         ... 5 more

I think you need some exposition on why this is a good thing.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to 
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-09-27 09:31 +0200
  Re: Thumbs up for suppressable exceptions in JDK 1.7 Roedy Green <see_website@mindprod.com.invalid> - 2011-09-27 02:28 -0700
    Re: Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-09-27 11:38 +0200
    Re: Thumbs up for suppressable exceptions in JDK 1.7 Tom Anderson <twic@urchin.earth.li> - 2011-09-27 20:43 +0100
      Re: Thumbs up for suppressable exceptions in JDK 1.7 Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-29 18:05 +0200
        Re: Thumbs up for suppressable exceptions in JDK 1.7 Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-09-29 11:25 -0700
          Re: Thumbs up for suppressable exceptions in JDK 1.7 Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-29 23:57 +0200
          Re: Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-09-30 11:30 +0200
        Re: Thumbs up for suppressable exceptions in JDK 1.7 Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-29 18:57 -0300
  Re: Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-02 13:38 +0200
    Re: Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-02 13:45 +0200
      Re: Thumbs up for suppressable exceptions in JDK 1.7 Tom Anderson <twic@urchin.earth.li> - 2011-10-03 19:08 +0100

csiph-web