Tried with 2.8.9, same problem, but, I had an idea...

replacing the line
>public pojo(@JsonProperty(index = 0) int x, @JsonProperty(index = 1) int y)

with the line

>public pojo(@JsonProperty(index = 0, value = "d") int x, 
@JsonProperty(index = 1, value = "e") int y)

made it work! Looks like there's a superfluous check in there somewhere. (I 
even got a 'duplicate name' error when I used 'd' for both of them, heh).

On Tuesday, June 20, 2017 at 2:05:58 PM UTC-7, Bwmat wrote:
>
> I get an exception when running the following program with 2.6.2:
>
> import java.io.IOException;
>
> import com.fasterxml.jackson.annotation.JsonCreator;
> import com.fasterxml.jackson.annotation.JsonFormat;
> import com.fasterxml.jackson.annotation.JsonProperty;
> import com.fasterxml.jackson.core.JsonProcessingException;
> import com.fasterxml.jackson.databind.ObjectMapper;
>
> public class test
> {
>     @JsonFormat(shape = JsonFormat.Shape.ARRAY)
>     final static class pojo
>     {
>         private final int x;
>         private final int y;
>         
>         @JsonCreator
>         public pojo(@JsonProperty(index = 0) int x, @JsonProperty(index = 
> 1) int y)
>         {
>             this.x = x;
>             this.y = y;
>         }
>         
>         @Override
>         public String toString()
>         {
>             return String.format("(%d,%d)", x, y);
>         }
>     }
>     
>     public static void main(String[] args) throws JsonProcessingException, 
> IOException
>     {
>         ObjectMapper mapper = new ObjectMapper();
>         
>         pojo deserialized = mapper.reader(pojo.class).readValue("[1, 2]");
>         
>         System.out.println(deserialized);
>     }
> }
>
>
> The exception:
> Exception in thread "main" 
> com.fasterxml.jackson.databind.JsonMappingException: Argument #0 of 
> constructor [constructor for test$pojo, annotations: {interface 
> com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator(mode=DEFAULT)}]
>  
> has no property name annotation; must have name when multiple-parameter 
> constructor annotated as Creator
>     at 
> com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:269)
>     at 
> com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
>     at 
> com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
>     at 
> com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:461)
>     at 
> com.fasterxml.jackson.databind.ObjectReader._findRootDeserializer(ObjectReader.java:1749)
>     at 
> com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1506)
>     at 
> com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1136)
>     at test.main(test.java:36)
> Caused by: java.lang.IllegalArgumentException: Argument #0 of constructor 
> [constructor for test$pojo, annotations: {interface 
> com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator(mode=DEFAULT)}]
>  
> has no property name annotation; must have name when multiple-parameter 
> constructor annotated as Creator
>     at 
> com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._addDeserializerConstructors(BasicDeserializerFactory.java:512)
>     at 
> com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._constructDefaultValueInstantiator(BasicDeserializerFactory.java:324)
>     at 
> com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findValueInstantiator(BasicDeserializerFactory.java:254)
>     at 
> com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:222)
>     at 
> com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:142)
>     at 
> com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:403)
>     at 
> com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352)
>     at 
> com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
>     ... 7 more
>
>
> When I remove the constructor, and move the @JsonProperty annotations 
> directly to the members, everything works. Is this expected?
>

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to