Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] coverage, decompile, recompile

My apologies for claiming that decompiling did not receive attention. I was misinformed.

Also, I didn't mean to imply that AspectJ was at fault in incompatibility problems. IMHO most decompilers are not nearly as sophisticated or well-engineered as AspectJ. I'd place the fault with them.

Cheers,
Nick


On May 28, 2004, at 9:14 AM, Andrew Clement wrote:

We are down in the dirty details aren't we .... we fixed a
number of problems with decompilation in the run up to AspectJ1.2.  
AspectJ always generates valid bytecode but certain decompilers
(and even JVMs) aren't always compliant with the JVM spec and they
don't interpret the bytecode correctly or they make certain assumptions
when they see certain patterns.  The case below is an example that
I believe we have an open bug report on.  The code we are creating in
aspectOf() is simply to check there is a valid aspect instance
around.  The decompiler should have said:

<x-tad-smaller>    public static NameChecking aspectOf()</x-tad-smaller>
<x-tad-smaller>     {</x-tad-smaller>
<x-tad-smaller>         if(ajc$perSingletonInstance == null) </x-tad-smaller>
<x-tad-smaller>           throw new NoAspectBoundException(</x-tad-smaller>
<x-tad-smaller>             "org_codehaus_wadi_shared_NameChecking",</x-tad-smaller>
<x-tad-smaller>             ajc$initFailureCause);</x-tad-smaller>
<x-tad-smaller>           return ajc$perSingletonInstance;</x-tad-smaller>
<x-tad-smaller>     }</x-tad-smaller>

Andy.







<x-tad-smaller>Jules Gosnell <jules@xxxxxxxxxxxxxxxxxx></x-tad-smaller><x-tad-smaller> </x-tad-smaller>
<x-tad-smaller>Sent by: aspectj-users-admin@xxxxxxxxxxx</x-tad-smaller>
<x-tad-smaller>28/05/2004 16:40</x-tad-smaller>
<x-tad-smaller>Please respond to</x-tad-smaller>
<x-tad-smaller> aspectj-users</x-tad-smaller>
<x-tad-smaller>To</x-tad-smaller>
<x-tad-smaller>aspectj-users@xxxxxxxxxxx</x-tad-smaller>
<x-tad-smaller>cc</x-tad-smaller>
<x-tad-smaller>Subject</x-tad-smaller>
<x-tad-smaller>Re: [aspectj-users] coverage, decompile, recompile</x-tad-smaller>
<x-tad-smaller>Thanks for the suggestion, Ron.</x-tad-smaller>

<x-tad-smaller> I tried that. Things look a little better - I don't get the inner class </x-tad-smaller>
<x-tad-smaller> problem first anymore - but this one instead :</x-tad-smaller>


<x-tad-smaller> /home/jgosnell/cvs/wadi/src/java/org/codehaus/wadi/shared/NameChecking.java:33</x-tad-smaller>
<x-tad-smaller> error Syntax error, insert "AssignmentOperator ArrayInitializer" to </x-tad-smaller>
<x-tad-smaller> complete Expression</x-tad-smaller>
<x-tad-smaller> ajc$perSingletonInstance;</x-tad-smaller>
<x-tad-smaller> ^^^^^^^^^^^^^^^</x-tad-smaller>
<x-tad-smaller> /home/jgosnell/cvs/wadi/src/java/org/codehaus/wadi/shared/NameChecking.java:34</x-tad-smaller>
<x-tad-smaller> error Syntax error on token "Invalid Character", throw expected</x-tad-smaller>
<x-tad-smaller> if(ajc$perSingletonInstance == null) goto _L2; else goto _L1</x-tad-smaller>


<x-tad-smaller> The code at this point has decompiled to :</x-tad-smaller>

<x-tad-smaller>     public static NameChecking aspectOf()</x-tad-smaller>
<x-tad-smaller>     {</x-tad-smaller>
<x-tad-smaller>         ajc$perSingletonInstance;    // < line 33</x-tad-smaller>
<x-tad-smaller>         if(ajc$perSingletonInstance == null) goto _L2; else goto _L1</x-tad-smaller>
<x-tad-smaller> _L1:</x-tad-smaller>
<x-tad-smaller>         return;</x-tad-smaller>
<x-tad-smaller> _L2:</x-tad-smaller>
<x-tad-smaller>         throw new </x-tad-smaller>
<x-tad-smaller> NoAspectBoundException("org_codehaus_wadi_shared_NameChecking",</x-tad-smaller>
<x-tad-smaller> ajc$initFailureCause);</x-tad-smaller>
<x-tad-smaller>     }</x-tad-smaller>

<x-tad-smaller>     public static boolean hasAspect()</x-tad-smaller>
<x-tad-smaller>     {</x-tad-smaller>
<x-tad-smaller>         return ajc$perSingletonInstance != null;</x-tad-smaller>
<x-tad-smaller>     }</x-tad-smaller>


<x-tad-smaller> Line 33 looks very dodgy :-(. It looks like a variable declaration with </x-tad-smaller>
<x-tad-smaller> no type... JAD bug ?</x-tad-smaller>

<x-tad-smaller> I'm using :</x-tad-smaller>

<x-tad-smaller> aspectj1.2 for the original compile and recompile step.</x-tad-smaller>
<x-tad-smaller> jad v1.5.8e for the decompilation.</x-tad-smaller>


<x-tad-smaller> Should this sort of thing work, or am I wasting my time ?</x-tad-smaller>

<x-tad-smaller> Thanks for any help.</x-tad-smaller>


<x-tad-smaller> Jules</x-tad-smaller>



<x-tad-smaller> DiFrango, Ron wrote:</x-tad-smaller>
<x-tad-smaller> > Jules,</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > This is a known problem with AspectJ.  The following link should get you to</x-tad-smaller>
<x-tad-smaller> > the bug report:</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> >                  https://bugs.eclipse.org/bugs/show_bug.cgi?id=46298</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > One alternative approach you could take is to re-name your .aj files to</x-tad-smaller>
<x-tad-smaller> > .java and the aspectj compiler will work fine.</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Ron</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > -----Original Message-----</x-tad-smaller>
<x-tad-smaller> > From: Jules Gosnell [mailto:jules@xxxxxxxxxxxxxxxxxx]</x-tad-smaller>
<x-tad-smaller> > Sent: Friday, May 28, 2004 10:32 AM</x-tad-smaller>
<x-tad-smaller> > To: aspectj-users@xxxxxxxxxxx</x-tad-smaller>
<x-tad-smaller> > Subject: [aspectj-users] coverage, decompile, recompile</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Because AspectJ compiles directly from .aj to .class with no </x-tad-smaller>
<x-tad-smaller> > intermediate .java stage, I am currently thwarted in my efforts to run </x-tad-smaller>
<x-tad-smaller> > e.g. Clover over my codebase to do coverage testing.</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Clover only understands Java (AFAIK).</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > I guess this must be the situation for a number of useful tools.</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > I recently had the idea of compiling .aj to .class, decompiling .class </x-tad-smaller>
<x-tad-smaller> > to .java and then recompiling .java back to .class with clover...</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Needless to say this was wishful thinking (I used the latest JAD, which </x-tad-smaller>
<x-tad-smaller> > wasn't happy with the version of my class files). The first </x-tad-smaller>
<x-tad-smaller> > recompilation error, of many, turned out to be an inner class that had </x-tad-smaller>
<x-tad-smaller> > got lost - further investiation revealed that jad had failed to </x-tad-smaller>
<x-tad-smaller> > decompile it :</x-tad-smaller>
<x-tad-smaller> >  </x-tad-smaller>
<x-tad-smaller> > WEB-INF/classes/org/codehaus/wadi/jetty/Manager$HouseKeeper.class...The</x-tad-smaller>
<x-tad-smaller> > class file version is 48.0 (only 45.3, 46.0 and 47.0 are supported)</x-tad-smaller>
<x-tad-smaller> >   Generating jad/org/codehaus/wadi/jetty/Manager$HouseKeeper.java</x-tad-smaller>
<x-tad-smaller> > Couldn't resolve all access$ methods in method run</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Has anyone else tried anything like this ?</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Is it possible to decompile Aspectj programs back into Java, or do they </x-tad-smaller>
<x-tad-smaller> > contain untranslatable bytecode ?</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Is there a better decompiler around ?</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Cheers,</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > Jules</x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>
<x-tad-smaller> > </x-tad-smaller>


<x-tad-smaller> -- </x-tad-smaller>
<x-tad-smaller> /**********************************</x-tad-smaller>
<x-tad-smaller>  * Jules Gosnell</x-tad-smaller>
<x-tad-smaller>  * Partner</x-tad-smaller>
<x-tad-smaller>  * Core Developers Network (Europe)</x-tad-smaller>
<x-tad-smaller>  *</x-tad-smaller>
<x-tad-smaller>  *    www.coredevelopers.net</x-tad-smaller>
<x-tad-smaller>  *</x-tad-smaller>
<x-tad-smaller>  * Open Source Training & Support.</x-tad-smaller>
<x-tad-smaller>  **********************************/</x-tad-smaller>

<x-tad-smaller> _______________________________________________</x-tad-smaller>
<x-tad-smaller> aspectj-users mailing list</x-tad-smaller>
<x-tad-smaller> aspectj-users@xxxxxxxxxxx</x-tad-smaller>
<x-tad-smaller> http://dev.eclipse.org/mailman/listinfo/aspectj-users</x-tad-smaller>



Back to the top