Skip to content

Commit

Permalink
Make @AutoBuilder available unconditionally.
Browse files Browse the repository at this point in the history
RELNOTES=The `@AutoBuilder` annotation documented [here](https://github.com/google/auto/blob/master/value/userguide/autobuilder.md) is now fully stable and supported.
PiperOrigin-RevId: 414523614
  • Loading branch information
eamonnmcmanus authored and Google Java Core Libraries committed Dec 6, 2021
1 parent 0b21d83 commit 1f8d7f2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ public synchronized void init(ProcessingEnvironment processingEnv) {

@Override
void processType(TypeElement autoBuilderType) {
if (!processingEnv.getOptions().containsKey(ALLOW_OPTION)) {
errorReporter()
.abortWithError(
autoBuilderType,
"Compile with -A%s to enable this UNSUPPORTED AND UNSTABLE prototype",
ALLOW_OPTION);
if (processingEnv.getOptions().containsKey(ALLOW_OPTION)) {
errorReporter().reportWarning(autoBuilderType, "The -A%s option is obsolete", ALLOW_OPTION);
}
if (autoBuilderType.getKind() != ElementKind.CLASS
&& autoBuilderType.getKind() != ElementKind.INTERFACE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public void simpleSuccess() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation)
.generatedSourceFile("foo.bar.AutoBuilder_Baz_Builder")
Expand Down Expand Up @@ -148,7 +147,6 @@ public void simpleRecord() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation)
.generatedSourceFile("foo.bar.AutoBuilder_Baz_Builder")
Expand Down Expand Up @@ -192,7 +190,6 @@ public void buildOtherPackage() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(built, builder);
assertThat(compilation).succeededWithoutWarnings();
assertThat(compilation).generatedSourceFile("foo.bar.AutoBuilder_Builder");
Expand All @@ -214,7 +211,6 @@ public void autoBuilderOnEnum() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -242,7 +238,6 @@ public void autoBuilderPrivate() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -271,7 +266,6 @@ public void autoBuilderNestedInPrivate() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -299,7 +293,6 @@ public void autoBuilderInner() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -328,7 +321,6 @@ public void innerConstructor() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand All @@ -355,7 +347,6 @@ public void noVisibleConstructor() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -386,7 +377,6 @@ public void noVisibleMethod() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -418,7 +408,6 @@ public void methodNotStatic() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -451,7 +440,6 @@ public void noMatchingConstructor() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -489,7 +477,6 @@ public void twoMatchingConstructors() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -519,7 +506,6 @@ public void constructInterface() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -553,7 +539,6 @@ public void inconsistentSetPrefix() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -584,7 +569,6 @@ public void missingSetter() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -618,7 +602,6 @@ public void tooManyArgs() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -650,7 +633,6 @@ public void alienNoArgMethod() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -686,7 +668,6 @@ public void alienOneArgMethod() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -719,7 +700,6 @@ public void setterReturnType() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -761,7 +741,6 @@ public void nullableSetterForNonNullableParameter() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject, nullableFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -794,7 +773,6 @@ public void setterWrongType() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -827,7 +805,6 @@ public void setterWrongTypeEvenWithConversion() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down Expand Up @@ -862,7 +839,6 @@ public void typeParamMismatch() {
Compilation compilation =
javac()
.withProcessors(new AutoBuilderProcessor())
.withOptions("-Acom.google.auto.value.AutoBuilderIsUnstable")
.compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
Expand Down
3 changes: 0 additions & 3 deletions value/userguide/autobuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ corresponding to the getter methods in the `@AutoValue` class, an `@AutoBuilder`
has setter methods corresponding to the parameters of a constructor or static
method. Apart from that, the two are very similar.

AutoBuilder is **unstable** and it is possible that its API
may change. We do not recommend depending on it for production code yet.

## Example: calling a constructor

Here is a simple example:
Expand Down

0 comments on commit 1f8d7f2

Please sign in to comment.