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                        
  /  / /\ \ \/ / [EMAIL PROTECTED]            
 /  /  \_\/\  /  http://www.markcrocker.com/~mcrocker
/__/ /\ \ \_\/   ------------------------------------
\  \ \_\/        
 \  \ \          
  \__\/          


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to