Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365095 - [xtend] Always produce working Java code for catch clauses
Summary: [xtend] Always produce working Java code for catch clauses
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: M4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-29 11:36 EST by Moritz Eysholdt CLA
Modified: 2017-09-19 17:45 EDT (History)
2 users (show)

See Also:
sven.efftinge: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Moritz Eysholdt CLA 2011-11-29 11:36:13 EST
Example:


-----
class foo  {
	def bar() {
		try { "foo "} catch(IOException o) { "bar" }
	}
}
-----

this compiles to 

-----
public class foo {
  public String bar() {
    String _xtrycatchfinallyexpression = null;
    try {
      _xtrycatchfinallyexpression = "foo ";
    } catch (final IOException o) {
      _xtrycatchfinallyexpression = "bar";
    }
    return _xtrycatchfinallyexpression;
  }
}
-----

The Java code fails to compile with the message "Unreachable catch block for IOException. This exception is never thrown from the try statement body".

I'd expect to see the same validation message in Xtend.
Comment 1 Holger Schill CLA 2011-12-01 09:58:12 EST
Until https://bugs.eclipse.org/bugs/show_bug.cgi?id=365320 is not fixed we will not have the possibility to fix this issue because we would raise false errors in most of the cases.
Comment 2 Sven Efftinge CLA 2011-12-01 10:12:47 EST
We shouldn't have this validation but make sure that working Java code is produced.

something like this :

catch (Throwable t) {
   // translate catch clauses to instanceof
   if (t instance of IOException) {
       // handle code ...
   } ...
   } else {
       sneakyThrow
   }
}
Comment 3 Sven Efftinge CLA 2011-12-01 11:58:14 EST
pushed to master
Comment 4 Karsten Thoms CLA 2017-09-19 17:33:58 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 17:45:05 EDT
Closing all bugs that were set to RESOLVED before Neon.0