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


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

Re: Primitive return value after exception in method

Date 2013-09-01 13:57 -0700
From Patricia Shanahan <pats@acm.org>
Newsgroups comp.lang.java.programmer
Subject Re: Primitive return value after exception in method
References <kvumu7$idc$1@speranza.aioe.org>
Message-ID <ZNydnQuiG9ajN77PnZ2dnUVZ_qSdnZ2d@earthlink.com> (permalink)

Show all headers | View raw


On 8/31/2013 11:30 PM, Richard Maher wrote:
...
> I know this is a case of suck-it-and see but I'd like a reference to the
> architectural performance description please. (I'm pretty bad at seeding
> Google)
>
> if: -
>
> int fred = -1;
> try {
>      fred = someMethod(String blah);
> } catch (e) {};
>
> Now before someMethod raised an exception it had set the designated and
> referenced RETURN value to say 1, what will the value of fred be?
...

The appropriate document for this sort of question is the Java Language
Specification, http://docs.oracle.com/javase/specs/jls/se5.0/html/j3TOC.html

The specific issue of the effect of assignment in the presence of an
exception in evaluating its right hand size is covered in section
"15.26.1 Simple Assignment Operator =" at
http://docs.oracle.com/javase/specs/jls/se5.0/html/expressions.html#15.26.1

"Otherwise, the right-hand operand is evaluated. If this evaluation
completes abruptly, then the assignment expression completes abruptly
for the same reason and no assignment occurs."

A call to a method that throws an exception completes abruptly, so no
assignment occurs. fred has the same value after completion of the
try-catch as it had immediately before the call.

Patricia

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


Thread

Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-01 14:30 +0800
  Re: Primitive return value after exception in method Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-09-01 09:23 +0200
    Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-01 15:38 +0800
    Re: Primitive return value after exception in method Arne Vajhøj <arne@vajhoej.dk> - 2013-09-01 11:49 -0400
      Re: Primitive return value after exception in method Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-09-01 19:05 +0200
        Re: Primitive return value after exception in method Robert Klemme <shortcutter@googlemail.com> - 2013-09-02 08:34 +0200
          Re: Primitive return value after exception in method Arne Vajhøj <arne@vajhoej.dk> - 2013-09-02 22:18 -0400
          Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 09:12 +0100
            Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-08 17:16 +0800
              Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 12:39 +0100
                Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-08 19:49 +0800
                Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 12:59 +0100
                Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-08 20:13 +0800
                Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 13:15 +0100
                Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-08 20:20 +0800
                Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 13:27 +0100
            Re: Primitive return value after exception in method Robert Klemme <shortcutter@googlemail.com> - 2013-09-08 12:33 +0200
              Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 12:41 +0100
                Re: Primitive return value after exception in method Robert Klemme <shortcutter@googlemail.com> - 2013-09-08 14:15 +0200
                Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 13:24 +0100
  Re: Primitive return value after exception in method Patricia Shanahan <pats@acm.org> - 2013-09-01 13:57 -0700

csiph-web