You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by Igor Maznitsa <ig...@igormaznitsa.com> on 2003/05/26 03:33:05 UTC

the StackMap attribute

Terve BCEL!

 How to use the StackMap attribute in BCEL? Could anyone show a simple
 source example? I have interest to change an exist Java class what
 contains methods with the attribute and I'd like to know how to update
 the attribute when I have changed the code of a method...

-------------
Igor Maznitsa      Monday, May 26, 2003
                   5:29:51 AM


Cell    +7 812 9422891
HomePage:  http://www.igormaznitsa.com
EMail      igor.maznitsa@igormaznitsa.com


---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org


Re: the StackMap attribute

Posted by Mark Crocker <mc...@markcrocker.com>.
On Mon, 26 May 2003 05:33:05 +0400, Igor Maznitsa wrote:

I'm so sorry that this reply has taken so long, but I've been busy :)

>  How to use the StackMap attribute in BCEL? Could anyone show a simple
>  source example? I have interest to change an exist Java class what
>  contains methods with the attribute and I'd like to know how to update
>  the attribute when I have changed the code of a method...

BCEL doesn't have any facilities for creating a new StackMap.  The StackMap is there because they exist in J2ME MIDP class files and BCEL needs a structure to read the data into and write it back out from.

Creating a StackMap from scratch is difficult.  Calculating the StackMapEntry's requires a complex, iterative data flow analysis.  To complicate things, Sun's preverifier has a number of bugs, so any StackMap generator would have to emulate Sun's bugs in order to work reliably.

Even when you know what StackMapEntry's you want to include in a StackMap object, it is not entirely trivial to create the instance because you need to do all sorts of calculations to figure out the parameters in the constructor.  In addition, you need to make sure that the ConstantPool has an entry for "StackMap".  If this is all you want, I can post some code examples of how to do this.

The open source version of the Purifier1 project (see http://www.markcrocker.com/~mcrocker/Computer/Purifier/) does was an attempt to create a substitute for Sun's preverifier, and, consequently, it does calculate and create StackMaps.  However, the first attempt failed to duplicate all of Sun's idiosyncrasies because the Purifier1 project attempted to speed up the horrifically intensive calculations required of the data flow analysis by using a different analysis technique.  Although the technique is MUCH faster, it did not always (~95%) produce the same results as Sun's preverifier.  At that point, funding ran out and the project was moved to a commercial venture with an algorithm that follows Sun's algorithm more closely.  The commercial version is mostly done, but has not been polished up for release and the project release date has not been set yet.

The open source version, Purifier1, is available by email request only.  This is because the algorithm in that version cannot be used to reliably preverify a class and I don't want to be distributing broken code for general use.  If you're still interested in the code for academic reasons or have some business proposal, then I'll be glad to send you a copy.


           __    
     __   / /\   
    /  /\/ / /_  ------------------------------------
   /  /  \/ / /\ Mark Crocker                        
  /  / /\ \ \/ / mcrocker@markcrocker.com            
 /  /  \_\/\  /  http://www.markcrocker.com/~mcrocker
/__/ /\ \ \_\/   ------------------------------------
\  \ \_\/        
 \  \ \          
  \__\/          


---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org