-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fields generated by @Memoized
should be excluded automatically
#181
Comments
Are you able to decompile the bytecode into Java and post it here? (I don't have any means of doing this myself because I'm currently in the process of moving overseas) |
This class: @AutoValue
public abstract class Foo {
@Memoized
public String foo() {
return "foo";
}
} generates @Generated("com.google.auto.value.processor.AutoValueProcessor")
abstract class $AutoValue_Foo extends Foo {
$AutoValue_Foo(
) {
}
@Override
public String toString() {
return "Foo{"
+ "}";
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (o instanceof Foo) {
return true;
}
return false;
}
@Override
public int hashCode() {
int h = 1;
return h;
}
} and @Generated("com.google.auto.value.extension.memoized.MemoizeExtension")
final class AutoValue_Foo extends $AutoValue_Foo {
private volatile String foo;
AutoValue_Foo() {
super();
}
@Override
public String foo() {
if (foo == null) {
synchronized (this) {
if (foo == null) {
foo = super.foo();
if (foo == null) {
throw new NullPointerException("foo() cannot return null");
}
}
}
}
return foo;
}
} The field always has the same name as the method. If the field is nullable or primitive this is generated: @Generated("com.google.auto.value.extension.memoized.MemoizeExtension")
final class AutoValue_Foo extends $AutoValue_Foo {
private volatile String foo;
private volatile boolean foo$Memoized;
AutoValue_Foo() {
super();
}
@Override
@Nullable
public String foo() {
if (!foo$Memoized) {
synchronized (this) {
if (!foo$Memoized) {
foo = super.foo();
foo$Memoized = true;
}
}
}
return foo;
}
} |
It's a workaround, but for now you could exclude all @ProcessorConfig(
options = @PaperParcel.Options(
excludeModifiers = { Modifier.TRANSIENT, Modifier.STATIC, Modifier.VOLATILE }
)
) |
Yeah, that's what I did now. Ideally this issue should be fixed: google/auto#406 |
This class:
Will generate a field called
someMethod
that unfortunately isn't transient so PaperParcel complains. Ideally they should be excluded automatically.The text was updated successfully, but these errors were encountered: