是否存在“指针”的概念。或“不安全代码”或在Java? [英] Is there a concept of "pointers" or "unsafe code" in Java?

查看:129
本文介绍了是否存在“指针”的概念。或“不安全代码”或在Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天我正在参加一家知名欧洲公司的首席技术官的谈话,直到最近他还不知道java有指针。在面对他时,他说他绝对肯定在java中存在指针/不安全代码。

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.

推荐答案

有一个名为 sun.misc.Unsafe ,很多是真的。但它没有在Java代码中使用指针(因为Java没有指针,虽然我同意java引用在概念上类似),但大多数是使用本机代码实现的。

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.

正如我在评论中提到的,这不是公共API的一部分,不应被客户端代码使用。但是,当你在 Atomic * 类的来源时,你可以看到它的工作原理。 6 / docs / api / index.html?java / util / concurrent / atomic / package-summary.html> java.util.concurrent.atomic

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.

这篇关于是否存在“指针”的概念。或“不安全代码”或在Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆