Skip to content

Commit b74033d

Browse files
authored
Yasson deserialization and serialization rework (#537)
Yasson deserialization and serialization reworked Signed-off-by: David Kral <[email protected]>
1 parent e7ff427 commit b74033d

File tree

343 files changed

+10471
-11362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+10471
-11362
lines changed

.github/workflows/maven.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ jobs:
5454
java-version: ${{ matrix.java_version }}
5555
- name: Yasson tests
5656
run: mvn -U -C -Dmaven.javadoc.skip=true -Pstaging verify
57-
- name: JSONB-API TCK
58-
run: cd yasson-tck && mvn -U -B test
57+
# TMP removal
58+
# - name: JSONB-API TCK
59+
# run: cd yasson-tck && mvn -U -B test

etc/checkstyle.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0 which is available at
@@ -119,7 +119,7 @@
119119
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
120120
<module name="RedundantImport"/>
121121
<module name="ImportOrder">
122-
<property name="groups" value="java, jakarta, javax, org.eclipse.yasson"/>
122+
<property name="groups" value="java, javax, jakarta, org.eclipse.yasson"/>
123123
<property name="ordered" value="true"/>
124124
<property name="separated" value="true"/>
125125
<property name="option" value="bottom"/>
@@ -223,7 +223,9 @@
223223
<!-- See http://checkstyle.sf.net/config_design.html -->
224224
<module name="HideUtilityClassConstructor"/>
225225
<module name="InterfaceIsType"/>
226-
<module name="VisibilityModifier"/>
226+
<module name="VisibilityModifier">
227+
<property name="packageAllowed" value="true"/>
228+
</module>
227229
<module name="ThrowsCount">
228230
<property name="max" value="3"/>
229231
</module>
@@ -235,7 +237,7 @@
235237
<module name="UpperEll"/>
236238

237239
<module name="OneStatementPerLine"/>
238-
<module name="FallThrough"/>
240+
<!-- <module name="FallThrough"/>-->
239241

240242
<module name="NoFinalizer"/>
241243
</module>

pom.xml

+64-64
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@
1414
-->
1515

1616
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
17+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1818

1919
<parent>
2020
<groupId>org.eclipse.ee4j</groupId>
2121
<artifactId>project</artifactId>
22-
<version>1.0.6</version>
22+
<version>1.0.7</version>
2323
</parent>
2424

2525
<modelVersion>4.0.0</modelVersion>
2626
<groupId>org.eclipse</groupId>
2727
<artifactId>yasson</artifactId>
28-
<version>2.0.5-SNAPSHOT</version>
28+
<version>3.0.0-SNAPSHOT</version>
2929
<packaging>jar</packaging>
30-
<name>org.eclipse.yasson</name>
30+
<name>Yasson</name>
3131

3232
<description>Eclipse Yasson. Reference implementation of JSR-367 (JSON-B).</description>
3333
<url>https://projects.eclipse.org/projects/ee4j.yasson</url>
3434

3535
<properties>
3636
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<jakarta.json.version>2.0.0</jakarta.json.version>
38-
<jakarta.json.bind.version>2.0.0</jakarta.json.bind.version>
39-
<jakarta.enterprise.cdi-api.version>3.0.0</jakarta.enterprise.cdi-api.version>
37+
<jakarta.json.version>2.0.1</jakarta.json.version>
38+
<jakarta.json.bind.version>3.0.0-RC1</jakarta.json.bind.version>
39+
<jakarta.enterprise.cdi-api.version>4.0.0-RC2</jakarta.enterprise.cdi-api.version>
4040
<netbeans.hint.jdkPlatform>JDK_9</netbeans.hint.jdkPlatform>
4141
</properties>
4242

@@ -69,25 +69,13 @@
6969
<dependency>
7070
<groupId>org.jboss.weld.se</groupId>
7171
<artifactId>weld-se-core</artifactId>
72-
<version>4.0.0.Beta2</version>
72+
<version>5.0.0.Beta1</version>
7373
<scope>test</scope>
7474
<exclusions>
7575
<exclusion>
7676
<groupId>jakarta.el</groupId>
7777
<artifactId>jakarta.el-api</artifactId>
7878
</exclusion>
79-
<exclusion>
80-
<groupId>jakarta.annotation</groupId>
81-
<artifactId>jakarta.annotation-api</artifactId>
82-
</exclusion>
83-
<exclusion>
84-
<groupId>jakarta.enterprise</groupId>
85-
<artifactId>jakarta.enterprise.cdi-api</artifactId>
86-
</exclusion>
87-
<exclusion>
88-
<groupId>jakarta.interceptor</groupId>
89-
<artifactId>jakarta.interceptor-api</artifactId>
90-
</exclusion>
9179
</exclusions>
9280
</dependency>
9381
<dependency>
@@ -102,6 +90,11 @@
10290
<version>5.6.2</version>
10391
<scope>test</scope>
10492
</dependency>
93+
<dependency>
94+
<groupId>org.hamcrest</groupId>
95+
<artifactId>hamcrest-all</artifactId>
96+
<version>1.3</version>
97+
</dependency>
10598
</dependencies>
10699

107100
<organization>
@@ -284,15 +277,49 @@
284277
</plugins>
285278
</build>
286279
</profile>
280+
281+
<!-- remove when not needed -->
282+
<profile>
283+
<id>staging</id>
284+
<activation>
285+
<activeByDefault>false</activeByDefault>
286+
</activation>
287+
<repositories>
288+
<repository>
289+
<id>sonatype-nexus-staging</id>
290+
<name>Sonatype Nexus Staging</name>
291+
<url>${sonatypeOssDistMgmtStagingUrl}</url>
292+
<releases>
293+
<enabled>true</enabled>
294+
</releases>
295+
<snapshots>
296+
<enabled>true</enabled>
297+
</snapshots>
298+
</repository>
299+
</repositories>
300+
<pluginRepositories>
301+
<pluginRepository>
302+
<id>sonatype-nexus-staging</id>
303+
<name>Sonatype Nexus Staging</name>
304+
<url>${sonatypeOssDistMgmtStagingUrl}</url>
305+
<releases>
306+
<enabled>true</enabled>
307+
</releases>
308+
<snapshots>
309+
<enabled>true</enabled>
310+
</snapshots>
311+
</pluginRepository>
312+
</pluginRepositories>
313+
</profile>
287314
</profiles>
288315

289316
<build>
290-
<testResources>
291-
<testResource>
292-
<directory>src/test/resources</directory>
293-
<filtering>true</filtering>
294-
</testResource>
295-
</testResources>
317+
<!-- <testResources>-->
318+
<!-- <testResource>-->
319+
<!-- <directory>src/test/resources</directory>-->
320+
<!-- <filtering>true</filtering>-->
321+
<!-- </testResource>-->
322+
<!-- </testResources>-->
296323
<finalName>${project.artifactId}</finalName>
297324
<pluginManagement>
298325
<plugins>
@@ -327,28 +354,19 @@
327354
<executions>
328355
<execution>
329356
<id>default-compile</id>
357+
<goals>
358+
<goal>compile</goal>
359+
</goals>
330360
<configuration>
331-
<!-- compile everything to ensure module-info contains right entries -->
332-
<!-- required when JAVA_HOME is JDK 8 or below -->
333-
<release>9</release>
334-
<compilerArgs>
335-
<!--Remove when CDI is updated to support modules-->
336-
<arg>--add-reads</arg>
337-
<arg>org.eclipse.yasson=ALL-UNNAMED</arg>
338-
</compilerArgs>
361+
<release>11</release>
362+
<source>11</source>
363+
<target>11</target>
339364
</configuration>
340365
</execution>
341366
<execution>
342-
<id>multi-release-compile-9</id>
343-
<goals>
344-
<goal>compile</goal>
345-
</goals>
367+
<id>default-testCompile</id>
346368
<configuration>
347-
<release>9</release>
348-
<compileSourceRoots>
349-
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
350-
</compileSourceRoots>
351-
<multiReleaseOutput>true</multiReleaseOutput>
369+
<release>11</release>
352370
</configuration>
353371
</execution>
354372
<execution>
@@ -364,29 +382,11 @@
364382
<multiReleaseOutput>true</multiReleaseOutput>
365383
</configuration>
366384
</execution>
367-
<execution>
368-
<id>base-compile</id>
369-
<goals>
370-
<goal>compile</goal>
371-
</goals>
372-
<!-- recompile everything for 1.8 except the module-info.java -->
373-
<configuration>
374-
<release>8</release>
375-
<excludes>
376-
<exclude>module-info.java</exclude>
377-
</excludes>
378-
</configuration>
379-
</execution>
380-
<execution>
381-
<id>default-testCompile</id>
382-
<configuration>
383-
<release>11</release>
384-
</configuration>
385-
</execution>
386385
</executions>
387386
<!-- defaults for compile and testCompile -->
388387
<configuration>
389388
<compilerArgs>
389+
<compilerArgument>-proc:none</compilerArgument>
390390
<arg>-Xlint:all</arg>
391391
</compilerArgs>
392392
</configuration>
@@ -486,7 +486,7 @@
486486
java.beans;resolution:="optional",
487487
*
488488
</Import-Package>
489-
<Require-Capability>osgi.ee;filter:="(&amp;(osgi.ee=JavaSE)(version=1.8))"</Require-Capability>
489+
<Require-Capability>osgi.ee;filter:="(&amp;(osgi.ee=JavaSE)(version=11))"</Require-Capability>
490490
</instructions>
491491
</configuration>
492492
</execution>
@@ -555,7 +555,7 @@
555555
<configuration>
556556
<rules>
557557
<requireJavaVersion>
558-
<version>[9,)</version>
558+
<version>[11,)</version>
559559
</requireJavaVersion>
560560
<requireMavenVersion>
561561
<version>[3.3.9,)</version>

src/main/assembly/assembly-src-licensee.xml

-42
This file was deleted.

src/main/java/module-info.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -10,6 +10,9 @@
1010
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
1111
*/
1212

13+
/**
14+
* Eclipse implementation of the JSONB-API.
15+
*/
1316
module org.eclipse.yasson {
1417
requires jakarta.json;
1518
requires jakarta.json.bind;

src/main/java/org/eclipse/yasson/YassonConfig.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2021 IBM and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2022 IBM and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -9,6 +9,7 @@
99
*
1010
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
1111
*/
12+
1213
package org.eclipse.yasson;
1314

1415
import java.util.Map;
@@ -50,7 +51,12 @@ public class YassonConfig extends JsonbConfig {
5051
* @see #withForceMapArraySerializerForNullKeys(boolean)
5152
*/
5253
public static final String FORCE_MAP_ARRAY_SERIALIZER_FOR_NULL_KEYS = "yasson.force-map-array-serializer-for-null-keys";
53-
54+
55+
/**
56+
* @see #withJsonbParametersRequired(boolean)
57+
*/
58+
public static final String JSONB_CREATOR_PARAMETERS_REQUIRED = "yasson.jsonb-creator-parameters-required";
59+
5460
/**
5561
* Property used to specify behaviour on deserialization when JSON document contains properties
5662
* which doesn't exist in the target class. Default value is 'false'.
@@ -120,4 +126,21 @@ public YassonConfig withForceMapArraySerializerForNullKeys(boolean value) {
120126
setProperty(FORCE_MAP_ARRAY_SERIALIZER_FOR_NULL_KEYS, value);
121127
return this;
122128
}
129+
130+
131+
/**
132+
* {@link jakarta.json.bind.annotation.JsonbCreator} parameters are required to be optional since the spec 3.0.0.
133+
* However, if it is needed to revert functionality as it used to be before, it is possible to use this switch
134+
* which globally turns the requirement of the {@link jakarta.json.bind.annotation.JsonbCreator} parameters
135+
* to be required.
136+
*
137+
* @param value whether to treat {@link jakarta.json.bind.annotation.JsonbCreator} parameters
138+
* as required. Default value is {@code false}.
139+
* @return This YassonConfig instance
140+
*/
141+
public YassonConfig withJsonbParametersRequired(boolean value) {
142+
setProperty(JSONB_CREATOR_PARAMETERS_REQUIRED, value);
143+
return this;
144+
}
145+
123146
}

0 commit comments

Comments
 (0)