AiorosXu / google-gson

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

java.lang.IllegalStateException when parsing String as double #59

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Define a class with a double type called "test"
2. Construct some JSON passing a String in place of the double: {"test": "-1"}
3. Parse the JSON into your class

What is the expected output? What do you see instead?

Expected: JSONException

Actual:
Exception in thread "Timer-0" java.lang.IllegalStateException: How can the type 
variable not be 
present in the class declaration!
    at com.google.gson.TypeInfoFactory.getIndex(TypeInfoFactory.java:121)
    at com.google.gson.TypeInfoFactory.getActualType(TypeInfoFactory.java:92)
    at com.google.gson.TypeInfoFactory.extractRealTypes(TypeInfoFactory.java:110)
    at com.google.gson.TypeInfoFactory.getActualType(TypeInfoFactory.java:65)
    at com.google.gson.TypeInfoFactory.getTypeInfoForField(TypeInfoFactory.java:54)
    at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:166)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:151)
    at com.google.gson.JsonDeserializationVisitor.visitChild(JsonDeserializationVisitor.java:131)
    at 
com.google.gson.JsonDeserializationVisitor.visitChildAsObject(JsonDeserializatio
nVisitor.java:93)
    at 
com.google.gson.JsonObjectDeserializationVisitor.visitObjectField(JsonObjectDese
rializationVisit
or.java:75)
    at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:179)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:151)
    at 
com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializa
tionContextD
efault.java:75)
    at 
com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializatio
nContextDefaul
t.java:47)
    at com.google.gson.Gson.fromJson(Gson.java:378)
    at com.google.gson.Gson.fromJson(Gson.java:326)
    at com.google.gson.Gson.fromJson(Gson.java:302)

What version of the product are you using? On what operating system?

GSON 1.2 on OSX

Please provide any additional information below.

Original issue reported on code.google.com by ch...@gmail.com on 15 Oct 2008 at 6:14

GoogleCodeExporter commented 9 years ago
Actually, you can close this. I think I misdiagnosed the problem. Sorry about 
that!

Original comment by ch...@gmail.com on 15 Oct 2008 at 6:19

GoogleCodeExporter commented 9 years ago
This actually is a problem for certain types; however, it is covered by issue 
#40. 
Closing this off as a duplicate.

Original comment by joel.leitch@gmail.com on 16 Oct 2008 at 5:58