在寻求源代码时:数组的clone()方法在哪里实现? [英] In quest of source code: where is the clone() method of arrays implemented?

查看:85
本文介绍了在寻求源代码时:数组的clone()方法在哪里实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

new String[] { "foo", "bar" }.clone();

使用我最喜欢的IDE(例如Eclipse),我想通过 Ctrl-单击来查看上述clone()方法的源代码(照常),但是它带我进入了Object的本机代码,仅提供签名而不提供方法的正文.

With my favorite IDE (i.e. Eclipse), I wanted to see the source code of the above clone() method by Ctrl-clicking on it (as usual), but it brought me to the Object's native one, which provides only the signature and not the body of the method.

自动完成功能告诉我,所述clone()方法属于String类(clone() : String[] - String),但是String类的源代码未提供这种方法(因为我正在处理与String[]类...).

The autocomplete told me that the said clone() method belonged to the String class (clone() : String[] - String), but the source code of the String class doesn't provide such a method (since I'm dealing with the String[] class...).

那么,该实现隐藏在哪里?自动完成功能应该修复吗?

So, where is that implementation hiding? Should the autocomplete be fixed?

推荐答案

克隆数组的代码在JVM中(这是本机方法).对于热点,它位于 jvm.cpp .

The code for cloning an array is in the JVM (it is a native method). For hotspot, it is around lines 550/560 of jvm.cpp.

这篇关于在寻求源代码时:数组的clone()方法在哪里实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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