Code Monkey home page Code Monkey logo

rjvm's Introduction

Andrea Bergia

Developer, gamer, cat lover, tea addict ๐Ÿ‡ฎ๐Ÿ‡น๐Ÿ‡ช๐Ÿ‡บ

Currently Sr Staff Engineer @ ServiceNow, working on the JavaScript scripting engine

Links

My website LinkedIn Twitter Instagram Mastodon

rjvm's People

Contributors

andreabergia avatar eltociear avatar jayvdb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rjvm's Issues

git lfs failed

Downloading vm/rt.jar (60 MB) Error downloading object: vm/rt.jar (bbdd2f5): Smudge error: Error downloading vm/rt.jar (bbdd2f5909ea77fa115f03a2b030f231cc4bf720528b0436f83459a2be429349): batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.

Expose more attributes

Generics

We need to parse generics correctly and to suppor them in the VM.

Classpath and class loaders

Need to support a concept of "classpath" in the vm.

Also, class loaders should be a hierarchy - not sure if this should be done at the same time as the classpath or not.

Threads

We need to support multiple threads.

Support arrays

The vm does not support arrays currently. We need to implement:

  • primitive arrays
  • object arrays
  • multidimensional arrays

Support long/double in the vm

We only support int and float. Long/double are complex because they take two slots in the local variables, but we need to handle them.

Access violation reading location

Test for Java Code:

package rjvm.test;

import java.io.PrintStream;

public class Test {
    public static void main(String[] args) {
        final PrintStream p = System.out;
    }
}
#[test_log::test]
fn invoke_test() {
    let mut vm = Vm::new(DEFAULT_MAX_MEMORY);

    let src_dir = env!("CARGO_MANIFEST_DIR");

    vm.append_class_path(&format!("{src_dir}/rt.jar;{src_dir}/tests/resources"))
        .expect("should be able to add entries to the classpath");

    let _ = invoke(
        &mut vm,
        "rjvm/test/Test",
        "main",
        "([Ljava/lang/String;)V",
    );
}

run result (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

Exceptions

The VM does not support exceptions currently.

how to implement this ?

there is a java method named "xxx" which calls a native function from native lib,
how to invoke xxx from rust side?

Unsound VM lifetime

VM has a lifetime 'a. This lifetime is arbitrary โ€“ it is chosen by the caller with no restrictions. This means it can outlive the VM, but other structs assume the VM is life for 'a. This is unsound.

Segfaulting example:

    let mut vm = create_base_vm(DEFAULT_MAX_MEMORY);
    let call_stack = vm.allocate_call_stack();
    let main_method = vm
        .resolve_class_method(
            call_stack,
            "rjvm/SimpleMain",
            "main",
            "([Ljava/lang/String;)V",
        )
        .expect("should find main method");
    drop(vm);
    println!("{main_method:?}");

Possible solutions:

  • Remove lifetime from VM. All methods that produce lifetimed objects take their lifetime from the reference to the VM.
  • Remove lifetime from VM. Keep VM in an Arc. Erase lifetimes internally. Don't hand out structs referencing VM memory directly, instead hand out a wrapper object that also contains a copy of the Arc (this can be transparent to the user).

Aastore null

Aastore cannot store nulls (trying to do so generates a ValidationException).

API allows using data managed by one VM with another VM (unsound)

The API allows data (CallStack, AbstractObject, ClassRefm โ€ฆ) managed by one VM to be used with another VM. This allows e.g. storing a pointer to an object on the heap of vm1 in a static field in the heap of vm2. If a garbage collection then triggers on vm1, the static field on vm2 now points to cleared/invalid data.

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.