From 63aa269f8f97ed853c98af7b0ae3da84a1c23422 Mon Sep 17 00:00:00 2001 From: Michael Starzinger Date: Thu, 2 Apr 2009 17:45:14 +0200 Subject: [PATCH] Fixes PR126. * src/vm/loader.cpp (load_class_from_classloader): Correct faulty classloader behavior. * src/vm/options.c: Added option flag for -XX:+PrintWarnings. * src/vm/options.h: Likewise. --- src/vm/loader.cpp | 13 +++++++++++++ src/vm/options.c | 7 +++++++ src/vm/options.h | 1 + 3 files changed, 21 insertions(+) diff --git a/src/vm/loader.cpp b/src/vm/loader.cpp index 083f00b30..2dd8dac9f 100644 --- a/src/vm/loader.cpp +++ b/src/vm/loader.cpp @@ -2,6 +2,7 @@ Copyright (C) 1996-2005, 2006, 2007, 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2009 Theobroma Systems Ltd. This file is part of CACAO. @@ -1188,6 +1189,18 @@ classinfo *load_class_from_classloader(utf *name, classloader_t *cl) c = tmpc; } + else { + // Expected behavior for the classloader is to throw an exception + // and never return NULL. If the classloader shows a different + // behavior, we are correcting it here (see PR126). + if (exceptions_get_exception() == NULL) { +#if !defined(NDEBUG) + if (opt_PrintWarnings) + log_message_utf("load_class_from_classloader: Correcting faulty classloader behavior (PR126) for ", name); +#endif + exceptions_throw_classnotfoundexception(name); + } + } RT_TIMING_GET_TIME(time_cache); diff --git a/src/vm/options.c b/src/vm/options.c index 7ead267c6..cc94d11cd 100644 --- a/src/vm/options.c +++ b/src/vm/options.c @@ -190,6 +190,7 @@ int opt_InlineMinSize = 0; #endif #endif int opt_PrintConfig = 0; +int opt_PrintWarnings = 0; int opt_ProfileGCMemoryUsage = 0; int opt_ProfileMemoryUsage = 0; FILE *opt_ProfileMemoryUsageGNUPlot = NULL; @@ -254,6 +255,7 @@ enum { OPT_InlineMaxSize, OPT_InlineMinSize, OPT_PrintConfig, + OPT_PrintWarnings, OPT_ProfileGCMemoryUsage, OPT_ProfileMemoryUsage, OPT_ProfileMemoryUsageGNUPlot, @@ -321,6 +323,7 @@ option_t options_XX[] = { #endif #endif { "PrintConfig", OPT_PrintConfig, OPT_TYPE_BOOLEAN, "print VM configuration" }, + { "PrintWarnings", OPT_PrintWarnings, OPT_TYPE_BOOLEAN, "print warnings about suspicious behavior"}, { "ProfileGCMemoryUsage", OPT_ProfileGCMemoryUsage, OPT_TYPE_VALUE, "profiles GC memory usage in the given interval, is in seconds (default: 5)" }, { "ProfileMemoryUsage", OPT_ProfileMemoryUsage, OPT_TYPE_VALUE, "TODO" }, { "ProfileMemoryUsageGNUPlot", OPT_ProfileMemoryUsageGNUPlot, OPT_TYPE_VALUE, "TODO" }, @@ -735,6 +738,10 @@ void options_xx(JavaVMInitArgs *vm_args) opt_PrintConfig = enable; break; + case OPT_PrintWarnings: + opt_PrintWarnings = enable; + break; + case OPT_ProfileGCMemoryUsage: if (value == NULL) opt_ProfileGCMemoryUsage = 5; diff --git a/src/vm/options.h b/src/vm/options.h index 18c1c0013..a5b693270 100644 --- a/src/vm/options.h +++ b/src/vm/options.h @@ -212,6 +212,7 @@ extern int opt_InlineMinSize; #endif #endif extern int opt_PrintConfig; +extern int opt_PrintWarnings; extern int opt_ProfileGCMemoryUsage; extern int opt_ProfileMemoryUsage; extern FILE *opt_ProfileMemoryUsageGNUPlot; -- 2.25.1