Comments (23)
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.
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.
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.
@jacobtabak, did you have a chance to look at this? It's deployed under version 0.2.14-SNAPSHOT.
from parceler.
@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.
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.
This is what I see in the IDE:
from parceler.
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.
hmm, are you using the SNAPSHOT? Can you share your annotated class?
from parceler.
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.
Sounds good. I'm particularly curious if I missed a validation case. Let me know.
from parceler.
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.
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.
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.
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.
Updated this a bit... give it another try.
I'll need to look into proper intellij output.
from parceler.
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.
And that's against the same Meta
class?
from parceler.
Yes, same class
from parceler.
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:
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.
That looks a lot better!
from parceler.
If you'd like to try it, it's available under 0.2.15-SNAPSHOT.
from parceler.
Im going to close as this seems to be working well. Please reopen if it's still an issue.
from parceler.
Related Issues (20)
- Ability to treat reflection warnings as errors HOT 5
- Parceler fails when used with with Lifecycle-viewmodel 2.2.0 HOT 7
- Facing Vulnerabilities in parceler library HOT 1
- Facing Vulnerabilities in parceler library HOT 1
- Polymorphism documentation not updated? HOT 6
- Cannot get working with navigation graph HOT 1
- Crashing on background HOT 4
- ParcelAnnotationProcessor.process take lot amount of time. HOT 15
- Unable to find generated Parcelable class HOT 1
- error: Parceler: Code generation did not complete successfully. HOT 47
- Cant find class to parcel ! HOT 1
- Can't generate code HOT 3
- Unable to Marshall with Parceler HOT 2
- Errors in HashMap$$PackageHelper HOT 3
- cannot running with kapt HOT 1
- Parceler: Code generation did not complete successfully. org.parceler.transfuse.transaction.TransactionRuntimeException: Encountered ErrorType <error>, unable to recover HOT 4
- [Request Feature] Support for Kotlin Symbol Processing
- Parceler code generation fails on AS 2023.3.1
- Getters and Setter Alphabetically Order for Write and Read
- Not sure how to convert a Cursor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parceler.