Setting outer variable from anonymous inner class

Java doesn’t know that doWork is going to be synchronous and that the stack frame that result is in will still be there. You need to alter something that isn’t in the stack.

I think this would work

 final Long[] result = new Long[1];

and then

 result[0] = st.getLong(4);

in execute(). At the end, you need to return result[0];

Leave a Comment