This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Application (GC) stuck in "_Jv_MarkArray" when doing "klass->getName();"
You somehow want to move the getName call out of the collector. Calling
it from GC_dump() or a partial clone, and then calling that from a
debugger or the client code should work. Just printing klass and then
using a debugger to perform the getName() call should also work. As
should dumping the klass values into a static buffer, and then later
traversing it and performing the getName call.
I made a terrible hack, caching the array when gc'ing and then dumping
the stuff in the next call to "_Jv_GCTotalMemory".
But that reveal much, since it was just an array of "java.lang.Object".
The next thing is to invoke "toString()" on the elements, so I may get
an idea of what they consist of...
However, that does not work (at least not the way I'm doing it). Now I'm
stuck there.
It seems invoking either toString() or getClass() on the array elements,
just makes the current thread hang... Is there any reason (besides maybe
it has been garbage collected?) that this should not work?
My hacked _Jv_GCTotalMemory looks something like the following, where
"men_analyseThis" is a "void*" cached in "_Jv_MarkArray" when discovered
there.
long _Jv_GCTotalMemory (void) {
if ( men_analyseThis )
{
jobjectArray array = (jobjectArray) men_analyseThis;
_Jv_VTable *dt = *(_Jv_VTable **) men_analyseThis;
jclass klass = dt->clas;
int arrayLength = JvGetArrayLength (array);
printf( "MEN: length: %d\n", arrayLength );
for (int i = 0; i < arrayLength; ++i) {
jobject obj = elements (array)[i];
if ( obj )
{
jstring toString;
printf( "MEN 1\n" );
toString = = obj->toString();
printf( "MEN 2\n" );
--- 8< 8< 8< ---
// Martin