This site requires JavaScript, please enable it in your browser!
Greenfoot back
danpost
danpost wrote ...

2012/7/29

Bug in Greenfoot 2.2.1 using removeObjects(null)

danpost danpost

2012/7/29

#
Terminal Window Error Message wrote...
java.lang.NullPointerException at greenfoot.World.removeObjects(World.java:446) at __SHELL0.run(__SHELL0.java:9) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at greenfoot.localdebugger.LocalDebugger$QueuedExecution.run(LocalDebugger.java:267) at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:465) at greenfoot.core.Simulation.maybePause(Simulation.java:279) at greenfoot.core.Simulation.runContent(Simulation.java:210) at greenfoot.core.Simulation.run(Simulation.java:203)
While editing scenario, left-clicked on world for drop-down of available methods; selected removeObjects(Collection) and entered 'null' in the input box for the parameter and got the output above.
davmac davmac

2012/7/29

#
Hmm, the docs say: Parameters: objects - A list of Actors to remove "null" isn't a list, so I think this classifies as passing invalid input to a method - in which case an exception is pretty much an expected result.
SPower SPower

2012/7/29

#
He might have thought it works the same like getObjects, but obviously, it isn't :). @danpost, this should work:
removeObjects(getObjects(null));
danpost danpost

2012/7/29

#
Sorry, I did not think it through well enough. I know you will not say it, so I will: I should have caught on to that!
danpost danpost

2012/7/29

#
@SPower, I think that was my confusion. But your suggestion would not do for the way I am using it (read how I am using the method in my initial post of this 'should never have been' discussion).
You need to login to post a reply.