Fixes PR126.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Thu, 2 Apr 2009 15:45:14 +0000 (17:45 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Thu, 2 Apr 2009 15:45:14 +0000 (17:45 +0200)
* 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
src/vm/options.c
src/vm/options.h

index 083f00b30a7f8d2e6fa034fa7dc286af018de523..2dd8dac9feeabf7c6ced20ea9e317c696b8fc6ce 100644 (file)
@@ -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);
 
index 7ead267c6ef226f565a64d5ebd62b6508efdf35f..cc94d11cd966cd7907fa403f4359e72b6296eaac 100644 (file)
@@ -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, <value> 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;
index 18c1c0013ebe8e04af82c0b06544a5f953b11d5c..a5b6932703867c9b4877f9a7c3795167cc4007e6 100644 (file)
@@ -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;