Java-变量名或标识符存储在哪里,堆栈或堆? [英] Java- Where does the variable name or Identifier gets stored, Stack or Heap?

查看:347
本文介绍了Java-变量名或标识符存储在哪里,堆栈或堆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标识符或变量名在Java中的哪里存储?我知道对象会存储在堆中,变量会存储在堆或栈中,具体取决于变量的类型和范围.我们可以调试或编写任何程序来确认它吗?

Where does the identifiers or variable name gets stored in java? I understand that objects get stored in heap and variable gets store in heap or stack depending on the type and scope of variable. Can we debug or write any program to confirm it?

感谢&问候

推荐答案

字段的名称作为类元数据的一部分存储在以前的PermGen now-Metaspace中.

Names of fields are stored as part of the class metadata, in formerly-PermGen now-Metaspace.

数组元素没有名称,只有数字. (提示Patrick McGoohan.)

Array elements don't have names, only numbers. (Cue Patrick McGoohan.)

方法和构造函数参数的名称以及局部变量和处理程序参数的名称仅存储在类文件的调试符号信息中(如果选择了该选项). JVM不需要它们,因为编译器已将它们映射到字节码中使用的堆栈帧插槽号.

Names of method and constructor parameters and local variables and handler parameters are stored only in the debug-symbols info in the classfile, if that option is selected. They aren't needed by the JVM because the compiler has mapped them to stack-frame slot numbers used in the bytecode.

这篇关于Java-变量名或标识符存储在哪里,堆栈或堆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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