Merge branch '2.5'
diff --git a/pom.xml b/pom.xml
index 72104e1..370f5b4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.5.1-SNAPSHOT</version>
+ <version>2.6.0-SNAPSHOT</version>
<name>jackson-databind</name>
<packaging>bundle</packaging>
<description>General data-binding functionality for Jackson: works on core streaming API</description>
@@ -74,7 +74,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.5.1-SNAPSHOT</version>
+ <version>2.6.0-SNAPSHOT</version>
</dependency>
<!-- and for testing we need a few libraries
@@ -86,12 +86,6 @@
<version>2.2.2</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy</artifactId>
- <version>1.7.9</version>
- <scope>test</scope>
- </dependency>
<!-- For testing TestNoClassDefFoundDeserializer -->
<dependency>
<groupId>javax.measure</groupId>
diff --git a/release-notes/CREDITS b/release-notes/CREDITS
index 655d66f..76d9a72 100644
--- a/release-notes/CREDITS
+++ b/release-notes/CREDITS
@@ -203,3 +203,7 @@
Ludevik@github:
* Reported #682: Class<?>-valued Map keys not serialized properly
(2.5.1)
+
+Charles Allen (drcrallen@github)
+ * Reported #696: Copy constructor does not preserve `_injectableValues`
+ (2.6.0)
diff --git a/release-notes/VERSION b/release-notes/VERSION
index 301efa3..8e14544 100644
--- a/release-notes/VERSION
+++ b/release-notes/VERSION
@@ -4,6 +4,12 @@
=== Releases ===
------------------------------------------------------------------------
+2.6.0 (not yet released)
+
+#649: Make `BeanDeserializer` use new `parser.nextFieldName()` and `.hasTokenId()` methods
+#696: Copy constructor does not preserve `_injectableValues`
+ (reported by Charles A)
+
2.5.1 (not yet released)
#667: Problem with bogus conflict between single-arg-String vs `CharSequence` constructor
diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
index 4172f1d..25acf68 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
@@ -970,7 +970,7 @@
public SerializerProvider getSerializerProvider() {
return _serializerProvider;
}
-
+
/*
/**********************************************************
/* Configuration: mix-in annotations
@@ -1524,7 +1524,14 @@
_injectableValues = injectableValues;
return this;
}
-
+
+ /**
+ * @since 2.6
+ */
+ public InjectableValues getInjectableValues() {
+ return _injectableValues;
+ }
+
/**
* Method for overriding default locale to use for formatting.
* Default value used is {@link Locale#getDefault()}.
@@ -3310,7 +3317,7 @@
* Method for visiting type hierarchy for given type, using specified visitor.
*<p>
* This method can be used for things like
- * generating <a href="http://json-schema.org/">Json Schema</a>
+ * generating <a href="http://json-schema.org/">JSON Schema</a>
* instance for specified type.
*
* @param type Type to generate schema for (possibly with generic signature)
@@ -3328,7 +3335,7 @@
* Visitation uses <code>Serializer</code> hierarchy and related properties
*<p>
* This method can be used for things like
- * generating <a href="http://json-schema.org/">Json Schema</a>
+ * generating <a href="http://json-schema.org/">JSON Schema</a>
* instance for specified type.
*
* @param type Type to generate schema for (possibly with generic signature)
diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectReader.java b/src/main/java/com/fasterxml/jackson/databind/ObjectReader.java
index 3cbe124..950408c 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ObjectReader.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ObjectReader.java
@@ -834,7 +834,14 @@
public ContextAttributes getAttributes() {
return _config.getAttributes();
}
-
+
+ /**
+ * @since 2.6
+ */
+ public InjectableValues getInjectableValues() {
+ return _injectableValues;
+ }
+
/*
/**********************************************************
/* Deserialization methods; basic ones to support ObjectCodec first
diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java b/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java
index 6d0146f..c3db9e9 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java
@@ -973,15 +973,21 @@
*
* @since 2.2
*/
- public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor)
- throws JsonMappingException
+ public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException
{
if (type == null) {
throw new IllegalArgumentException("type must be provided");
}
_serializerProvider(_config).acceptJsonFormatVisitor(type, visitor);
}
-
+
+ /**
+ * Since 2.6
+ */
+ public void acceptJsonFormatVisitor(Class<?> rawType, JsonFormatVisitorWrapper visitor) throws JsonMappingException {
+ acceptJsonFormatVisitor(_config.constructType(rawType), visitor);
+ }
+
public boolean canSerialize(Class<?> type) {
return _serializerProvider(_config).hasSerializerFor(type, null);
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/PropertyMetadata.java b/src/main/java/com/fasterxml/jackson/databind/PropertyMetadata.java
index 05c7bbb..e92ef9e 100644
--- a/src/main/java/com/fasterxml/jackson/databind/PropertyMetadata.java
+++ b/src/main/java/com/fasterxml/jackson/databind/PropertyMetadata.java
@@ -142,12 +142,17 @@
public String getDefaultValue() { return _defaultValue; }
/**
- * @since 2.5
+ * @deprecated Since 2.6: typo in name, use {@link #hasDefaultValue()} instead.
*/
+ @Deprecated
public boolean hasDefuaultValue() { return hasDefaultValue(); }
- // NOTE: officially only added in 2.6 (to replace 'hasDefuaultValue()'; actually added in 2.5.1
- // for forwards-compatibility
+ /**
+ * Accessor for determining whether property has declared "default value",
+ * which may be used by extension modules.
+ *
+ * @since 2.6
+ */
public boolean hasDefaultValue() { return (_defaultValue != null); }
public boolean isRequired() { return (_required != null) && _required.booleanValue(); }
diff --git a/src/main/java/com/fasterxml/jackson/databind/PropertyName.java b/src/main/java/com/fasterxml/jackson/databind/PropertyName.java
index a4f1444..34a701f 100644
--- a/src/main/java/com/fasterxml/jackson/databind/PropertyName.java
+++ b/src/main/java/com/fasterxml/jackson/databind/PropertyName.java
@@ -76,7 +76,18 @@
}
return this;
}
-
+
+ /**
+ * @since 2.6
+ */
+ public static PropertyName construct(String simpleName)
+ {
+ if (simpleName == null || simpleName.length() == 0) {
+ return USE_DEFAULT;
+ }
+ return new PropertyName(InternCache.instance.intern(simpleName), null);
+ }
+
public static PropertyName construct(String simpleName, String ns)
{
if (simpleName == null) {
@@ -85,7 +96,7 @@
if (ns == null && simpleName.length() == 0) {
return USE_DEFAULT;
}
- return new PropertyName(simpleName, ns);
+ return new PropertyName(InternCache.instance.intern(simpleName), ns);
}
public PropertyName internSimpleName()
@@ -100,7 +111,6 @@
return new PropertyName(interned, _namespace);
}
-
/**
* Fluent factory method for constructing an instance with different
* simple name.
diff --git a/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java b/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java
index 851a4d7..4149b14 100644
--- a/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java
+++ b/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java
@@ -195,7 +195,8 @@
}
/**
- * "Copy-constructor", used by sub-classes.
+ * "Copy-constructor", used by sub-classes when creating actual non-blueprint
+ * instances to use.
*
* @param src Blueprint object used as the baseline for this instance
*/
@@ -217,20 +218,20 @@
_stdNullValueSerializer = (_nullValueSerializer == DEFAULT_NULL_KEY_SERIALIZER);
_rootNames = src._rootNames;
-
+
+ _serializationView = config.getActiveView();
+ _attributes = config.getAttributes();
+
/* Non-blueprint instances do have a read-only map; one that doesn't
* need synchronization for lookups.
*/
_knownSerializers = _serializerCache.getReadOnlyLookupMap();
-
- _serializationView = config.getActiveView();
- _attributes = config.getAttributes();
}
/**
* Copy-constructor used when making a copy of a blueprint instance.
*
- * @since 2.4.4
+ * @since 2.5.0
*/
protected SerializerProvider(SerializerProvider src)
{
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java
index 2e9ce02..9ea18fe 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java
@@ -821,7 +821,7 @@
*/
String str = intr.findImplicitPropertyName(param);
if (str != null && !str.isEmpty()) {
- return new PropertyName(str);
+ return PropertyName.construct(str);
}
}
return null;
@@ -839,7 +839,7 @@
{
String str = intr.findImplicitPropertyName(param);
if (str != null && !str.isEmpty()) {
- return new PropertyName(str);
+ return PropertyName.construct(str);
}
return null;
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java
index 5e60cb5..1a2c007 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java
@@ -20,20 +20,13 @@
{
/* TODOs for future versions:
*
- * For 2.6
+ * For 2.6?
*
- * - Start using new (2.5) methods in JsonParser, like
- * * 'hasTokenId(xxx)'
- * * 'nextFieldName()'
- *
- * for slightly more efficient property lookups, handling
- * (2-3% faster deserialization)
- * Not done for 2.5 since it was just introduced, trying to
- * keep some level of compatibility between "adjacent" minor
- * versions.
- * Also: need to ensure efficient impl of those methods for Smile, CBOR
- * at least (in addition to JSON)
- *
+ * - New method in JsonDeserializer (deserializeNext()) to allow use of more
+ * efficient 'nextXxx()' method `JsonParser` provides.
+ *
+ * Also: need to ensure efficient impl of those methods for Smile, CBOR
+ * at least (in addition to JSON)
*/
private static final long serialVersionUID = 1L;
@@ -47,8 +40,7 @@
/**
* Constructor used by {@link BeanDeserializerBuilder}.
*/
- public BeanDeserializer(BeanDeserializerBuilder builder,
- BeanDescription beanDesc,
+ public BeanDeserializer(BeanDeserializerBuilder builder, BeanDescription beanDesc,
BeanPropertyMap properties, Map<String, SettableBeanProperty> backRefs,
HashSet<String> ignorableProps, boolean ignoreAllUnknown,
boolean hasViews)
@@ -126,12 +118,10 @@
* like Afterburner change definition.
*/
@Override
- public Object deserialize(JsonParser p, DeserializationContext ctxt)
- throws IOException
+ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException
{
- JsonToken t = p.getCurrentToken();
// common case first
- if (t == JsonToken.START_OBJECT) { // TODO: in 2.6, use 'p.hasTokenId()'
+ if (p.isExpectedStartObjectToken()) {
if (_vanillaProcessing) {
return vanillaDeserialize(p, ctxt, p.nextToken());
}
@@ -141,6 +131,7 @@
}
return deserializeFromObject(p, ctxt);
}
+ JsonToken t = p.getCurrentToken();
return _deserializeOther(p, ctxt, t);
}
@@ -177,9 +168,7 @@
}
}
- protected Object _missingToken(JsonParser p, DeserializationContext ctxt)
- throws JsonProcessingException
- {
+ protected Object _missingToken(JsonParser p, DeserializationContext ctxt) throws IOException {
throw ctxt.endOfInputException(handledType());
}
@@ -189,8 +178,7 @@
* after collecting some or all of the properties to set.
*/
@Override
- public Object deserialize(JsonParser p, DeserializationContext ctxt, Object bean)
- throws IOException
+ public Object deserialize(JsonParser p, DeserializationContext ctxt, Object bean) throws IOException
{
// [databind#631]: Assign current value, to be accessible by custom serializers
p.setCurrentValue(bean);
@@ -203,10 +191,20 @@
if (_externalTypeIdHandler != null) {
return deserializeWithExternalTypeId(p, ctxt, bean);
}
- JsonToken t = p.getCurrentToken();
+ String propName;
+
// 23-Mar-2010, tatu: In some cases, we start with full JSON object too...
- if (t == JsonToken.START_OBJECT) {
- t = p.nextToken();
+ if (p.isExpectedStartObjectToken()) {
+ propName = p.nextFieldName();
+ if (propName == null) {
+ return bean;
+ }
+ } else {
+ if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) {
+ propName = p.getCurrentName();
+ } else {
+ return bean;
+ }
}
if (_needViewProcesing) {
Class<?> view = ctxt.getActiveView();
@@ -214,13 +212,12 @@
return deserializeWithView(p, ctxt, bean, view);
}
}
- for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) {
- String propName = p.getCurrentName();
+ do {
p.nextToken();
if (!_beanProperties.findDeserializeAndSet(p, ctxt, bean, propName)) {
handleUnknownVanilla(p, ctxt, bean, propName);
}
- }
+ } while ((propName = p.nextFieldName()) != null);
return bean;
}
@@ -241,17 +238,6 @@
final Object bean = _valueInstantiator.createUsingDefault(ctxt);
// [databind#631]: Assign current value, to be accessible by custom serializers
p.setCurrentValue(bean);
-
- for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) {
- String propName = p.getCurrentName();
- p.nextToken();
- if (!_beanProperties.findDeserializeAndSet(p, ctxt, bean, propName)) {
- handleUnknownVanilla(p, ctxt, bean, propName);
- }
- }
-
- // 13-Dec-2014, tatu: For 2.6, we'll do:
- /*
if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) {
String propName = p.getCurrentName();
do {
@@ -261,7 +247,6 @@
}
} while ((propName = p.nextFieldName()) != null);
}
- */
return bean;
}
@@ -279,8 +264,7 @@
* but let's only do that if and when that becomes necessary.
*/
if (_objectIdReader != null && _objectIdReader.maySerializeAsObject()) {
- // TODO: in 2.6, use 'p.hasTokenId()'
- if ((p.getCurrentTokenId() == JsonTokenId.ID_FIELD_NAME)
+ if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)
&& _objectIdReader.isValidReferencePropertyName(p.getCurrentName(), p)) {
return deserializeFromObjectId(p, ctxt);
}
@@ -328,16 +312,6 @@
return deserializeWithView(p, ctxt, bean, view);
}
}
- JsonToken t = p.getCurrentToken();
- for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) {
- String propName = p.getCurrentName();
- p.nextToken();
- if (!_beanProperties.findDeserializeAndSet(p, ctxt, bean, propName)) {
- handleUnknownVanilla(p, ctxt, bean, propName);
- }
- }
- // 13-Dec-2014, tatu: For 2.6, we'll do:
- /*
if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) {
String propName = p.getCurrentName();
do {
@@ -347,7 +321,6 @@
}
} while ((propName = p.nextFieldName()) != null);
}
- */
return bean;
}
@@ -459,30 +432,31 @@
/* Deserializing when we have to consider an active View
/**********************************************************
*/
-
+
protected final Object deserializeWithView(JsonParser p, DeserializationContext ctxt,
Object bean, Class<?> activeView)
throws IOException
{
- JsonToken t = p.getCurrentToken();
- for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) {
+ if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) {
String propName = p.getCurrentName();
- // Skip field name:
- p.nextToken();
- SettableBeanProperty prop = _beanProperties.find(propName);
- if (prop != null) {
- if (!prop.visibleInView(activeView)) {
- p.skipChildren();
+ do {
+ p.nextToken();
+ // TODO: 06-Jan-2015, tatu: try streamlining call sequences here as well
+ SettableBeanProperty prop = _beanProperties.find(propName);
+ if (prop != null) {
+ if (!prop.visibleInView(activeView)) {
+ p.skipChildren();
+ continue;
+ }
+ try {
+ prop.deserializeAndSet(p, ctxt, bean);
+ } catch (Exception e) {
+ wrapAndThrow(e, bean, propName, ctxt);
+ }
continue;
}
- try {
- prop.deserializeAndSet(p, ctxt, bean);
- } catch (Exception e) {
- wrapAndThrow(e, bean, propName, ctxt);
- }
- continue;
- }
- handleUnknownVanilla(p, ctxt, bean, propName);
+ handleUnknownVanilla(p, ctxt, bean, propName);
+ } while ((propName = p.nextFieldName()) != null);
}
return bean;
}
@@ -518,9 +492,9 @@
injectValues(ctxt, bean);
}
final Class<?> activeView = _needViewProcesing ? ctxt.getActiveView() : null;
- JsonToken t = p.getCurrentToken();
- for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) {
- String propName = p.getCurrentName();
+ String propName = p.hasTokenId(JsonTokenId.ID_FIELD_NAME) ? p.getCurrentName() : null;
+
+ for (; propName != null; propName = p.nextFieldName()) {
p.nextToken();
SettableBeanProperty prop = _beanProperties.find(propName);
if (prop != null) { // normal case
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java
index 8fa05b3..8b0b6f0 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java
@@ -642,7 +642,7 @@
if (fixAccess) {
m.fixAccess(); // to ensure we can call it
}
- builder.addInjectable(new PropertyName(m.getName()),
+ builder.addInjectable(PropertyName.construct(m.getName()),
beanDesc.resolveType(m.getGenericType()),
beanDesc.getClassAnnotations(), m, entry.getKey());
}
@@ -663,7 +663,7 @@
}
// we know it's a 2-arg method, second arg is the value
JavaType type = beanDesc.bindingsForBeanType().resolveType(setter.getGenericParameterType(1));
- BeanProperty.Std property = new BeanProperty.Std(new PropertyName(setter.getName()),
+ BeanProperty.Std property = new BeanProperty.Std(PropertyName.construct(setter.getName()),
type, null, beanDesc.getClassAnnotations(), setter,
PropertyMetadata.STD_OPTIONAL);
type = resolveType(ctxt, beanDesc, type, setter);
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/CreatorProperty.java b/src/main/java/com/fasterxml/jackson/databind/deser/CreatorProperty.java
index 9ff886a..403f60e 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/CreatorProperty.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/CreatorProperty.java
@@ -6,10 +6,7 @@
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.PropertyMetadata;
-import com.fasterxml.jackson.databind.PropertyName;
+import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter;
import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/ManagedReferenceProperty.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/ManagedReferenceProperty.java
index fe6bbba..028cc09 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/ManagedReferenceProperty.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/ManagedReferenceProperty.java
@@ -6,7 +6,7 @@
import java.util.Map;
import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
+
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.PropertyName;
@@ -95,20 +95,20 @@
*/
@Override
- public void deserializeAndSet(JsonParser jp, DeserializationContext ctxt, Object instance)
- throws IOException, JsonProcessingException {
- set(instance, _managedProperty.deserialize(jp, ctxt));
+ public void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance)
+ throws IOException {
+ set(instance, _managedProperty.deserialize(p, ctxt));
}
@Override
- public Object deserializeSetAndReturn(JsonParser jp, DeserializationContext ctxt, Object instance)
- throws IOException, JsonProcessingException {
- return setAndReturn(instance, deserialize(jp, ctxt));
+ public Object deserializeSetAndReturn(JsonParser p, DeserializationContext ctxt, Object instance)
+ throws IOException {
+ return setAndReturn(instance, deserialize(p, ctxt));
}
@Override
public final void set(Object instance, Object value) throws IOException {
- setAndReturn(instance, value);
+ setAndReturn(instance, value);
}
@Override
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/ObjectIdReferenceProperty.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/ObjectIdReferenceProperty.java
index ac04b96..c73631b 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/ObjectIdReferenceProperty.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/ObjectIdReferenceProperty.java
@@ -58,20 +58,19 @@
}
@Override
- public void deserializeAndSet(JsonParser jp, DeserializationContext ctxt, Object instance) throws IOException {
- deserializeSetAndReturn(jp, ctxt, instance);
+ public void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException {
+ deserializeSetAndReturn(p, ctxt, instance);
}
@Override
- public Object deserializeSetAndReturn(JsonParser jp, DeserializationContext ctxt, Object instance)
- throws IOException
+ public Object deserializeSetAndReturn(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException
{
try {
- return setAndReturn(instance, deserialize(jp, ctxt));
+ return setAndReturn(instance, deserialize(p, ctxt));
} catch (UnresolvedForwardReference reference) {
boolean usingIdentityInfo = (_objectIdInfo != null) || (_valueDeserializer.getObjectIdReader() != null);
if (!usingIdentityInfo) {
- throw JsonMappingException.from(jp, "Unresolved forward reference but no identity info.", reference);
+ throw JsonMappingException.from(p, "Unresolved forward reference but no identity info.", reference);
}
reference.getRoid().appendReferring(new PropertyReferring(this, reference, _type.getRawClass(), instance));
return null;
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/ObjectIdValueProperty.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/ObjectIdValueProperty.java
index cf9fa17..56c1ba0 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/ObjectIdValueProperty.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/ObjectIdValueProperty.java
@@ -34,16 +34,10 @@
_objectIdReader = src._objectIdReader;
}
- @Deprecated // since 2.3
protected ObjectIdValueProperty(ObjectIdValueProperty src, PropertyName newName) {
super(src, newName);
_objectIdReader = src._objectIdReader;
}
-
- @Deprecated // since 2.3
- protected ObjectIdValueProperty(ObjectIdValueProperty src, String newName) {
- this(src, new PropertyName(newName));
- }
@Override
public ObjectIdValueProperty withName(PropertyName newName) {
@@ -71,18 +65,18 @@
*/
@Override
- public void deserializeAndSet(JsonParser jp, DeserializationContext ctxt,
+ public void deserializeAndSet(JsonParser p, DeserializationContext ctxt,
Object instance) throws IOException
{
- deserializeSetAndReturn(jp, ctxt, instance);
+ deserializeSetAndReturn(p, ctxt, instance);
}
@Override
- public Object deserializeSetAndReturn(JsonParser jp,
+ public Object deserializeSetAndReturn(JsonParser p,
DeserializationContext ctxt, Object instance) throws IOException
{
// note: no null checks (unlike usually); deserializer should fail if one found
- Object id = _valueDeserializer.deserialize(jp, ctxt);
+ Object id = _valueDeserializer.deserialize(p, ctxt);
ReadableObjectId roid = ctxt.findObjectId(id, _objectIdReader.generator, _objectIdReader.resolver);
roid.bindItem(instance);
// also: may need to set a property value as well
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/JsonLocationInstantiator.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/JsonLocationInstantiator.java
index b087ee2..4cef2dd 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/std/JsonLocationInstantiator.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/JsonLocationInstantiator.java
@@ -38,7 +38,7 @@
}
private static CreatorProperty creatorProp(String name, JavaType type, int index) {
- return new CreatorProperty(new PropertyName(name), type, null,
+ return new CreatorProperty(PropertyName.construct(name), type, null,
null, null, null, index, null, PropertyMetadata.STD_REQUIRED);
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java b/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java
index 3936ab3..422b966 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java
@@ -545,26 +545,25 @@
protected PropertyName _findCreatorPropertyName(AnnotatedParameter param)
{
- PropertyName name = _annotationIntrospector.findNameForDeserialization(param);
- if (name == null || name.isEmpty()) {
- String str = _annotationIntrospector.findImplicitPropertyName(param);
- if (str != null && !str.isEmpty()) {
- name = new PropertyName(str);
- }
- }
- return name;
+ PropertyName name = _annotationIntrospector.findNameForDeserialization(param);
+ if (name == null || name.isEmpty()) {
+ String str = _annotationIntrospector.findImplicitPropertyName(param);
+ if (str != null && !str.isEmpty()) {
+ name = PropertyName.construct(str);
+ }
+ }
+ return name;
}
-
+
/*
/**********************************************************
/* Introspection for deserialization, other
/**********************************************************
*/
-
+
@Override
- public Class<?> findPOJOBuilder()
- {
- return (_annotationIntrospector == null) ?
+ public Class<?> findPOJOBuilder() {
+ return (_annotationIntrospector == null) ?
null : _annotationIntrospector.findPOJOBuilder(_classInfo);
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
index 88592e4..cd84c3f 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
@@ -440,7 +440,7 @@
return null;
}
// In future may need to allow passing namespace?
- PropertyName name = new PropertyName(info.property());
+ PropertyName name = PropertyName.construct(info.property());
return new ObjectIdInfo(name, info.scope(), info.generator(), info.resolver());
}
@@ -572,7 +572,7 @@
// allow explicit renaming; if none, default to attribute name
PropertyName propName = _propertyName(attr.propName(), attr.propNamespace());
if (!propName.hasSimpleName()) {
- propName = new PropertyName(attrName);
+ propName = PropertyName.construct(attrName);
}
// now, then, we need a placeholder for member (no real Field/Method):
AnnotatedMember member = new VirtualAnnotatedMember(ac, ac.getRawType(),
@@ -637,10 +637,7 @@
return null;
}
}
- if (name.length() == 0) { // empty String means 'default'
- return PropertyName.USE_DEFAULT;
- }
- return new PropertyName(name);
+ return PropertyName.construct(name);
}
@Override
@@ -790,10 +787,7 @@
return null;
}
}
- if (name.length() == 0) { // empty String means 'default'
- return PropertyName.USE_DEFAULT;
- }
- return new PropertyName(name);
+ return PropertyName.construct(name);
}
@Override
@@ -861,9 +855,9 @@
return PropertyName.USE_DEFAULT;
}
if (namespace == null || namespace.isEmpty()) {
- return new PropertyName(localName);
+ return PropertyName.construct(localName);
}
- return new PropertyName(localName, namespace);
+ return PropertyName.construct(localName, namespace);
}
/**
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
index 576f94a..5ad75e9 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
@@ -482,7 +482,7 @@
if (!_annotationIntrospector.hasCreatorAnnotation(param.getOwner())) {
return;
}
- pn = new PropertyName(impl);
+ pn = PropertyName.construct(impl);
}
// shouldn't need to worry about @JsonIgnore, since creators only added
@@ -907,7 +907,7 @@
{
POJOPropertyBuilder prop = _properties.get(implName);
if (prop == null) {
- prop = new POJOPropertyBuilder(new PropertyName(implName),
+ prop = new POJOPropertyBuilder(PropertyName.construct(implName),
_annotationIntrospector, _forSerialization);
_properties.put(implName, prop);
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java b/src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java
index 34de57e..7170c02 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java
@@ -325,9 +325,9 @@
if (newName.equals(_name.toString())) {
return this;
}
- return new BeanPropertyWriter(this, new PropertyName(newName));
+ return new BeanPropertyWriter(this, PropertyName.construct(newName));
}
-
+
/**
* Method called to assign value serializer for property
*
@@ -384,7 +384,7 @@
@Override public PropertyName getFullName() { // !!! TODO: impl properly
return new PropertyName(_name.getValue());
}
-
+
@Override public JavaType getType() { return _declaredType; }
@Override public PropertyName getWrapperName() { return _wrapperName; }
@Override public boolean isRequired() { return _metadata.isRequired(); }
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializerFactory.java
index 1712a1a..7049d59 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializerFactory.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializerFactory.java
@@ -395,7 +395,7 @@
MapSerializer mapSer = MapSerializer.construct(/* ignored props*/ null, type, staticTyping,
typeSer, null, null, /*filterId*/ null);
// TODO: can we find full PropertyName?
- PropertyName name = new PropertyName(anyGetter.getName());
+ PropertyName name = PropertyName.construct(anyGetter.getName());
BeanProperty.Std anyProp = new BeanProperty.Std(name, valueType, null,
beanDesc.getClassAnnotations(), anyGetter, PropertyMetadata.STD_OPTIONAL);
builder.setAnyGetter(new AnyGetterWriter(anyProp, anyGetter, mapSer));
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/SerializerCache.java b/src/main/java/com/fasterxml/jackson/databind/ser/SerializerCache.java
index 8f7cc5c..60bd509 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/SerializerCache.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/SerializerCache.java
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.databind.ser;
import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.ser.impl.ReadOnlyClassToSerializerMap;
@@ -33,7 +34,8 @@
/**
* Most recent read-only instance, created from _sharedMap, if any.
*/
- private volatile ReadOnlyClassToSerializerMap _readOnlyMap = null;
+ private final AtomicReference<ReadOnlyClassToSerializerMap> _readOnlyMap
+ = new AtomicReference<ReadOnlyClassToSerializerMap>();
public SerializerCache() { }
@@ -43,16 +45,22 @@
*/
public ReadOnlyClassToSerializerMap getReadOnlyLookupMap()
{
- ReadOnlyClassToSerializerMap m = _readOnlyMap;
- if(m == null) {
- synchronized (this) {
- m = _readOnlyMap;
- if (m == null) {
- _readOnlyMap = m = ReadOnlyClassToSerializerMap.from(_sharedMap);
- }
- }
+ ReadOnlyClassToSerializerMap m = _readOnlyMap.get();
+ if (m != null) {
+ return m.instance();
}
- return m.instance();
+ return _makeReadOnlyLookupMap();
+ }
+
+ private final synchronized ReadOnlyClassToSerializerMap _makeReadOnlyLookupMap() {
+ // double-locking; safe, but is it really needed? Not doing that is only a perf problem,
+ // not correctness
+ ReadOnlyClassToSerializerMap m = _readOnlyMap.get();
+ if (m == null) {
+ m = ReadOnlyClassToSerializerMap.from(_sharedMap);
+ _readOnlyMap.set(m);
+ }
+ return m;
}
/*
@@ -113,7 +121,7 @@
synchronized (this) {
if (_sharedMap.put(new TypeKey(type, true), ser) == null) {
// let's invalidate the read-only copy, too, to get it updated
- _readOnlyMap = null;
+ _readOnlyMap.set(null);
}
}
}
@@ -123,7 +131,7 @@
synchronized (this) {
if (_sharedMap.put(new TypeKey(cls, true), ser) == null) {
// let's invalidate the read-only copy, too, to get it updated
- _readOnlyMap = null;
+ _readOnlyMap.set(null);
}
}
}
@@ -134,8 +142,7 @@
{
synchronized (this) {
if (_sharedMap.put(new TypeKey(type, false), ser) == null) {
- // let's invalidate the read-only copy, too, to get it updated
- _readOnlyMap = null;
+ _readOnlyMap.set(null);
}
/* Finally: some serializers want to do post-processing, after
* getting registered (to handle cyclic deps).
@@ -156,8 +163,7 @@
{
synchronized (this) {
if (_sharedMap.put(new TypeKey(type, false), ser) == null) {
- // let's invalidate the read-only copy, too, to get it updated
- _readOnlyMap = null;
+ _readOnlyMap.set(null);
}
/* Finally: some serializers want to do post-processing, after
* getting registered (to handle cyclic deps).
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java
index ce020d1..66c67fc 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java
@@ -31,7 +31,7 @@
extends ContainerSerializer<Map<?,?>>
implements ContextualSerializer
{
- private static final long serialVersionUID = -3465193297149553004L;
+ private static final long serialVersionUID = 1L;
protected final static JavaType UNSPECIFIED_TYPE = TypeFactory.unknownType();
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/NonTypedScalarSerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/NonTypedScalarSerializerBase.java
index 3506279..8d5151d 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/std/NonTypedScalarSerializerBase.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/NonTypedScalarSerializerBase.java
@@ -21,6 +21,10 @@
super(t);
}
+ protected NonTypedScalarSerializerBase(Class<?> t, boolean bogus) {
+ super(t, bogus);
+ }
+
@Override
public final void serializeWithType(T value, JsonGenerator jgen, SerializerProvider provider,
TypeSerializer typeSer) throws IOException
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java
index ca9bbc1..b4de561 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java
@@ -22,7 +22,7 @@
public class NumberSerializers
{
protected NumberSerializers() { }
-
+
public static void addAll(Map<String, JsonSerializer<?>> allDeserializers)
{
final JsonSerializer<?> intS = new IntegerSerializer();
@@ -55,8 +55,8 @@
protected final String _schemaType;
protected final boolean _isInt;
- protected Base(Class<T> cls, JsonParser.NumberType numberType, String schemaType) {
- super(cls);
+ protected Base(Class<?> cls, JsonParser.NumberType numberType, String schemaType) {
+ super(cls, false);
_numberType = numberType;
_schemaType = schemaType;
_isInt = (numberType == JsonParser.NumberType.INT)
@@ -121,8 +121,8 @@
public ShortSerializer() { super(Short.class, JsonParser.NumberType.INT, "number"); }
@Override
- public void serialize(Short value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- jgen.writeNumber(value.shortValue());
+ public void serialize(Short value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+ gen.writeNumber(value.shortValue());
}
}
@@ -131,24 +131,27 @@
* (and primitive ints)
*<p>
* Since this is one of "native" types, no type information is ever
- * included on serialization (unlike for most scalar types as of 1.5)
+ * included on serialization (unlike for most scalar types)
+ *<p>
+ * NOTE: as of 2.6, generic signature changed to Object, to avoid generation
+ * of bridge methods.
*/
@JacksonStdImpl
- public final static class IntegerSerializer extends Base<Integer>
+ public final static class IntegerSerializer extends Base<Object>
{
public IntegerSerializer() { super(Integer.class, JsonParser.NumberType.INT ,"integer"); }
@Override
- public void serialize(Integer value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- jgen.writeNumber(value.intValue());
+ public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+ gen.writeNumber(((Integer) value).intValue());
}
// IMPORTANT: copied from `NonTypedScalarSerializerBase`
@Override
- public void serializeWithType(Integer value, JsonGenerator jgen,
+ public void serializeWithType(Object value, JsonGenerator gen,
SerializerProvider provider, TypeSerializer typeSer) throws IOException {
// no type info, just regular serialization
- serialize(value, jgen, provider);
+ serialize(value, gen, provider);
}
}
@@ -167,21 +170,21 @@
}
@Override
- public void serialize(Number value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- jgen.writeNumber(value.intValue());
+ public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+ gen.writeNumber(value.intValue());
}
}
@JacksonStdImpl
- public final static class LongSerializer extends Base<Long>
+ public final static class LongSerializer extends Base<Object>
{
final static LongSerializer instance = new LongSerializer();
public LongSerializer() { super(Long.class, JsonParser.NumberType.LONG, "number"); }
@Override
- public void serialize(Long value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- jgen.writeNumber(value.longValue());
+ public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+ gen.writeNumber(((Long) value).longValue());
}
}
@@ -193,8 +196,8 @@
public FloatSerializer() { super(Float.class, JsonParser.NumberType.FLOAT, "number"); }
@Override
- public void serialize(Float value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- jgen.writeNumber(value.floatValue());
+ public void serialize(Float value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+ gen.writeNumber(value.floatValue());
}
}
@@ -206,23 +209,23 @@
* included on serialization (unlike for most scalar types as of 1.5)
*/
@JacksonStdImpl
- public final static class DoubleSerializer extends Base<Double>
+ public final static class DoubleSerializer extends Base<Object>
{
final static DoubleSerializer instance = new DoubleSerializer();
public DoubleSerializer() { super(Double.class, JsonParser.NumberType.DOUBLE, "number"); }
@Override
- public void serialize(Double value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- jgen.writeNumber(value.doubleValue());
+ public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+ gen.writeNumber(((Double) value).doubleValue());
}
// IMPORTANT: copied from `NonTypedScalarSerializerBase`
@Override
- public void serializeWithType(Double value, JsonGenerator jgen,
+ public void serializeWithType(Object value, JsonGenerator gen,
SerializerProvider provider, TypeSerializer typeSer) throws IOException {
// no type info, just regular serialization
- serialize(value, jgen, provider);
+ serialize(value, gen, provider);
}
}
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdKeySerializers.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdKeySerializers.java
index 2cb9bbd..652a89e 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdKeySerializers.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdKeySerializers.java
@@ -12,9 +12,7 @@
{
protected final static JsonSerializer<Object> DEFAULT_KEY_SERIALIZER = new StdKeySerializer();
- @SuppressWarnings("unchecked")
- protected final static JsonSerializer<Object> DEFAULT_STRING_SERIALIZER
- = (JsonSerializer<Object>)(JsonSerializer<?>) new StringKeySerializer();
+ protected final static JsonSerializer<Object> DEFAULT_STRING_SERIALIZER = new StringKeySerializer();
private StdKeySerializers() { }
@@ -25,7 +23,6 @@
* @param useDefault If no match is found, should we return fallback deserializer
* (true), or null (false)?
*/
- @SuppressWarnings("unchecked")
public static JsonSerializer<Object> getStdKeySerializer(SerializationConfig config,
Class<?> rawKeyType, boolean useDefault)
{
@@ -38,13 +35,17 @@
return DEFAULT_KEY_SERIALIZER;
}
if (rawKeyType == Class.class) {
- return (JsonSerializer<Object>) ClassKeySerializer.instance;
+ return new Default(Default.TYPE_CLASS, rawKeyType);
}
if (Date.class.isAssignableFrom(rawKeyType)) {
- return (JsonSerializer<Object>) DateKeySerializer.instance;
+ return new Default(Default.TYPE_DATE, rawKeyType);
}
if (Calendar.class.isAssignableFrom(rawKeyType)) {
- return (JsonSerializer<Object>) CalendarKeySerializer.instance;
+ return new Default(Default.TYPE_CALENDAR, rawKeyType);
+ }
+ // other types we know convert properly with 'toString()'?
+ if (rawKeyType == java.util.UUID.class) {
+ return new Default(Default.TYPE_TO_STRING, rawKeyType);
}
}
return useDefault ? DEFAULT_KEY_SERIALIZER : null;
@@ -64,20 +65,59 @@
/*
/**********************************************************
- /* Standard implementations
+ /* Standard implementations used
/**********************************************************
*/
- public static class StringKeySerializer extends StdSerializer<String>
- {
- public StringKeySerializer() { super(String.class); }
+ public static class Default extends StdSerializer<Object> {
+ final static int TYPE_DATE = 1;
+ final static int TYPE_CALENDAR = 2;
+ final static int TYPE_CLASS = 3;
+ final static int TYPE_TO_STRING = 4;
+
+ protected final int _typeId;
+ public Default(int typeId, Class<?> type) {
+ super(type, false);
+ _typeId = typeId;
+ }
+
@Override
- public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
- jgen.writeFieldName(value);
+ public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
+ switch (_typeId) {
+ case TYPE_DATE:
+ provider.defaultSerializeDateKey((Date)value, jgen);
+ break;
+ case TYPE_CALENDAR:
+ provider.defaultSerializeDateKey(((Calendar) value).getTimeInMillis(), jgen);
+ break;
+ case TYPE_CLASS:
+ jgen.writeFieldName(((Class<?>)value).getName());
+ break;
+ case TYPE_TO_STRING:
+ default:
+ jgen.writeFieldName(value.toString());
+ }
}
}
+ public static class StringKeySerializer extends StdSerializer<Object>
+ {
+ public StringKeySerializer() { super(String.class, false); }
+
+ @Override
+ public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
+ jgen.writeFieldName((String) value);
+ }
+ }
+
+ /*
+ /**********************************************************
+ /* Deprecated implementations: to be removed in future
+ /**********************************************************
+ */
+
+ @Deprecated // since 2.6; remove from 2.7 or later
public static class DateKeySerializer extends StdSerializer<Date> {
protected final static JsonSerializer<?> instance = new DateKeySerializer();
@@ -89,6 +129,7 @@
}
}
+ @Deprecated // since 2.6; remove from 2.7 or later
public static class CalendarKeySerializer extends StdSerializer<Calendar> {
protected final static JsonSerializer<?> instance = new CalendarKeySerializer();
@@ -99,15 +140,4 @@
provider.defaultSerializeDateKey(value.getTimeInMillis(), jgen);
}
}
-
- public static class ClassKeySerializer extends StdSerializer<Class<?>> {
- protected final static JsonSerializer<?> instance = new ClassKeySerializer();
-
- public ClassKeySerializer() { super(Class.class, false); }
-
- @Override
- public void serialize(Class<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
- jgen.writeFieldName(value.getName());
- }
- }
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java
index 040734b..08ff8b0 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java
@@ -20,29 +20,33 @@
*/
@JacksonStdImpl
public final class StringSerializer
- extends NonTypedScalarSerializerBase<String>
+// NOTE: generic parameter changed from String to Object in 2.6, to avoid
+// use of bridge methods
+ extends NonTypedScalarSerializerBase<Object>
{
private static final long serialVersionUID = 1L;
- public StringSerializer() { super(String.class); }
+ public StringSerializer() { super(String.class, false); }
/**
* For Strings, both null and Empty String qualify for emptiness.
*/
@Override
@Deprecated
- public boolean isEmpty(String value) {
- return (value == null) || (value.length() == 0);
+ public boolean isEmpty(Object value) {
+ String str = (String) value;
+ return (str == null) || (str.length() == 0);
}
@Override
- public boolean isEmpty(SerializerProvider prov, String value) {
- return (value == null) || (value.length() == 0);
+ public boolean isEmpty(SerializerProvider prov, Object value) {
+ String str = (String) value;
+ return (str == null) || (str.length() == 0);
}
@Override
- public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- jgen.writeString(value);
+ public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
+ jgen.writeString((String) value);
}
@Override
diff --git a/src/main/java/com/fasterxml/jackson/databind/util/RootNameLookup.java b/src/main/java/com/fasterxml/jackson/databind/util/RootNameLookup.java
index 7227718..c2748d5 100644
--- a/src/main/java/com/fasterxml/jackson/databind/util/RootNameLookup.java
+++ b/src/main/java/com/fasterxml/jackson/databind/util/RootNameLookup.java
@@ -40,7 +40,7 @@
// No answer so far? Let's just default to using simple class name
if (name == null || !name.hasSimpleName()) {
// Should we strip out enclosing class tho? For now, nope:
- name = new PropertyName(rootType.getSimpleName());
+ name = PropertyName.construct(rootType.getSimpleName());
}
_rootNames.put(key, name);
return name;
diff --git a/src/main/java/com/fasterxml/jackson/databind/util/SimpleBeanPropertyDefinition.java b/src/main/java/com/fasterxml/jackson/databind/util/SimpleBeanPropertyDefinition.java
index a6eba35..a879ae3 100644
--- a/src/main/java/com/fasterxml/jackson/databind/util/SimpleBeanPropertyDefinition.java
+++ b/src/main/java/com/fasterxml/jackson/databind/util/SimpleBeanPropertyDefinition.java
@@ -99,7 +99,7 @@
*/
public static SimpleBeanPropertyDefinition construct(MapperConfig<?> config,
AnnotatedMember member) {
- return new SimpleBeanPropertyDefinition(member, new PropertyName(member.getName()),
+ return new SimpleBeanPropertyDefinition(member, PropertyName.construct(member.getName()),
(config == null) ? null : config.getAnnotationIntrospector(),
null, null);
}
@@ -110,7 +110,7 @@
@Deprecated
public static SimpleBeanPropertyDefinition construct(MapperConfig<?> config,
AnnotatedMember member, String name) {
- return new SimpleBeanPropertyDefinition(member, new PropertyName(name),
+ return new SimpleBeanPropertyDefinition(member, PropertyName.construct(name),
(config == null) ? null : config.getAnnotationIntrospector(),
null, null);
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java b/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java
index 2dbb7df..4aa179f 100644
--- a/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java
+++ b/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java
@@ -249,8 +249,7 @@
* @return This buffer
*/
@SuppressWarnings("resource")
- public TokenBuffer append(TokenBuffer other)
- throws IOException, JsonGenerationException
+ public TokenBuffer append(TokenBuffer other) throws IOException
{
// Important? If source has native ids, need to store
if (!_hasNativeTypeIds) {
@@ -278,8 +277,7 @@
* references (from core to mapper package); and as such we also
* can not take second argument.
*/
- public void serialize(JsonGenerator jgen)
- throws IOException, JsonGenerationException
+ public void serialize(JsonGenerator jgen) throws IOException
{
Segment segment = _first;
int ptr = -1;
@@ -579,16 +577,14 @@
*/
@Override
- public final void writeStartArray()
- throws IOException, JsonGenerationException
+ public final void writeStartArray() throws IOException
{
_append(JsonToken.START_ARRAY);
_writeContext = _writeContext.createChildArrayContext();
}
@Override
- public final void writeEndArray()
- throws IOException, JsonGenerationException
+ public final void writeEndArray() throws IOException
{
_append(JsonToken.END_ARRAY);
// Let's allow unbalanced tho... i.e. not run out of root level, ever
@@ -599,16 +595,14 @@
}
@Override
- public final void writeStartObject()
- throws IOException, JsonGenerationException
+ public final void writeStartObject() throws IOException
{
_append(JsonToken.START_OBJECT);
_writeContext = _writeContext.createChildObjectContext();
}
@Override
- public final void writeEndObject()
- throws IOException, JsonGenerationException
+ public final void writeEndObject() throws IOException
{
_append(JsonToken.END_OBJECT);
// Let's allow unbalanced tho... i.e. not run out of root level, ever
@@ -619,16 +613,14 @@
}
@Override
- public final void writeFieldName(String name)
- throws IOException, JsonGenerationException
+ public final void writeFieldName(String name) throws IOException
{
_append(JsonToken.FIELD_NAME, name);
_writeContext.writeFieldName(name);
}
@Override
- public void writeFieldName(SerializableString name)
- throws IOException, JsonGenerationException
+ public void writeFieldName(SerializableString name) throws IOException
{
_append(JsonToken.FIELD_NAME, name);
_writeContext.writeFieldName(name.getValue());
@@ -641,7 +633,7 @@
*/
@Override
- public void writeString(String text) throws IOException,JsonGenerationException {
+ public void writeString(String text) throws IOException {
if (text == null) {
writeNull();
} else {
@@ -650,12 +642,12 @@
}
@Override
- public void writeString(char[] text, int offset, int len) throws IOException, JsonGenerationException {
+ public void writeString(char[] text, int offset, int len) throws IOException {
writeString(new String(text, offset, len));
}
@Override
- public void writeString(SerializableString text) throws IOException, JsonGenerationException {
+ public void writeString(SerializableString text) throws IOException {
if (text == null) {
writeNull();
} else {
@@ -665,7 +657,7 @@
@Override
public void writeRawUTF8String(byte[] text, int offset, int length)
- throws IOException, JsonGenerationException
+ throws IOException
{
// could add support for buffering if we really want it...
_reportUnsupportedOperation();
@@ -673,49 +665,49 @@
@Override
public void writeUTF8String(byte[] text, int offset, int length)
- throws IOException, JsonGenerationException
+ throws IOException
{
// could add support for buffering if we really want it...
_reportUnsupportedOperation();
}
@Override
- public void writeRaw(String text) throws IOException, JsonGenerationException {
+ public void writeRaw(String text) throws IOException {
_reportUnsupportedOperation();
}
@Override
- public void writeRaw(String text, int offset, int len) throws IOException, JsonGenerationException {
+ public void writeRaw(String text, int offset, int len) throws IOException {
_reportUnsupportedOperation();
}
@Override
- public void writeRaw(SerializableString text) throws IOException, JsonGenerationException {
+ public void writeRaw(SerializableString text) throws IOException {
_reportUnsupportedOperation();
}
@Override
- public void writeRaw(char[] text, int offset, int len) throws IOException, JsonGenerationException {
+ public void writeRaw(char[] text, int offset, int len) throws IOException {
_reportUnsupportedOperation();
}
@Override
- public void writeRaw(char c) throws IOException, JsonGenerationException {
+ public void writeRaw(char c) throws IOException {
_reportUnsupportedOperation();
}
@Override
- public void writeRawValue(String text) throws IOException, JsonGenerationException {
+ public void writeRawValue(String text) throws IOException {
_reportUnsupportedOperation();
}
@Override
- public void writeRawValue(String text, int offset, int len) throws IOException, JsonGenerationException {
+ public void writeRawValue(String text, int offset, int len) throws IOException {
_reportUnsupportedOperation();
}
@Override
- public void writeRawValue(char[] text, int offset, int len) throws IOException, JsonGenerationException {
+ public void writeRawValue(char[] text, int offset, int len) throws IOException {
_reportUnsupportedOperation();
}
@@ -726,32 +718,32 @@
*/
@Override
- public void writeNumber(short i) throws IOException, JsonGenerationException {
+ public void writeNumber(short i) throws IOException {
_append(JsonToken.VALUE_NUMBER_INT, Short.valueOf(i));
}
@Override
- public void writeNumber(int i) throws IOException, JsonGenerationException {
+ public void writeNumber(int i) throws IOException {
_append(JsonToken.VALUE_NUMBER_INT, Integer.valueOf(i));
}
@Override
- public void writeNumber(long l) throws IOException, JsonGenerationException {
+ public void writeNumber(long l) throws IOException {
_append(JsonToken.VALUE_NUMBER_INT, Long.valueOf(l));
}
@Override
- public void writeNumber(double d) throws IOException,JsonGenerationException {
+ public void writeNumber(double d) throws IOException {
_append(JsonToken.VALUE_NUMBER_FLOAT, Double.valueOf(d));
}
@Override
- public void writeNumber(float f) throws IOException, JsonGenerationException {
+ public void writeNumber(float f) throws IOException {
_append(JsonToken.VALUE_NUMBER_FLOAT, Float.valueOf(f));
}
@Override
- public void writeNumber(BigDecimal dec) throws IOException,JsonGenerationException {
+ public void writeNumber(BigDecimal dec) throws IOException {
if (dec == null) {
writeNull();
} else {
@@ -760,7 +752,7 @@
}
@Override
- public void writeNumber(BigInteger v) throws IOException, JsonGenerationException {
+ public void writeNumber(BigInteger v) throws IOException {
if (v == null) {
writeNull();
} else {
@@ -769,7 +761,7 @@
}
@Override
- public void writeNumber(String encodedValue) throws IOException, JsonGenerationException {
+ public void writeNumber(String encodedValue) throws IOException {
/* 03-Dec-2010, tatu: related to [JACKSON-423], should try to keep as numeric
* identity as long as possible
*/
@@ -777,12 +769,12 @@
}
@Override
- public void writeBoolean(boolean state) throws IOException,JsonGenerationException {
+ public void writeBoolean(boolean state) throws IOException {
_append(state ? JsonToken.VALUE_TRUE : JsonToken.VALUE_FALSE);
}
@Override
- public void writeNull() throws IOException, JsonGenerationException {
+ public void writeNull() throws IOException {
_append(JsonToken.VALUE_NULL);
}
@@ -837,8 +829,7 @@
*/
@Override
- public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len)
- throws IOException, JsonGenerationException
+ public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException
{
/* 31-Dec-2009, tatu: can do this using multiple alternatives; but for
* now, let's try to limit number of conversions.
@@ -897,7 +888,7 @@
*/
@Override
- public void copyCurrentEvent(JsonParser jp) throws IOException, JsonProcessingException
+ public void copyCurrentEvent(JsonParser jp) throws IOException
{
if (_mayHaveNativeIds) {
_checkNativeIds(jp);
@@ -967,7 +958,7 @@
}
@Override
- public void copyCurrentStructure(JsonParser jp) throws IOException, JsonProcessingException
+ public void copyCurrentStructure(JsonParser jp) throws IOException
{
JsonToken t = jp.getCurrentToken();
@@ -1006,7 +997,7 @@
}
- private final void _checkNativeIds(JsonParser jp) throws IOException, JsonProcessingException
+ private final void _checkNativeIds(JsonParser jp) throws IOException
{
if ((_typeId = jp.getTypeId()) != null) {
_hasNativeId = true;
@@ -1198,7 +1189,7 @@
*/
@Override
- public JsonToken nextToken() throws IOException, JsonParseException
+ public JsonToken nextToken() throws IOException
{
// If we are closed, nothing more to do
if (_closed || (_segment == null)) return null;
@@ -1234,6 +1225,23 @@
}
@Override
+ public String nextFieldName() throws IOException
+ {
+ // inlined common case from nextToken()
+ if (_closed || (_segment == null)) return null;
+
+ int ptr = _segmentPtr+1;
+ if (ptr < Segment.TOKENS_PER_SEGMENT && _segment.type(ptr) == JsonToken.FIELD_NAME) {
+ _segmentPtr = ptr;
+ Object ob = _segment.get(ptr); // inlined _currentObject();
+ String name = (ob instanceof String) ? ((String) ob) : ob.toString();
+ _parsingContext.setCurrentName(name);
+ return name;
+ }
+ return (nextToken() == JsonToken.FIELD_NAME) ? getCurrentName() : null;
+ }
+
+ @Override
public boolean isClosed() { return _closed; }
/*
@@ -1241,7 +1249,7 @@
/* Public API, token accessors
/**********************************************************
*/
-
+
@Override
public JsonStreamContext getParsingContext() { return _parsingContext; }
@@ -1270,13 +1278,13 @@
throw new RuntimeException(e);
}
}
-
+
/*
/**********************************************************
/* Public API, access to token information, text
/**********************************************************
*/
-
+
@Override
public String getText()
{
diff --git a/src/test/java/com/fasterxml/jackson/databind/TestObjectMapper.java b/src/test/java/com/fasterxml/jackson/databind/TestObjectMapper.java
index ce9056f..1a3758c 100644
--- a/src/test/java/com/fasterxml/jackson/databind/TestObjectMapper.java
+++ b/src/test/java/com/fasterxml/jackson/databind/TestObjectMapper.java
@@ -47,6 +47,7 @@
assertNotNull(m.getNodeFactory());
JsonNodeFactory nf = JsonNodeFactory.instance;
m.setNodeFactory(nf);
+ assertNull(m.getInjectableValues());
assertSame(nf, m.getNodeFactory());
}
@@ -138,6 +139,8 @@
assertTrue(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
m.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
+ InjectableValues inj = new InjectableValues.Std();
+ m.setInjectableValues(inj);
// // First: verify that handling of features is decoupled:
@@ -145,6 +148,8 @@
assertFalse(m2.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
m2.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
assertTrue(m2.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
+ assertSame(inj, m2.getInjectableValues());
+
// but should NOT change the original
assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
diff --git a/src/test/java/com/fasterxml/jackson/databind/interop/TestGroovyBeans.java b/src/test/java/com/fasterxml/jackson/databind/interop/TestGroovyBeans.java
deleted file mode 100644
index d0a874b..0000000
--- a/src/test/java/com/fasterxml/jackson/databind/interop/TestGroovyBeans.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.fasterxml.jackson.databind.interop;
-
-import java.util.*;
-
-import groovy.lang.GroovyClassLoader;
-
-import com.fasterxml.jackson.databind.*;
-
-/**
- * Basic tests to see that simple Groovy beans can be serialized
- * and deserialized
- */
-public class TestGroovyBeans
- extends com.fasterxml.jackson.databind.BaseMapTest
-{
- final static String SIMPLE_POGO =
- "public class GBean {\n"
- +"long id = 3;\n"
- +"String name = \"whome\";\n"
- +"}";
-
- private final ObjectMapper MAPPER = new ObjectMapper();
-
- public void testSimpleSerialization() throws Exception
- {
- Object ob = newGroovyObject(SIMPLE_POGO);
- Map<String,Object> result = writeAndMap(MAPPER, ob);
- assertEquals(2, result.size());
- assertEquals("whome", result.get("name"));
- /* 26-Nov-2009, tatu: Strange... Groovy seems to decide
- * 'long' means 'int'... Oh well.
- */
- Object num = result.get("id");
- assertNotNull(num);
- assertTrue(num instanceof Number);
- assertEquals(3, ((Number) num).intValue());
- }
-
- public void testSimpleDeserialization() throws Exception
- {
- Class<?> cls = defineGroovyClass(SIMPLE_POGO);
- // First: deserialize from data
- Object pogo = MAPPER.readValue("{\"id\":9,\"name\":\"Bob\"}", cls);
- assertNotNull(pogo);
- /* Hmmh. Could try to access using Reflection, or by defining
- * a Java interface it implements. Or, maybe simplest, just
- * re-serialize and see what we got.
- */
- Map<String,Object> result = writeAndMap(MAPPER, pogo);
- assertEquals(2, result.size());
- assertEquals("Bob", result.get("name"));
- // as per earlier, we just get a number...
- Object num = result.get("id");
- assertNotNull(num);
- assertTrue(num instanceof Number);
- assertEquals(9, ((Number) num).intValue());
- }
-
- /*
- *************************************************
- * Helper methods
- *************************************************
- */
-
- protected Class<?> defineGroovyClass(String src) throws Exception
- {
- return new GroovyClassLoader(getClass().getClassLoader()).parseClass(src);
-
- }
-
- protected Object newGroovyObject(String src) throws Exception
- {
- Class<?> cls = defineGroovyClass(src);
- return cls.newInstance();
- }
-}
diff --git a/src/test/java/com/fasterxml/jackson/databind/introspect/TestAnnotionBundles.java b/src/test/java/com/fasterxml/jackson/databind/introspect/TestAnnotionBundles.java
index 804afa8..761f0bc 100644
--- a/src/test/java/com/fasterxml/jackson/databind/introspect/TestAnnotionBundles.java
+++ b/src/test/java/com/fasterxml/jackson/databind/introspect/TestAnnotionBundles.java
@@ -90,7 +90,7 @@
{
InformativeHolder informativeHolder = a.getAnnotation(InformativeHolder.class);
if ((informativeHolder != null) && informativeHolder.important()) {
- return new PropertyName("important");
+ return PropertyName.construct("important");
}
return super.findNameForSerialization(a);
}
diff --git a/src/test/java/com/fasterxml/jackson/failing/TestScalaLikeImplicitProperties.java b/src/test/java/com/fasterxml/jackson/databind/introspect/TestScalaLikeImplicitProperties.java
similarity index 98%
rename from src/test/java/com/fasterxml/jackson/failing/TestScalaLikeImplicitProperties.java
rename to src/test/java/com/fasterxml/jackson/databind/introspect/TestScalaLikeImplicitProperties.java
index a0cf4c2..f69b0c9 100644
--- a/src/test/java/com/fasterxml/jackson/failing/TestScalaLikeImplicitProperties.java
+++ b/src/test/java/com/fasterxml/jackson/databind/introspect/TestScalaLikeImplicitProperties.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.failing;
+package com.fasterxml.jackson.databind.introspect;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.*;
diff --git a/src/test/java/com/fasterxml/jackson/databind/jsontype/TestSubtypes.java b/src/test/java/com/fasterxml/jackson/databind/jsontype/TestSubtypes.java
index 68df8f4..dae8004 100644
--- a/src/test/java/com/fasterxml/jackson/databind/jsontype/TestSubtypes.java
+++ b/src/test/java/com/fasterxml/jackson/databind/jsontype/TestSubtypes.java
@@ -75,6 +75,9 @@
@JsonTypeName("x")
static class ImplX extends BaseX {
public int x;
+
+ public ImplX() { }
+ public ImplX(int x) { this.x = x; }
}
@JsonTypeName("y")
@@ -82,12 +85,22 @@
public int y;
}
+ // [databind#663]
+ static class AtomicWrapper {
+ public BaseX value;
+
+ public AtomicWrapper() { }
+ public AtomicWrapper(int x) { value = new ImplX(x); }
+ }
+
/*
/**********************************************************
/* Unit tests
/**********************************************************
*/
+ private final ObjectMapper MAPPER = new ObjectMapper();
+
// JACKSON-510
public void testPropertyWithSubtypes() throws Exception
{
@@ -115,11 +128,10 @@
{
// serialization can detect type name ok without anything extra:
SubB bean = new SubB();
- ObjectMapper mapper = new ObjectMapper();
- assertEquals("{\"@type\":\"TypeB\",\"b\":1}", mapper.writeValueAsString(bean));
+ assertEquals("{\"@type\":\"TypeB\",\"b\":1}", MAPPER.writeValueAsString(bean));
// but we can override type name here too
- mapper = new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper();
mapper.registerSubtypes(new NamedType(SubB.class, "typeB"));
assertEquals("{\"@type\":\"typeB\",\"b\":1}", mapper.writeValueAsString(bean));
@@ -178,22 +190,21 @@
public void testDefaultImpl() throws Exception
{
- ObjectMapper mapper = new ObjectMapper();
// first, test with no type information
- SuperTypeWithDefault bean = mapper.readValue("{\"a\":13}", SuperTypeWithDefault.class);
+ SuperTypeWithDefault bean = MAPPER.readValue("{\"a\":13}", SuperTypeWithDefault.class);
assertEquals(DefaultImpl.class, bean.getClass());
assertEquals(13, ((DefaultImpl) bean).a);
// and then with unmapped info
- bean = mapper.readValue("{\"a\":14,\"#type\":\"foobar\"}", SuperTypeWithDefault.class);
+ bean = MAPPER.readValue("{\"a\":14,\"#type\":\"foobar\"}", SuperTypeWithDefault.class);
assertEquals(DefaultImpl.class, bean.getClass());
assertEquals(14, ((DefaultImpl) bean).a);
- bean = mapper.readValue("{\"#type\":\"foobar\",\"a\":15}", SuperTypeWithDefault.class);
+ bean = MAPPER.readValue("{\"#type\":\"foobar\",\"a\":15}", SuperTypeWithDefault.class);
assertEquals(DefaultImpl.class, bean.getClass());
assertEquals(15, ((DefaultImpl) bean).a);
- bean = mapper.readValue("{\"#type\":\"foobar\"}", SuperTypeWithDefault.class);
+ bean = MAPPER.readValue("{\"#type\":\"foobar\"}", SuperTypeWithDefault.class);
assertEquals(DefaultImpl.class, bean.getClass());
assertEquals(0, ((DefaultImpl) bean).a);
}
@@ -204,16 +215,15 @@
final String JSON = "{\"a\":123}";
// first: without registration etc, epic fail:
- ObjectMapper mapper = new ObjectMapper();
try {
- mapper.readValue(JSON, SuperTypeWithoutDefault.class);
+ MAPPER.readValue(JSON, SuperTypeWithoutDefault.class);
fail("Expected an exception");
} catch (JsonMappingException e) {
verifyException(e, "missing property");
}
// but then succeed when we register default impl
- mapper = new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule("test", Version.unknownVersion());
module.addAbstractTypeMapping(SuperTypeWithoutDefault.class, DefaultImpl505.class);
mapper.registerModule(module);
@@ -237,4 +247,14 @@
verifyException(e, "known type ids =");
}
}
+
+ public void testViaAtomic() throws Exception {
+ AtomicWrapper input = new AtomicWrapper(3);
+ String json = MAPPER.writeValueAsString(input);
+
+ AtomicWrapper output = MAPPER.readValue(json, AtomicWrapper.class);
+ assertNotNull(output);
+ assertEquals(ImplX.class, output.value.getClass());
+ assertEquals(3, ((ImplX) output.value).x);
+ }
}
diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/JSOGDeserialize622Test.java b/src/test/java/com/fasterxml/jackson/databind/objectid/JSOGDeserialize622Test.java
similarity index 71%
rename from src/test/java/com/fasterxml/jackson/databind/struct/JSOGDeserialize622Test.java
rename to src/test/java/com/fasterxml/jackson/databind/objectid/JSOGDeserialize622Test.java
index b58bc23..216ae3c 100644
--- a/src/test/java/com/fasterxml/jackson/databind/struct/JSOGDeserialize622Test.java
+++ b/src/test/java/com/fasterxml/jackson/databind/objectid/JSOGDeserialize622Test.java
@@ -1,14 +1,21 @@
-package com.fasterxml.jackson.databind.struct;
-
-import java.io.IOException;
+package com.fasterxml.jackson.databind.objectid;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
+import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.BaseMapTest;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.*;
+
+import java.io.IOException;
/**
* Unit test(s) for [databind#622], supporting non-scalar-Object-ids,
@@ -92,8 +99,15 @@
@Override
public JSOGRef deserialize(JsonParser jp, DeserializationContext ctx) throws IOException {
JsonNode node = jp.readValueAsTree();
- return node.isTextual()
- ? new JSOGRef(node.asInt()) : new JSOGRef(node.get(REF_KEY).asInt());
+ if (node.isTextual()) {
+ return new JSOGRef(node.asInt());
+ }
+ JsonNode n = node.get(REF_KEY);
+ if (n == null) {
+ throw new JsonMappingException("Could not find key '"+REF_KEY
+ +"' from ("+node.getClass().getName()+"): "+node);
+ }
+ return new JSOGRef(n.asInt());
}
}
@@ -151,6 +165,34 @@
public JSOGWrapper(int v) { value = v; }
}
+ // For [databind#669]
+
+ @JsonIdentityInfo(generator=JSOGGenerator.class)
+ @JsonTypeInfo(use=Id.CLASS, include= As.PROPERTY, property="@class")
+ public static class Inner {
+ public String bar;
+
+ protected Inner() {}
+ public Inner(String bar) { this.bar = bar; }
+ }
+
+ public static class SubInner extends Inner {
+ public String extra;
+
+ protected SubInner() {}
+ public SubInner(String bar, String extra) {
+ super(bar);
+ this.extra = extra;
+ }
+ }
+
+ @JsonIdentityInfo(generator=JSOGGenerator.class)
+ public static class Outer {
+ public String foo;
+ public Inner inner1;
+ public Inner inner2;
+ }
+
/*
/**********************************************************************
/* Test methods
@@ -159,7 +201,7 @@
private final ObjectMapper MAPPER = new ObjectMapper();
- // Basic for [#622]
+ // Basic for [databind#622]
public void testStructJSOGRef() throws Exception
{
IdentifiableExampleJSOG result = MAPPER.readValue(EXP_EXAMPLE_JSOG,
@@ -168,7 +210,7 @@
assertSame(result, result.next);
}
- // polymorphic alternative for [#622]
+ // polymorphic alternative for [databind#622]
public void testPolymorphicRoundTrip() throws Exception
{
JSOGWrapper w = new JSOGWrapper(15);
@@ -187,4 +229,18 @@
assertEquals(123, jsog.foo);
assertSame(jsog, jsog.next);
}
+
+ // polymorphic alternative for [databind#669]
+ public void testAlterativePolymorphicRoundTrip669() throws Exception
+ {
+ Outer outer = new Outer();
+ outer.foo = "foo";
+ outer.inner1 = outer.inner2 = new SubInner("bar", "extra");
+
+ String jsog = MAPPER.writeValueAsString(outer);
+
+ Outer back = MAPPER.readValue(jsog, Outer.class);
+
+ assertSame(back.inner1, back.inner2);
+ }
}
diff --git a/src/test/java/com/fasterxml/jackson/databind/jsontype/TestAbstractWithObjectId.java b/src/test/java/com/fasterxml/jackson/databind/objectid/TestAbstractWithObjectId.java
similarity index 97%
rename from src/test/java/com/fasterxml/jackson/databind/jsontype/TestAbstractWithObjectId.java
rename to src/test/java/com/fasterxml/jackson/databind/objectid/TestAbstractWithObjectId.java
index ea586b3..b2267fb 100644
--- a/src/test/java/com/fasterxml/jackson/databind/jsontype/TestAbstractWithObjectId.java
+++ b/src/test/java/com/fasterxml/jackson/databind/objectid/TestAbstractWithObjectId.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.databind.jsontype;
+package com.fasterxml.jackson.databind.objectid;
import com.fasterxml.jackson.annotation.*;
diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectId.java b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectId.java
similarity index 98%
rename from src/test/java/com/fasterxml/jackson/databind/struct/TestObjectId.java
rename to src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectId.java
index 3ca990c..04522f4 100644
--- a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectId.java
+++ b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectId.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.databind.struct;
+package com.fasterxml.jackson.databind.objectid;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/test/java/com/fasterxml/jackson/failing/TestObjectId154.java b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectId154.java
similarity index 63%
rename from src/test/java/com/fasterxml/jackson/failing/TestObjectId154.java
rename to src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectId154.java
index cb21240..f040331 100644
--- a/src/test/java/com/fasterxml/jackson/failing/TestObjectId154.java
+++ b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectId154.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.failing;
+package com.fasterxml.jackson.databind.objectid;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
@@ -6,9 +6,9 @@
public class TestObjectId154 extends BaseMapTest
{
@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="@id")
+ @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
public static class BaseEntity { }
- @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
public static class Foo extends BaseEntity {
public BaseEntity ref;
}
@@ -22,19 +22,18 @@
{
final ObjectMapper mapper = new ObjectMapper();
- Bar bar = new Bar();
- Foo foo = new Foo();
- bar.next = foo;
- foo.ref = bar;
+ Bar inputRoot = new Bar();
+ Foo inputChild = new Foo();
+ inputRoot.next = inputChild;
+ inputChild.ref = inputRoot;
- String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(bar);
-
- System.out.println("JSON: "+json);
+ String json = mapper.writerWithDefaultPrettyPrinter()
+ .writeValueAsString(inputRoot);
- BaseEntity result = mapper.readValue(json, BaseEntity.class);
- assertNotNull(result);
- assertTrue(result instanceof Bar);
- Bar first = (Bar) result;
+ BaseEntity resultRoot = mapper.readValue(json, BaseEntity.class);
+ assertNotNull(resultRoot);
+ assertTrue(resultRoot instanceof Bar);
+ Bar first = (Bar) resultRoot;
assertNotNull(first.next);
assertTrue(first.next instanceof Foo);
diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdDeserialization.java b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdDeserialization.java
similarity index 98%
rename from src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdDeserialization.java
rename to src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdDeserialization.java
index 171ffd7..d016f68 100644
--- a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdDeserialization.java
+++ b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdDeserialization.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.databind.struct;
+package com.fasterxml.jackson.databind.objectid;
import java.util.HashMap;
import java.util.Iterator;
@@ -19,8 +19,8 @@
import com.fasterxml.jackson.databind.cfg.ContextAttributes;
import com.fasterxml.jackson.databind.deser.UnresolvedForwardReference;
import com.fasterxml.jackson.databind.deser.UnresolvedId;
-import com.fasterxml.jackson.databind.struct.TestObjectId.Company;
-import com.fasterxml.jackson.databind.struct.TestObjectId.Employee;
+import com.fasterxml.jackson.databind.objectid.TestObjectId.Company;
+import com.fasterxml.jackson.databind.objectid.TestObjectId.Employee;
/**
* Unit test to verify handling of Object Id deserialization
diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdSerialization.java b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdSerialization.java
similarity index 99%
rename from src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdSerialization.java
rename to src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdSerialization.java
index b40ba66..50cc523 100644
--- a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdSerialization.java
+++ b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdSerialization.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.databind.struct;
+package com.fasterxml.jackson.databind.objectid;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdWithEquals.java b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdWithEquals.java
similarity index 97%
rename from src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdWithEquals.java
rename to src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdWithEquals.java
index 07229ad..3b57c4b 100644
--- a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdWithEquals.java
+++ b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdWithEquals.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.databind.struct;
+package com.fasterxml.jackson.databind.objectid;
import java.util.*;
diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdWithPolymorphic.java b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdWithPolymorphic.java
similarity index 98%
rename from src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdWithPolymorphic.java
rename to src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdWithPolymorphic.java
index 5ba30dd..2ecca8e 100644
--- a/src/test/java/com/fasterxml/jackson/databind/struct/TestObjectIdWithPolymorphic.java
+++ b/src/test/java/com/fasterxml/jackson/databind/objectid/TestObjectIdWithPolymorphic.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.databind.struct;
+package com.fasterxml.jackson.databind.objectid;
import java.util.*;
diff --git a/src/test/java/com/fasterxml/jackson/databind/ser/TestMapSerialization.java b/src/test/java/com/fasterxml/jackson/databind/ser/TestMapSerialization.java
index 87fab15..2ef1d0c 100644
--- a/src/test/java/com/fasterxml/jackson/databind/ser/TestMapSerialization.java
+++ b/src/test/java/com/fasterxml/jackson/databind/ser/TestMapSerialization.java
@@ -4,22 +4,15 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
-import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.*;
+
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@SuppressWarnings("serial")
-public class TestMapSerialization
- extends BaseMapTest
+public class TestMapSerialization extends BaseMapTest
{
- /**
- * Class needed for testing [JACKSON-220]
- */
@JsonSerialize(using=MapSerializer.class)
static class PseudoMap extends LinkedHashMap<String,String>
{
@@ -120,8 +113,31 @@
}
}
+ // for [databind#47]
+ public static class Wat
+ {
+ private final String wat;
+
+ @JsonCreator
+ Wat(String wat) {
+ this.wat = wat;
+ }
+
+ @JsonValue
+ public String getWat() {
+ return wat;
+ }
+
+ @Override
+ public String toString() {
+ return "(String)[Wat: " + wat + "]";
+ }
+ }
+
+ static class WatMap extends HashMap<Wat,Boolean> { }
+
// for [databind#691]
- @JsonTypeInfo(use=Id.NAME)
+ @JsonTypeInfo(use=JsonTypeInfo.Id.NAME)
@JsonTypeName("mymap")
static class MapWithTypedValues extends LinkedHashMap<String,String> { }
@@ -256,6 +272,18 @@
assertEquals(aposToQuotes("{'stuff':{'a':'foo','c':'bar'}}"), json);
}
+ // [databind#47]
+ public void testMapJsonValueKey() throws Exception
+ {
+ WatMap input = new WatMap();
+ input.put(new Wat("3"), true);
+
+ ObjectMapper mapper = new ObjectMapper();
+ String json = mapper.writeValueAsString(input);
+ assertEquals(aposToQuotes("{'3':true}"), json);
+ }
+
+ // [databind#682]
public void testClassKey() throws IOException
{
Map<Class<?>,Integer> map = new LinkedHashMap<Class<?>,Integer>();
@@ -277,3 +305,4 @@
json);
}
}
+
diff --git a/src/test/java/com/fasterxml/jackson/failing/TestMapSerialization588.java b/src/test/java/com/fasterxml/jackson/failing/TestEmptyMapSerialization588.java
similarity index 94%
rename from src/test/java/com/fasterxml/jackson/failing/TestMapSerialization588.java
rename to src/test/java/com/fasterxml/jackson/failing/TestEmptyMapSerialization588.java
index 19136e4..9859bc3 100644
--- a/src/test/java/com/fasterxml/jackson/failing/TestMapSerialization588.java
+++ b/src/test/java/com/fasterxml/jackson/failing/TestEmptyMapSerialization588.java
@@ -7,13 +7,13 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.*;
-public class TestMapSerialization588 extends BaseMapTest
+public class TestEmptyMapSerialization588 extends BaseMapTest
{
static class NoEmptiesMapContainer {
@JsonInclude(value=JsonInclude.Include.NON_EMPTY,
content=JsonInclude.Include.NON_EMPTY)
public Map<String,String> stuff = new LinkedHashMap<String,String>();
-
+
public NoEmptiesMapContainer add(String key, String value) {
stuff.put(key, value);
return this;
@@ -36,5 +36,4 @@
.add("b", ""));
assertEquals(aposToQuotes("{}"), json);
}
-
}
diff --git a/src/test/java/com/fasterxml/jackson/failing/TestMapJsonValueKey47.java b/src/test/java/com/fasterxml/jackson/failing/TestMapJsonValueKey47.java
deleted file mode 100644
index 9b03bba..0000000
--- a/src/test/java/com/fasterxml/jackson/failing/TestMapJsonValueKey47.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.fasterxml.jackson.failing;
-
-import java.util.HashMap;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import com.fasterxml.jackson.databind.BaseMapTest;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-// [Issue#47]
-public class TestMapJsonValueKey47 extends BaseMapTest
-{
- public static class Wat
- {
- private final String wat;
-
- @JsonCreator
- Wat(String wat) {
- this.wat = wat;
- }
-
- @JsonValue
- public String getWat() {
- return wat;
- }
-
- @Override
- public String toString() {
- return "(String)[Wat: " + wat + "]";
- }
- }
-
- @SuppressWarnings("serial")
- static class WatMap extends HashMap<Wat,Boolean> { }
-
- public void testMapJsonValueKey()
- throws Exception
- {
- WatMap input = new WatMap();
- input.put(new Wat("3"), true);
-
- ObjectMapper mapper = new ObjectMapper();
- String json = mapper.writeValueAsString(input);
- assertEquals(aposToQuotes("{'3':true}"), json);
- }
-}
diff --git a/src/test/java/com/fasterxml/jackson/failing/TestObjectId687.java b/src/test/java/com/fasterxml/jackson/failing/TestObjectId687.java
new file mode 100644
index 0000000..03988c9
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/failing/TestObjectId687.java
@@ -0,0 +1,106 @@
+package com.fasterxml.jackson.failing;
+
+import java.io.IOException;
+import java.util.*;
+
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.*;
+
+public class TestObjectId687 extends BaseMapTest
+{
+ @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="label")
+ static class ReferredWithCreator {
+ @JsonProperty("label")
+ private String label;
+
+ @JsonCreator
+ ReferredWithCreator(@JsonProperty("label")String label) {
+ this.label = label;
+ }
+ }
+
+ @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="label")
+ static class ReferringToObjWithCreator {
+ @JsonProperty("label")
+ private String label = "test1";
+ @JsonProperty("refs")
+ private List<ReferredWithCreator> refs = new ArrayList<ReferredWithCreator>();
+ public void addRef(ReferredWithCreator r) {
+ this.refs.add(r);
+ }
+ }
+
+ @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="label")
+ static class EnclosingForRefsWithCreator {
+ @JsonProperty("label")
+ String label = "enclosing1";
+ @JsonProperty("baseRef")
+ ReferredWithCreator baseRef;
+ @JsonProperty("nextRef")
+ ReferringToObjWithCreator nextRef;
+ }
+
+ @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="label")
+ static class ReferredWithNoCreator {
+ @JsonProperty("label")
+ private String label = "label2";
+ }
+
+ @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="label")
+ static class ReferringToObjWithNoCreator {
+ @JsonProperty("label")
+ private String label = "test2";
+ @JsonProperty("refs")
+ private List<ReferredWithNoCreator> refs = new ArrayList<ReferredWithNoCreator>();
+ public void addRef(ReferredWithNoCreator r) {
+ this.refs.add(r);
+ }
+ }
+
+ @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="label")
+ static class EnclosingForRefWithNoCreator {
+ @JsonProperty("label")
+ String label = "enclosing2";
+ @JsonProperty("baseRef")
+ ReferredWithNoCreator baseRef;
+ @JsonProperty("nextRef")
+ ReferringToObjWithNoCreator nextRef;
+ }
+
+
+ /*
+ /*****************************************************
+ /* Test methods
+ /*****************************************************
+ */
+
+ private final ObjectMapper MAPPER = objectMapper();
+
+ public void testSerializeDeserializeWithCreator() throws IOException {
+ ReferredWithCreator base = new ReferredWithCreator("label1");
+ ReferringToObjWithCreator r = new ReferringToObjWithCreator();
+ r.addRef(base);
+ EnclosingForRefsWithCreator e = new EnclosingForRefsWithCreator();
+ e.baseRef = base;
+ e.nextRef = r;
+
+ String jsonStr = MAPPER.writeValueAsString(e);
+
+ EnclosingForRefsWithCreator deserialized = MAPPER.readValue(jsonStr, EnclosingForRefsWithCreator.class);
+ assertNotNull(deserialized);
+ }
+
+ public void testSerializeDeserializeNoCreator() throws IOException {
+ ReferredWithNoCreator base = new ReferredWithNoCreator();
+ ReferringToObjWithNoCreator r = new ReferringToObjWithNoCreator();
+ r.addRef(base);
+ EnclosingForRefWithNoCreator e = new EnclosingForRefWithNoCreator();
+ e.baseRef = base;
+ e.nextRef = r;
+
+ String jsonStr = MAPPER.writeValueAsString(e);
+
+ EnclosingForRefWithNoCreator deserialized = MAPPER.readValue(jsonStr, EnclosingForRefWithNoCreator.class);
+ assertNotNull(deserialized);
+ }
+}
diff --git a/src/test/java/com/fasterxml/jackson/failing/TestObjectIdDeserialization.java b/src/test/java/com/fasterxml/jackson/failing/TestObjectIdDeserialization.java
index f281379..338d7e9 100644
--- a/src/test/java/com/fasterxml/jackson/failing/TestObjectIdDeserialization.java
+++ b/src/test/java/com/fasterxml/jackson/failing/TestObjectIdDeserialization.java
@@ -7,7 +7,7 @@
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.struct.TestObjectId.Employee;
+import com.fasterxml.jackson.databind.objectid.TestObjectId.Employee;
import com.fasterxml.jackson.failing.TestObjectIdDeserialization.EnumMapCompany.FooEnum;
/**
@@ -55,9 +55,7 @@
/*****************************************************
*/
-
- public void testForwardReferenceInArray()
- throws Exception
+ public void testForwardReferenceInArray() throws Exception
{
String json = "{\"employees\":["
+ "{\"id\":1,\"name\":\"First\",\"manager\":null,\"reports\":[2]},"
@@ -72,8 +70,7 @@
}
// Do a specific test for ArrayBlockingQueue since it has its own deser.
- public void testForwardReferenceInQueue()
- throws Exception
+ public void testForwardReferenceInQueue() throws Exception
{
String json = "{\"employees\":["
+ "{\"id\":1,\"name\":\"First\",\"manager\":null,\"reports\":[2]},"