[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: note: JasminClass change



Hi Pat,

Actually, it still doesn't work -- I guess we just didn't test it properly. If I do:

$ echo HelloWorld java.lang.Object | xargs transform-full

eventually I get:

java.lang.Object.jasmin:3: Warning - Syntax error.
.method
        ^
java.lang.Object.jasmin:3: Error - Couldn't repair and continue parse.
.method
        ^
./sootOutput-full/java.lang.Object.jasmin: Found 2 errors

I tried adding an else clause after your changes like so:

if(sootClass.hasSuperclass())
    emit(".super " + slashify(sootClass.getSuperclass().getName()));
else
  emit(".super");

but that didn't work either. If you look at the jasmin grammar in jasmin-sable-1.2/src/jasmin/parser.cup, you'll see at line 126:

/* The grammar */

jas_file ::=
        source_spec
        class_spec
        super_spec
        implements
        class_attrs
        fields
        methods
    ;

and at line 205:

// ---- Superclass specification

super_spec ::=
    DSUPER classname:name SEP
        {:
            classFile.setSuperClass(name);
        :}
  ;

I think the grammar forces you to specify a superclass. I don't really know how much effort is required to fix jasmin; the best way seems to be to change the grammar so that a solitary '.super' means set a super_class field of 0 (or you could try and use some invalid classname). I couldn't see any trivial solution from the handful of files in jas and jasmin that I looked at. There's some binary code at the beginning of parser.java which looks like it would need to change if you changed the grammar.

A simpler solution might be to repass any written java.lang.Object classfiles back through Coffi and have it change the super_class field; that's what I'm doing by hand for now anyway.

Cheers,
Chris

Note to others: we also found that the [Ljava.lang.Object problem has gone away in the Soot trunk.

Patrick LAM wrote:
Hi all,

I thought I'd get this archived:

Chris Pickett asked soot-list a question a long time ago about Soot's
generation of java.lang.Object classes (e.g. when transforming CLASSPATH).
I looked into it today and noticed that JasminClass always generates a
.super java/lang/Object declaration even if the superclass field is not
set.  I changed this so that it wouldn't generate a .super declaration
anymore.  I have a vague fear that there was a reason the .super
declaration was there, but not enough to avoid making this change.  But
in case it breaks anything, you can talk to me about it.

pat

---------- Forwarded message ----------
Date: Wed, 21 Apr 2004 17:44:42 -0400 (EDT)
From: plam-sable.svn <owner-soot-repos-commits@sable.mcgill.ca>
To: soot-repos-commits@sable.mcgill.ca
Subject: r1430: in soot/trunk/src/soot: baf jimple

Author: plam
Date: 2004-04-21 17:44:38 -0400 (Wed, 21 Apr 2004)
New Revision: 1430

Log:
1. replace SootClass parameter with sootClass parameter (bad naming!)
2. do not emit .super java/lang/Object for java.lang.Object class
     in jasmin output


Modified: soot/trunk/src/soot/baf/JasminClass.java soot/trunk/src/soot/jimple/JasminClass.java