It looks like the InitShim class was missed in the resolution to #756 and #792. I am using Immutables 2.7.1 and have an @Immutable object with a couple of @Default annotated getters. A special note here is that the InitShim class seems to only be generated if you have 2+ @Default methods.
import org.immutables.value.Value.Default;
import org.immutables.value.Value.Immutable;
@Immutable
public abstract class Foo {
public abstract String getString();
@Default
public Integer getI() {
return 1;
}
@Default
public Long getL() {
return 1L;
}
}
Generates this class (lots of code snipped out to only show the relevant pieces):
/**
* Immutable implementation of {@link Foo}.
* <p>
* Use the builder to create immutable instances:
* {@code ImmutableFoo.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated("org.immutables.processor.ProxyProcessor")
@org.immutables.value.Generated(from = "Foo", generator = "Immutables")
@Immutable
@CheckReturnValue
public final class ImmutableFoo extends Foo {
// <SNIP/>
private final class InitShim {
// <SNIP/>
}
// <SNIP/>
/**
* Builds instances of type {@link ImmutableFoo ImmutableFoo}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* <p><em>{@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.</em>
*/
@org.immutables.value.Generated(from = "Foo", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
// <SNIP/>
}
}
The InitShim, and any other internal class that Immutables may generate, should have the @org.immutables.value.Generated(from = "Foo", generator = "Immutables") annotation added.
yep, make sense need to find all such inner classes and make sure they are annotated. Thanks for spotting this!
I've found more nested classes that needs to be annotated with org.immutables.value.Generated.
*.GsonAdapters*.*NamingFields*.GsonAdapters*.*TypeAdapter*.*Repository.Criteria*.*Repository.Finder*.*Repository.Modifier*.*Repository.Replacer*.*Repository.Serialization*.*Repository.*NamingFieldsPlease review my Pull Request #854.
@before Yep, I was a bit lazy to go over other generators, thank you for the PR!
Most helpful comment
yep, make sense need to find all such inner classes and make sure they are annotated. Thanks for spotting this!