Yesterday I was attending a talk by a CTO of a reputed European Company, and he told until recently he did not know that java has pointers. On confronting him he said he is absolutely sure about existence of pointers/unsafe code in java.
Java doesn't have pointers; Java has references.
No pointer support make Java more secure because they point to memory location or used for memory management that loses the security as we use them directly.
1)Pointers lead to confusion for a programmer. 2)Pointers may crash a program easily, for example, when we add two pointers, the program crashers immediately. 3)Pointers break security. Using pointers, harmful programs like Virus and other hacking programs can be developed.
Unsafe code in general is a keyword that denotes a code section that is not handled by the Common Language Runtime(CLR). Pointers are not supported by default in C# but unsafe keyword allows the use of the pointer variables.
There's a class called sun.misc.Unsafe
, that much is true. But it doesn't use pointers in Java code (because Java has no pointers, although I agree that java references are similar in concept), most of it is implemented using native code.
As I mentioned in the comments, this is not part of the public API and shouldn't be used by client code. However, you can see it at work when you look at the sources of the Atomic*
classes in the java.util.concurrent.atomic
package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With