structural search

I'm trying to find all methods that contain a call to System.exit.
I'm not interesting in the main methods of runnable classes.

Is this possible using Structural Search ?

5 comments

i've made a step in the direction using the following template

class $Class$ {
$returnType$ $methodName$($ParameterType$ $ParameterName$) {
$Statement1$;
System.exit($param$);
$Statement2$;
}
}

But this does not find cases where the System.exit statement is in a catch block for example (or I guess any kind of a block)

0

- Navigate to System class
- Put the cursor on the exit() method
- ALT+F7

Or for some reason you really need to use structural search?

0

Thibaut wrote:

i've made a step in the direction using the following template

class $Class$ {
$returnType$ $methodName$($ParameterType$ $ParameterName$) {
$Statement1$;
System.exit($param$);
$Statement2$;
}
}

But this does not find cases where the System.exit statement is in a catch block for example (or I guess any kind of a block)

Yes, this is current limiation of SS.

--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

the reason why i tried to use SSR is i have 200+ usages of System.exit.

We consider "legal" to call System.exit from the main method, but not from anywhere else in the code and of those 200+ usages, a large portion is from main methods.

So I was trying to refine the search so as not to have so many false positives

0

Please sign in to leave a comment.