@@ -377,8 +377,10 @@ private void detectCtor(ClassDescriptor desc) {
377377 private void updateBindings (ClassDescriptor desc ) {
378378 boolean globalOmitDefault = JsoniterSpi .getCurrentConfig ().omitDefaultValue ();
379379 for (Binding binding : desc .allBindings ()) {
380+ boolean annotated = false ;
380381 JsonIgnore jsonIgnore = getJsonIgnore (binding .annotations );
381382 if (jsonIgnore != null ) {
383+ annotated = true ;
382384 if (jsonIgnore .ignoreDecoding ()) {
383385 binding .fromNames = new String [0 ];
384386 }
@@ -389,6 +391,7 @@ private void updateBindings(ClassDescriptor desc) {
389391 // map JsonUnwrapper is not getter
390392 JsonUnwrapper jsonUnwrapper = getJsonUnwrapper (binding .annotations );
391393 if (jsonUnwrapper != null ) {
394+ annotated = true ;
392395 binding .fromNames = new String [0 ];
393396 binding .toNames = new String [0 ];
394397 }
@@ -397,20 +400,30 @@ private void updateBindings(ClassDescriptor desc) {
397400 }
398401 JsonProperty jsonProperty = getJsonProperty (binding .annotations );
399402 if (jsonProperty != null ) {
403+ annotated = true ;
400404 updateBindingWithJsonProperty (binding , jsonProperty );
401405 }
402406 if (getAnnotation (binding .annotations , JsonMissingProperties .class ) != null ) {
407+ annotated = true ;
403408 // this binding will not bind from json
404409 // instead it will be set by jsoniter with missing property names
405410 binding .fromNames = new String [0 ];
406411 desc .onMissingProperties = binding ;
407412 }
408413 if (getAnnotation (binding .annotations , JsonExtraProperties .class ) != null ) {
414+ annotated = true ;
409415 // this binding will not bind from json
410416 // instead it will be set by jsoniter with extra properties
411417 binding .fromNames = new String [0 ];
412418 desc .onExtraProperties = binding ;
413419 }
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+ }
414427 }
415428 }
416429
0 commit comments