Update java-basic-questions-01.md#2882
Closed
JasonZhangZx wants to merge 1 commit into
Closed
Conversation
静态成员变量在方法区(元空间),下文还有2个插图也描述的是堆
daltino
approved these changes
Jul 12, 2026
daltino
left a comment
There was a problem hiding this comment.
The change clarifies an important distinction regarding the location of static variables in memory, correcting the explanation for versions after JDK 1.7 by specifying the "method area" instead of the heap. This update improves the technical accuracy of the documentation.
Snailclimb
requested changes
Jul 19, 2026
Snailclimb
left a comment
Owner
There was a problem hiding this comment.
感谢修正这段说明,不过当前替换后的表述仍不准确,麻烦再调整后提交:
- HotSpot 的永久代是在 JDK 8 才移除,而不是 JDK 1.7;
- OpenJDK 的 JEP 122 说明,移除永久代后,类静态变量移至 Java 堆,类元数据移至本地内存;
- “方法区”是 JVM 规范中的逻辑运行时区域,不能直接替代这里关于 HotSpot 实现存储位置的描述。
建议将这一小节整体改为区分“JVM 规范的逻辑概念”和“HotSpot 在不同 JDK 版本的实现”,并一并核对 PR 描述中提到的两张插图。参考:https://openjdk.org/jeps/122
Owner
|
感谢反馈!你指出原文需要修正这一点是对的,不过当前 PR 将静态字段改成“一直存放在方法区”仍不准确:方法区是 JVM 规范中的逻辑概念;对于 HotSpot,JDK 8 移除永久代后,类静态字段位于 Java 堆,类元数据则进入本地内存中的元空间。 主分支目前已经将这段内容改为:静态字段的存储属于 JVM 实现细节,并明确说明 JDK 8 及之后的 HotSpot 中静态字段位于 Java 堆,同时修正了相关上下文。因此这个 PR 已被主分支上的更完整修改覆盖,我这边将其关闭。再次感谢你帮助发现原文问题! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
静态成员变量在方法区(元空间),下文还有2个插图也描述的是堆