title: Preventing infinite loop in java
body: <p>I wanted to make a little game like robot wars in Java.</p>
  
  <p>the idea is to extend my class Robot, with the custom rules, you add to it.</p>
  
  <p>however, i have so things I want to prevent coders to do, like infinite loops.</p>
  
  <p>I know some compilers will complain if there is an endless loop, in a Methode the requires a returning value. but I don't think all compilers will return an error on this, so I was thinking if there was a way to check this another way too?</p>
  
  <p>or maybe a way to make some sort of timeout on a method?</p>
  
  <p><strong>Update:</strong>
  Looking back to this question I posted almost 3 and a half year ago, I am no longer doing programming in Java, however still an active Programmer, and with the years, I learned how hard it is to police 3rd party code if there is no review cycle implemented.
  There is no simple way to check if Code is malicious (that is why we have anti-virus programs).</p>
  
  <p>To do a thing that I wanted to do, I first of need to control the entire platform I am developing too, to check for reasons the code is behaving as it is, a task that would be nearly imposable or too time-consuming.</p>
  
  <p>that is why to do this more securely, the solution I reached is to use a Scripting Language that limits the user to the idea you had in mind.</p>
  
  <p>Hosting a Program on servers, that everybody has access to add code to is simply not a good idea. not even with Manage Program Languages as Java and CIL, as the platforms are not checking for those specifics, it would simply take too much effort to do this.</p>
  
  <p>Even though there is a way to "Sandbox" programs in Java, by using <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/PolicyFiles.html" rel="nofollow noreferrer">Policies</a>
  and C# have <a href="https://docs.microsoft.com/en-us/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox" rel="nofollow noreferrer">something similar</a>, it would never prevent a skilled programmer to exploit or do something that was never intended.</p>
  
  <p>I hope this update gives other a warning to what they are doing since I noticed this topic recently go searched a lot.</p>