Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » a way to find catcher?
a way to find catcher? [message #1827236] Mon, 11 May 2020 08:32 Go to next message
Juergen Weber is currently offline Juergen WeberFriend
Messages: 65
Registered: July 2009
Member
Hi,

can Eclipse show where a certain exception is caught in the workspace?

With the cursor on c() I'd like Eclipse to show the catch clause in a().

a()
{
try { b(); } catch (RuntimeException e) {}
}

b()
{
c();
}

c()
{
throw new RuntimeException();
}
Re: a way to find catcher? [message #1827308 is a reply to message #1827236] Tue, 12 May 2020 18:45 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
To find "where a certain exception is caught in the workspace" the comprehensive answer is
Search > Java >
Search String : java.lang.RuntimeException
Serach for: Type
Limit To: Match Locations > In expressions > (x) catch clauses

If by "a certain exception" you mean, only those thrown from a particular method, then the Call Hierarchy is you friend, but you'll have to inspect the code of each method in the hierarchy. But when looking at a particular method that has a catch clause: select the caught exception type and Mark Occurrences will highlight the methods which can throw this exception - for declared exceptions that is.

The most precise result can be seen in the debugger.
Re: a way to find catcher? [message #1827331 is a reply to message #1827308] Wed, 13 May 2020 08:37 Go to previous messageGo to next message
Juergen Weber is currently offline Juergen WeberFriend
Messages: 65
Registered: July 2009
Member
With the cursor on a method name definition, I can right click -> References

So, with the cursor on a throw or throws statement, I'd like to right click -> Caught in

The places where the exception is caught should be computable.

Like Find reference Find Catchers would be very useful if you try to understand Java code.
Re: a way to find catcher? [message #1827339 is a reply to message #1827331] Wed, 13 May 2020 11:57 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Quote:
The places where the exception is caught should be computable.


Yes, but ...

As a prerequisite you need the full call graph of all paths into the given method. Incrementally inspecting the caller graph in the Call Hierarchy view works nice (already this is a bit slow sometimes), but what you need would correspond to an "expand all" button with depth infinite. In real world programs, this operation will take unacceptably long time.

I'm sure, though, that JDT provides all the necessary API to implement such a tool, so you are free to prove me wrong by implementing a plug-in that provides this feature in acceptable performance :)


Previous Topic:Breakpoint is always set to strike-off
Next Topic:Error during java ide installation
Goto Forum:
  


Current Time: Tue Dec 10 00:12:13 GMT 2024

Powered by FUDForum. Page generated in 0.04418 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top