Giter VIP home page Giter VIP logo

Comments (23)

johncarl81 avatar johncarl81 commented on May 16, 2024

Yeah, the stacktraces suck... we can do a lot better. Would you like to take this challenge on?

Here's an example of line specific error registration:
https://github.com/johncarl81/parceler/blob/master/parceler%2Fsrc%2Fmain%2Fjava%2Forg%2Fparceler%2Finternal%2FParcelableAnalysis.java#L227-L228

Really we can do even better than you are suggesting, potentially underlining errors in IDEs and this sort of build error:

/.../parceler/examples/gradle/gradleParceler/src/main/java/org/demo/ExampleParcel.java:25: warning: Parceler: Reflection is required to modify private field: String message, consider using non-private.
    private String message;
                   ^

So, all you need to do is @Inject the Validator into the appropriate spot (ParcelableGenerator?) and gracefully handle the related error. What do you think @jacobtabak?

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

I'd love to look into it but I won't be able to get to it for quite some time, so if anyone else stumbles upon this issue please feel free to dig in.

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

Fair enough. I went ahead and tackled it (4c5f762). Here's what the error message looks like:

:gradleParceler:compileDebugJava
/mnt/hd1/home/john/dev/parceler/examples/gradle/gradleParceler/src/main/java/org/demo/ExampleParcel.java:25: error: Parceler: Unable to find read/write generator for type java.lang.Object
    private Object message;
                   ^
1 error

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

@jacobtabak, did you have a chance to look at this? It's deployed under version 0.2.14-SNAPSHOT.

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

@johncarl81 Do I need to add a snapshot repository? I tried adding

compile "org.parceler:parceler-api:0.2.14-SNAPSHOT"
provided "org.parceler:parceler:0.2.14-SNAPSHOT"

I also tried adding the sonatype snapshots repo but it could not be found.

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024
repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}

Here's an example: https://github.com/johncarl81/parceler/blob/master/examples/gradle/gradleParceler/build.gradle

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

This is what I see in the IDE:

screen shot 2014-11-01 at 10 12 40 am

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

I deleted one of my comments above because I think that was the existing functionality. I'm still seeing pretty much the same stack trace as before, with no clue as to where or what the actual problem is.

Exception in thread "pool-5-thread-1" org.parceler.ParcelerRuntimeException: Unable to find appropriate Parcel method to write java.lang.Object
at org.parceler.internal.Generators.getGenerator(Generators.java:49)
at org.parceler.internal.generator.MapReadWriteGenerator.generateReader(MapReadWriteGenerator.java:90)
at org.parceler.internal.ParcelableGenerator.buildReadFromParcelExpression(ParcelableGenerator.java:282)
at org.parceler.internal.ParcelableGenerator.buildReadFromParcel(ParcelableGenerator.java:234)
at org.parceler.internal.ParcelableGenerator.buildParcelRead(ParcelableGenerator.java:166)
at org.parceler.internal.generator.ParcelReadWriteGenerator.generateReader(ParcelReadWriteGenerator.java:63)
at org.parceler.internal.ParcelableGenerator.buildReadFromParcelExpression(ParcelableGenerator.java:282)
at org.parceler.internal.ParcelableGenerator.buildReadFromParcel(ParcelableGenerator.java:234)
at org.parceler.internal.ParcelableGenerator.buildParcelRead(ParcelableGenerator.java:166)
at org.parceler.internal.ParcelableGenerator.generateParcelable(ParcelableGenerator.java:100)
at org.parceler.internal.ParcelTransactionWorker.innerRun(ParcelTransactionWorker.java:54)
at org.parceler.internal.ParcelTransactionWorker.innerRun(ParcelTransactionWorker.java:34)
at org.parceler.transfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.parceler.transfuse.transaction.CodeGenerationScopedTransactionWorker.innerRun(CodeGenerationScopedTransactionWorker.java:47)
at org.parceler.transfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.parceler.transfuse.transaction.ScopedTransactionWorker.run(ScopedTransactionWorker.java:55)
at org.parceler.transfuse.transaction.Transaction.run(Transaction.java:77)
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:744)
Exception in thread "pool-5-thread-2" org.parceler.ParcelerRuntimeException: Unable to find appropriate Parcel method to write java.lang.Object
at org.parceler.internal.Generators.getGenerator(Generators.java:49)
at org.parceler.internal.generator.MapReadWriteGenerator.generateReader(MapReadWriteGenerator.java:90)
at org.parceler.internal.ParcelableGenerator.buildReadFromParcelExpression(ParcelableGenerator.java:282)
at org.parceler.internal.ParcelableGenerator.buildReadFromParcel(ParcelableGenerator.java:234)
at org.parceler.internal.ParcelableGenerator.buildParcelRead(ParcelableGenerator.java:166)
at org.parceler.internal.ParcelableGenerator.generateParcelable(ParcelableGenerator.java:100)
at org.parceler.internal.ParcelTransactionWorker.innerRun(ParcelTransactionWorker.java:54)
at org.parceler.internal.ParcelTransactionWorker.innerRun(ParcelTransactionWorker.java:34)
at org.parceler.transfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.parceler.transfuse.transaction.CodeGenerationScopedTransactionWorker.innerRun(CodeGenerationScopedTransactionWorker.java:47)
at org.parceler.transfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.parceler.transfuse.transaction.ScopedTransactionWorker.run(ScopedTransactionWorker.java:55)
at org.parceler.transfuse.transaction.Transaction.run(Transaction.java:77)
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:744)

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

hmm, are you using the SNAPSHOT? Can you share your annotated class?

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

Yes, definitely using Snapshot.

I will spend some time later (in the next few days hopefully) trying to figure out exactly what the problem is and where we can improve the error messages to give users guidance about how they can resolve the issue, but it's definitely a very complex class that Parceler wouldn't be able to handle automatically - it has fields that are abstract classes, other complex objects, etc. It can be serialized, though, and I am doing that for now.

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

Sounds good. I'm particularly curious if I missed a validation case. Let me know.

from parceler.

felipe-silvestre-morais avatar felipe-silvestre-morais commented on May 16, 2024

I was using version 0.2.13, Until today was working good, but now it happens the same problem:

Error:Exception in thread "pool-18-thread-1" java.lang.NullPointerException
at com.sun.tools.javac.model.JavacElements.cast(JavacElements.java:632)
at com.sun.tools.javac.model.JavacElements.getPackageOf(JavacElements.java:367)
at org.androidtransfuse.adapter.element.ASTElementFactory.buildPackageClass(ASTElementFactory.java:130)
at org.androidtransfuse.adapter.element.ASTElementFactory.buildType(ASTElementFactory.java:87)
at org.androidtransfuse.adapter.element.ASTElementFactory.getType(ASTElementFactory.java:78)
at org.androidtransfuse.adapter.element.ReloadableASTElementFactory$ReloadableASTTypeProvider.get(ReloadableASTElementFactory.java:65)
at org.androidtransfuse.adapter.element.ReloadableASTElementFactory$ReloadableASTTypeProvider.get(ReloadableASTElementFactory.java:53)
at org.parceler.internal.ExternalParcelTransactionWorker.innerRun(ExternalParcelTransactionWorker.java:53)
at org.parceler.internal.ExternalParcelTransactionWorker.innerRun(ExternalParcelTransactionWorker.java:37)
at org.androidtransfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.androidtransfuse.transaction.CodeGenerationScopedTransactionWorker.innerRun(CodeGenerationScopedTransactionWorker.java:47)
at org.androidtransfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.androidtransfuse.transaction.ScopedTransactionWorker.run(ScopedTransactionWorker.java:55)
at org.androidtransfuse.transaction.Transaction.run(Transaction.java:77)
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)
Exception in thread "pool-18-thread-2" java.lang.NullPointerException
at com.sun.tools.javac.model.JavacElements.cast(JavacElements.java:632)
at com.sun.tools.javac.model.JavacElements.getPackageOf(JavacElements.java:367)
at org.androidtransfuse.adapter.element.ASTElementFactory.buildPackageClass(ASTElementFactory.java:130)
at org.androidtransfuse.adapter.element.ASTElementFactory.buildType(ASTElementFactory.java:87)
at org.androidtransfuse.adapter.element.ASTElementFactory.getType(ASTElementFactory.java:78)
at org.androidtransfuse.adapter.element.ReloadableASTElementFactory$ReloadableASTTypeProvider.get(ReloadableASTElementFactory.java:65)
at org.androidtransfuse.adapter.element.ReloadableASTElementFactory$ReloadableASTTypeProvider.get(ReloadableASTElementFactory.java:53)
at org.parceler.internal.ExternalParcelTransactionWorker.innerRun(ExternalParcelTransactionWorker.java:53)
at org.parceler.internal.ExternalParcelTransactionWorker.innerRun(ExternalParcelTransactionWorker.java:37)
at org.androidtransfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.androidtransfuse.transaction.CodeGenerationScopedTransactionWorker.innerRun(CodeGenerationScopedTransactionWorker.java:47)
at org.androidtransfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.androidtransfuse.transaction.ScopedTransactionWorker.run(ScopedTransactionWorker.java:55)
at org.androidtransfuse.transaction.Transaction.run(Transaction.java:77)
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)
Exception in thread "pool-19-thread-1" java.lang.NullPointerException
at com.sun.tools.javac.model.JavacElements.cast(JavacElements.java:632)
at com.sun.tools.javac.model.JavacElements.getPackageOf(JavacElements.java:367)
at org.androidtransfuse.adapter.element.ASTElementFactory.buildPackageClass(ASTElementFactory.java:130)
at org.androidtransfuse.adapter.element.ASTElementFactory.buildType(ASTElementFactory.java:87)
at org.androidtransfuse.adapter.element.ASTElementFactory.getType(ASTElementFactory.java:78)
at org.androidtransfuse.adapter.element.ReloadableASTElementFactory$ReloadableASTTypeProvider.get(ReloadableASTElementFactory.java:65)
at org.androidtransfuse.adapter.element.ReloadableASTElementFactory$ReloadableASTTypeProvider.get(ReloadableASTElementFactory.java:53)
at org.parceler.internal.ExternalParcelTransactionWorker.innerRun(ExternalParcelTransactionWorker.java:53)
at org.parceler.internal.ExternalParcelTransactionWorker.innerRun(ExternalParcelTransactionWorker.java:37)
at org.androidtransfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.androidtransfuse.transaction.CodeGenerationScopedTransactionWorker.innerRun(CodeGenerationScopedTransactionWorker.java:47)
at org.androidtransfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.androidtransfuse.transaction.ScopedTransactionWorker.run(ScopedTransactionWorker.java:55)
at org.androidtransfuse.transaction.Transaction.run(Transaction.java:77)
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)
Exception in thread "pool-19-thread-2" java.lang.NullPointerException
at com.sun.tools.javac.model.JavacElements.cast(JavacElements.java:632)
at com.sun.tools.javac.model.JavacElements.getPackageOf(JavacElements.java:367)
at org.androidtransfuse.adapter.element.ASTElementFactory.buildPackageClass(ASTElementFactory.java:130)
at org.androidtransfuse.adapter.element.ASTElementFactory.buildType(ASTElementFactory.java:87)

at org.androidtransfuse.adapter.element.ASTElementFactory.getType(ASTElementFactory.java:78)
at org.androidtransfuse.adapter.element.ReloadableASTElementFactory$ReloadableASTTypeProvider.get(ReloadableASTElementFactory.java:65)
at org.androidtransfuse.adapter.element.ReloadableASTElementFactory$ReloadableASTTypeProvider.get(ReloadableASTElementFactory.java:53)
at org.parceler.internal.ExternalParcelTransactionWorker.innerRun(ExternalParcelTransactionWorker.java:53)
at org.parceler.internal.ExternalParcelTransactionWorker.innerRun(ExternalParcelTransactionWorker.java:37)
at org.androidtransfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)
at org.androidtransfuse.transaction.CodeGenerationScopedTransactionWorker.innerRun(CodeGenerationScopedTransactionWorker.java:47)

FAILURE: Build failed with an exception.
at org.androidtransfuse.transaction.AbstractCompletionTransactionWorker.run(AbstractCompletionTransactionWorker.java:35)

at org.androidtransfuse.transaction.ScopedTransactionWorker.run(ScopedTransactionWorker.java:55)
  • What went wrong:
    at org.androidtransfuse.transaction.Transaction.run(Transaction.java:77)
    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)
    Execution failed for task ':app:compileDebugJava'.

    org.androidtransfuse.TransfuseAnalysisException: @parcel code generation did not complete successfully.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

One case that I just ran into was this. I'm sorry I haven't tested this with the snapshot, but it definitely reproduces a case where there should be a better error message.

@Parcel
public class TestModel {
  List testList;
}

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

Ah, I see, the generic parameter is not mapped (Object in this case). Here's the fix: 8b3c092 and it's deployed under 0.2.14-SNAPSHOT.

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

Thanks, I did a ./gradlew --refresh-dependencies and saw the latest snapshot (from 11/10) come down, but I'm still seeing the same behavior on this class (with a hashmap, rather than a list)

    @Parcel
    public class Meta {
      String request;
      String method;
      int code;
      HashMap request_parameters;
      String error_type;
      String error_message;
    }

Also, in the 'messages' window in AS/IntelliJ, I see this error:

org.parceler.transfuse.TransfuseAnalysisException: @parcel code generation did not complete successfully.

I think it would be very helpful to see the actual exception in the 'messages' window, something like this:

org.parceler.transfuse.TransfuseAnalysisException: @parcel code generation did not complete successfully. Unable to find appropriate Parcel method to write java.lang.Object

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

Updated this a bit... give it another try.

I'll need to look into proper intellij output.

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

Still not seeing anything useful in the gradle build output (using 0.2.14 from Central, now). I haven't noticed any of your changes in the output.

Exception in thread "pool-5-thread-1" org.parceler.ParcelerRuntimeException: Unable to find appropriate Parcel method to write java.lang.Object at org.parceler.internal.Generators.getGenerator(Generators.java:49)

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

And that's against the same Meta class?

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

Yes, same class

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

Finally got some time to look at this deeper..

I could remove or otherwise mask (optional?) the exception thrown during the last round of annotation processing. The results are this:

Intellij:
image

Maven:

[ERROR] /.../src/main/java/org/demo/Meta.java:[13,11] Parceler: Unable to find read/write generator for type java.util.Map

Gradle:

/.../src/main/java/org/app/Meta.java:13: error: Parceler: Unable to find read/write generator for type java.util.Map
      Map request_parameters;
          ^

Is this what you are looking for @jacobtabak?

FYI, with my latest changes to 0.2.14 HashMap will be considered a Serializable where HashMap<Stuff, Stuff> is parceled properly. I wonder if I should throw a warning if the Serializalbe read/write generator is called for.

from parceler.

jacobtabak avatar jacobtabak commented on May 16, 2024

That looks a lot better!

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

If you'd like to try it, it's available under 0.2.15-SNAPSHOT.

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

Im going to close as this seems to be working well. Please reopen if it's still an issue.

from parceler.

Related Issues (20)

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.