@@ -377,8 +377,10 @@ private void detectCtor(ClassDescriptor desc) {
377
377
private void updateBindings (ClassDescriptor desc ) {
378
378
boolean globalOmitDefault = JsoniterSpi .getCurrentConfig ().omitDefaultValue ();
379
379
for (Binding binding : desc .allBindings ()) {
380
+ boolean annotated = false ;
380
381
JsonIgnore jsonIgnore = getJsonIgnore (binding .annotations );
381
382
if (jsonIgnore != null ) {
383
+ annotated = true ;
382
384
if (jsonIgnore .ignoreDecoding ()) {
383
385
binding .fromNames = new String [0 ];
384
386
}
@@ -389,6 +391,7 @@ private void updateBindings(ClassDescriptor desc) {
389
391
// map JsonUnwrapper is not getter
390
392
JsonUnwrapper jsonUnwrapper = getJsonUnwrapper (binding .annotations );
391
393
if (jsonUnwrapper != null ) {
394
+ annotated = true ;
392
395
binding .fromNames = new String [0 ];
393
396
binding .toNames = new String [0 ];
394
397
}
@@ -397,20 +400,30 @@ private void updateBindings(ClassDescriptor desc) {
397
400
}
398
401
JsonProperty jsonProperty = getJsonProperty (binding .annotations );
399
402
if (jsonProperty != null ) {
403
+ annotated = true ;
400
404
updateBindingWithJsonProperty (binding , jsonProperty );
401
405
}
402
406
if (getAnnotation (binding .annotations , JsonMissingProperties .class ) != null ) {
407
+ annotated = true ;
403
408
// this binding will not bind from json
404
409
// instead it will be set by jsoniter with missing property names
405
410
binding .fromNames = new String [0 ];
406
411
desc .onMissingProperties = binding ;
407
412
}
408
413
if (getAnnotation (binding .annotations , JsonExtraProperties .class ) != null ) {
414
+ annotated = true ;
409
415
// this binding will not bind from json
410
416
// instead it will be set by jsoniter with extra properties
411
417
binding .fromNames = new String [0 ];
412
418
desc .onExtraProperties = binding ;
413
419
}
420
+ if (annotated && binding .field != null ) {
421
+ for (Binding setter : desc .setters ) {
422
+ if (binding .name .equals (setter .name )) {
423
+ throw new JsonException ("annotation should be marked on getter/setter for field: " + binding .name );
424
+ }
425
+ }
426
+ }
414
427
}
415
428
}
416
429
0 commit comments