From e9ad27fcdcb59be573ffd20811e82bced7c78948 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 12 Dec 2024 18:53:33 +0000 Subject: [PATCH] 8339313: 32-bit build broken Reviewed-by: coleenp, mbaesken, szaldana --- .../NoClassDefFoundError/libNoClassDefFoundErrorTest.c | 9 +++++++++ test/hotspot/jtreg/serviceability/sa/libupcall.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/exceptionMsgs/NoClassDefFoundError/libNoClassDefFoundErrorTest.c b/test/hotspot/jtreg/runtime/exceptionMsgs/NoClassDefFoundError/libNoClassDefFoundErrorTest.c index 023f299a5d4..ad2a85ec0ba 100644 --- a/test/hotspot/jtreg/runtime/exceptionMsgs/NoClassDefFoundError/libNoClassDefFoundErrorTest.c +++ b/test/hotspot/jtreg/runtime/exceptionMsgs/NoClassDefFoundError/libNoClassDefFoundErrorTest.c @@ -47,6 +47,7 @@ Java_NoClassDefFoundErrorTest_callFindClass(JNIEnv *env, jclass klass, jstring c static char* giant_string() { +#ifdef _LP64 size_t len = ((size_t)INT_MAX) + 3; char* c_name = malloc(len * sizeof(char)); if (c_name != NULL) { @@ -54,6 +55,14 @@ static char* giant_string() { c_name[len - 1] = '\0'; } return c_name; +#else + /* On 32-bit, gcc warns us against using values larger than ptrdiff_t for malloc, + * memset and as array subscript. Since the chance of a 2GB allocation to be + * successful is slim (would typically reach or exceed the user address space + * size), lets just not bother. Returning NULL will cause the test to be silently + * skipped. */ + return NULL; +#endif } JNIEXPORT jboolean JNICALL diff --git a/test/hotspot/jtreg/serviceability/sa/libupcall.c b/test/hotspot/jtreg/serviceability/sa/libupcall.c index 2139e717fef..210c03587f1 100644 --- a/test/hotspot/jtreg/serviceability/sa/libupcall.c +++ b/test/hotspot/jtreg/serviceability/sa/libupcall.c @@ -22,11 +22,12 @@ */ #include +#include typedef void (*upcall_func)(void); JNIEXPORT void JNICALL Java_LingeredAppWithFFMUpcall_callJNI(JNIEnv *env, jclass cls, jlong upcallAddr) { - upcall_func upcall = (upcall_func)upcallAddr; + upcall_func upcall = (upcall_func)(uintptr_t)upcallAddr; upcall(); }