Manipulate new in a class file using BCEL?

Hans Søndergaard <[email protected]> Wed, 15 Nov 2006 08:25:50 +0100
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
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/