Skip to content

Commit 0bbc791

Browse files
committed
Always call gc
1 parent 3cbc605 commit 0bbc791

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

java_runtime/src/classes/java/lang/runtime.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ impl Runtime {
5252
Ok(0x100000) // TODO: hardcoded
5353
}
5454

55-
async fn gc(_: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Runtime>) -> Result<()> {
56-
tracing::warn!("stub java.lang.Runtime::gc({:?})", &this);
55+
async fn gc(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Runtime>) -> Result<()> {
56+
tracing::debug!("java.lang.Runtime::gc({:?})", &this);
57+
58+
jvm.collect_garbage()?;
5759

5860
Ok(())
5961
}

java_runtime/src/classes/java/lang/system.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,7 @@ impl System {
9696
async fn gc(jvm: &Jvm, _: &mut RuntimeContext) -> Result<()> {
9797
tracing::debug!("java.lang.System::gc()");
9898

99-
// TODO should be jvm arg
100-
let disable_explicit_gc_property: ClassInstanceRef<String> = jvm
101-
.invoke_static(
102-
"java/lang/System",
103-
"getProperty",
104-
"(Ljava/lang/String;)Ljava/lang/String;",
105-
(JavaLangString::from_rust_string(jvm, "rustjava.disable_explicit_gc").await?,),
106-
)
107-
.await?;
108-
109-
if disable_explicit_gc_property.is_null() || JavaLangString::to_rust_string(jvm, &disable_explicit_gc_property).await? != "true" {
110-
jvm.collect_garbage()?;
111-
}
99+
jvm.collect_garbage()?;
112100

113101
Ok(())
114102
}

0 commit comments

Comments
 (0)