Giter VIP home page Giter VIP logo

Comments (13)

Aks-4125 avatar Aks-4125 commented on May 22, 2024 3

Alternative
Use serialization bean to avoid warnings.

@Parcel(Parcel.Serialization.BEAN)

from parceler.

johncarl81 avatar johncarl81 commented on May 22, 2024

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.

tom91136 avatar tom91136 commented on May 22, 2024

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.

johncarl81 avatar johncarl81 commented on May 22, 2024

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.

tom91136 avatar tom91136 commented on May 22, 2024

Yep, something like that would be awesome!
My Android Studio's gradle console looks like this when compiling:
2014-6-3 10-01-09

Having the field type would be handy too :)

from parceler.

johncarl81 avatar johncarl81 commented on May 22, 2024

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.

tom91136 avatar tom91136 commented on May 22, 2024

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.

johncarl81 avatar johncarl81 commented on May 22, 2024

It's up there. make sure you include the SNAPSHOT repository:

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}

from parceler.

tom91136 avatar tom91136 commented on May 22, 2024

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.

mochadwi avatar mochadwi commented on May 22, 2024

@Parcel(Parcel.Serialization.BEAN)

Awesome findings!!! Thanks.

from parceler.

aniketmane avatar aniketmane commented on May 22, 2024

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.

johncarl81 avatar johncarl81 commented on May 22, 2024

The impact is that the Parcelable wrapper uses the getters instead of the fields directly, which adds some (hopefully) minimal overhead.

from parceler.

aniketmane avatar aniketmane commented on May 22, 2024

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)

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.