diff --git a/release-notes/VERSION b/release-notes/VERSION
index 7da72be3f5..2bbee0a57d 100644
--- a/release-notes/VERSION
+++ b/release-notes/VERSION
@@ -68,6 +68,7 @@ Versions: 3.x (for earlier see VERSION-2.x)
(contributed by Joo-Hyuk K)
#4589: Remove `MapperFeature.SORT_CREATOR_PROPERTIES_BY_DECLARATION_ORDER` from 3.0;
make logic default
+#4659: Remove use of global static `TypeFactory` singleton from 3.0
#4664: Change `EnumNamingStrategy.convertEnumToExternalName()` to take `MapperConfig` argument-
(contributed by Joo-Hyuk K)
- Remove `MappingJsonFactory`
diff --git a/src/main/java/tools/jackson/databind/cfg/MapperBuilder.java b/src/main/java/tools/jackson/databind/cfg/MapperBuilder.java
index ac21fd40be..86264f4b2b 100644
--- a/src/main/java/tools/jackson/databind/cfg/MapperBuilder.java
+++ b/src/main/java/tools/jackson/databind/cfg/MapperBuilder.java
@@ -550,10 +550,10 @@ public TypeFactory typeFactory() {
}
/**
- * Overridable method for changing default {@link SubtypeResolver} instance to use
+ * Overridable method for changing default {@link TypeFactory} instance to use
*/
protected TypeFactory _defaultTypeFactory() {
- return TypeFactory.defaultInstance();
+ return TypeFactory.createDefaultInstance();
}
public ClassIntrospector classIntrospector() {
diff --git a/src/main/java/tools/jackson/databind/ser/jdk/JDKArraySerializers.java b/src/main/java/tools/jackson/databind/ser/jdk/JDKArraySerializers.java
index 05c01522ba..62f30ebcdd 100644
--- a/src/main/java/tools/jackson/databind/ser/jdk/JDKArraySerializers.java
+++ b/src/main/java/tools/jackson/databind/ser/jdk/JDKArraySerializers.java
@@ -44,10 +44,8 @@ public static ValueSerializer> findStandardImpl(Class> cls) {
return _arraySerializers.get(cls.getName());
}
- // @since 2.19
- @SuppressWarnings("deprecation")
static JavaType simpleElementType(Class> elemClass) {
- return TypeFactory.defaultInstance().uncheckedSimpleType(elemClass);
+ return TypeFactory.unsafeSimpleType(elemClass);
}
/*
diff --git a/src/main/java/tools/jackson/databind/ser/jdk/StringArraySerializer.java b/src/main/java/tools/jackson/databind/ser/jdk/StringArraySerializer.java
index e4785b0c79..13cacd3c02 100644
--- a/src/main/java/tools/jackson/databind/ser/jdk/StringArraySerializer.java
+++ b/src/main/java/tools/jackson/databind/ser/jdk/StringArraySerializer.java
@@ -25,8 +25,7 @@ public class StringArraySerializer
/* Note: not clean in general, but we are betting against
* anyone re-defining properties of String.class here...
*/
- @SuppressWarnings("deprecation")
- private final static JavaType VALUE_TYPE = TypeFactory.defaultInstance().uncheckedSimpleType(String.class);
+ private final static JavaType VALUE_TYPE = TypeFactory.unsafeSimpleType(String.class);
public final static StringArraySerializer instance = new StringArraySerializer();
diff --git a/src/main/java/tools/jackson/databind/type/TypeFactory.java b/src/main/java/tools/jackson/databind/type/TypeFactory.java
index 3e0ea67061..83b176eec0 100644
--- a/src/main/java/tools/jackson/databind/type/TypeFactory.java
+++ b/src/main/java/tools/jackson/databind/type/TypeFactory.java
@@ -75,13 +75,6 @@ public final class TypeFactory
private final static JavaType[] NO_TYPES = new JavaType[0];
- /**
- * Globally shared singleton. Not accessed directly; non-core
- * code should use per-ObjectMapper instance (via configuration objects).
- * Core Jackson code uses {@link #defaultInstance} for accessing it.
- */
- protected final static TypeFactory instance = new TypeFactory();
-
protected final static TypeBindings EMPTY_BINDINGS = TypeBindings.emptyBindings();
/*
@@ -161,7 +154,10 @@ public final class TypeFactory
protected final TypeModifier[] _modifiers;
/**
- * ClassLoader used by this factory [databind#624].
+ * ClassLoader used by this factory.
+ *
+ * See [databind#624]
+ * for details.
*/
protected final ClassLoader _classLoader;
@@ -171,8 +167,9 @@ public final class TypeFactory
/**********************************************************************
*/
- private TypeFactory() {
- this(new SimpleLookupCache