rustjava_runtime/classes/java/util/
missing_format_width_exception.rs1use alloc::vec;
2
3use jvm::{ClassInstanceRef, Jvm, Result};
4use jvm_class_proto::{JavaFieldProto, JavaMethodProto};
5use jvm_types::{ClassAccessFlags, FieldAccessFlags, MethodAccessFlags};
6
7use crate::{RuntimeClassProto, RuntimeContext, classes::java::lang::String};
8
9pub struct MissingFormatWidthException;
11
12impl MissingFormatWidthException {
13 pub fn as_proto() -> RuntimeClassProto {
14 RuntimeClassProto {
15 name: "java/util/MissingFormatWidthException",
16 parent_class: Some("java/util/IllegalFormatException"),
17 interfaces: vec![],
18 methods: vec![
19 JavaMethodProto::new("<init>", "(Ljava/lang/String;)V", Self::init, MethodAccessFlags::PUBLIC),
20 JavaMethodProto::new(
21 "getFormatSpecifier",
22 "()Ljava/lang/String;",
23 Self::get_format_specifier,
24 MethodAccessFlags::PUBLIC,
25 ),
26 JavaMethodProto::new(
27 "getMessage",
28 "()Ljava/lang/String;",
29 Self::get_format_specifier,
30 MethodAccessFlags::PUBLIC,
31 ),
32 ],
33 fields: vec![JavaFieldProto::new("specifier", "Ljava/lang/String;", FieldAccessFlags::PRIVATE)],
34 access_flags: ClassAccessFlags::PUBLIC,
35 }
36 }
37
38 async fn init(jvm: &Jvm, _: &mut RuntimeContext, mut this: ClassInstanceRef<Self>, specifier: ClassInstanceRef<String>) -> Result<()> {
39 if specifier.is_null() {
40 return Err(jvm.exception("java/lang/NullPointerException", "specifier is null").await);
41 }
42 let _: () = jvm.invoke_special(&this, "java/util/IllegalFormatException", "<init>", "()V", ()).await?;
43 jvm.put_field(&mut this, "specifier", "Ljava/lang/String;", specifier).await
44 }
45
46 async fn get_format_specifier(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<ClassInstanceRef<String>> {
47 jvm.get_field(&this, "specifier", "Ljava/lang/String;").await
48 }
49}