[jboss-user] [Javassist] - Changing array fields into java.util.concurrent.atomic.AtomicReferenceArray

Christoph Angerer do-not-reply at jboss.com
Tue Feb 22 13:24:26 EST 2011


Christoph Angerer [http://community.jboss.org/people/chmaruni] created the discussion

"Changing array fields into java.util.concurrent.atomic.AtomicReferenceArray"

To view the discussion, visit: http://community.jboss.org/message/589069#589069

--------------------------------------------------------------
Hi,

I am trying to replace fields of array type into fields of type java.util.concurrent.atomic.AtomicReferenceArray


My approach was like this:
1) change the field type through CtField.setType()
2) redirect reads/writes to arrays to static methods using CodeConverter.replaceArrayAccess(). In the static methods I would call the AtomicReferenceArray.set() and .get() methods.
3) rewrite array new bytecodes to calls to new java.util.concurrent.atomic.AtomicReferenceArray()

Besides several more or less small problems (e.g., I would have to rewrite local arrays and method signatures, too) my biggest problem is in step 3. I was trying inside ExprEditor.edit(NewArray a) something like: a.replace("$_ = new java.util.concurrent.atomic.AtomicReferenceArray(" + dim + ");");

However, this does not work because the javassist bytecode checks the type and sees that AtomicReferenceArray is not an array. Which is true, but since I will rewrite subsequent array accesses, too, I think that should be fine.

So my question(s) is (are): Does anybody have experience with something as intrusive as replacing all arrays in a program with a non-array object and if yes, is there any code out there from which I could learn or which I could use? If not, does anybody have an idea how I could make the third step work without the javassist compiler complaining about the type?

Thanks in advance for your time and effort!
Christoph
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/589069#589069]

Start a new discussion in Javassist at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2062]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110222/a65f866d/attachment.html 


More information about the jboss-user mailing list