Exiting Eclipse with the Scala Interpreter
If you enter exit in the interpreter it closes Eclipse completely.
Leave a comment
updated version to 2.0.0 final
on 2011-12-21 10:25 *
By Iulian Dragos
The problem with computers is that they will do exactly what you tell them.. :)
This is one of those issues where good arguments can be made in support of different and incompatible fixes.
Michael is correct: it is very wrong for a plugin to call Runtime.exit (or halt). This skips at the very least the last save-to-disk of the workspace: you will loose unsaved changes, and if those are in configuration files there is potential to break the workspace. And if you are in the middle of an install/uninstall... yikes!
Iulian has a point, too: in spite of all the potential problems I can't know for certain that there will never be a time when calling exit/halt is the best option, and my inner libertarian wants to say that if the user really wants to do this, well, it's their machine.
The interpreter can easily be tweaked to recognize a bare 'exit' (see line 994 of scala.tools.nsc.interpreter.ILoop). I will look into implementing that idea.
What about the indirect calls? I can't count the projects I've seen that use System.exit or EXIT_ON_CLOSE incorrectly, and I can have sympathy for someone that calls a library not expecting it to halt the VM. It would be nice to redirect all exit/halt calls to the Eclipse shutdown methods. And this sounds like something AspectJ could do, but there are significant problems (e.g. Runtime is loaded before AspectJ) that make me think the costs outweigh the benefits.
Another option would be to run the interpreter in its own VM. Again, significant complexity, not sure costs outweigh benefits. Plus, there are some really interesting things you can do if the interpreter can reach out and manipulate the running Eclipse class instances.
One final observation: The only thing that prevents plugins from calling exit/halt is societal pressure: a misbehaving plugin - even a closed-source one - will be found out very easily, mocked mercilessly, and driven from the marketplace. The Scala IDE will be judged in this manner regardless of the technical merits of and associated arguments behind the proposed fixes.
Jeremy
Michael is correct: it is very wrong for a plugin to call Runtime.exit (or halt). This skips at the very least the last save-to-disk of the workspace: you will loose unsaved changes, and if those are in configuration files there is potential to break the workspace. And if you are in the middle of an install/uninstall... yikes!
Iulian has a point, too: in spite of all the potential problems I can't know for certain that there will never be a time when calling exit/halt is the best option, and my inner libertarian wants to say that if the user really wants to do this, well, it's their machine.
The interpreter can easily be tweaked to recognize a bare 'exit' (see line 994 of scala.tools.nsc.interpreter.ILoop). I will look into implementing that idea.
What about the indirect calls? I can't count the projects I've seen that use System.exit or EXIT_ON_CLOSE incorrectly, and I can have sympathy for someone that calls a library not expecting it to halt the VM. It would be nice to redirect all exit/halt calls to the Eclipse shutdown methods. And this sounds like something AspectJ could do, but there are significant problems (e.g. Runtime is loaded before AspectJ) that make me think the costs outweigh the benefits.
Another option would be to run the interpreter in its own VM. Again, significant complexity, not sure costs outweigh benefits. Plus, there are some really interesting things you can do if the interpreter can reach out and manipulate the running Eclipse class instances.
One final observation: The only thing that prevents plugins from calling exit/halt is societal pressure: a misbehaving plugin - even a closed-source one - will be found out very easily, mocked mercilessly, and driven from the marketplace. The Scala IDE will be judged in this manner regardless of the technical merits of and associated arguments behind the proposed fixes.
Jeremy
on 2015-03-13 15:39 *
By Simon Schäfer
Eclipse version changed from Helios to Luna - Eclipse 4.4
Version changed from 2.0.0-final-28 to 4.0.0
Description changed from If you enter exit in the in... to If you enter exit in the in...
Closed because it is out of scope.