Robust / Secure / Safe
• Java is very robust
o Both, vs. unintentional errors and vs. malicious code such as viruses.
o Java has slightly worse performance since it does all this checking. (Or put the other way, C can be faster since it doesn't check anything.)
• The JVM "verifier" checks the code when it is loaded to verify that it has the correct structure -- that it does not use an uninitialized pointer, or mix int and pointer types. This is one-time "static" analysis -- checking that the code has the correct structure without running it.
• The JVM also does "dynamic" checking at runtime for certain operations, such as pointer and array access, to make sure they are touching only the memory they should. You will write code that runs into
• As a result, many common bugs and security problems (e.g. "buffer overflow") are not possible in java. The checks also make it easier to find many common bugs easy, since they are caught by the runtime checker.
• You will generally never write code that fails the verifier, since your compiler is smart enough to only generate correct code. You will write code that runs into the runtime checks all the time as you debug -- array out of bounds, null pointer.
• Java also has a runtime Security Manager can check which operations a particular piece of code is allowed to do. As a result, java can run un-trusted code in a "sandbox" where, for example, it can draw to the screen but cannot access the local file system.


Sponsored Links