omanand / dex2jar

Automatically exported from code.google.com/p/dex2jar
0 stars 0 forks source link

Annotation with type, type lost to a string #222

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Take this class that is using jackson databinding :

package com.example.android.apis.annotations;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

@JsonSubTypes(
    {
      @com.fasterxml.jackson.annotation.JsonSubTypes.Type(name="subObject", value=MrSubObject.class)
    }
  )
@JsonTypeInfo(defaultImpl=MrObject.class, include=JsonTypeInfo.As.PROPERTY, 
property="type", use=JsonTypeInfo.Id.NAME, visible=true)
public class MrObject
{

}

Compile it and dex it (like any android build), running dex2jar will produce a 
class where type information has been replaced by string :

package com.example.android.apis.annotations;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;

@JsonSubTypes({@com.fasterxml.jackson.annotation.JsonSubTypes.Type(name="subObje
ct", value="Lcom/example/android/apis/annotations/MrSubObject;")})
@JsonTypeInfo(defaultImpl="Lcom/example/android/apis/annotations/MrObject;", 
include=JsonTypeInfo.As.PROPERTY, property="type", use=JsonTypeInfo.Id.NAME, 
visible=true)
public class MrObject
{
}

At android runtime you will get :

E/AndroidRuntime(19667): Caused by: java.lang.IllegalStateException: Expected 
18 but was 17
E/AndroidRuntime(19667):    at 
com.android.dex.EncodedValueReader.checkType(EncodedValueReader.java:283)
E/AndroidRuntime(19667):    at 
com.android.dex.EncodedValueReader.readType(EncodedValueReader.java:183)
E/AndroidRuntime(19667):    at 
libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:723)
E/AndroidRuntime(19667):    at 
libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:692)
E/AndroidRuntime(19667):    at 
libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:718)
E/AndroidRuntime(19667):    at 
libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:705)
E/AndroidRuntime(19667):    at 
libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:692)
E/AndroidRuntime(19667):    at 
libcore.reflect.AnnotationAccess.annotationSetToAnnotations(AnnotationAccess.jav
a:662)
E/AndroidRuntime(19667):    at 
libcore.reflect.AnnotationAccess.getDeclaredAnnotations(AnnotationAccess.java:16
2)
E/AndroidRuntime(19667):    at 
java.lang.Class.getDeclaredAnnotations(Class.java:858)
E/AndroidRuntime(19667):    at 
com.fasterxml.jackson.databind.introspect.AnnotatedClass.resolveClassAnnotations
(Unknown Source)

Reproduction with dex2jar-0.0.9.15

Original issue reported on code.google.com by emmanuel...@gmail.com on 20 Mar 2014 at 1:33

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The last build works fine.
Thanks, that was fast !

Original comment by emmanuel...@gmail.com on 20 Mar 2014 at 3:31