|
27 | 27 | import com.igormaznitsa.jbbp.utils.DslBinCustom; |
28 | 28 | import com.igormaznitsa.jbbp.utils.JBBPUtils; |
29 | 29 | import com.igormaznitsa.jbbp.utils.ReflectUtils; |
30 | | - |
31 | 30 | import java.lang.reflect.Array; |
32 | 31 | import java.lang.reflect.Field; |
33 | 32 | import java.lang.reflect.Modifier; |
@@ -117,7 +116,9 @@ protected void processObject(final Object obj, Field field, final Object customF |
117 | 116 | final Bin clazzAnno = clazzToProcess.getAnnotation(Bin.class); |
118 | 117 |
|
119 | 118 | for (Field f : clazzToProcess.getDeclaredFields()) { |
120 | | - f = ReflectUtils.makeAccessible(f); |
| 119 | + if (!ReflectUtils.isPotentiallyAccessibleField(f)) { |
| 120 | + f = ReflectUtils.makeAccessible(f); |
| 121 | + } |
121 | 122 |
|
122 | 123 | final int modifiers = f.getModifiers(); |
123 | 124 | if (Modifier.isTransient(modifiers) || Modifier.isStatic(modifiers) || f.getName().indexOf('$') >= 0) { |
@@ -146,7 +147,9 @@ protected void processObject(final Object obj, Field field, final Object customF |
146 | 147 | } |
147 | 148 | } |
148 | 149 |
|
149 | | - field = ReflectUtils.makeAccessible(field); |
| 150 | + if (field != null && !ReflectUtils.isPotentiallyAccessibleField(field)) { |
| 151 | + field = ReflectUtils.makeAccessible(field); |
| 152 | + } |
150 | 153 |
|
151 | 154 | final Bin clazzAnno = obj.getClass().getAnnotation(Bin.class); |
152 | 155 | final DslBinCustom clazzCustomAnno = obj.getClass().getAnnotation(DslBinCustom.class); |
@@ -472,7 +475,7 @@ protected void processObjectField(final Object obj, final Field field, final Bin |
472 | 475 | this.onArrayStart(obj, field, annotation, len); |
473 | 476 | for (int i = 0; i < len; i++) { |
474 | 477 | final Object value = Array.get(array, i); |
475 | | - String nullableStrValue = value == null ? null : String.valueOf (value); |
| 478 | + String nullableStrValue = value == null ? null : String.valueOf(value); |
476 | 479 | if (nullableStrValue != null && reverseBits) { |
477 | 480 | nullableStrValue = JBBPFieldString.reverseBits(nullableStrValue); |
478 | 481 | } |
|
0 commit comments