Giter Site home page Giter Site logo

pjh0x0 / jvm-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 33.57 MB

License: MIT License

C++ 54.55% C 35.43% CMake 2.06% Java 0.14% Starlark 0.52% Shell 0.55% HTML 0.03% SCSS 0.04% Python 3.16% Batchfile 0.01% Makefile 0.25% Perl 2.41% M4 0.85% XSLT 0.01%

jvm-demo's Introduction

项目介绍

这是一个基于《自己动手写Java虚拟机》的C++实现,用于学习Java虚拟机的实现原理。

项目构建

依赖

  • cmake version >= 3.11.0
  • C++11
  • jdk 1.8

构建

mkdir build
cmake -B build
cmake --build build

运行

确定jdk 1.8已经安装,然后执行,并且找到对应的jre路径,替换下面的路径

# /usr/lib/jvm/java-8-openjdk-amd64/jre需要替换成对应的jre路径
# -cp tests/javasample/需要替换成对应的class文件路径,这里是javasample目录
./build/java -Xjre /usr/lib/jvm/java-8-openjdk-amd64/jre -cp tests/javasample/ com.sample.ch06.MyObject

coredump

由于项目不是特别稳定,可能会出现崩溃,可以通过下面的命令查看coredump

ulimit -c unlimited

Linux下默认的coredump地址是/var/lib/apport/coredump, macos下默认的coredump地址是/cores/

# 查看coredump,/cores/core.1234需要替换成对应的coredump路径
lldb -c /cores/core.1234

项目结构

libs

用于存放第三方库,目前有glog和ziplib,glog用于日志输出,ziplib用于读取jar文件

src

用于存放实现的源代码

  • classfile: 解析class文件,包括常量池、字段、方法、属性等
  • classpath: 查找class文件,包括目录、zip文件、jar文件等,同时也包括读取class文件到内存
  • instructions: 实现字节码指令
  • native : 实现本地方法
  • runtime : 实现运行时数据区,包括线程、栈、帧、局部变量表、操作数栈等
  • runtime/heap: 实现堆内存,包括对象、数组、方法区等

tests

用于存放测试代码

  • javasample: 用于测试书中java demo
  • googletest: gtest三方库代码
  • src: 单元测试代码

jvm-demo's People

Contributors

pjh0x0 avatar

Watchers

 avatar

jvm-demo's Issues

Refactor重构代码

如何设计方法区内存空间,运行时常量拷贝,代码段和属性内存的拷贝

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.