Throw a pre-fabricated NoClassDefFoundError.
When a class loader tries to load a class, it first asks its parent to
look for it. This continues up the chain until the bootstrap class loader
is reached. If the class can't be found, the bootstrap loader throws a
NoClassDefFoundError. As a result, we're throwing at least one exception
for every class we load that doesn't come from the bootstrap path.
This change creates a "stock" NoClassDefFoundError exception with a trivial
stack trace and throws that instead, saving the overhead of creating and
initializing the exception object.
I think the only way that anyone will see this is if they try to
load a class directly from the bootstrap loader, in which case the
ClassNotFoundException will show the canned NCDFE as the cause. I
don't think any useful diagnostic information is being lost.
diff --git a/vm/Init.c b/vm/Init.c
index 3663745..f546dab 100644
--- a/vm/Init.c
+++ b/vm/Init.c
@@ -1211,7 +1211,7 @@
* Do some "late" initialization for the memory allocator. This may
* allocate storage and initialize classes.
*/
- if (!dvmGcLateInit())
+ if (!dvmCreateStockExceptions())
goto fail;
/*