Skip to content

Commit af3ff3a

Browse files
committed
Add missing exception class constructors
1 parent eab5314 commit af3ff3a

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

java_runtime/src/classes/java/io/eof_exception.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use alloc::vec;
22

3-
use crate::RuntimeClassProto;
3+
use java_class_proto::JavaMethodProto;
4+
use jvm::{ClassInstanceRef, Jvm, Result};
5+
6+
use crate::{classes::java::lang::String, RuntimeClassProto, RuntimeContext};
47

58
// class java.io.EOFException
69
pub struct EOFException;
@@ -11,8 +14,29 @@ impl EOFException {
1114
name: "java/io/EOFException",
1215
parent_class: Some("java/io/IOException"),
1316
interfaces: vec![],
14-
methods: vec![],
17+
methods: vec![
18+
JavaMethodProto::new("<init>", "()V", Self::init, Default::default()),
19+
JavaMethodProto::new("<init>", "(Ljava/lang/String;)V", Self::init_with_message, Default::default()),
20+
],
1521
fields: vec![],
1622
}
1723
}
24+
25+
async fn init(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<()> {
26+
tracing::debug!("java.io.EOFException::<init>({:?})", &this);
27+
28+
let _: () = jvm.invoke_special(&this, "java/io/IOException", "<init>", "()V", ()).await?;
29+
30+
Ok(())
31+
}
32+
33+
async fn init_with_message(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>, message: ClassInstanceRef<String>) -> Result<()> {
34+
tracing::debug!("java.io.EOFException::<init>({:?}, {:?})", &this, &message);
35+
36+
let _: () = jvm
37+
.invoke_special(&this, "java/io/IOException", "<init>", "(Ljava/lang/String;)V", (message,))
38+
.await?;
39+
40+
Ok(())
41+
}
1842
}

java_runtime/src/classes/java/io/file_not_found_exception.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use alloc::vec;
22

3-
use crate::RuntimeClassProto;
3+
use java_class_proto::JavaMethodProto;
4+
use jvm::{ClassInstanceRef, Jvm, Result};
5+
6+
use crate::{classes::java::lang::String, RuntimeClassProto, RuntimeContext};
47

58
// class java.io.FileNotFoundException
69
pub struct FileNotFoundException;
@@ -11,8 +14,29 @@ impl FileNotFoundException {
1114
name: "java/io/FileNotFoundException",
1215
parent_class: Some("java/io/IOException"),
1316
interfaces: vec![],
14-
methods: vec![],
17+
methods: vec![
18+
JavaMethodProto::new("<init>", "()V", Self::init, Default::default()),
19+
JavaMethodProto::new("<init>", "(Ljava/lang/String;)V", Self::init_with_message, Default::default()),
20+
],
1521
fields: vec![],
1622
}
1723
}
24+
25+
async fn init(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<()> {
26+
tracing::debug!("java.io.FileNotFoundException::<init>({:?})", &this);
27+
28+
let _: () = jvm.invoke_special(&this, "java/io/IOException", "<init>", "()V", ()).await?;
29+
30+
Ok(())
31+
}
32+
33+
async fn init_with_message(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>, message: ClassInstanceRef<String>) -> Result<()> {
34+
tracing::debug!("java.io.FileNotFoundException::<init>({:?}, {:?})", &this, &message);
35+
36+
let _: () = jvm
37+
.invoke_special(&this, "java/io/IOException", "<init>", "(Ljava/lang/String;)V", (message,))
38+
.await?;
39+
40+
Ok(())
41+
}
1842
}

0 commit comments

Comments
 (0)