From c855224d141799959540a8d9e3f36d9269ddff1a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 17 Jan 2011 09:36:03 -0700 Subject: [PATCH] fix VM abort when ClassLoader.defineClass is used in bootimage build When loading a class which extends another class that contained a field of primitive array type using defineClass in a bootimage=true build, the VM was unable to find the primitive array class, and makeArrayClass refused to create one since it should already have existed. The problem was that the bootimage=true build uses an empty Machine::BootstrapClassMap, and resolveArrayClass expected to find the primitive array classes there. The fix is to check the Machine::BootLoader map if we can't find it in Machine::BootstrapClassMap. --- src/machine.cpp | 11 ++++++++++- test/DefineClass.java | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/machine.cpp b/src/machine.cpp index 1fade5edbe..14ad1632c7 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1835,7 +1835,16 @@ resolveArrayClass(Thread* t, object loader, object spec, bool throw_) return c; } else { - return makeArrayClass(t, loader, spec, throw_); + PROTECT(t, loader); + PROTECT(t, spec); + + c = findLoadedClass(t, root(t, Machine::BootLoader), spec); + + if (c) { + return c; + } else { + return makeArrayClass(t, loader, spec, throw_); + } } } diff --git a/test/DefineClass.java b/test/DefineClass.java index 0b72cd5b95..ad98028b91 100644 --- a/test/DefineClass.java +++ b/test/DefineClass.java @@ -72,6 +72,7 @@ public class DefineClass { public abstract static class Base { public int foo; + public int[] array; public void bar() { }