pascallouisperez / jsonmarshaller

JsonMarshaller is a Java 1.5 library that allows marshalling and unmarshalling of JSON objects to and from entities ("Java classes").
Apache License 2.0
1 stars 0 forks source link

primitive array issue #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
@Entity 
public class Data {

@Value int[] rows;

public void set(int[] _rows){..}
public int[] get() {..}
}

This throws IllegalArgumentException when setting the field. I believe this
is because and Integer[] is created and attempted to set the field.
The stack-trace is below. I working on a patch since I need this feature soon.
java.lang.IllegalArgumentException
    at
sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java
:63)
    at java.lang.reflect.Field.set(Field.java:656)
    at
com.twolattes.json.FieldDescriptor$DirectAccessFieldDescriptor.setFieldValue(Fie
ldDescriptor.java:168)
    at
com.twolattes.json.ConcreteEntityDescriptor.unmarshallFields(ConcreteEntityDescr
iptor.java:271)
    at
com.twolattes.json.ConcreteEntityDescriptor.unmarshall(ConcreteEntityDescriptor.
java:229)
    at com.twolattes.json.Marshaller.unmarshall(Marshaller.java:183)
    at com.twolattes.json.Marshaller.unmarshall(Marshaller.java:172)
    at
...............................JsonBuilderTest.testJson(JsonBuilderTest.java:196
)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Original issue reported on code.google.com by labikni...@gmail.com on 11 Apr 2008 at 2:28

GoogleCodeExporter commented 9 years ago
I decided to create a PrimitiveSupport interface to represent Descriptors that 
can
support their primitive forms. e.g IntegerDescriptor. The appropiate descriptors
implemented this interface and the ArrayDescriptor relies on this interface to 
tell
if a descriptor supports primitives or not. I have not tested with the 
non-primitive
kinds. I have attached the sources files that I changed

Original comment by labikni...@gmail.com on 11 Apr 2008 at 4:19

Attachments:

GoogleCodeExporter commented 9 years ago
I forgot to add the PrimitiveSupport interface to my previous patch.

Original comment by labikni...@gmail.com on 11 Apr 2008 at 4:25

Attachments:

GoogleCodeExporter commented 9 years ago
Apologies for the delayed response, this patch got lost.

I'm unable to accept the path in its current form, mostly because of it's 
run-time 
impact on unmarshalling. I'm however going to work on a fix for this issue 
myself.

Original comment by pascallo...@gmail.com on 14 Dec 2008 at 6:39

GoogleCodeExporter commented 9 years ago
This has been addressed, see 
http://code.google.com/p/jsonmarshaller/source/detail?
r=47 for an efficient and simple implementation.

Original comment by pascallo...@gmail.com on 14 Dec 2008 at 7:49