File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
src/AndroidClient/client/src/main/java/net/servicestack/client Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1616import java .io .InputStream ;
1717import java .io .InputStreamReader ;
1818import java .io .UnsupportedEncodingException ;
19+ import java .lang .annotation .Annotation ;
1920import java .lang .reflect .Field ;
2021import java .lang .reflect .Modifier ;
2122import java .net .HttpURLConnection ;
@@ -53,19 +54,34 @@ public static Double tryParseDouble(String str) {
5354 }
5455 }
5556
57+ static final String KotlinAnnotationClass = "kotlin.jvm.internal.KotlinClass" ;
5658
59+ public static boolean isKotlinClass (Class type )
60+ {
61+ for (Annotation attr : type .getAnnotations ()){
62+ if (KotlinAnnotationClass .equals (attr .annotationType ().getName ()))
63+ return true ;
64+ }
65+ return false ;
66+ }
5767
5868 public static Field [] getSerializableFields (Class type ){
5969 List <Field > fields = new ArrayList <Field >();
70+ boolean isKotlin = isKotlinClass (type );
6071 for (Class <?> c = type ; c != null ; c = c .getSuperclass ()) {
6172 if (c == Object .class )
6273 break ;
6374
6475 for (Field f : c .getDeclaredFields ()) {
6576 if (Modifier .isStatic (f .getModifiers ()))
6677 continue ;
67- if (!Modifier .isPublic (f .getModifiers ()))
68- continue ;
78+ if (!Modifier .isPublic (f .getModifiers ())){
79+ if (isKotlin ){
80+ f .setAccessible (true ); //Kotlin class convention has private backing fields
81+ } else {
82+ continue ;
83+ }
84+ }
6985
7086 fields .add (f );
7187 }
You can’t perform that action at this time.
0 commit comments