Skip to content
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

NullPointerException processing ImmutableList.Builder Builder method #264

Open
chris9871 opened this issue Oct 22, 2021 · 0 comments
Open

Comments

@chris9871
Copy link

Sample class:

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;

@AutoValue
abstract class MyAv2 {
    public abstract ImmutableList<String> items();

    public static Builder builder() {
        return new AutoValue_MyAv2.Builder();
    }

    @AutoValue.Builder
    public abstract static class Builder {
        public abstract ImmutableList.Builder<String> itemsBuilder();

        public Builder addItem(final String item) {
            itemsBuilder().add(item);
            return this;
        }

        public abstract MyAv2 build();
    }

    public static TypeAdapter<MyAv2> typeAdapter(Gson gson) {
        return new AutoValue_MyAv2.GsonTypeAdapter(gson);
    }
}

Exception shape:

BUILD:128:13: Building projects/services/disco/zoobernetes/libbase_lib-class.jar (30 source files) and running annotation processors (AutoValueProcessor, AutoValueGsonAdapterFactoryProcessor) failed (Exit 1): java failed: error executing command tools/jdk/Darwin/openjdk_11.0.10_11.45.28_x64/bin/java -XX:+UseParallelOldGC -XX:-CompactStrings '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' ... (remaining 15 argument(s) skipped)
MyAv2.java:9: error: [AutoValueException] @AutoValue processor threw an exception: java.lang.NullPointerException
abstract class MyAv2 {
         ^
  	at com.ryanharter.auto.value.gson.AutoValueGsonExtension.addBuilderFieldSetting(AutoValueGsonExtension.java:559)
  	at com.ryanharter.auto.value.gson.AutoValueGsonExtension.createReadMethod(AutoValueGsonExtension.java:821)
  	at com.ryanharter.auto.value.gson.AutoValueGsonExtension.createTypeAdapter(AutoValueGsonExtension.java:513)
  	at com.ryanharter.auto.value.gson.AutoValueGsonExtension.generateClass(AutoValueGsonExtension.java:286)
  	at com.google.auto.value.processor.AutoValueProcessor.writeExtensions(AutoValueProcessor.java:301)
  	at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:263)
  	at com.google.auto.value.processor.AutoValueishProcessor.process(AutoValueishProcessor.java:350)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:972)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:888)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1214)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1326)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:936)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
  	at com.google.devtools.build.buildjar.javac.BlazeJavacMain.compile(BlazeJavacMain.java:117)
  	at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.fallback(ReducedClasspathJavaLibraryBuilder.java:103)
  	at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.compileSources(ReducedClasspathJavaLibraryBuilder.java:65)
  	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:108)
  	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:115)
  	at com.google.devtools.build.buildjar.BazelJavaBuilder.build(BazelJavaBuilder.java:81)
  	at com.google.devtools.build.buildjar.BazelJavaBuilder.parseAndBuild(BazelJavaBuilder.java:61)
  	at com.google.devtools.build.buildjar.WorkRequestHandler.respondToRequest(WorkRequestHandler.java:99)
  	at com.google.devtools.build.buildjar.WorkRequestHandler.lambda$createResponseThread$0(WorkRequestHandler.java:82)
  	at java.base/java.lang.Thread.run(Thread.java:834)
java.lang.RuntimeException: java.lang.NullPointerException
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:163)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
	at com.google.devtools.build.buildjar.javac.BlazeJavacMain.compile(BlazeJavacMain.java:117)
	at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.fallback(ReducedClasspathJavaLibraryBuilder.java:103)
	at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.compileSources(ReducedClasspathJavaLibraryBuilder.java:65)
	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:108)
	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:115)
	at com.google.devtools.build.buildjar.BazelJavaBuilder.build(BazelJavaBuilder.java:81)
	at com.google.devtools.build.buildjar.BazelJavaBuilder.parseAndBuild(BazelJavaBuilder.java:61)
	at com.google.devtools.build.buildjar.WorkRequestHandler.respondToRequest(WorkRequestHandler.java:99)
	at com.google.devtools.build.buildjar.WorkRequestHandler.lambda$createResponseThread$0(WorkRequestHandler.java:82)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
	at com.ryanharter.auto.value.gson.AutoValueGsonExtension.addBuilderFieldSetting(AutoValueGsonExtension.java:559)
	at com.ryanharter.auto.value.gson.AutoValueGsonExtension.createReadMethod(AutoValueGsonExtension.java:821)
	at com.ryanharter.auto.value.gson.AutoValueGsonExtension.createTypeAdapter(AutoValueGsonExtension.java:513)
	at com.ryanharter.auto.value.gson.AutoValueGsonExtension.generateClass(AutoValueGsonExtension.java:286)
	at com.google.auto.value.processor.AutoValueProcessor.writeExtensions(AutoValueProcessor.java:301)
	at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:263)
	at com.google.auto.value.processor.AutoValueishProcessor.process(AutoValueishProcessor.java:350)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:972)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:888)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1214)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1326)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:936)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
	... 12 more
INFO: Elapsed time: 1.884s, Critical Path: 1.52s

This appears to fail in 1.3.0+ and works in 1.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant