Merge pull request #731 from KyleAure/prep-3.1.0
Prep next dev cycle org.eclipse.yasson:yasson:3.1.0-SNAPSHOT
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 7038eba..6718d4e 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -4,5 +4,18 @@
directory: /
schedule:
interval: daily
-
-# TODO - add maven dependabot if community agrees it's useful
\ No newline at end of file
+
+ - package-ecosystem: maven
+ directory: /
+ schedule:
+ interval: daily
+
+ - package-ecosystem: maven
+ directory: /yasson-jmh
+ schedule:
+ interval: weekly
+
+ - package-ecosystem: maven
+ directory: /yasson-tck
+ schedule:
+ interval: weekly
\ No newline at end of file
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 6374c2a..3a56d39 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -29,7 +29,7 @@
strategy:
matrix:
- java_version: [ 11, 17, 21 ]
+ java_version: [ 17, 21, 25 ]
include:
- locale: en_US
# Use a different locale when running against one of the java versions
@@ -54,6 +54,8 @@
run: mvn -B checkstyle:checkstyle
- name: Yasson install
run: mvn -U -C clean install -DskipTests
+ - name: Yasson jmh package
+ run: mvn -U -C -f yasson-jmh/pom.xml clean package
- name: Yasson tests
run: |
export LANG_TAG="${{ matrix.locale }}"
@@ -62,5 +64,5 @@
-Duser.language="${LANG_TAG%%_*}" \
-Duser.country="${LANG_TAG##*_}" \
verify
- - name: JSONB-API TCK
+ - name: Jakarta JSON-B TCK
run: cd yasson-tck && mvn -U -B test -DargLine="-Djava.locale.providers=COMPAT"
diff --git a/pom.xml b/pom.xml
index 372e6a8..067c3f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.yasson</groupId>
<artifactId>yasson</artifactId>
- <version>3.0.5-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Yasson</name>
@@ -35,9 +35,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.release>11</maven.compiler.release>
- <maven.compiler.target>11</maven.compiler.target>
- <maven.compiler.testRelease>${maven.compiler.release}</maven.compiler.testRelease>
+ <maven.compiler.release>17</maven.compiler.release>
<nexus.staging.repository>yasson-maven2-staging</nexus.staging.repository>
@@ -45,18 +43,20 @@
<hamcrest.version>2.2</hamcrest.version>
<!-- Jakarta API -->
+ <!-- TODO finalize versions to EE 12 -->
<jakarta.annotation-api.version>3.0.0</jakarta.annotation-api.version>
- <jakarta.el-api.version>6.0.0</jakarta.el-api.version>
+ <jakarta.el-api.version>6.1.0-M2</jakarta.el-api.version>
<jakarta.enterprise.cdi-api.version>4.1.0</jakarta.enterprise.cdi-api.version>
<jakarta.interceptor-api.version>2.2.0</jakarta.interceptor-api.version>
- <jakarta.json.bind.version>3.0.1</jakarta.json.bind.version>
+ <jakarta.json.bind.version>3.1.0-M1</jakarta.json.bind.version>
<jakarta.json.version>2.1.3</jakarta.json.version>
<!-- Jakarta Implementation -->
+ <!-- TODO update to EE 12 version-->
<jakarta.parson.version>1.1.9</jakarta.parson.version>
<!-- Test dependencies-->
- <junit-jupiter.version>5.14.4</junit-jupiter.version> <!-- TODO update to Junit 6 when running on Java 17+ -->
+ <junit-jupiter.version>6.1.1</junit-jupiter.version>
<weld-se-core.version>6.0.4.Final</weld-se-core.version>
<!--Plugins-->
@@ -70,7 +70,7 @@
<maven-enforcer-plugin.version>3.4.1</maven-enforcer-plugin.version>
<maven-jar-plugin.version>3.4.1</maven-jar-plugin.version>
<maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
- <maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
+ <maven-surefire-plugin.version>3.5.6</maven-surefire-plugin.version>
</properties>
<dependencyManagement>
@@ -312,50 +312,6 @@
</plugins>
</build>
</profile>
- <profile>
- <id>jdk16</id>
- <activation>
- <jdk>[16,)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default-testCompile</id>
- <configuration>
- <release>16</release>
- <testRelease>16</testRelease>
- <compileSourceRoots>
- <compileSourceRoot>${project.basedir}/src/test/java</compileSourceRoot>
- <compileSourceRoot>${project.basedir}/src/test/java16</compileSourceRoot>
- </compileSourceRoots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <includes>
- <include>**/RecordTest.java</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
<build>
@@ -366,39 +322,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
- <!-- defaults for compile and testCompile -->
- <executions>
- <execution>
- <id>default-compile</id>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <release>${maven.compiler.release}</release>
- <source>${maven.compiler.release}</source>
- <target>${maven.compiler.release}</target>
- </configuration>
- </execution>
- <execution>
- <id>default-testCompile</id>
- <configuration>
- <release>11</release>
- </configuration>
- </execution>
- <execution>
- <id>multi-release-compile-16</id>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <release>16</release>
- <compileSourceRoots>
- <compileSourceRoot>${project.basedir}/src/main/java16</compileSourceRoot>
- </compileSourceRoots>
- <multiReleaseOutput>true</multiReleaseOutput>
- </configuration>
- </execution>
- </executions>
<configuration>
<compilerArgs>
<arg>-Xlint:all</arg>
@@ -473,7 +396,7 @@
java.beans;resolution:="optional",
*
</Import-Package>
- <Require-Capability>osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=11))"</Require-Capability>
+ <Require-Capability>osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=17))"</Require-Capability>
</instructions>
</configuration>
</execution>
@@ -496,7 +419,6 @@
<excludes>
<exclude>**/JavaxNamingExcludedTest.java</exclude>
<exclude>**/AnnotationIntrospectorWithoutOptionalModulesTest.java</exclude>
- <exclude>**/*Record*</exclude>
</excludes>
<argLine>
<!--Remove when CDI is updated to support modules
@@ -542,7 +464,7 @@
<configuration>
<rules>
<requireJavaVersion>
- <version>[11,)</version>
+ <version>[17,)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[3.6.0,)</version>
diff --git a/src/main/java/org/eclipse/yasson/internal/AnnotationIntrospector.java b/src/main/java/org/eclipse/yasson/internal/AnnotationIntrospector.java
index 36c2943..2228c51 100644
--- a/src/main/java/org/eclipse/yasson/internal/AnnotationIntrospector.java
+++ b/src/main/java/org/eclipse/yasson/internal/AnnotationIntrospector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2023 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2026 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
@@ -186,7 +186,9 @@
}
}
if (jsonbCreator == null) {
- jsonbCreator = ClassMultiReleaseExtension.findCreator(clazz, declaredConstructors, this, propertyNamingStrategy);
+ if (clazz.isRecord() && declaredConstructors.length == 1) {
+ jsonbCreator = createJsonbCreator(declaredConstructors[0], null, clazz, propertyNamingStrategy);
+ }
if (jsonbCreator == null) {
jsonbCreator = constructorPropertiesIntrospector.getCreator(declaredConstructors);
}
diff --git a/src/main/java/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java b/src/main/java/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java
index 72653cf..f83ed39 100644
--- a/src/main/java/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java
+++ b/src/main/java/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, 2024 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2026 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
@@ -12,17 +12,6 @@
package org.eclipse.yasson.internal;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.Optional;
-
-import jakarta.json.bind.JsonbException;
-import jakarta.json.bind.config.PropertyNamingStrategy;
-
-import org.eclipse.yasson.internal.model.JsonbCreator;
-import org.eclipse.yasson.internal.model.Property;
-
/**
* Search for instance creator from other sources.
* Mainly intended to add extensibility for different java versions and new features.
@@ -33,27 +22,5 @@
throw new IllegalStateException("This class cannot be instantiated");
}
- static boolean shouldTransformToPropertyName(Method method) {
- return true;
- }
-
- static boolean isSpecialAccessorMethod(Method method, Map<String, Property> classProperties) {
- return false;
- }
-
- static JsonbCreator findCreator(Class<?> clazz,
- Constructor<?>[] declaredConstructors,
- AnnotationIntrospector introspector,
- PropertyNamingStrategy propertyNamingStrategy) {
- return null;
- }
-
- public static boolean isRecord(Class<?> clazz) {
- return false;
- }
-
- public static Optional<JsonbException> exceptionToThrow(Class<?> clazz) {
- return Optional.empty();
- }
-
+ // Currently is unused - but could be used in the future.
}
diff --git a/src/main/java/org/eclipse/yasson/internal/ClassParser.java b/src/main/java/org/eclipse/yasson/internal/ClassParser.java
index 4adce65..b63dc00 100644
--- a/src/main/java/org/eclipse/yasson/internal/ClassParser.java
+++ b/src/main/java/org/eclipse/yasson/internal/ClassParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2026 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
@@ -198,14 +198,14 @@
for (Method method : declaredMethods) {
String name = method.getName();
//isBridge method filters out methods inherited from interfaces
- boolean isAccessorMethod = ClassMultiReleaseExtension.isSpecialAccessorMethod(method, classProperties)
+ boolean isAccessorMethod = isSpecialAccessorMethod(method, classProperties)
|| isPropertyMethod(method);
if (!isAccessorMethod || method.isBridge() || isSpecialCaseMethod(clazz, method)) {
continue;
}
- final String propertyName = ClassMultiReleaseExtension.shouldTransformToPropertyName(method)
- ? toPropertyMethod(name)
- : name;
+ final String propertyName = method.getDeclaringClass().isRecord()
+ ? name
+ : toPropertyMethod(name);
registerMethod(propertyName, method, classElement, classProperties);
}
@@ -265,6 +265,13 @@
return isGetter(m) || isSetter(m);
}
+ private static boolean isSpecialAccessorMethod(Method method, Map<String, Property> classProperties) {
+ return method.getDeclaringClass().isRecord()
+ && method.getParameterCount() == 0
+ && !void.class.equals(method.getReturnType())
+ && classProperties.containsKey(method.getName());
+ }
+
private static void parseFields(JsonbAnnotatedElement<Class<?>> classElement, Map<String, Property> classProperties) {
Field[] declaredFields = AccessController.doPrivileged(
(PrivilegedAction<Field[]>) () -> classElement.getElement().getDeclaredFields());
diff --git a/src/main/java/org/eclipse/yasson/internal/deserializer/DefaultObjectInstanceCreator.java b/src/main/java/org/eclipse/yasson/internal/deserializer/DefaultObjectInstanceCreator.java
index 822da18..d4358ab 100644
--- a/src/main/java/org/eclipse/yasson/internal/deserializer/DefaultObjectInstanceCreator.java
+++ b/src/main/java/org/eclipse/yasson/internal/deserializer/DefaultObjectInstanceCreator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2026 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
@@ -17,7 +17,6 @@
import jakarta.json.bind.JsonbException;
import jakarta.json.stream.JsonParser;
-import org.eclipse.yasson.internal.ClassMultiReleaseExtension;
import org.eclipse.yasson.internal.DeserializationContextImpl;
import org.eclipse.yasson.internal.ReflectionUtils;
import org.eclipse.yasson.internal.properties.MessageKeys;
@@ -40,8 +39,11 @@
if (clazz.isInterface()) {
this.exception = new JsonbException(Messages.getMessage(MessageKeys.INFER_TYPE_FOR_UNMARSHALL, clazz.getName()));
} else if (defaultConstructor == null) {
- this.exception = ClassMultiReleaseExtension.exceptionToThrow(clazz)
- .orElse(new JsonbException(Messages.getMessage(MessageKeys.NO_DEFAULT_CONSTRUCTOR, clazz)));
+ if (clazz.isRecord() && clazz.getDeclaredConstructors().length > 1) {
+ this.exception = new JsonbException(Messages.getMessage(MessageKeys.RECORD_MULTIPLE_CONSTRUCTORS, clazz));
+ } else {
+ this.exception = new JsonbException(Messages.getMessage(MessageKeys.NO_DEFAULT_CONSTRUCTOR, clazz));
+ }
} else {
this.exception = null;
}
diff --git a/src/main/java/org/eclipse/yasson/internal/model/ClassModel.java b/src/main/java/org/eclipse/yasson/internal/model/ClassModel.java
index 8cdbdde..af7765b 100644
--- a/src/main/java/org/eclipse/yasson/internal/model/ClassModel.java
+++ b/src/main/java/org/eclipse/yasson/internal/model/ClassModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2026 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
@@ -23,7 +23,6 @@
import jakarta.json.bind.config.PropertyNamingStrategy;
-import org.eclipse.yasson.internal.ClassMultiReleaseExtension;
import org.eclipse.yasson.internal.ReflectionUtils;
import org.eclipse.yasson.internal.model.customization.ClassCustomization;
import org.eclipse.yasson.internal.model.customization.StrategiesProvider;
@@ -191,7 +190,7 @@
// Example: Deserialization into Map won't use this constructor, and therefore never needs to call this method.
// Note: Null is a valid result and needs to be cached.
if (!isInitialized.get()) {
- if (ClassMultiReleaseExtension.isRecord(clazz)) {
+ if (clazz.isRecord()) {
//No default constructor should be used in case of records
defaultConstructor = null;
} else {
diff --git a/src/main/java16/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java b/src/main/java16/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java
deleted file mode 100644
index 2f3d2dc..0000000
--- a/src/main/java16/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2021, 2024 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
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
- */
-
-package org.eclipse.yasson.internal;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.Optional;
-
-import jakarta.json.bind.JsonbException;
-import jakarta.json.bind.config.PropertyNamingStrategy;
-
-import org.eclipse.yasson.internal.model.JsonbCreator;
-import org.eclipse.yasson.internal.model.Property;
-import org.eclipse.yasson.internal.properties.MessageKeys;
-import org.eclipse.yasson.internal.properties.Messages;
-
-/**
- * Search for instance creator from other sources.
- * Mainly intended to add extensibility for different java versions and new features.
- */
-public class ClassMultiReleaseExtension {
-
- private ClassMultiReleaseExtension() {
- throw new IllegalStateException("This class cannot be instantiated");
- }
-
- static boolean shouldTransformToPropertyName(Method method) {
- return !method.getDeclaringClass().isRecord();
- }
-
- static boolean isSpecialAccessorMethod(Method method, Map<String, Property> classProperties) {
- return isRecord(method.getDeclaringClass())
- && method.getParameterCount() == 0
- && !void.class.equals(method.getReturnType())
- && classProperties.containsKey(method.getName());
- }
-
- static JsonbCreator findCreator(Class<?> clazz,
- Constructor<?>[] declaredConstructors,
- AnnotationIntrospector introspector,
- PropertyNamingStrategy propertyNamingStrategy) {
- if (clazz.isRecord()) {
- if (declaredConstructors.length == 1) {
- return introspector.createJsonbCreator(declaredConstructors[0], null, clazz, propertyNamingStrategy);
- }
- }
- return null;
- }
-
- public static boolean isRecord(Class<?> clazz) {
- return clazz.isRecord();
- }
-
- public static Optional<JsonbException> exceptionToThrow(Class<?> clazz) {
- if (clazz.isRecord()) {
- if (clazz.getDeclaredConstructors().length > 1) {
- return Optional.of(new JsonbException(Messages.getMessage(MessageKeys.RECORD_MULTIPLE_CONSTRUCTORS, clazz)));
- }
- }
- return Optional.empty();
- }
-
-}
diff --git a/yasson-jmh/pom.xml b/yasson-jmh/pom.xml
index ccfcb3d..d1dd60b 100644
--- a/yasson-jmh/pom.xml
+++ b/yasson-jmh/pom.xml
@@ -13,14 +13,17 @@
<groupId>org.eclipse.yasson</groupId>
<artifactId>yasson-jmh</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<description>This is a performance testing project for Yasson. It leverages a JMH technology.
See https://openjdk.java.net/projects/code-tools/jmh/.
</description>
<properties>
- <jmh.version>1.21</jmh.version>
- <yasson.version>3.0.5-SNAPSHOT</yasson.version>
+ <maven.compiler.release>17</maven.compiler.release>
+
+ <jmh.version>1.37</jmh.version>
+ <yasson.version>${project.version}</yasson.version>
+ <maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
</properties>
@@ -60,16 +63,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>11</source>
- <target>11</target>
- </configuration>
</plugin>
<!--run `java -jar yasson-jmh.jar -h` for help -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
- <version>3.2.1</version>
+ <version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
diff --git a/yasson-tck/pom.xml b/yasson-tck/pom.xml
index c0af096..035db18 100644
--- a/yasson-tck/pom.xml
+++ b/yasson-tck/pom.xml
@@ -14,29 +14,30 @@
<groupId>org.eclipse.yasson</groupId>
<artifactId>yasson-tck</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<properties>
- <maven.compiler.source>11</maven.compiler.source>
- <maven.compiler.target>11</maven.compiler.target>
+ <maven.compiler.release>17</maven.compiler.release>
<!-- API Versions -->
+ <!-- TODO update to EE 12 final versions -->
<jakarta.json.version>2.1.3</jakarta.json.version> <!-- EE10 -->
- <jakarta.json.bind.version>3.0.1</jakarta.json.bind.version> <!-- EE10 -->
+ <jakarta.json.bind.version>3.1.0-M1</jakarta.json.bind.version>
<!-- IMPL Versions -->
- <jsonb.tck.version>3.0.0</jsonb.tck.version> <!-- EE10 -->
- <yasson.version>3.0.5-SNAPSHOT</yasson.version> <!-- EE10 -->
+ <!-- TODO update to EE 12 final versions -->
+ <jsonb.tck.version>3.1.0-M1</jsonb.tck.version>
+ <yasson.version>${project.version}</yasson.version>
<!-- Test Versions -->
- <junit-jupiter.version>5.14.4</junit-jupiter.version> <!-- TODO update to Junit 6 when running on Java 17+ -->
+ <junit-jupiter.version>6.1.1</junit-jupiter.version>
<weld-se-core.version>6.0.4.Final</weld-se-core.version>
- <arquillian-junit5-container.version>1.8.0.Final</arquillian-junit5-container.version>
+ <arquillian-junit5-container.version>1.10.2.Final</arquillian-junit5-container.version>
<!-- Plugin Versions -->
- <maven-dependency-plugin.version>3.6.1</maven-dependency-plugin.version>
- <maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
- <maven-surefire-report-plugin.version>3.2.5</maven-surefire-report-plugin.version>
+ <maven-dependency-plugin.version>3.11.0</maven-dependency-plugin.version>
+ <maven-surefire-plugin.version>3.5.6</maven-surefire-plugin.version>
+ <maven-surefire-report-plugin.version>3.5.6</maven-surefire-report-plugin.version>
</properties>
<dependencies>