Recursion can often be unintentional and result in a Stackoverflow (.com). Especially as someone who doesn't like recursion very much, I would like to see a warning if there is some in my code.

I'm pretty sure that there is no setting to do this in Eclipse, so I'm searching for a plugin to do this.

It should preferably be compatible with the @SuppressWarnings annotation system so that I can mark intentional recursion.

(I'm programming in Java on Eclipse Mars, Neon, Oxygen and Photon (different setups (work work, work testing, private laptop and private PC (nested brackets))). If it's just available in/compatible with one of them, I also accept that.)

  • When I google this, I get stuff about recursive definitions, which this is not about. I'm looking for classical recursion, where method A calls method A or where method A calls method B and method B calls method A or a longer loop. – Fabian Röling Oct 30 '17 at 8:43
  • I think such a plugin is more complicated than it seems. It may be possible to do such in superficial ways, which I suppose is what you want... but if the issue is superficial how is this an issue for the programmer? What I mean by superficial is that you are entirely working in your own code, in which case it should be possible to determine with lexical analysis but if you are using Dependency Injection type magic then that will fail, you would need to do something like instrument everything with AspectJ which hooks all calls into a graph and watches for any cycles. While possible... – Quaternion Nov 3 '17 at 1:24
  • although kind of silly, Java being generally OO you tend to name things well (one of the features of classes is that they provide granular namespaces) so if the names make sense and the classes serve reasonable purpose the idea of accidentally applying recursion seems pretty implausible. Even the methods should have clear intention, making it difficult to use incorrectly. – Quaternion Nov 3 '17 at 1:27
  • If it only works for direct references, that's better than nothing. The last example I had was that I wanted two booleans to always be the opposite of each other, so I made the setters call each other, which of course made an infinite loop. In this case the program started pretty quickly, so I found the issue in a few seconds, but if it's a more complicated issue or the startup takes longer, I can lose more time with it. – Fabian Röling Nov 3 '17 at 7:06
  • I just found this as an option in Intellij Idea: settings->editor->general->"gutter icons"->recursive call – Fabian Röling Jul 22 '18 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.