AnswerBun.com

Using Protostuff on Android causes RuntimeException because of missing sun.reflect.ReflectionFactory

Stack Overflow Asked by Daan on December 15, 2020

I’m trying to use Protostuff version 1.7.2 in Android to serialize and deserialize some user-defined classes. I’m generating the Protostuff’s schema’s during runtime with the RuntimeSchema.getSchema() method. However, I’m running into a RuntimeException when I call this method.

I’ve pinned down the issue to sun.reflect.ReflectionFactory not existing in Android. Protostuff tries to load this class here, but appearently can’t do so on Android, causing the return value here to be null, which triggers the RuntimeException. I tried to run the same code (see below) on Ubuntu/Windows, there my code runs fine because the installed Java runtime includes sun.reflect.ReflectionFactory.

final DefaultIdStrategy STRATEGY = new DefaultIdStrategy(IdStrategy.DEFAULT_FLAGS
                | IdStrategy.ALLOW_NULL_ARRAY_ELEMENT
                | IdStrategy.MORPH_COLLECTION_INTERFACES
                | IdStrategy.MORPH_MAP_INTERFACES
                | IdStrategy.MORPH_NON_FINAL_POJOS);
schema = RuntimeSchema.getSchema(clazz, STRATEGY);

I tried to use protostuff-runtime-md, which should work on Android, but no luck.

Can anyone tell me how to get this to work on Android?

Add your own answers!

Related Questions

Undefined reference to vtable

19  Asked on November 20, 2021 by ryang

     

Using wildcards in between a C# DataTable Select statement

3  Asked on November 20, 2021 by bugaboo

   

SendKeys.send is sending more than one character

1  Asked on November 20, 2021 by onur-klekci

   

pwsh -Command is removing quotation marks

3  Asked on November 20, 2021 by chris-g

 

Django when is concrete inheritance appropriate

1  Asked on November 20, 2021 by natehawkboss

   

Get the sum of numbers from array objects

6  Asked on November 20, 2021 by askmen

 

Function to keep listening a service Angular 8

2  Asked on November 20, 2021 by rob-none

         

How to perform mathematical operation which is stored as character in R?

1  Asked on November 20, 2021 by hidden-layer

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP