Skip to content

Commit 4efbfb5

Browse files
PfarrerBrian Pfretzschner
andauthored
Fetch Runtime before Tests in Github actions
* Fetch Runtime before Tests in Github actions * update script * cargo fmt --------- Co-authored-by: Brian Pfretzschner <[email protected]>
1 parent f1b0a62 commit 4efbfb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+363
-201
lines changed

.github/workflows/rust-build-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
- name: Build
2020
run: cargo build
2121

22+
- name: Fetch Java Runtime
23+
run: ./fetch_runtime.sh
24+
2225
- name: Run tests
2326
run: cargo test
2427

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See it in action:
1313
- [x] Initialize VM & Runtime
1414
- [x] Run simple HelloWorld
1515

16-
- [ ] Java 11
16+
- [x] Java 11
1717
- [x] Parse Classfiles
1818
- [x] Initialize VM & Runtime
19-
- [ ] Run simple HelloWorld
19+
- [x] Run simple HelloWorld

cli/src/execute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::path::PathBuf;
22

33
use loader::CompositeLoader;
44
use model::vm::VmThread;
5+
use rt::bootstrap_vm;
56
use tracing::Level;
67
use vm::vm_thread::VmTheadImpl;
7-
use rt::bootstrap_vm;
88

99
const MAIN_METHOD_NAME: &str = "main";
1010
const MAIN_METHOD_SIGNATURE: &str = "([Ljava/lang/String;)V";

cli/src/main.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
extern crate prettytable;
33

44
use clap::{Parser, Subcommand};
5+
use std::path::PathBuf;
56
use tracing::{level_filters::LevelFilter, Level};
67
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
7-
use std::path::PathBuf;
88

99
mod execute;
1010
mod list_classes;
@@ -51,7 +51,13 @@ fn main() {
5151
class_paths,
5252
vm_init_log_level,
5353
vm_exec_log_level,
54-
} => execute::run(main_class, class_paths, vm_init_log_level, vm_exec_log_level, set_log_level_fn),
54+
} => execute::run(
55+
main_class,
56+
class_paths,
57+
vm_init_log_level,
58+
vm_exec_log_level,
59+
set_log_level_fn,
60+
),
5561
};
5662
}
5763

@@ -64,7 +70,11 @@ fn tracing_init() -> impl Fn(Level) {
6470
.with(filter)
6571
.init();
6672

67-
move |level: Level| reload_handle.modify(|layer| {
68-
*layer = LevelFilter::from_level(level);
69-
}).unwrap()
70-
}
73+
move |level: Level| {
74+
reload_handle
75+
.modify(|layer| {
76+
*layer = LevelFilter::from_level(level);
77+
})
78+
.unwrap()
79+
}
80+
}

fetch_runtime.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ shopt -s inherit_errexit
44

55
mkdir -p ./rt/jmods/java.base
66

7-
podman run --rm -it --userns keep-id \
8-
--security-opt label=disable \
7+
docker run --rm \
8+
-u $(id -u "${USER}"):$(id -g "${USER}") \
99
-v "./rt/jmods/java.base:/tmp/out" \
1010
eclipse-temurin:11 \
1111
sh -c "jmod extract --dir /tmp/out /opt/java/openjdk/jmods/java.base.jmod"

parser/src/version.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ pub fn parse<T: Read>(reader: &mut T) -> Result<ClassVersion> {
1919
let major = util::read_u16(reader)?;
2020

2121
if major > SUPPORTED_MAJOR_VERSION {
22-
panic!("Unsupported Classfile version: {}.{} > {}.0.", major, minor, SUPPORTED_MAJOR_VERSION);
22+
panic!(
23+
"Unsupported Classfile version: {}.{} > {}.0.",
24+
major, minor, SUPPORTED_MAJOR_VERSION
25+
);
2326
}
2427

2528
Ok(ClassVersion { major, minor })

rt/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub fn make_classloader(parser: &impl Parser) -> impl Classloader {
1515
ClassfileLoader::open(rt_path, parser).unwrap()
1616
}
1717

18-
1918
pub fn bootstrap_vm(classloader: impl Classloader + 'static) -> Vm {
2019
let vm = new_vm(native::NativeClassloader {
2120
classloader: Box::new(classloader),
@@ -29,4 +28,4 @@ pub fn bootstrap_vm(classloader: impl Classloader + 'static) -> Vm {
2928
);
3029

3130
vm
32-
}
31+
}

rt/src/native/java_io_filedescriptor.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,30 @@ use vm::frame::VmFrameImpl;
44

55
pub fn get_method(_jvm_class: &JvmClass, class_method: &ClassMethod) -> Option<NativeMethod> {
66
match class_method.name.as_str() {
7-
"initIDs" => Some(init_ids), // ()V
7+
"initIDs" => Some(init_ids), // ()V
88
"getHandle" => Some(get_handle), // (I)J
99
"getAppend" => Some(get_append), // (I)Z
1010
_ => None,
1111
}
1212
}
1313

1414
/// ()V
15-
fn init_ids(_: &mut VmThread) {
16-
}
15+
fn init_ids(_: &mut VmThread) {}
1716

1817
/// (I)J
1918
fn get_handle(vm_thread: &mut VmThread) {
2019
let frame = vm_thread.frame_stack.last_mut().unwrap();
21-
20+
2221
let fd = frame.stack_pop_int();
2322
frame.stack_push(VmPrimitive::Long(fd as i64));
2423
}
2524

2625
/// (I)Z
2726
fn get_append(vm_thread: &mut VmThread) {
2827
let frame = vm_thread.frame_stack.last_mut().unwrap();
29-
28+
3029
let fd = frame.stack_pop_int();
3130

3231
trace!("Push Boolean true for getAppend of fd {}", fd);
3332
frame.stack_push(VmPrimitive::Boolean(true));
34-
}
33+
}

rt/src/native/java_io_fileinputstream.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ pub fn get_method(_jvm_class: &JvmClass, class_method: &ClassMethod) -> Option<N
88
}
99

1010
/// ()V
11-
fn init_ids(_: &mut VmThread) {
12-
}
11+
fn init_ids(_: &mut VmThread) {}

rt/src/native/java_io_fileoutputstream.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ use vm::frame::VmFrameImpl;
33

44
pub fn get_method(_jvm_class: &JvmClass, class_method: &ClassMethod) -> Option<NativeMethod> {
55
match class_method.name.as_str() {
6-
"initIDs" => Some(init_ids), // ()V
6+
"initIDs" => Some(init_ids), // ()V
77
"writeBytes" => Some(write_bytes), // ([BIIZ)V
88
_ => None,
99
}
1010
}
1111

1212
/// ()V
13-
fn init_ids(_: &mut VmThread) {
14-
}
13+
fn init_ids(_: &mut VmThread) {}
1514

1615
/// ([BIIZ)V
1716
fn write_bytes(vm_thread: &mut VmThread) {
@@ -30,12 +29,12 @@ fn write_bytes(vm_thread: &mut VmThread) {
3029

3130
let fd_instance = match fos_instance.fields.get("fd").unwrap() {
3231
&VmPrimitive::Objectref(ref rc_fd_instance) => rc_fd_instance.borrow(),
33-
a => panic!("Not implemented for {:?}", a)
32+
a => panic!("Not implemented for {:?}", a),
3433
};
3534

3635
match fd_instance.fields.get("fd").unwrap() {
3736
&VmPrimitive::Int(ref val) => val.clone(),
38-
a => panic!("Not implemented for {:?}", a)
37+
a => panic!("Not implemented for {:?}", a),
3938
}
4039
};
4140

0 commit comments

Comments
 (0)