pilgr / Paper

Paper is a fast NoSQL-like storage for Java/Kotlin objects on Android with automatic schema migration support.
Apache License 2.0
2.35k stars 234 forks source link

Explicitly Make PaperTable Public #195

Closed nabil6391 closed 2 years ago

nabil6391 commented 2 years ago

This PR makes PaperTable explicitly public. This is to avoid R8 obsfuscation removing the public access modifier that started happening in AGP 7.0.2

Steps to reproduce (Taken from #188 )

2021-09-07 12:25:56.147 7132-7177/paperdb.io.paperdb W/erdb.io.paperd: Accessing hidden method Lsun/nio/ch/DirectBuffer;->cleaner()Lsun/misc/Cleaner; (greylist, linking, allowed)
2021-09-07 12:25:56.147 7132-7177/paperdb.io.paperdb W/erdb.io.paperd: Accessing hidden method Lsun/misc/Cleaner;->clean()V (greylist,core-platform-api, linking, allowed)
2021-09-07 12:25:56.154 7132-7177/paperdb.io.paperdb W/erdb.io.paperd: Accessing hidden field Ljava/util/Arrays$ArrayList;->a:[Ljava/lang/Object; (greylist, reflection, allowed)
2021-09-07 12:25:56.154 7132-7177/paperdb.io.paperdb W/erdb.io.paperd: Accessing hidden field Ljava/util/Collections$UnmodifiableCollection;->c:Ljava/util/Collection; (greylist, reflection, allowed)
2021-09-07 12:25:56.154 7132-7177/paperdb.io.paperdb W/erdb.io.paperd: Accessing hidden field Ljava/util/Collections$UnmodifiableMap;->m:Ljava/util/Map; (greylist, reflection, allowed)
2021-09-07 12:25:56.157 7132-7177/paperdb.io.paperdb W/erdb.io.paperd: Accessing hidden field Ljava/util/Collections$SynchronizedCollection;->c:Ljava/util/Collection; (greylist, reflection, allowed)
2021-09-07 12:25:56.157 7132-7177/paperdb.io.paperdb W/erdb.io.paperd: Accessing hidden field Ljava/util/Collections$SynchronizedMap;->m:Ljava/util/Map; (greylist, reflection, allowed)
2021-09-07 12:25:56.163 7132-7177/paperdb.io.paperdb E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
    Process: paperdb.io.paperdb, PID: 7132
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$4.done(AsyncTask.java:415)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: io.paperdb.PaperDbException: Couldn't read/deserialize file /data/user/0/paperdb.io.paperdb/files/io.paperdb/o1.pt for table o1
        at io.paperdb.DbStoragePlainFile.readTableFile(:323)
        at io.paperdb.DbStoragePlainFile.select(:166)
        at io.paperdb.Book.read(:73)
        at paperdb.io.paperdb.MainActivity$e.a(:131)
        at paperdb.io.paperdb.MainActivity$e.doInBackground(:120)
        at android.os.AsyncTask$3.call(AsyncTask.java:394)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 
     Caused by: com.esotericsoftware.kryo.KryoException: Error constructing instance of class: io.paperdb.PaperTable
        at com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy$2.newInstance(:1300)
        at com.esotericsoftware.kryo.Kryo.newInstance(:1139)
        at com.esotericsoftware.kryo.serializers.FieldSerializer.create(:562)
        at com.esotericsoftware.kryo.serializers.FieldSerializer.read(:538)
        at com.esotericsoftware.kryo.Kryo.readObject(:712)
        at io.paperdb.DbStoragePlainFile.readContent(:332)
        at io.paperdb.DbStoragePlainFile.readTableFile(:316)
        at io.paperdb.DbStoragePlainFile.select(:166) 
        at io.paperdb.Book.read(:73) 
        at paperdb.io.paperdb.MainActivity$e.a(:131) 
        at paperdb.io.paperdb.MainActivity$e.doInBackground(:120) 
        at android.os.AsyncTask$3.call(AsyncTask.java:394) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 
     Caused by: java.lang.IllegalAccessException: java.lang.Class<io.paperdb.PaperTable> is not accessible from java.lang.Class<com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy$2>
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy$2.newInstance(:1298)
        at com.esotericsoftware.kryo.Kryo.newInstance(:1139) 
        at com.esotericsoftware.kryo.serializers.FieldSerializer.create(:562) 
        at com.esotericsoftware.kryo.serializers.FieldSerializer.read(:538) 
        at com.esotericsoftware.kryo.Kryo.readObject(:712) 
        at io.paperdb.DbStoragePlainFile.readContent(:332) 
        at io.paperdb.DbStoragePlainFile.readTableFile(:316) 
        at io.paperdb.DbStoragePlainFile.select(:166) 
        at io.paperdb.Book.read(:73) 
        at paperdb.io.paperdb.MainActivity$e.a(:131) 
        at paperdb.io.paperdb.MainActivity$e.doInBackground(:120) 
        at android.os.AsyncTask$3.call(AsyncTask.java:394) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 

Testing My Build

nabil6391 commented 2 years ago

This pull request fixes the issues #188 #189 #190 #191 #192 #193.

I am sorry I created another PR because the previous PR was not being updated as per the request. Hope you guys understand

@pilgr

pilgr commented 2 years ago

@nabil6391 thanks for making the PR!