From fd1d46cb7fe882b7acc0462ffb33aff6290c7150 Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Sun, 13 Jul 2014 18:50:53 -0700 Subject: [PATCH] pass ClassInfo instead of class name to getMethod --- classes.js | 8 +++----- frame.js | 6 ++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/classes.js b/classes.js index 45e4de47..19897b3e 100644 --- a/classes.js +++ b/classes.js @@ -89,7 +89,7 @@ Classes.prototype.getClass = function(caller, className) { return this.getArrayClass(caller, className); if (!!(classInfo = this.loadClassFile(className + ".class"))) { classInfo.staticFields = {}; - var clinit = this.getMethod(caller, className, "", "()V", true); + var clinit = this.getMethod(caller, classInfo, "", "()V", true); if (clinit) caller.invoke(clinit); classInfo.constructor = function () { @@ -128,10 +128,8 @@ Classes.prototype.setStaticField = function(caller, className, fieldName, value) this.getClass(caller, className).staticFields[fieldName] = value; } -Classes.prototype.getMethod = function(caller, className, methodName, signature, staticFlag) { - console.log(className, methodName, signature); - // Only force initialization when accessing a static method. - var classInfo = this.getClass(caller, className); +Classes.prototype.getMethod = function(caller, classInfo, methodName, signature, staticFlag) { + console.log(classInfo.className, methodName, signature); var methods = classInfo.methods; for (var i=0; i", "(Ljava/lang/String;)V", false); + var ctor = CLASSES.getMethod(this, ex.class, "", "(Ljava/lang/String;)V", false); this.stack.push(ex); this.stack.push(message); this.invoke(ctor); @@ -983,11 +983,13 @@ Frame.prototype.invokestatic = Frame.prototype.invokevirtual = Frame.prototype.i } var cp = this.cp; + var className = cp[cp[cp[idx].class_index].name_index].bytes; var methodName = cp[cp[cp[idx].name_and_type_index].name_index].bytes; var signature = cp[cp[cp[idx].name_and_type_index].signature_index].bytes; - var method = CLASSES.getMethod(this, className, methodName, signature, op === OPCODES.invokestatic); + var classInfo = CLASSES.getClass(this, className); + var method = CLASSES.getMethod(this, classInfo, methodName, signature, op === OPCODES.invokestatic); this.invoke(method); }