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 Hans Søndergaard <hs...@VitusBering.dk> on 2006/11/15 08:25:50 UTC
Manipulate new in a class file using BCEL?
In the Ravenscar-Java Profile the garbage collector is disabled (Ravenscar-Java is a subset of RTSJ (Real-Time Specification of Java)).
Instead of using the heap when running, a periodic thread has attached some physical memory, called scoped memory, when allocating memory for new objects.
This scoped memory works like a stack.
I already have access to physical memory.
My question is:
Is it possible to use BCEL to malipulate the class file (new, newarray, ..) so that a new object is created on a particular address in this scoped memory?
A piece of code could look like this:
MemoryArea localMem = new Memory(1024); // allocate 1024 bytes
Runnable localLogic = new Runnable()
{
public void run()
{
...
/* if new objects are created in this scope of the run method,
they must be allocated in localMem
*/
...
}
};
for (;;)
{
localMem.enter(localLogic);
PeriodicThread.waitForNextPeriod();
}
When enter is called any objects created by new are created in localMem (not on the heap).
When enter goes out of scope, the localMem is re-initialised to empty, - just as a stack works.
Regards
Hans Sondergaard
http://www.cs.aau.dk/ravenscar/
Re: Manipulate new in a class file using BCEL?
Posted by Martin Schoeberl <ma...@jopdesign.com>.
>Is it possible to use BCEL to malipulate the class file (new, newarray, ..) so >that a new object is created on a particular
>address in this scoped memory?
You can substitute each new or newarray in BCEL with e.g., a invokation
of a static method where you implement your scoped memory version of
new.
The main issue is: Do you know the object layout of your target JVM?
The internal structure (handles or not)?
This is not a BCEL property, but it depends on your JVM.
Furthermore you need a low-level (native) function to directly
manupulate the memory (heap).
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org