Skip to content

Commit 28fd95c

Browse files
committed
Add ByteArrayOutputStream::reset
1 parent bd46b14 commit 28fd95c

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
@@ -20,6 +20,7 @@ impl ByteArrayOutputStream {
2020
JavaMethodProto::new("write", "(I)V", Self::write, Default::default()),
2121
JavaMethodProto::new("toByteArray", "()[B", Self::to_byte_array, Default::default()),
2222
JavaMethodProto::new("size", "()I", Self::size, Default::default()),
23+
JavaMethodProto::new("reset", "()V", Self::reset, Default::default()),
2324
JavaMethodProto::new("close", "()V", Self::close, Default::default()),
2425
],
2526
fields: vec![
@@ -93,6 +94,14 @@ impl ByteArrayOutputStream {
9394
Ok(pos)
9495
}
9596

97+
async fn reset(jvm: &Jvm, _: &mut RuntimeContext, mut this: ClassInstanceRef<Self>) -> Result<()> {
98+
tracing::debug!("java.io.ByteArrayOutputStream::reset({:?})", &this);
99+
100+
jvm.put_field(&mut this, "pos", "I", 0).await?;
101+
102+
Ok(())
103+
}
104+
96105
async fn close(_jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<()> {
97106
tracing::debug!("java.io.ByteArrayOutputStream::close({this:?})");
98107

0 commit comments

Comments
 (0)