forked from dlunch/RustJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_concat_exception.rs
More file actions
37 lines (31 loc) · 1.41 KB
/
Copy pathstring_concat_exception.rs
File metadata and controls
37 lines (31 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use alloc::vec;
use jvm::{ClassInstanceRef, Jvm, Result};
use jvm_class_proto::JavaMethodProto;
use jvm_types::{ClassAccessFlags, MethodAccessFlags};
use crate::{RuntimeClassProto, RuntimeContext, classes::java::lang::String};
// class java.lang.invoke.StringConcatException
// Only the constructor `Jvm::exception` calls: this class exists to be the cause of the
// BootstrapMethodError a mismatched string concat recipe raises (jvm-bytecode/src/interpreter.rs).
pub struct StringConcatException;
impl StringConcatException {
pub fn as_proto() -> RuntimeClassProto {
RuntimeClassProto {
name: "java/lang/invoke/StringConcatException",
parent_class: Some("java/lang/Exception"),
interfaces: vec![],
methods: vec![JavaMethodProto::new(
"<init>",
"(Ljava/lang/String;)V",
Self::init_with_message,
MethodAccessFlags::PUBLIC,
)],
fields: vec![],
access_flags: ClassAccessFlags::PUBLIC,
}
}
async fn init_with_message(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>, message: ClassInstanceRef<String>) -> Result<()> {
tracing::debug!("java.lang.invoke.StringConcatException::<init>({this:?}, {message:?})");
jvm.invoke_special(&this, "java/lang/Exception", "<init>", "(Ljava/lang/String;)V", (message,))
.await
}
}