Git Product home page Git Product logo

auto-value-parcel's People

Contributors

0xdca avatar cushon avatar d-los avatar eamonnmcmanus avatar felipecsl avatar gabrielittner avatar grandstaish avatar guavabot avatar jakewharton avatar luciofm avatar mateusazis avatar maxchursin avatar menny avatar mik9 avatar ndurell avatar nightlynexus avatar paulwoitaschek avatar realdm avatar rharter avatar supercilex avatar vanniktech avatar zacsweers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auto-value-parcel's Issues

Parcelable.Creator field needs to be public

http://developer.android.com/reference/android/os/Parcelable.Creator.html

Otherwise you'll get an exception:

android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called  CREATOR on class com.gabrielittner.timetable.notemute.AutoValue_LessonTime
            at android.os.Parcel.readParcelableCreator(Parcel.java:2298)
            at android.os.Parcel.readParcelable(Parcel.java:2239)
            at android.os.Parcel.readValue(Parcel.java:2146)
            at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
            at android.os.BaseBundle.unparcel(BaseBundle.java:221)
            at android.os.Bundle.getParcelable(Bundle.java:804)
            at android.content.Intent.getParcelableExtra(Intent.java:4850)

Ignore @AutoValue.Builder return type

I am currently using @AutoValue.Builder to automatically create builders for some of my classes using @autovalue.

AutoValue lets you easily convert an object to a new builder by creating a method like this:
public abstract Builder toBuilder();

Builder is a class that is annotated with @AutoValue.Builder.

Unfortunately, when I try to use auto-value-parcel I get the following error. It would be nice if auto-value-parcel would ignore methods whose return type is annotated with @AutoValue.Builder. Also it would be nice if there was some kind of @IgnoreParcel annotation which would cause auto-value-parcel to skip including it in the Parcelable implementation.

Error:(52, 27) error: AutoValue property toBuilder is not a supported Parcelable type.
Error:(14, 17) error: @AutoValue processor threw an exception: com.ryanharter.auto.value.parcel.AutoValueParcelException
at com.ryanharter.auto.value.parcel.AutoValueParcelExtension.validateProperties(AutoValueParcelExtension.java:164)
at com.ryanharter.auto.value.parcel.AutoValueParcelExtension.generateClass(AutoValueParcelExtension.java:108)
at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:424)
at com.google.auto.value.processor.AutoValueProcessor.process(AutoValueProcessor.java:143)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:45)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:103)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:52)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:34)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:157)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:139)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:93)
at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Generic bounds checking fails when bound is not Parcelable but declared type is.

interface Foo {}
interface Bar<F extends Foo> {
  F foo();
}
@AutoValue abstract class PFoo implements Foo, Parcelable {}
@AutoValue abstract class PBar implements Bar<PFoo>, Parcelable {}
Bar.java:340: error: AutoValue property foo is not a supported Parcelable type.
    F foo();
      ^
PBar:11: error: @AutoValue processor threw an exception: com.ryanharter.auto.value.parcel.AutoValueParcelException
@AutoValue public abstract class PBar implements Bar<PFoo>,
                           ^
        at com.ryanharter.auto.value.parcel.AutoValueParcelExtension.validateProperties(AutoValueParcelExtension.java:279)
        at com.ryanharter.auto.value.parcel.AutoValueParcelExtension.generateClass(AutoValueParcelExtension.java:158)
        at com.google.auto.value.processor.AutoValueProcessor.writeExtensions(AutoValueProcessor.java:474)
        at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:460)
        at com.google.auto.value.processor.AutoValueProcessor.process(AutoValueProcessor.java:150)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)

Looks like the implementation is resolving the bounds and trying to verify they are parcelable which fails, except that the generic was given a concrete type on the implementation class.

AV 1.3, extension 0.2.5

Parceling ArrayList of auto-value generated class.

I have a class generated through Auto-Value-Parcel e.g. Spec. I have another hand created Class say Brand which contains ArrayList<Spec> which could be nullable. While creating a Parcelable implementation for Brand, I was trying to use in.readTypedArray(), but since Spec is generated it does not expose CREATOR. What would be a better way to expose that? As a work around, I am using in.readList but then it wold create empty list even if source was a null.

AIDL: CREATOR cannot be resolved or is not a field

I'm attempting to use this extension because I want to pass an AutoValue-annotated class across a process boundary with AIDL. Project here, specific commit demonstrating issue here.

It's possible I'm simply not using something correctly.

When I run ./gradlew assembleDebug, I get the following error:

ERROR: /workspace/ReactiveStopwatch/app/build/generated/source/aidl/debug/com/autonomousapps/reactivestopwatch/service/IStopwatchService.java:172: CREATOR cannot be resolved or is not a field

The generated IStopwatchService.java class has this line:

_result = com.autonomousapps.reactivestopwatch.time.Lap.CREATOR.createFromParcel(_reply);

Which might be the problem. After all, Lap doesn't have that field. AutoValue_Lap, however, does. I could change all my implementations to use the latter instead of the former, but that seems to be against the spirit of the thing.

Here's my AutoValue-annotated class:

package com.autonomousapps.reactivestopwatch.time;

@AutoValue
public abstract class Lap implements Parcelable {

    public static Lap create(long duration, long endTime) {
        return new AutoValue_Lap(duration, endTime);
    }

    abstract long duration();

    abstract long endTime();
}

AIDL definition:

package com.autonomousapps.reactivestopwatch.time;

parcelable Lap;

Use in other AIDL file:

package com.autonomousapps.reactivestopwatch.service;

import com.autonomousapps.reactivestopwatch.time.Lap;

interface IStopwatchService {
    // other methods omitted
    Lap lap();
}

Java.lang.NoSuchMethodError: com.squareup.javapoet.TypeName.isBoxedPrimitive()Z

Hi,

I tried to update to the latest 0.2.2 and I have this error while compiling.

[...]GeevApp.java
Error:(12, 59) error: cannot find symbol class DaggerApplicationComponent
[...]GeevServiceModule.java
Error:(5, 38) error: package com.ryanharter.auto.value.gson does not exist
Warning:@AutoValue classes cannot have abstract methods other than property getters and Builder converters
:app:compileRetrolambdaDebug
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.NoSuchMethodError: com.squareup.javapoet.TypeName.isBoxedPrimitive()Z

I use those AutoValue versions:

// Autovalue 
    apt 'com.google.auto.value:auto-value:1.2'
    provided 'com.jakewharton.auto.value:auto-value-annotations:1.2-update1'
    apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.2'
    apt 'com.ryanharter.auto.value:auto-value-gson:0.3.1'

Everything ok on 0.2.1

Create TypeAdapter once per class

Currently for each writeToParcle and for each createFromParcel a new TypeAdapter is created, i.e

@Override  public AutoValue_ShowGridViewModel createFromParcel(Parcel in) {
      DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter();
      return new AutoValue_ShowGridViewModel(
          in.readString(),
          in.readString(),
          in.readString(),
          in.readString(),
          dateTimeTypeAdapter.fromParcel(in),
          in.readString()
      );
    }

This is very inefficient as it creates 1000 additional objects when you pass 500 Objects. Instead the library should create a

private static final DateTimeTypeAdapter DATE_TIME_TYPE_ADAPTER = new DateTimeTypeAdapter();

and use that one.

Identifier expected

Hi :)

Here is the source file:

@AutoValue
public abstract class CurrencyViewState implements ViewState {
    public abstract CurrencyInfo currency();
    public abstract Transient<SolidList<CurrencyInfo>> currencies();

Here is the generated class:

final class AutoValue_CurrencyViewState extends $AutoValue_CurrencyViewState {
  public static final Parcelable.Creator<AutoValue_CurrencyViewState> CREATOR = new Parcelable.Creator<AutoValue_CurrencyViewState>() {
    @Override
    public AutoValue_CurrencyViewState createFromParcel(Parcel in) {
      return new AutoValue_CurrencyViewState(
          (CurrencyInfo) in.readParcelable(CurrencyInfo.class.getClassLoader()),
          (Transient<SolidList<CurrencyInfo>>) in.readParcelable(SolidList<T>.class.getClassLoader())
      );
    }
    @Override
    public AutoValue_CurrencyViewState[] newArray(int size) {
      return new AutoValue_CurrencyViewState[size];
    }
  };

Please take a look at: SolidList<T>.class.getClassLoader().

It causes the compilation error: "Error:(16, 79) error: expected"

Is there a quick fix possible from your side or it will be quicker for me to clone/explore/fix/push?

java.lang.IncompatibleClassChangeError: Implementing class

in build.gradle dependencies:

apt 'com.google.auto.value:auto-value:1.2-SNAPSHOT'
compile 'com.google.auto.value:auto-value:1.2-SNAPSHOT'
apt 'com.ryanharter.auto.value:auto-value-parcel:0.2-SNAPSHOT'

I get the following exception on compiling:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
    Caused by: java.lang.RuntimeException: java.lang.IncompatibleClassChangeError: Implementing class
        at com.sun.tools.javac.main.Main.compile(Main.java:553)
        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:42)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:35)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:97)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:50)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:36)
        at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:34)
        at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
        at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:158)
        at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:138)
        at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:92)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:235)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:222)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 47 more
    Caused by: java.lang.IncompatibleClassChangeError: Implementing class
        at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:369)
        at com.google.auto.value.processor.AutoValueProcessor.process(AutoValueProcessor.java:141)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        ... 66 more

Doesn't check valid Parcelable types for Maps

Parcelables place some extra restrictions around Maps that we aren't checking for, specifically that the keys in a map need to be Strings, and the values must be Parcelable. isValidType should be checking for this.

Emit type-specific writeXxx method calls instead of writeValue.

Calling writeValue is the easy thing to do, but it's not as efficient as it could be. When you have a long there's no need to round-trip through boxing. When you have a Parcelable (or subtype) there's no need to do the giant instanceof dance inside of writeValue.

toBuilder() isn't supported

public abstract Builder toBuilder();
Error:(37, 29) error: AutoValue property toBuilder is not a supported Parcelable type.
Error:(14, 17) error: @AutoValue processor threw an exception: com.ryanharter.auto.value.parcel.AutoValueParcelException
at com.ryanharter.auto.value.parcel.AutoValueParcelExtension.validateProperties(AutoValueParcelExtension.java:164)
at com.ryanharter.auto.value.parcel.AutoValueParcelExtension.generateClass(AutoValueParcelExtension.java:108)
at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:424)
at com.google.auto.value.processor.AutoValueProcessor.process(AutoValueProcessor.java:143)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:45)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
.....
compile 'com.google.auto.value:auto-value:1.2'
apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.1'
compile 'com.ryanharter.auto.value:auto-value-parcel-adapter:0.2.1'

Generated code doesn't consider @Nullable when using TypeAdapter

When using a TypeAdapter, I would expect the generated parceling code to consider if the field is @Nullable, the way it's done when not using TypeAdapter. For example, I was expecting something like this:

@Override
public void writeToParcel(Parcel dest, int flags) {
    LocalDateAdapter localDateAdapter = new LocalDateAdapter();
    if (getDate() == null) {
        dest.writeInt(1);
    } else {
        dest.writeInt(0);
        localDateAdapter.toParcel(getDate(), dest);
    }
}

Is it on purpose that the responsibility to check for null is being left to the TypeAdapters? If yes, this should be documented, otherwise, should I fix this with a PR?

Can't include lib snapshot into Android app project

I'm getting this error after including this lib into an android app project:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.UnsupportedClassVersionError: com/ryanharter/auto/value/parcel/AutoValueParcelExtension : Unsupported major.minor version 52.0

build.gradle:
compile 'com.google.auto.value:auto-value:1.2-SNAPSHOT'

I tried cloning the repo and building myself on Java 7 and surprisingly it compiled fine (except for one test that failed for some reason). Maybe you built it with Java 8 when you uploaded to Sonatype? Could that be the reason for this error?

Multiple TypeAdapters with the same name generated

In 0.2, when I have a AutoValue class that has multiple abstract methods annotated @ParcelAdapter that has the same TypeAdapter class auto-value-parcel-adapter generates multiple TypeAdapters with the same property name. This causes compilation to fail.

Ideally it would only generate one TypeAdapter property per TypeAdapter. Otherwise it could append a number to the end of the property name.

Here is a example of what I am describing:

  public abstract class Meta implements Parcelable {

    @Nullable
    @ParcelAdapter(HttpUrlParcelTypeAdapter.class)
    public abstract HttpUrl href();

    @Nullable
    @ParcelAdapter(HttpUrlParcelTypeAdapter.class)
    public abstract HttpUrl nextHref();

    @Nullable
    @ParcelAdapter(HttpUrlParcelTypeAdapter.class)
    public abstract HttpUrl previousHref();
}

Generates the following class which doesn't compile:

final class AutoValue_Meta extends $AutoValue_Meta {
  public static final Parcelable.Creator<AutoValue_Meta> CREATOR = new Parcelable.Creator<AutoValue_Meta>() {
    @Override
    public AutoValue_Meta createFromParcel(Parcel in) {
      HttpUrlParcelTypeAdapter httpUrlParcelTypeAdapter = new HttpUrlParcelTypeAdapter();
      HttpUrlParcelTypeAdapter httpUrlParcelTypeAdapter = new HttpUrlParcelTypeAdapter();
      HttpUrlParcelTypeAdapter httpUrlParcelTypeAdapter = new HttpUrlParcelTypeAdapter();
      return new AutoValue_Meta(
          httpUrlParcelTypeAdapter.fromParcel(in),
          httpUrlParcelTypeAdapter.fromParcel(in),
          httpUrlParcelTypeAdapter.fromParcel(in)
      );
    }
    @Override
    public AutoValue_Meta[] newArray(int size) {
      return new AutoValue_Meta[size];
    }
  };

  AutoValue_Meta(HttpUrl href, HttpUrl nextHref, HttpUrl previousHref) {
    super(href, nextHref, previousHref);
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    HttpUrlParcelTypeAdapter httpUrlParcelTypeAdapter = new HttpUrlParcelTypeAdapter();
    HttpUrlParcelTypeAdapter httpUrlParcelTypeAdapter = new HttpUrlParcelTypeAdapter();
    HttpUrlParcelTypeAdapter httpUrlParcelTypeAdapter = new HttpUrlParcelTypeAdapter();
    httpUrlParcelTypeAdapter.toParcel(href(), dest);
    httpUrlParcelTypeAdapter.toParcel(nextHref(), dest);
    httpUrlParcelTypeAdapter.toParcel(previousHref(), dest);
  }

  @Override
  public int describeContents() {
    return 0;
  }
}

Warning when compiling `Parcelable` classes

AutoValue is complaining about having abstract methods which are not properties or Builders:
warning: @AutoValue classes cannot have abstract methods other than property getters and Builder converters

Since we are using "-Werror" compiler options (we are strict about compiler warnings in our code), the compilation will fail.

Is there a way around this warning?

Thanks

Error adding Action0 as autovalue attribute.

I want to use Action0 as a field of my auto value class that implements Parcelable, but I am getting this error:

Note: Generating a MembersInjector for com.mdlive.mdlcore.activity.core.MdlCoreActivity. Prefer to run the dagger processor over that class instead.
MdlDialogScreenKey.java:36: error: AutoValue property positiveAction is not a supported Parcelable type.
    public abstract Action0 positiveAction();

I have needed to create a mixed interface as a workaround:

public interface MyAction0 extends Action0, Serializable {}

Is this behavior planned to be supported by auto-value-parcel?

Set collection is not a supported parcelable type

Can you provide support for Sets in the parcelable extension? I got the following error when I tried to use the parcelable extension for the Set collection:

Error:(15, 17) error: @AutoValue processor threw an exception: com.ryanharter.auto.value.parcel.AutoValueParcelException
at com.ryanharter.auto.value.parcel.AutoValueParcelExtension.validateProperties(AutoValueParcelExtension.java:255)
at com.ryanharter.auto.value.parcel.AutoValueParcelExtension.generateClass(AutoValueParcelExtension.java:155)
at com.google.auto.value.processor.AutoValueProcessor.writeExtensions(AutoValueProcessor.java:474)
at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:460)
at com.google.auto.value.processor.AutoValueProcessor.process(AutoValueProcessor.java:150)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:46)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:104)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:53)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:163)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:145)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:93)
at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

JavaBeans-style name prefixes stop working when implementing Parcelable

I have a class that has both AutoValue and your AutoValue Gson Extension enabled and working well. The class uses JavaBeans-style name prefixes.

When I try to make the class Parcelable the JavaBeans-style prefixes stop working. The GSON extension starts using the field name including the JavaBeans prefix (in generated source I see jsonWriter.name("getName");) instead of stripping it like it does without Parcelable (jsonWriter.name("name");)

Let me know if I can provide any additional information. It should be easy enough to see what's going on using this minimal class and toggling implements Parcelable on and off:

@AutoValue
public abstract class Test implements Parcelable {

    public abstract String getName();

    public static TypeAdapterFactory typeAdapterFactory() {
        return AutoValue_Test.typeAdapterFactory();
    }
}

From gradle.build:

    apt 'com.google.auto.value:auto-value:1.2'
    provided 'com.google.auto.value:auto-value:1.2'
    apt 'com.ryanharter.auto.value:auto-value-gson:0.2.2'
    apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.1'

Use bytes instead of ints as a boolean values

I guess it's low priority but it would be beneficial if AVP wrote bytes instead of int to signal null values and when writing booleans.

Example:

Old:

if (foo() == null) {
    dest.writeInt(1);
} else {
    dest.writeInt(0);
    dest.writeString(foo());
}
dest.writeInt(bar() ? 1 : 0);

Suggested change:

if (foo() == null) {
    dest.writeByte((byte) 1);
} else {
    dest.writeByte((byte) 0);
    dest.writeString(foo());
}
dest.writeByte((byte) (bar() ? 1 : 0));

BadParcelableException in Robolectric unit-tests

Seems like Robolectric doesn't like the class hierarchy Auto-Value outputs.

I have an example project that shows this:
https://github.com/menny/auto-value-parcel-robolectric/tree/master

MainActivity has three static method:

  1. testParcel - which shows AutoValue-Parcel usage.
  2. testParcel2 - which creates the same class hierarchy manually.
  3. testParcelC - which has a single class that declare the Parcelable interface and implements it.

When running on device, all three methods run without any exception, or errors.
When running a Robolectric unit-test testParcel and testParcel2 will fail with BadParcelableException, while testParcelC passes.

The exception stack-trace is:

android.os.BadParcelableException: IllegalAccessException when unmarshalling: com.example.menny.roboautovalue.AutoValue_TestModel
    at android.os.Parcel.readParcelableCreator(Parcel.java:2099)
    at android.os.Parcel.readParcelable(Parcel.java:2055)
    at com.example.menny.roboautovalue.TestModelTest.testParcel(TestModelTest.java:22)

I also opened an issue at Robolectric: robolectric/robolectric#2398, but I would love some insight into this.

Custom Type Adapters

Basically the same thing Gson and Moshi provide—the support for writing and reading custom not-first-hand-supported types using Parcel, such as boolean, Date, Map<String, Set<String>> and what not.

This is a proposed example for such type adapters.

public final class DateAdapter implements Adapter<Date>
{
    @Override
    public void writeToParcel(@NonNull Parcel parcel, @NonNull Date date) {
        parcel.writeLong(date.getTime());
    }

    @Override
    public Date readFromParcel(@NonNull Parcel parcel) {
        return new Date(parcel.readLong());
    }
}

Compile error when using same TypeAdapter twice

I have the following class:

import com.google.android.gms.maps.model.LatLng;
...
@AutoValue
public abstract class RouteSegment implements Parcelable {
    @ParcelAdapter(LatLngTypeAdapter.class)
    public abstract LatLng startPoint();
    @ParcelAdapter(LatLngTypeAdapter.class)
    public abstract LatLng endPoint();
    ...
    public static class LatLngTypeAdapter implements
        com.ryanharter.auto.value.parcel.TypeAdapter<LatLng> {
        @Override
        public LatLng fromParcel(Parcel in) {
            return in.readParcelable(RouteSegment.class.getClassLoader());
        }

        @Override
        public void toParcel(LatLng value, Parcel dest) {
            dest.writeParcelable(value, 0);
        }
    }
}

That generates the following error:
AutoValue_RouteSegment.java:14: error: variable latLngTypeAdapter is already defined in method createFromParcel(Parcel)

If I remove the ParcelAdapter to endPoint I get the following error:
error: AutoValue property endPoint is not a supported Parcelable type.

How should ParcelAdapter be used in this scenario?

Global/implicit TypeAdapters

TypeAdapters abstraction is really nice but can be a pain when you need to write @ParcelAdapter(XXX.class) every time for the same type in every definition.

Would it be possible to add something like Global / Implicit TypeAdapters like :

@ImplicitParcelAdapter(Date.class)
public class DateTypeAdapter implements TypeAdapter<Date> { ... }

That would be resolved at compile time to append to the list of supported type adapters ?

Generated class does not contain template

Not sure where the bug actually lives (might be my code) but the class generated by auto-value-parcelable isn't templating properly (but the $Class generated by vanilla auto-value does)

Heres a sample class:

@AutoValue public abstract class Stuff<T extends Parcelable> implements Parcelable {
  public abstract List<T> data();
}

heres what auto-value-parcel generates:

final class AutoValue_Stuff extends $AutoValue_Stuff {
  public static final Parcelable.Creator<AutoValue_Stuff> CREATOR = new Parcelable.Creator<AutoValue_Stuff>() {
    @Override
    public AutoValue_Stuff createFromParcel(Parcel in) {
      ClassLoader cl = AutoValue_Stuff.class.getClassLoader();
      return new AutoValue_Stuff(
          (List<T>) in.readArrayList(cl)
      );
    }
    @Override
    public AutoValue_Stuff[] newArray(int size) {
      return new AutoValue_Stuff[size];
    }
  };

  AutoValue_Stuff(List<T> data) {
    super(data);
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeList(data());
  }

  @Override
  public int describeContents() {
    return 0;
  }
}

and heres what vanilla auto-value has generated:

@Generated("com.google.auto.value.processor.AutoValueProcessor")
 abstract class $AutoValue_Stuff<T extends Parcelable> extends Stuff<T> {

  private final List<T> data;

  $AutoValue_Stuff(
      List<T> data) {
    if (data == null) {
      throw new NullPointerException("Null data");
    }
    this.data = data;
  }

  @Override
  public List<T> data() {
    return data;
  }

  @Override
  public String toString() {
    return "Stuff{"
        + "data=" + data
        + "}";
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }
    if (o instanceof Stuff) {
      Stuff<?> that = (Stuff<?>) o;
      return (this.data.equals(that.data()));
    }
    return false;
  }

  @Override
  public int hashCode() {
    int h = 1;
    h *= 1000003;
    h ^= this.data.hashCode();
    return h;
  }

}

I'm using 0.2.1

createFromParcel does not use correct ClassLoaders

This is whats being generated:

@Override
public AutoValue_Entry createFromParcel(Parcel in) {
  ClassLoader cl = AutoValue_Entry.class.getClassLoader();
  return new AutoValue_Entry(
      in.readString(),
      (EntryAccount) in.readParcelable(cl),
      in.readInt() == 0 ? (EntryLogo) in.readParcelable(cl) : null
  );
}

The generated method uses the Entry ClassLoader for both objects, but both EntryAccount and EntryLogo should use their own ClassLoader.

This is the exception I get when trying to use the Parcelable in an Intent.
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: AutoValue_Entry
So, I'm guessing this is the problem.

This is my Entry class (I'm using this library alongside auto-value-gson) :

@AutoValue
public abstract class Entry implements Parcelable {

    @SerializedName("introduction") abstract public String introduction();
    @SerializedName("account") abstract public EntryAccount account();
    @SerializedName("logo") @Nullable abstract public EntryLogo logo();

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

}

What could be the problem

Parcelable subinterfaces reported as not supported Parcelable type

I have the following class:

import com.google.android.gms.maps.model.LatLng;
...
@AutoValue
public abstract class RouteSegment implements Parcelable {
    public abstract LatLng startPoint();
    public abstract LatLng endPoint();
    ...
}

LatLng is provided by Google Maps Android API which implements SafeParcelable which in turn extends Parcelable.

Since LatLng implements Parcelable I expected it to be handled properly without the need for a TypeAdapter.

All tests fail

While trying to run the tests almost every test fails. (Except of acceptsParcelableProperties and throwsForNonParcelableProperty).

Do you have any idea what is going on here?

java.lang.AssertionError: Compilation produced the following errors:

/SOURCE_OUTPUT/test/AutoValue_No.java:7: error: test.AutoValue_No is not abstract and does not override abstract method writeToParcel(android.os.Parcel,int) in android.os.Parcelable
 final class AutoValue_No extends No {
       ^
/SOURCE_OUTPUT/test/AutoValue_Yes.java:7: error: test.AutoValue_Yes is not abstract and does not override abstract method writeToParcel(android.os.Parcel,int) in android.os.Parcelable
 final class AutoValue_Yes extends Yes {
       ^


Generated Files
===============

/SOURCE_OUTPUT/test/AutoValue_Yes.java:

package test;

import javax.annotation.Generated;

@Generated("com.google.auto.value.processor.AutoValueProcessor")
 final class AutoValue_Yes extends Yes {

  private final String name;

  AutoValue_Yes(
      String name) {
    if (name == null) {
      throw new NullPointerException("Null name");
    }
    this.name = name;
  }

  @Override
  public String name() {
    return name;
  }

  @Override
  public String toString() {
    return "Yes{"
        + "name=" + name
        + "}";
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }
    if (o instanceof Yes) {
      Yes that = (Yes) o;
      return (this.name.equals(that.name()));
    }
    return false;
  }

  @Override
  public int hashCode() {
    int h = 1;
    h *= 1000003;
    h ^= this.name.hashCode();
    return h;
  }

}


/SOURCE_OUTPUT/test/AutoValue_No.java:

package test;

import javax.annotation.Generated;

@Generated("com.google.auto.value.processor.AutoValueProcessor")
 final class AutoValue_No extends No {

  private final String name;
  private final int describeContents;

  AutoValue_No(
      String name,
      int describeContents) {
    if (name == null) {
      throw new NullPointerException("Null name");
    }
    this.name = name;
    this.describeContents = describeContents;
  }

  @Override
  public String name() {
    return name;
  }

  @Override
  public int describeContents() {
    return describeContents;
  }

  @Override
  public String toString() {
    return "No{"
        + "name=" + name + ", "
        + "describeContents=" + describeContents
        + "}";
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }
    if (o instanceof No) {
      No that = (No) o;
      return (this.name.equals(that.name()))
           && (this.describeContents == that.describeContents());
    }
    return false;
  }

  @Override
  public int hashCode() {
    int h = 1;
    h *= 1000003;
    h ^= this.name.hashCode();
    h *= 1000003;
    h ^= this.describeContents;
    return h;
  }

}



    at com.google.common.truth.FailureStrategy.fail(FailureStrategy.java:24)
    at com.google.common.truth.FailureStrategy.fail(FailureStrategy.java:20)
    at com.google.testing.compile.JavaSourcesSubject$CompilationClause.compilesWithoutError(JavaSourcesSubject.java:274)
    at com.ryanharter.auto.value.parcel.AutoValueParcelExtensionTest.describeContentsOmittedWhenAlreadyDefined(AutoValueParcelExtensionTest.java:463)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at com.google.testing.compile.CompilationRule$1$1.process(CompilationRule.java:83)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$200(JavacProcessingEnvironment.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.runContributingProcs(JavacProcessingEnvironment.java:627)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1033)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1198)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at com.google.testing.compile.Compilation.compile(Compilation.java:73)
    at com.google.testing.compile.CompilationRule$1.evaluate(CompilationRule.java:59)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Doesn't work with auto-value-moshi

Сan generate the code for AdapterFactory.
auto-value-parcel v0.3.2
auto-value-parcel v0.2.2

stacktrace:

Error:(10, 39) error: package com.ryanharter.auto.value.moshi does not exist
Warning:@autovalue classes cannot have abstract methods other than property getters and Builder converters
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.lang.NoSuchMethodError: com.squareup.javapoet.TypeName.isBoxedPrimitive()Z

Non-compilable code is generated when 2 TypeAdapters of the same class name, but different namespaces are used.

Good day,

I have 2 TypeAdapters, EditHybridStations.HybridStation.ListTypeAdapter and GetParentStationsAll.Station.ListTypeAdapter used as ParcelAdapters for another AutoValue class, GetParentStationsAll.Response. The generated code is:

public AutoValue_GetParentStationsAll_Response createFromParcel(Parcel in) {
  EditHybridStations.HybridStation.ListTypeAdapter listTypeAdapter = new EditHybridStations.HybridStation.ListTypeAdapter();
  GetParentStationsAll.Station.ListTypeAdapter listTypeAdapter = new GetParentStationsAll.Station.ListTypeAdapter();
  return new AutoValue_GetParentStationsAll_Response(
      listTypeAdapter.fromParcel(in),
      listTypeAdapter.fromParcel(in)
  );
}

As you can see, there are 2 variables named listTypeAdapter within the same scope. The same bug occurs also for the corresponding writeToParcel method.

Removes annotations from the constructor

AutoValue annotates constructor parameters that belong to @Nullable values with @Nullable.

So the generated autovalue class looks like this

$AutoValue_FoodDetailArgs(
      UUID productId,
      FoodTime foodTime,
      LocalDate date,
      @Nullable FoodDetailPresetServing foodDetailPresetServing) {
    if (productId == null) {
      throw new NullPointerException("Null productId");
    }
    this.productId = productId;
    if (foodTime == null) {
      throw new NullPointerException("Null foodTime");
    }
    this.foodTime = foodTime;
    if (date == null) {
      throw new NullPointerException("Null date");
    }
    this.date = date;
    this.foodDetailPresetServing = foodDetailPresetServing;
  }

When now autoparcel generates its implementation the annotations are not shown in its generated class:

  AutoValue_FoodDetailArgs(UUID productId, FoodTime foodTime, LocalDate date, FoodDetailPresetServing foodDetailPresetServing) {
    super(productId, foodTime, date, foodDetailPresetServing);
  }

Unmarshalling unknown type code XXXXX at offset XXXXX

I have a service defined in an app that takes auto-value objects that implement parcelable using auto-value-parcel defined in an AAR that's crashing with the following exception:

  java.lang.RuntimeException: Parcel android.os.Parcel@420a36e0: Unmarshalling unknown type code 5177414 at offset 224
  at android.os.Parcel.readValue(Parcel.java:2080)
  at android.os.Parcel.readListInternal(Parcel.java:2343)
  at android.os.Parcel.readArrayList(Parcel.java:1703)
  at android.os.Parcel.readValue(Parcel.java:2034)
  at com.realityi.sceaa.shared.logging.AutoValue_Event.<init>(AutoValue_Event.java:49)
  at com.realityi.sceaa.shared.logging.AutoValue_Event.<init>(AutoValue_Event.java:7)
  at com.realityi.sceaa.shared.logging.AutoValue_Event$1.createFromParcel(AutoValue_Event.java:62)
  at com.realityi.sceaa.shared.logging.AutoValue_Event$1.createFromParcel(AutoValue_Event.java:59)
  at android.os.Parcel.readParcelable(Parcel.java:2104)
  at android.os.Parcel.readValue(Parcel.java:2013)
  at android.os.Parcel.readArrayMapInternal(Parcel.java:2314)
  at android.os.Bundle.unparcel(Bundle.java:249)
  at android.os.Bundle.getParcelable(Bundle.java:1206)
  at android.content.Intent.getParcelableExtra(Intent.java:4660)
  at com.realityi.bitshuttle.android.deviceconfigurationmanager.logging.LoggingIntentService.onHandleIntent(LoggingIntentService.java:40)

The generated file for my type is https://gist.github.com/AcaudalAoudad/4ebf63bb3dbe22249c9db5f0c2bfe19f.js

I'm using Intent.putExtra and Intent.getParcelableExtra to send and receive, could the fact that AutoValue_Event is defined in my AAR be the reason I'm getting this error? When I go through my calls with the debugger after calling Intent.putExtra in my AAR library I can immediately call getParcelableExtra and get the correct object, the problem doesn't appear until I receive the object in my Service, which isn't in the AAR library. I was using AutoParcel earlier, and it seemed to work for this use-case, but wasn't handling null values, so I'm not sure if it might just be something I'm doing wrong on my end.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.