Since Jenkins 2.580, two annotations let plugin developers declare whether a transient field should participate in XStream deserialization.
-
The annotation @XStreamNotDeserializable marks a transient field as not participating in XStream deserialization.
-
The annotation @XStreamDeserializable marks a transient field as participating in XStream deserialization (e.g., for migration of configuration to different fields as part of #readResolve).
By default, Jenkins allows fields lacking these annotations to be deserialized (i.e., @XStreamDeserializable has no effect), but a future version of Jenkins is expected to invert this default so that transient fields are skipped unless opted in.
Administrators can set the Java system property hudson.util.RobustReflectionConverter.TRANSIENT_FIELD_STRICT_MODE to true to invert the default behavior.
This will break potential backward compatibility support code processing transient fields not already annotated with @XStreamDeserializable.
Plugin compatibility (simple-name matching)
While these annotations are not yet available in LTS releases, Jenkins also recognizes the annotations by their simple name only, so plugins can define their own copies without updating their core dependency:
// In your plugin: com.example.myplugin.XStreamNotDeserializable
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface XStreamNotDeserializable {}
// In your plugin: com.example.myplugin.MyConfig
public class MyConfig {
@XStreamNotDeserializable
private transient String runtimeComputedValue;
}
This is temporary and will be removed once the annotations have been available in LTS releases for a while, so plugin developers should switch to the official annotations as soon as practical.