From 60db8cc047df0cb8f175c449ed454edff31ed058 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 8 Apr 2011 18:46:43 -0600 Subject: [PATCH] add some commented-out debug code to defineClass When uncommented, this code will write each defined class to disk, which allows one to examine e.g. dynamically-generated classes using e.g. javap. --- src/machine.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index a4bf4c1d0e..bc6d1bdf63 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -4287,12 +4287,25 @@ defineClass(Thread* t, object loader, const uint8_t* buffer, unsigned length) PROTECT(t, loader); object c = parseClass(t, loader, buffer, length); + + // char name[byteArrayLength(t, className(t, c))]; + // memcpy(name, &byteArrayBody(t, className(t, c), 0), + // byteArrayLength(t, className(t, c))); + // replace('/', '-', name); - if (c) { - PROTECT(t, c); + // const unsigned BufferSize = 1024; + // char path[BufferSize]; + // snprintf(path, BufferSize, "/tmp/avian-define-class/%s.class", name); - saveLoadedClass(t, loader, c); - } + // FILE* file = fopen(path, "wb"); + // if (file) { + // fwrite(buffer, length, 1, file); + // fclose(file); + // } + + PROTECT(t, c); + + saveLoadedClass(t, loader, c); return c; }