Menu

#130 Can't transform Groovy map to JSONObject with key "log"

open
nobody
None
5
2012-07-25
2012-07-25
Ken Weiner
No

The following line causes the error: java.lang.VerifyError: Cannot inherit from final class

def fromMap = [log: 1, other: true] as JSONObject

The reason seems to be that the JSONObject class has a member variable called log. This should be documented in the Javadoc

Similarly, you can't instantiate JSONObject passing it a similar map containing a key "log":

def jsonObject = new JSONObject([log: 1, other: true])

You end up with:

groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: log for class: net.sf.json.JSONObject

I think that it needs to be documented that the word "log" is not allowed, or more preferably, JSONObject needs to be fixed to allow maps with key "log".

Discussion


Log in to post a comment.