Skip to content

Commit

Permalink
Yasson deserialization and serialization rework (#537)
Browse files Browse the repository at this point in the history
Yasson deserialization and serialization reworked

Signed-off-by: David Kral <david.k.kral@oracle.com>
  • Loading branch information
Verdent authored Feb 16, 2022
1 parent e7ff427 commit b74033d
Show file tree
Hide file tree
Showing 343 changed files with 10,471 additions and 11,362 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ jobs:
java-version: ${{ matrix.java_version }}
- name: Yasson tests
run: mvn -U -C -Dmaven.javadoc.skip=true -Pstaging verify
- name: JSONB-API TCK
run: cd yasson-tck && mvn -U -B test
# TMP removal
# - name: JSONB-API TCK
# run: cd yasson-tck && mvn -U -B test
10 changes: 6 additions & 4 deletions etc/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -119,7 +119,7 @@
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="ImportOrder">
<property name="groups" value="java, jakarta, javax, org.eclipse.yasson"/>
<property name="groups" value="java, javax, jakarta, org.eclipse.yasson"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
<property name="option" value="bottom"/>
Expand Down Expand Up @@ -223,7 +223,9 @@
<!-- See http://checkstyle.sf.net/config_design.html -->
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<module name="VisibilityModifier">
<property name="packageAllowed" value="true"/>
</module>
<module name="ThrowsCount">
<property name="max" value="3"/>
</module>
Expand All @@ -235,7 +237,7 @@
<module name="UpperEll"/>

<module name="OneStatementPerLine"/>
<module name="FallThrough"/>
<!-- <module name="FallThrough"/>-->

<module name="NoFinalizer"/>
</module>
Expand Down
128 changes: 64 additions & 64 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@
-->

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

<parent>
<groupId>org.eclipse.ee4j</groupId>
<artifactId>project</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>2.0.5-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>org.eclipse.yasson</name>
<name>Yasson</name>

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

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakarta.json.version>2.0.0</jakarta.json.version>
<jakarta.json.bind.version>2.0.0</jakarta.json.bind.version>
<jakarta.enterprise.cdi-api.version>3.0.0</jakarta.enterprise.cdi-api.version>
<jakarta.json.version>2.0.1</jakarta.json.version>
<jakarta.json.bind.version>3.0.0-RC1</jakarta.json.bind.version>
<jakarta.enterprise.cdi-api.version>4.0.0-RC2</jakarta.enterprise.cdi-api.version>
<netbeans.hint.jdkPlatform>JDK_9</netbeans.hint.jdkPlatform>
</properties>

Expand Down Expand Up @@ -69,25 +69,13 @@
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>4.0.0.Beta2</version>
<version>5.0.0.Beta1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.interceptor</groupId>
<artifactId>jakarta.interceptor-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -102,6 +90,11 @@
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
</dependencies>

<organization>
Expand Down Expand Up @@ -284,15 +277,49 @@
</plugins>
</build>
</profile>

<!-- remove when not needed -->
<profile>
<id>staging</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<repositories>
<repository>
<id>sonatype-nexus-staging</id>
<name>Sonatype Nexus Staging</name>
<url>${sonatypeOssDistMgmtStagingUrl}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>sonatype-nexus-staging</id>
<name>Sonatype Nexus Staging</name>
<url>${sonatypeOssDistMgmtStagingUrl}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<!-- <testResources>-->
<!-- <testResource>-->
<!-- <directory>src/test/resources</directory>-->
<!-- <filtering>true</filtering>-->
<!-- </testResource>-->
<!-- </testResources>-->
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -327,28 +354,19 @@
<executions>
<execution>
<id>default-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<!-- compile everything to ensure module-info contains right entries -->
<!-- required when JAVA_HOME is JDK 8 or below -->
<release>9</release>
<compilerArgs>
<!--Remove when CDI is updated to support modules-->
<arg>--add-reads</arg>
<arg>org.eclipse.yasson=ALL-UNNAMED</arg>
</compilerArgs>
<release>11</release>
<source>11</source>
<target>11</target>
</configuration>
</execution>
<execution>
<id>multi-release-compile-9</id>
<goals>
<goal>compile</goal>
</goals>
<id>default-testCompile</id>
<configuration>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
<release>11</release>
</configuration>
</execution>
<execution>
Expand All @@ -364,29 +382,11 @@
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
<execution>
<id>base-compile</id>
<goals>
<goal>compile</goal>
</goals>
<!-- recompile everything for 1.8 except the module-info.java -->
<configuration>
<release>8</release>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<configuration>
<release>11</release>
</configuration>
</execution>
</executions>
<!-- defaults for compile and testCompile -->
<configuration>
<compilerArgs>
<compilerArgument>-proc:none</compilerArgument>
<arg>-Xlint:all</arg>
</compilerArgs>
</configuration>
Expand Down Expand Up @@ -486,7 +486,7 @@
java.beans;resolution:="optional",
*
</Import-Package>
<Require-Capability>osgi.ee;filter:="(&amp;(osgi.ee=JavaSE)(version=1.8))"</Require-Capability>
<Require-Capability>osgi.ee;filter:="(&amp;(osgi.ee=JavaSE)(version=11))"</Require-Capability>
</instructions>
</configuration>
</execution>
Expand Down Expand Up @@ -555,7 +555,7 @@
<configuration>
<rules>
<requireJavaVersion>
<version>[9,)</version>
<version>[11,)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[3.3.9,)</version>
Expand Down
42 changes: 0 additions & 42 deletions src/main/assembly/assembly-src-licensee.xml

This file was deleted.

5 changes: 4 additions & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -10,6 +10,9 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

/**
* Eclipse implementation of the JSONB-API.
*/
module org.eclipse.yasson {
requires jakarta.json;
requires jakarta.json.bind;
Expand Down
27 changes: 25 additions & 2 deletions src/main/java/org/eclipse/yasson/YassonConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021 IBM and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022 IBM and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -9,6 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

package org.eclipse.yasson;

import java.util.Map;
Expand Down Expand Up @@ -50,7 +51,12 @@ public class YassonConfig extends JsonbConfig {
* @see #withForceMapArraySerializerForNullKeys(boolean)
*/
public static final String FORCE_MAP_ARRAY_SERIALIZER_FOR_NULL_KEYS = "yasson.force-map-array-serializer-for-null-keys";


/**
* @see #withJsonbParametersRequired(boolean)
*/
public static final String JSONB_CREATOR_PARAMETERS_REQUIRED = "yasson.jsonb-creator-parameters-required";

/**
* Property used to specify behaviour on deserialization when JSON document contains properties
* which doesn't exist in the target class. Default value is 'false'.
Expand Down Expand Up @@ -120,4 +126,21 @@ public YassonConfig withForceMapArraySerializerForNullKeys(boolean value) {
setProperty(FORCE_MAP_ARRAY_SERIALIZER_FOR_NULL_KEYS, value);
return this;
}


/**
* {@link jakarta.json.bind.annotation.JsonbCreator} parameters are required to be optional since the spec 3.0.0.
* However, if it is needed to revert functionality as it used to be before, it is possible to use this switch
* which globally turns the requirement of the {@link jakarta.json.bind.annotation.JsonbCreator} parameters
* to be required.
*
* @param value whether to treat {@link jakarta.json.bind.annotation.JsonbCreator} parameters
* as required. Default value is {@code false}.
* @return This YassonConfig instance
*/
public YassonConfig withJsonbParametersRequired(boolean value) {
setProperty(JSONB_CREATOR_PARAMETERS_REQUIRED, value);
return this;
}

}
Loading

0 comments on commit b74033d

Please sign in to comment.