users@jsonb-spec.java.net

[jsonb-spec users] [jsr367-experts] Re: Re: Re: Re: JsonbCreator parameter names

From: Dmitry Kornilov <dmitry.kornilov_at_oracle.com>
Date: Fri, 10 Feb 2017 13:14:46 +0100

Changing this:

 

Parameters of constructor/factory method annotated with JsonbCreator will be mapped from JSON fields with the same name. The name of a parameter can be changed by annotating the given parameter with the JsonbProperty annotation. When a JSON field is not mappable to a parameter with the same name, JsonbException MUST be thrown.

 

To:

 

Mapping between parameters of constructor/factory method annotated with JsonbCreator and JSON fields is defined using JsonbProperty annotation on all parameters.

In case JsonbProperty annotation on parameters is not used, parameters should be mapped from JSON fields with the same name. In this case the proper mapping is NOT guaranteed.

In case JSON field cannot be mapped to a parameter, JsonbException MUST be thrown.

 

--Dmitry

 

 

From: Lovro Pandzic <lovro.pandzic_at_gmail.com>
Reply-To: <jsr367-experts_at_jsonb-spec.java.net>
Date: Thursday, 9 February 2017 at 17:44
To: <jsr367-experts_at_jsonb-spec.java.net>
Subject: [jsonb-spec users] [jsr367-experts] Re: Re: Re: JsonbCreator parameter names

 

Agreed. Fyi, debug information is not the same as parameter names in Java 8. It is Java SE 8 spec.

 

On Feb 9, 2017 17:42, "Romain Manni-Bucau" <rmannibucau_at_tomitribe.com> wrote:

ok, so it will fall in the not portable features. Fine while not prevented by the spec :).


 

Romain Manni-Bucau

@rmannibucau

http://www.tomitribe.com

https://blog-rmannibucau.rhcloud.com

https://github.com/rmannibucau

 

2017-02-09 17:40 GMT+01:00 Dmitry Kornilov <dmitry.kornilov_at_oracle.com>:

It means that in the spec it will be said that using @JsonbProperty on constructor parameters is required for proper matching. If it’s not used, matching is not guaranteed.

 

--Dmitry

 

From: Romain Manni-Bucau <rmannibucau_at_tomitribe.com>
Reply-To: <jsr367-experts_at_jsonb-spec.java.net>
Date: Thursday, 9 February 2017 at 17:29
To: <jsr367-experts_at_jsonb-spec.java.net>
Subject: [jsonb-spec users] [jsr367-experts] Re: JsonbCreator parameter names

 

kind of agree but what does it mean? @JsonbCreator(jvmParameters = true) and default to false and @JsonbProperty?


 

Romain Manni-Bucau

@rmannibucau

http://www.tomitribe.com

https://blog-rmannibucau.rhcloud.com

https://github.com/rmannibucau

 

2017-02-09 17:28 GMT+01:00 <cepoi.eugen_at_gmail.com>:

Yes but this is not guaranteed to work. The method and constructor parameter names are available if the code has been compiled with debug symbols on. Which is the case most of the time.

I think having an annotation to name parameters is the must have and the automatic resolution is optional but nice to have.

Eugen


On Feb 9, 2017, at 1:00 AM, Romain Manni-Bucau <rmannibucau_at_tomitribe.com> wrote:

Hi Roman,

 

can't we use java 8 Parameter if property annotation is not there? it is possible to keep names in the bytecode now and access it through reflection.


 

Romain Manni-Bucau

@rmannibucau

http://www.tomitribe.com

https://blog-rmannibucau.rhcloud.com

https://github.com/rmannibucau

 

2017-02-09 9:57 GMT+01:00 Roman Grigoriadi <roman.grigoriadi_at_oracle.com>:

Hi experts,

There is no clear explanation in the spec how JsonbCreator parameter names should be resolved and mapped. I am suggesting making JsonbProperty annotation mandatory for parameters of JsonbCreators, so the name can be resolved unambiguously.

Thanks,
Roman