|
| 1 | +use alloc::vec; |
| 2 | + |
| 3 | +use java_class_proto::JavaMethodProto; |
| 4 | +use jvm::{ClassInstanceRef, Jvm, Result}; |
| 5 | + |
| 6 | +use crate::{RuntimeClassProto, RuntimeContext, classes::java::lang::String}; |
| 7 | + |
| 8 | +// class java.lang.ArithmeticException |
| 9 | +pub struct ArithmeticException; |
| 10 | + |
| 11 | +impl ArithmeticException { |
| 12 | + pub fn as_proto() -> RuntimeClassProto { |
| 13 | + RuntimeClassProto { |
| 14 | + name: "java/lang/ArithmeticException", |
| 15 | + parent_class: Some("java/lang/RuntimeException"), |
| 16 | + interfaces: 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 | + ], |
| 21 | + fields: vec![], |
| 22 | + access_flags: Default::default(), |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + async fn init(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<()> { |
| 27 | + tracing::debug!("java.lang.ArithmeticException::<init>({:?})", &this); |
| 28 | + |
| 29 | + let _: () = jvm.invoke_special(&this, "java/lang/RuntimeException", "<init>", "()V", ()).await?; |
| 30 | + |
| 31 | + Ok(()) |
| 32 | + } |
| 33 | + |
| 34 | + async fn init_with_message(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>, message: ClassInstanceRef<String>) -> Result<()> { |
| 35 | + tracing::debug!("java.lang.ArithmeticException::<init>({:?}, {:?})", &this, &message); |
| 36 | + |
| 37 | + let _: () = jvm |
| 38 | + .invoke_special(&this, "java/lang/RuntimeException", "<init>", "(Ljava/lang/String;)V", (message,)) |
| 39 | + .await?; |
| 40 | + |
| 41 | + Ok(()) |
| 42 | + } |
| 43 | +} |
0 commit comments