method is null

Project:JNode Core
Category:bug report

in some contexts some methods are null and cant be invoced. Invocation fails with NPE.

for example, PriorityQueue::add present, but PriorityQueue::offer does not. PriorityQueue::add delegates PriorityQueue::offer (just calls it).

If i call PriorityQueue::add, NPE happens in PriorityQueue::add at calling offer. If i call PriorityQueue::offer, NPE happens in my code.

Is it a bug or for some contexts "magic list" of compiled classes/methods required?


Could you be more speciffic about the context where you see this problem?


I used it in VmScheduler::addToSleepQueue like this:

try {
} finally {

exception will be in PriorityQueue::add when it calls PriorityQueue::offer.

If i write

try {
} finally {

Exception happens in my code at line when i call offer.


I think you should try with PriorityQueue something similiar to what is done to ArrayList and HashMap.
VmScheduler is instantiated build time and used runtime and so are the objects directly refrenced by it. This creates delicate problems.
My sugestion: please investigate org.jnode.util.BootabeArrayList and org.jnode.util.BootableHashMap and based on them try to create a BootablePriorityQueue and try to use this instead of the original PriorityQueue.
There are only a few places where this trick is needed but for instance if you replace in the JNode sources a useplace of BootableArrayList with ArrayList you will hit a similar problem. Pay special attention to the method verifyBeforeEmit().


Also strange: if i use PriorityQueue in constructor of VmScheduler, it works and no any NPE's..


Yes, BootablePriorityQueue works well.
I guess objects in this context created during building and serialized. And during boot they de-serialized. But, why so strange NPE?


And, whats a problem with java.util.* ? why do not need to make BootableString, BootableVmThreadQueue, etc.?


I wonder if this a consequence of the "flakiness" I described in the following issue.

Bear in mind that I didn't (and still don't) really understand the boot image loader, so my theories about it could be totally wrong. (And the original issue is "moot" of course, as explained by other comments.)