Broken annotations on Android with data class


#1

I am using Kotlin 0.491 and Simple XML 2.6.7 library (for xml processing)

This will return at runtime: ERROR/dalvikvm(1557): Unable to resolve Lcom/silverkeytech/android_rivers/outlines/Opml; annotation class 1207

package com.silverkeytech.android_rivers.outlines

import org.simpleframework.xml.Attribute
import org.simpleframework.xml.Element
import org.simpleframework.xml.Root

[Root(strict=false)]
public data class Opml() {
  [Element] public var head: Head? = null
  [Attribute] public var version: String? = null
}

package com.silverkeytech.android_rivers.outlines

import org.simpleframework.xml.Element

public data class Head() {
  [Element] public var title: String? = null
  [Element] public var dateCreated: String? = null
  [Element] public var dateModified: String? = null
  [Element] public var ownerName: String? = null
}

Kotlin function that makes the deserialization

  fun transformFromXml(xml : String?){   var serial : Serializer = Persister()

    try{

           val opml : Opml? = serial.read(javaClass<Opml>(),xml)
           Log.d(TAG, “OPML ${opml?.head?.title}”)

  &nbsp;&nbsp;}
  &nbsp;&nbsp;catch (e: Exception){

           Log.d(TAG, “Exception ${e.getMessage()}”)
  }
  }

However if you remove the data keyword, it works just fine.


#2

Looks like a bug, but we need some time to find where the problem is. So it would be great if you report it to your tracker.


#3

Yeah I will. There's actually more problem with this. I have to convert my kotlin class to java to be able to use Simple XML library in Android. Even if it compiles, it has all weird behavior and complains at run time especially when using [ElementList] annotation.