JSONType.parserFeatures support 'Feature.NonPublicFieldSupport'

This commit is contained in:
wenshao
2016-11-18 15:16:08 +08:00
parent a202b32f44
commit edc45fdb07
2 changed files with 13 additions and 1 deletions
@@ -779,7 +779,10 @@ public class JavaBeanDeserializer implements ObjectDeserializer {
}
}
if (fieldDeserializer == null && parser.lexer.isEnabled(Feature.SupportNonPublicField)) {
final int mask = Feature.SupportNonPublicField.mask;
if (fieldDeserializer == null
&& ((parser.lexer.features & mask) != 0
|| (this.beanInfo.parserFeatures & mask) != 0)) {
if (this.extraFieldDeserializers == null) {
ConcurrentHashMap extraFieldDeserializers = new ConcurrentHashMap<String, Object>(1, 0.75f, 1);
Field[] fields = this.clazz.getDeclaredFields();
@@ -35,6 +35,8 @@ class JavaBeanInfo {
public final String typeName;
public final int parserFeatures;
JavaBeanInfo(Class<?> clazz, //
Constructor<?> defaultConstructor, //
Constructor<?> creatorConstructor, //
@@ -49,6 +51,8 @@ class JavaBeanInfo {
this.factoryMethod = factoryMethod;
this.fields = fields;
this.jsonType = jsonType;
int parserFeatures = 0;
if (jsonType != null) {
String typeName = jsonType.typeName();
if (typeName.length() != 0) {
@@ -56,9 +60,14 @@ class JavaBeanInfo {
} else {
this.typeName = clazz.getName();
}
for (Feature feature : jsonType.parseFeatures()) {
parserFeatures |= feature.mask;
}
} else {
this.typeName = clazz.getName();
}
this.parserFeatures = parserFeatures;
boolean supportBeanToArray = false;
if (jsonType != null) {