{"id":16599221,"url":"https://github.com/collabh/jdk-source-read","last_synced_at":"2026-06-29T19:32:15.762Z","repository":{"id":105164267,"uuid":"231624064","full_name":"collabH/jdk-source-read","owner":"collabH","description":"学习jvm和分析阅读jdk源码","archived":false,"fork":false,"pushed_at":"2020-06-10T15:04:41.000Z","size":17643,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-03T03:44:49.724Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/collabH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-01-03T16:24:27.000Z","updated_at":"2021-08-09T10:34:26.000Z","dependencies_parsed_at":"2024-01-22T10:55:18.180Z","dependency_job_id":null,"html_url":"https://github.com/collabH/jdk-source-read","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/collabH/jdk-source-read","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fjdk-source-read","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fjdk-source-read/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fjdk-source-read/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fjdk-source-read/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/collabH","download_url":"https://codeload.github.com/collabH/jdk-source-read/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabH%2Fjdk-source-read/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34941026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T00:10:43.043Z","updated_at":"2026-06-29T19:32:15.756Z","avatar_url":"https://github.com/collabH.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# boolean类型在Jvm中的表示\n```text\nboolean类型支持true和false俩种值，但是jvm是无法识别这两种值的，因此在 Java 虚拟机规范中，\nboolean 类型则被映射成 int 类型。具体来说，“true”被映射为整数 1，而“false”被映射为整数 0。\n这个编码规则约束了 Java 字节码的具体实现。\n```\n# Java是如何进行算数运算的？\n```text\n了解到jvm一般是利用栈帧的操作数栈来进行算数运算的，jvm会将堆上的byte、boolean、char、short类型的数\n加载到操作数栈中，并且按照int类型来进行运算，因此boolean、char这些类型需要做零扩展，例如，char的大小为两字节。\n在加载的时候char的值会被复制到int的低二字节，高二字节则会用0来填充。又比如对于short两字节数来说根据符号为来进行\nint扩展，如果为正int高2位补0，否则补1。至于为什么操作数栈要存储int类型的数据，经过资料得到的解释是为：主要是变长数组不好控制，\n所以就选择浪费一些空间，以便访问时直接通过下标来计算地址\n\n```\n# 类的加载过程\n```text\n加载是指查找字节流，并且据此创建类的过程。加载需要借助类加载器，在 Java 虚拟机中，类加载器使用了双亲委派模型，即接收到加载请求时，会先将请求转发给父类加载器。\n\n链接，是指将创建成的类合并至 Java 虚拟机中，使之能够执行的过程。链接还分验证、准备和解析三个阶段。其中，解析阶段为非必须的。\n\n初始化，则是为标记为常量值的字段赋值，以及执行 \u003c clinit \u003e 方法的过程。类的初始化仅会被执行一次，这个特性被用来实现单例的延迟初始化。\n```\n# Jvm方法表方面\n```text\n虚方法调用包括 invokevirtual 指令和 invokeinterface 指令。如果这两种指令所声明的目标方法被标记为 final，那么 Java 虚拟机会采用静态绑定。否则，Java 虚拟机将采用动态绑定，在运行过程中根据调用者的动态类型，来决定具体的目标方法。\n\nJava 虚拟机的动态绑定是通过方法表这一数据结构来实现的。方法表中每一个重写方法的索引值，与父类方法表中被重写的方法的索引值一致。在解析虚方法调用时，Java 虚拟机会纪录下所声明的目标方法的索引值，并且在运行过程中根据这个索引值查找具体的目标方法。\n\nJava 虚拟机中的即时编译器会使用内联缓存来加速动态绑定。Java 虚拟机所采用的单态内联缓存将纪录调用者的动态类型，以及它所对应的目标方法。\n\n当碰到新的调用者时，如果其动态类型与缓存中的类型匹配，则直接调用缓存的目标方法。否则，Java 虚拟机将该内联缓存劣化为超多态内联缓存，在今后的执行过程中直接使用方法表进行动态绑定。\n```\n# jdk8源码分析\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollabh%2Fjdk-source-read","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcollabh%2Fjdk-source-read","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollabh%2Fjdk-source-read/lists"}