Comments (13)
Alternative
Use serialization bean to avoid warnings.
@Parcel(Parcel.Serialization.BEAN)
from parceler.
For me, warnings look like this:
Maven:
[WARNING] /.../FieldModifiers.java:[26,20] Parceler: Reflection is required to modify private fields, consider using non-private.
Gradle:
/.../ExampleParcel.java:25: warning: Parceler: Reflection is required to access private fields, consider using non-private.
private String message;
^
Both of these show class and line numbers specifically. I wonder if Maven could be configured to output like Gradle. What build tool are you using?
from parceler.
I'm using gradle with Android Studio, how did you enable line numbers for gradle?
I initially thought Android Studio's stripping line numbers and file info off so I tried to compile in a regular cmd window:
gradlew assembledebug
and the output is like
....
:app:generateDebugSources
:app:compileDebugJava
warning: Parceler: Reflection is required to modify final fields, consider using non-private.
warning: Parceler: Reflection is required to modify private fields, consider using non-private.
warning: Parceler: Reflection is required to access private fields, consider using non-private.
warning: Parceler: Reflection is required to modify private final fields, consider using non-private.
warning: Parceler: Reflection is required to access private fields, consider using non-private.
....
from parceler.
Hmm, does Android Studio add the yellow underline under the fields that these warnings are referencing? I am open to adding some more detail into the message output by Parceler, perhaps something like this:
warning: Parceler: Reflection is required to access private field: <FIELD_NAME>, consider using non-private.
from parceler.
Yep, something like that would be awesome!
My Android Studio's gradle console looks like this when compiling:
Having the field type would be handy too :)
from parceler.
I've added this to the latest build under 0.2.11-SNAPSHOT and deployed to Maven central if you'd like to try it out. Of course, let me know how it works for you. It may be a little while until I can release a non-SNAPSHOT as I'm working on some core changes in the supporting libraries where this change was made.
private field warnings should look like this now:
warning: Parceler: Reflection is required to modify private field: String message, consider using non-private.
warning: Parceler: Reflection is required to access private field: String message, consider using non-private.
For good measure I also implemented this for private constructor and method warnings which are used by Transfuse and not Parceler. This is what it looks like:
warning: Transfuse: Reflection is required to access private constructor: AssistedTarget(AssistedDependency dependency), consider using non-private.
warning: Transfuse: Reflection is required to call private method: setVibrator(Vibrator vibrator), consider using non-private.
from parceler.
Sorry for the late response,I was preparing for my high school graduation. I've added the dependency to my build.gradle like:
provided 'org.parceler:parceler:0.2.11-SNAPSHOT'
compile 'org.parceler:parceler-api:0.2.11-SNAPSHOT'
But it seems that the binaries are not on maven, can you try re-uploading?
from parceler.
It's up there. make sure you include the SNAPSHOT repository:
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
from parceler.
Repo added and project synced, here is my output:
warning: Parceler: Reflection is required to modify private final field: String NULL, consider using non-private.
warning: Parceler: Reflection is required to access private field: String NULL, consider using non-private.
(Yes, NULL
is the field name; this feature helped me discovered an useless constant that was in the codebase :))
Thanks! it worked.
Now I'm just waiting for this to be merged with master(along with the icepick stuff)
from parceler.
@Parcel(Parcel.Serialization.BEAN)
Awesome findings!!! Thanks.
from parceler.
Alternative
Use serialization bean to avoid warnings.
@Parcel(Parcel.Serialization.BEAN)
Are there any other impacts of using @Parcel(Parcel.Serialization.BEAN)
for deserialization?
from parceler.
The impact is that the Parcelable
wrapper uses the getters instead of the fields directly, which adds some (hopefully) minimal overhead.
from parceler.
In my case, I observed for subsequent in non-premitive data classes also you have to add @Parcel(Parcel.Serialization.BEAN)
otherwise it may lose the data.
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.