From 0800508b4e924e4f1dd5825e484347f861578c20 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 10 May 2014 18:52:41 -0600 Subject: [PATCH] move Runtime.freeMemory and totalMemory to builtin.cpp This allows them to be shared between the Avian and Android class library builds. This commit also disables the URL test in Misc.java on Android, since it's known to fail, and we still want to know whether the other tests pass. --- src/builtin.cpp | 14 ++++++++++++++ src/classpath-avian.cpp | 14 -------------- test/Misc.java | 13 +++++++++++-- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 72ef2ee4f3..356d02e6ce 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -302,6 +302,20 @@ Avian_java_lang_Runtime_exit t->m->system->exit(arguments[1]); } +extern "C" AVIAN_EXPORT int64_t JNICALL +Avian_java_lang_Runtime_freeMemory +(Thread* t, object, uintptr_t*) +{ + return t->m->heap->remaining(); +} + +extern "C" AVIAN_EXPORT int64_t JNICALL +Avian_java_lang_Runtime_totalMemory +(Thread* t, object, uintptr_t*) +{ + return t->m->heap->limit(); +} + extern "C" AVIAN_EXPORT int64_t JNICALL Avian_avian_avianvmresource_Handler_00024ResourceInputStream_getContentLength (Thread* t, object, uintptr_t* arguments) diff --git a/src/classpath-avian.cpp b/src/classpath-avian.cpp index f5b36f3d97..b7e2299adc 100644 --- a/src/classpath-avian.cpp +++ b/src/classpath-avian.cpp @@ -571,20 +571,6 @@ Avian_java_lang_Runtime_gc collect(t, Heap::MajorCollection); } -extern "C" AVIAN_EXPORT int64_t JNICALL -Avian_java_lang_Runtime_freeMemory -(Thread* t, object, uintptr_t*) -{ - return t->m->heap->remaining(); -} - -extern "C" AVIAN_EXPORT int64_t JNICALL -Avian_java_lang_Runtime_totalMemory -(Thread* t, object, uintptr_t*) -{ - return t->m->heap->limit(); -} - extern "C" AVIAN_EXPORT void JNICALL Avian_java_lang_Runtime_addShutdownHook (Thread* t, object, uintptr_t* arguments) diff --git a/test/Misc.java b/test/Misc.java index e339b5bf9e..ef78345a56 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -298,8 +298,14 @@ public class Misc { throw new RuntimeException(e); } - expect(new URL("http://oss.readytalk.com") - .getHost().equals("oss.readytalk.com")); + // as of this writing, we don't support URLs on Android, since it + // pulls in a third-party library we don't include: + if (! "http://www.android.com/".equals + (System.getProperty("java.vendor.url"))) + { + expect(new URL("http://oss.readytalk.com") + .getHost().equals("oss.readytalk.com")); + } expect(java.util.Arrays.equals (new byte[] { 0, 0, 0, 0 }, @@ -336,6 +342,9 @@ public class Misc { expect(System.getProperty("buzzy.buzzy.bim.bam").equals ("yippy yappy yin yang")); + + // just test that it's there; don't care what it returns: + Runtime.getRuntime().totalMemory(); } protected class Protected { }