Giter VIP home page Giter VIP logo

mini-jvm's Introduction

CircleCIGitHubGitHub commit activityGitHub last commit

使用 Java 8 实现 JVM

特性

元循环(Metacircular)

mini-jvm on mini-jvm on hotspot. 可以在 mini-jvm 里运行 mini-jvm .

$ java -jar jvm-core/target/mini-jvm.jar -jar jvm-core/target/mini-jvm.jar -jar test.jar
# Hello World!

动机

  1. 尝试了解 JVM 原理, Learning by doing
  2. 纸上得来终觉浅, 实践
  3. 用简单的代码帮助 Javaer 理解 JVM

快速体验 [Macos 用户]

Hello world

brew tap guxingke/repo && brew install mini-jvm

cat <<EOF > HelloWorld.java
public class HelloWorld {
  public static void main(String[] args) {
    if (args.length == 0) {
      System.out.println("hello");
      return;
    }

    for(int i = 0; i < args.length; i ++) {
      System.out.println(args[i]);
    }
  }
}
EOF

javac HelloWorld.java

# no args
mini-jvm HelloWold
# => hello

# with program args
mini-jvm HelloWold hello mini-jvm
# =>  hello
# =>  mini-jvm

# 输入 mini-jvm -help 了解更多.

快速体验 [其他操作系统]

需要自行下载打包. Dev

规划

  • Class 文件解析 90%
  • 字节码执行 90%
  • 类加载 90%
  • 方法调用 90%
  • 实例化 90%
  • Native 方法 90%
  • 异常处理 60%
  • self-booting 70%

局限

  1. 不实现 GC
  2. 不实现多线程

变更记录

  • 实现了元循环(Metacircular)
  • 反射特性基本可用
  • 增加简单的调试器 bin/jdb.
  • 支持 Lambda 调用, closure, currying 可用.
  • Hello World 级别可用

个人记录

建议

  • 在JDK1.8.0_121环境下发现编译不过的情况,详情见#25,本项目的目的是学习JVM,为了项目足够小,清晰和易于理解,并不打算做各种适配工作,建议大家在MacOSX,Maven 3.3+,JDK 1.8.0_192+下学习;

联系作者

微信群

加个人微信 `guxingke_`,备注 mini-jvm 拉你进群。

参考

其他

新项目地址 mini-jvm_x, 使用多种语言实现。

mini-jvm's People

Contributors

brycelee avatar deepbreath avatar et-stack avatar guxingke avatar hesherya avatar

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.