Search code examples
serializationinstall4j

Should we always set object back to the context in Install4j?


As described in http://blog.ej-technologies.com/2012/06/migrating-to-install4j-51.html

The variable writing to context should be serialisable and it's because the elevated action need it. The question is that, say, we have an object holding some variable for us, and is saved in the context

{var1:1, var2:true}

When we update var1, do we need to always set the object back to context? or is it safe to just update the object directly and get it later in other script.


Solution

  • So the question is, does the elevated helper

    A) retrieve variables each time the variable is accessed

    or

    B) is the variable transmitted to elevated helper when it is set via context.setVariable()

    The answer is B. Installer variables only live in the unelevated process. Each time a variable value is needed in the elevated helper, it requests it from the unelevated process. The variable value is never cached in the elevated helper.