Skip to content

Commit

Permalink
Change 3.0 to use module-info.java directly, remove use of Moditect (
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored Jan 11, 2025
1 parent 87c6b51 commit db8d824
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 41 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Needed by some of the tests -->
<argLine>--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED</argLine>
<argLine>--add-opens=java.base/java.lang=tools.jackson.databind
--add-opens=java.base/java.util=tools.jackson.databind
</argLine>
<!-- 26-Nov-2019, tatu: moar parallelism! Per-class basis, safe, efficient enough
... although not 100% sure this makes much difference TBH
-->
Expand Down Expand Up @@ -236,10 +238,6 @@
</executions>
</plugin>

<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
</plugin>
<!-- 03-Nov-2020, tatu: Add LICENSE from main level -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down Expand Up @@ -334,7 +332,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED</argLine>
<argLine>--add-opens=java.base/java.lang=tools.jackson.databind
--add-opens=java.base/java.util=tools.jackson.databind
</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Versions: 3.x (for earlier see VERSION-2.x)
#4875: Remove `JsonNode.fields()` from 3.0
#4879: Rename `TextNode` as `StringNode`; `JsonNode.xxxTextYyy()` (mostly) as
`JsonNode.xxxStringYyy()` [JSTEP-3]
#4891: Change 3.0 to use `module-info.java` directly for build (instead of via Moditect)
- Remove `MappingJsonFactory`
- Add context parameter for `TypeSerializer` contextualization (`forProperty()`)
- Default for `JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES` changed to `false` for 3.0
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Generated 14-Mar-2019 using Moditect maven plugin
module tools.jackson.databind {
// Jackson 3.x module-info for Main artifact
module tools.jackson.databind
{
// required for
// java.beans.ConstructorProperties
// java.beans.Transient
Expand All @@ -9,6 +10,7 @@
// these types were suggested as transitive, but aren't actually
// exposed externally (only within internal APIs)
requires static java.sql;
requires static java.sql.rowset;

// 05-Nov-2020, tatu: made optional in 2.x ("static") but for simplicity
// is (for now?) hard dep on 3.0. May want to change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ public abstract class JavaBeansAnnotations
static {
JavaBeansAnnotations impl = null;
try {
Class<?> cls = Class.forName("tools.jackson.databind.ext.beans.JavaBeansAnnotationsImpl");
impl = (JavaBeansAnnotations) ClassUtil.createInstance(cls, false);
impl = JavaBeansAnnotationsImpl.instance;
} catch (IllegalAccessError e) {
// [databind#4078]: make some jdk modules (such as java.desktop) optional, again.
// no-op
} catch (Throwable t) {
// 09-Sep-2019, tatu: Used to log earlier, but with 2.10 let's not log
// java.util.logging.Logger.getLogger(Java7Support.class.getName())
// java.util.logging.Logger.getLogger(JavaBeansAnnotations.class.getName())
// .warning("Unable to load JDK7 annotations (@ConstructorProperties, @Transient): no Java7 annotation support added");
ExceptionUtil.rethrowIfFatal(t);
// ExceptionUtil.rethrowIfFatal(t);
}
IMPL = impl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

public class JavaBeansAnnotationsImpl extends JavaBeansAnnotations
{
public final static JavaBeansAnnotationsImpl instance = new JavaBeansAnnotationsImpl();

@SuppressWarnings("unused") // compiler warns, just needed side-effects
private final Class<?> _bogus;

public JavaBeansAnnotationsImpl() {
// Trigger loading of annotations that only JDK 7 has, to trigger
// early fail (see [databind#2466])
// Trigger loading of annotations that only JDK 7 has, to trigger
// early fail (see [databind#2466])
Class<?> cls = Transient.class;
cls = ConstructorProperties.class;
_bogus = cls;
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/tools/jackson/databind/util/internal/Linked.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package tools.jackson.databind.util.internal;

import java.util.Deque;

/**
* An element that is linked on the {@link Deque}.
*/
interface Linked<T extends Linked<T>> {

/**
* Retrieves the previous element or <tt>null</tt> if either the element is
* unlinked or the first element on the deque.
*/
T getPrevious();

/** Sets the previous element or <tt>null</tt> if there is no link. */
void setPrevious(T prev);

/**
* Retrieves the next element or <tt>null</tt> if either the element is
* unlinked or the last element on the deque.
*/
T getNext();

/** Sets the next element or <tt>null</tt> if there is no link. */
void setNext(T next);
}
Original file line number Diff line number Diff line change
Expand Up @@ -434,27 +434,3 @@ public void remove() {
abstract E computeNext();
}
}

/**
* An element that is linked on the {@link Deque}.
*/
interface Linked<T extends Linked<T>> {

/**
* Retrieves the previous element or <tt>null</tt> if either the element is
* unlinked or the first element on the deque.
*/
T getPrevious();

/** Sets the previous element or <tt>null</tt> if there is no link. */
void setPrevious(T prev);

/**
* Retrieves the next element or <tt>null</tt> if either the element is
* unlinked or the last element on the deque.
*/
T getNext();

/** Sets the next element or <tt>null</tt> if there is no link. */
void setNext(T next);
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
*/
//@ThreadSafe
public final class PrivateMaxEntriesMap<K, V> extends AbstractMap<K, V>
implements ConcurrentMap<K, V>, Serializable {

implements ConcurrentMap<K, V>, Serializable
{
/*
* This class performs a best-effort bounding of a ConcurrentHashMap using a
* page-replacement algorithm to determine which entries to evict when the
Expand Down
96 changes: 96 additions & 0 deletions src/test/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Jackson 3.x module-info for Tests
module tools.jackson.databind
{
requires java.desktop;
requires java.sql;
requires java.sql.rowset;
requires java.xml;

// but we probably do want to expose streaming, annotations
// as transitive dependencies streaming types at least part of API
requires com.fasterxml.jackson.annotation;

requires tools.jackson.core;

// // Actual Test dependencies

// Guava testlib needed by CLMH tests, alas; brings in junit4
requires guava.testlib;
// JUnit4 should NOT be needed but is transitively required
requires junit;
requires org.assertj.core;
requires org.mockito;
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

// Main exports need to switch to "opens" for testing
opens tools.jackson.databind;
opens tools.jackson.databind.annotation;
opens tools.jackson.databind.cfg;
opens tools.jackson.databind.deser;
opens tools.jackson.databind.deser.bean;
opens tools.jackson.databind.deser.jackson;
opens tools.jackson.databind.deser.jdk;
opens tools.jackson.databind.deser.std;
opens tools.jackson.databind.exc;
opens tools.jackson.databind.introspect;
opens tools.jackson.databind.json;
opens tools.jackson.databind.jsonFormatVisitors;
opens tools.jackson.databind.jsontype;
opens tools.jackson.databind.jsontype.impl;
opens tools.jackson.databind.module;
opens tools.jackson.databind.node;
opens tools.jackson.databind.ser;
opens tools.jackson.databind.ser.bean;
opens tools.jackson.databind.ser.jackson;
opens tools.jackson.databind.ser.jdk;
opens tools.jackson.databind.ser.std;
opens tools.jackson.databind.type;
opens tools.jackson.databind.util;

// Additional test opens (not exported by main, or needed from src/test/java)
// needed by JUnit and other test libs
opens tools.jackson.databind.access;
opens tools.jackson.databind.contextual;
opens tools.jackson.databind.convert;
opens tools.jackson.databind.deser.builder;
opens tools.jackson.databind.deser.creators;
opens tools.jackson.databind.deser.dos;
opens tools.jackson.databind.deser.enums;
opens tools.jackson.databind.deser.filter;
opens tools.jackson.databind.deser.inject;
opens tools.jackson.databind.deser.lazy;
opens tools.jackson.databind.deser.merge;
opens tools.jackson.databind.deser.validate;
opens tools.jackson.databind.ext;
opens tools.jackson.databind.ext.desktop;
opens tools.jackson.databind.ext.jdk8;
opens tools.jackson.databind.ext.jdk9;
opens tools.jackson.databind.ext.jdk17;
opens tools.jackson.databind.ext.sql;
opens tools.jackson.databind.ext.xml;
opens tools.jackson.databind.format;
opens tools.jackson.databind.interop;
opens tools.jackson.databind.jsonschema;
opens tools.jackson.databind.jsontype.deftyping;
opens tools.jackson.databind.jsontype.ext;
opens tools.jackson.databind.jsontype.jdk;
opens tools.jackson.databind.jsontype.vld;
opens tools.jackson.databind.misc;
opens tools.jackson.databind.mixins;
opens tools.jackson.databind.objectid;
opens tools.jackson.databind.records;
opens tools.jackson.databind.records.tofix;
opens tools.jackson.databind.ser.dos;
opens tools.jackson.databind.ser.enums;
opens tools.jackson.databind.ser.filter;
opens tools.jackson.databind.seq;
opens tools.jackson.databind.struct;
opens tools.jackson.databind.testutil.failure;
opens tools.jackson.databind.tofix;
opens tools.jackson.databind.util.internal;
opens tools.jackson.databind.views;

// Also needed for some reason
uses tools.jackson.databind.JacksonModule;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.databind.big;
package tools.jackson.databind.deser.dos;

import java.util.*;

Expand Down

0 comments on commit db8d824

Please sign in to comment.