Skip to content

Commit 73b7a5e

Browse files
committed
Add OutputStream::Flush
1 parent 80a08ad commit 73b7a5e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ impl DataOutputStream {
2424
JavaMethodProto::new("writeLong", "(J)V", Self::write_long, Default::default()),
2525
JavaMethodProto::new("writeChars", "(Ljava/lang/String;)V", Self::write_chars, Default::default()),
2626
JavaMethodProto::new("close", "()V", Self::close, Default::default()),
27+
JavaMethodProto::new("flush", "()V", Self::flush, Default::default()),
2728
],
2829
fields: vec![JavaFieldProto::new("out", "Ljava/io/OutputStream;", Default::default())],
2930
}
@@ -93,6 +94,15 @@ impl DataOutputStream {
9394

9495
Ok(())
9596
}
97+
98+
async fn flush(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<()> {
99+
tracing::debug!("java.io.DataInputStream::flush({:?})", &this);
100+
101+
let out = jvm.get_field(&this, "out", "Ljava/io/OutputStream;").await?;
102+
let _: () = jvm.invoke_virtual(&out, "flush", "()V", []).await?;
103+
104+
Ok(())
105+
}
96106
}
97107

98108
#[cfg(test)]

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl OutputStream {
1919
JavaMethodProto::new("write", "([B)V", Self::write_bytes, Default::default()),
2020
JavaMethodProto::new("write", "([BII)V", Self::write_bytes_offset, Default::default()),
2121
JavaMethodProto::new_abstract("write", "(I)V", Default::default()),
22+
JavaMethodProto::new("flush", "()V", Self::flush, Default::default()),
2223
],
2324
fields: vec![],
2425
}
@@ -60,4 +61,10 @@ impl OutputStream {
6061

6162
Ok(())
6263
}
64+
65+
async fn flush(_jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<()> {
66+
tracing::debug!("java.io.OutputStream::flush({:?})", &this);
67+
68+
Ok(())
69+
}
6370
}

0 commit comments

Comments
 (0)