The Artima Developer Community
Sponsored Link

Articles Forum
Considering Closures for Java

19 replies on 20 pages. Most recent reply: Feb 10, 2007 11:33 PM by Neal Gafter

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 19 replies on 20 pages [ « | 1 ... 16 17 18 19 20 | » ]
Marcin Sarniak

Posts: 1
Nickname: saren
Registered: Jan, 2007

Re: Considering Closures for Java Posted: Jan 1, 2007 3:50 PM
Reply to this message Reply
I have some doubts about the propositions, it looks for me inconsistent.

What will hapen if I define code like that inside my method:

void initListeners() throws SomeException {

void addListener(ItemSelectable is) {
{ ItemEvent e => if (...) throw new SomeException(); }

The problem is, that closure may be executed after the end of execution of the enclosing method.

If the closure will be executed after the method
initListeners() will be finished, what will happen to the SomeException thrown from inside the closure?

It can not be just thrown to the Swing's API, because it didn't expect the checked exception of this type after calling itemStateChanged method from ItemEventListener interface.

Is there any planned way to inform compiler that a specific closure can not throw Exception (or return a value), because it might be executed after the end of execution of enclosing method? I do not see a clear way to enforce that rules by the compiler.

Flat View: This topic has 19 replies on 20 pages [ « | 16  17  18  19  20 | » ]
Topic: Refactoring the EJB APIs Previous Topic   Next Topic Topic: Spring Clustering with Terracotta

Sponsored Links


Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use