Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectStreamClass.newInstance(Class<?>, long) is private API and will be removed in a future Android release. #58

Closed
ivanfeli opened this issue Oct 10, 2016 · 16 comments

Comments

@ivanfeli
Copy link

Warning I get in logcat after every Book.write()

I guess this is actually a Kryo problem?

@pilgr
Copy link
Owner

pilgr commented Oct 10, 2016

What kind of class are you trying to save?

@ivanfeli
Copy link
Author

The usual (String, integers, floats, boolean). Others are classes such as Date, HashMaps and Enums.

Btw this is on paperdb 1.5

@pilgr
Copy link
Owner

pilgr commented Oct 11, 2016

I can't reproduce this on a device running API23

@ivanfeli
Copy link
Author

ivanfeli commented Oct 11, 2016

Only happens on API24 for me.

@pakoito
Copy link
Contributor

pakoito commented Oct 11, 2016

@ivanfeli
Copy link
Author

I've been trying to reproduce it in an example project but nothing.

Been trying with different variations of Maps with Enums/Classes as their keys/values but no luck yet.

@pilgr pilgr closed this as completed Oct 28, 2016
@Nlpilip
Copy link

Nlpilip commented Jan 18, 2017

hello pilgr,
i also get this error when im reading/writing the following class:

public class Driver extends ModelBase{
    private String fname;
    private String lname;
    private String phoneNumber;
    private String emailAddress;
    private String recoveryKey;
    private String activeVehicleId;
    private String connectionId;
    private Vehicle activeVehicle;
public class Vehicle extends ModelBase implements Serializable{
    private String brand;
    private String licensePlate;
    private String status;
    private GPS gps;
    private String driverId;
    private String companyId;
    private String type;
    private String model;
    private Integer maxPassengers;
    private String gpsTime;

hope this can help with fixing the warning message

@arunkumar9t2
Copy link

I am currently getting this warning on API 25. I ll see if I can create a sample project.

@miszmaniac
Copy link

I can confirm I'm getting this errors

@FrescoFlacko
Copy link

I can also confirm I am getting this error, and I'm getting a SIGSEGV signal 11 crash also.

@raviteja06
Copy link

+1

@SennaGehenna
Copy link

+1 on Android 7.1.1 (SDK 25)

@erva
Copy link

erva commented Apr 4, 2017

+1 on Android 7.0

public class Profile {
    public final String ssid;
    public final String ip;
    public final int port;
}

@pilgr
Copy link
Owner

pilgr commented May 26, 2017

good news, guys!

please check out the version 2.1-rc1 and let me know if it all good. I'll publish the release after that.
compile 'io.paperdb:paperdb:2.1-rc1'

Some details if you curious.

Paper uses Kryo for serialization and deserialization objects. https://github.com/EsotericSoftware/kryo
This makes Paper so fast.

Kryo uses Objenesis lib to instantiate objects in a most efficient, platform specific way.
https://github.com/easymock/objenesis

Objenesis used some of the private ObjectStream methods to instantiate objects.

Starting from Android N Google uses Open JDK which doesn't contain (obviously) those private methods. And Google added those private methods with a warning which we all seen.
https://android.googlesource.com/platform/libcore/+/987c9ca%5E!/
Please check out the NOTE in that diff, they made this to not break Paper (actually Objenesis) haha

Objenesis fixed this in v 2.3
https://github.com/easymock/objenesis/releases/tag/2.3
But Kryo 4.0 (latest stable release) still use Objenesis 2.2.

So I fixed this in a way by forcibly specifying the updated Objenesis version in the Paper dependencies.
a090a23
This should work until Kryo will be updated with new dependency.

To speed up this I made a PR to Kryo
EsotericSoftware/kryo#514

All this means for you is you should update Paper version to 2.1 (2.1-rc1 for now) and that's it. Enjoy! :)

@Neferetheka
Copy link

Thanks pilgr for addressing all our concerns and fixing the issue!

@obuiron
Copy link

obuiron commented Jul 24, 2017

@pilgr
Kryo 4.0.1 has been released.
No longer need to force version of Objenesis in Paper's build.gradle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests