Skip to content

Commit bd46b14

Browse files
committed
Add ByteArrayOutputStream::size
1 parent 6c2e41d commit bd46b14

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl ByteArrayOutputStream {
1919
JavaMethodProto::new("<init>", "(I)V", Self::init_with_size, Default::default()),
2020
JavaMethodProto::new("write", "(I)V", Self::write, Default::default()),
2121
JavaMethodProto::new("toByteArray", "()[B", Self::to_byte_array, Default::default()),
22+
JavaMethodProto::new("size", "()I", Self::size, Default::default()),
2223
JavaMethodProto::new("close", "()V", Self::close, Default::default()),
2324
],
2425
fields: vec![
@@ -84,6 +85,14 @@ impl ByteArrayOutputStream {
8485
Ok(dest.into())
8586
}
8687

88+
async fn size(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<i32> {
89+
tracing::debug!("java.io.ByteArrayOutputStream::size({:?})", &this);
90+
91+
let pos: i32 = jvm.get_field(&this, "pos", "I").await?;
92+
93+
Ok(pos)
94+
}
95+
8796
async fn close(_jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<()> {
8897
tracing::debug!("java.io.ByteArrayOutputStream::close({this:?})");
8998

0 commit comments

Comments
 (0)