final AnimComposer animComposer=new AnimComposer();
spatial.addControl(animComposer);
animComposer.addAnimClip(new AnimClip("anim"));
animComposer.setCurrentAction("anim");
produces:
java.lang.NullPointerException
at com.jme3.anim.tween.action.ClipAction.doInterpolate(ClipAction.java:25)
at com.jme3.anim.tween.action.BlendableAction.interpolate(BlendableAction.java:52)
at com.jme3.anim.AnimComposer.controlUpdate(AnimComposer.java:277)
at com.jme3.scene.control.AbstractControl.update(AbstractControl.java:111)
at com.jme3.scene.Spatial.runControlUpdate(Spatial.java:737)
at com.jme3.scene.Spatial.updateLogicalState(Spatial.java:880)
at com.jme3.scene.Node.updateLogicalState(Node.java:242)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:261)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:153)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:193)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:234)
at java.base/java.lang.Thread.run(Thread.java:832)
Your expectations are true. The getControl method should return the same object that you already have in the code you posted. I suspect the code you posted isn’t the whole story, though.
When do you call the getControl method? Is it some time later (in the next frame or more)?
Can you post both the code that works and the code that doesn’t without removing code you think is in-necessary? Just a simple “this works if you run it, and this doesn’t” example. It will help determine the difference in why calling the same method on the same object works, and why it doesn’t.