Built-in OS conditions don't work in 5.0

Description

The implementation of built-in OS conditions has changed in 5.0, and no longer work. The platform type used on which an installer is compiled is always treated as the 'current platform' when the installer runs.

In 4.3 and earlier, the OS conditions were created as instances of JavaCondition, where the 'current platform' was evaluated at condition execution time, when a certain platform-specific field of the OsVersion class was checked. In 5.0, RulesEngineImpl.initStandardConditions() creates the OS conditions as anonymous inner classes when a RulesEngineImpl object is initialised. The 'current platform' for each instance is set at creation time.

I guess the original idea was that the OS conditions would be created dynamically every time an installer runs, so the 'current platform' would be whatever platform the installer runs on. However, these conditions are currently being serialised at compile time into the installer itself (see RulesEngine.resolveConditions(), only called from CompilerConfig.addConditions(IXMLElement)). This is shown also by the fact that the NotSerializableException occurs at compile-time.

So, built-in OS "ref" conditions in 5.0 are actually using a value for 'current platform' equal to platform used to compile the installer, not the platform on which the installer is running! Moving the creation of the platform conditions into a separate class (as in my original patch) might still be a good idea, for neatness, but it doesn't solve the actual problem! An API change is probably required to implement a proper solution.

Maybe a new interface StaticCondition could be used to mark conditions that are constructed statically every time IzPack runs (rather than serialised at compile-time). RulesEngineImpl would have to call, e.g. StaticCondition.getConditions() and then add all returned conditions to a staticConditionsMap. The resolution of referenced conditions in the ConditionReference API would also have to be changed, to take into account static conditions. Perhaps referenced conditions should be resolved at installation time, not compile time? Static conditions would need some kind of dependency injection to provide specific required objects (e.g. Platform, in the case of the OS conditions). I'll spend some time looking into this, until I hear otherwise.

Alternatively, the 4.3 implementation could be restored (or something similar) to replace the current implementation.

Environment

None

Assignee

Former user

Reporter

Former user

Impact

None

Components

Fix versions

Affects versions

Priority

Highest
Configure