diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index cf59b9fc0..9569655a0 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -21,32 +21,25 @@ jobs:
strategy:
matrix:
- java_version: [ 11, 17 ]
+ java_version: [ 17, 21 ]
steps:
- name: Checkout for build
- uses: actions/checkout@v2.3.4
+ uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up compile JDK
uses: actions/setup-java@v4
- with: #Compile java needs to be the highest to ensure proper compilation of the multi-release jar
+ with:
distribution: 'temurin'
- java-version: 17
+ java-version: ${{ matrix.java_version }}
cache: 'maven'
- name: Copyright
run: bash etc/copyright.sh
- name: Checkstyle
run: mvn -B checkstyle:checkstyle
- name: Yasson install
-# run: mvn -U -C -Pstaging clean install -DskipTests
run: mvn -U -C clean install -DskipTests
- - name: Set up JDK for tests
- uses: actions/setup-java@v4
- with:
- distribution: 'temurin'
- java-version: ${{ matrix.java_version }}
- cache: 'maven'
- name: Yasson tests
run: mvn -U -B -C -Dmaven.javadoc.skip=true -Pstaging verify
- name: JSONB-API TCK
diff --git a/etc/checkstyle.xml b/etc/checkstyle.xml
index 3479136ab..69e6f2fea 100644
--- a/etc/checkstyle.xml
+++ b/etc/checkstyle.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/pom.xml b/pom.xml
index 0abc66b76..b17b70c8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,7 +1,7 @@
+ 2.2
+ 3.0.0
+ 6.0.0
+ 4.1.0
+ 2.2.0
+ 3.0.1
+ 2.1.3
+ 1.1.6
+ 5.10.2
+ 6.0.0.Beta1
+
+
+ 3.6.0
+ 3.2.0
+ 4.8.5.0
+ 2.4
+ 5.1.9
+ 3.3.1
+ 3.13.0
+ 3.4.1
+ 3.4.1
+ 3.6.3
+ 3.2.5
@@ -51,17 +73,17 @@
jakarta.el
jakarta.el-api
- 5.0.0
+ ${jakarta.el-api.version}
jakarta.interceptor
jakarta.interceptor-api
- 2.1.0
+ ${jakarta.interceptor-api.version}
jakarta.annotation
jakarta.annotation-api
- 2.1.0
+ ${jakarta.annotation-api.version}
@@ -81,7 +103,7 @@
org.eclipse.parsson
parsson
- 1.1.0
+ ${jakarta.parson.version}
@@ -93,25 +115,25 @@
org.jboss.weld.se
weld-se-core
- 5.0.0.Final
+ ${weld-se-core.version}
test
org.junit.jupiter
junit-jupiter-api
- 5.8.2
+ ${junit-jupiter.version}
test
org.junit.jupiter
junit-jupiter-engine
- 5.8.2
+ ${junit-jupiter.version}
test
org.hamcrest
hamcrest
- 2.2
+ ${hamcrest.version}
test
@@ -223,29 +245,23 @@
- copyright
+ spotbugs
- org.glassfish.copyright
- glassfish-copyright-maven-plugin
+ com.github.spotbugs
+ spotbugs-maven-plugin
+ ${spotbugs-maven-plugin.version}
+
+ Low
+
-
- print-copyright
-
- copyright
-
- validate
-
-
-
- check-copyright
+ analyze-compile
+ compile
check
- validate
@@ -253,159 +269,48 @@
- jdk16
-
- [16,)
-
+ copyright
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.1
+ org.glassfish.copyright
+ glassfish-copyright-maven-plugin
+
- default-testCompile
-
- 16
-
- ${project.basedir}/src/test/java
- ${project.basedir}/src/test/java16
-
-
+ print-copyright
+
+ copyright
+
+ validate
-
-
-
- org.apache.maven.plugins
- maven-failsafe-plugin
-
+
+ check-copyright
- integration-test
- verify
+ check
+ validate
-
-
- **/RecordTest.java
-
-
-
-
-
- staging
-
- false
-
-
-
- sonatype-nexus-staging
- Sonatype Nexus Staging
- ${sonatypeOssDistMgmtStagingUrl}
-
- true
-
-
- true
-
-
-
-
-
- sonatype-nexus-staging
- Sonatype Nexus Staging
- ${sonatypeOssDistMgmtStagingUrl}
-
- true
-
-
- true
-
-
-
-
-
-
-
-
-
-
${project.artifactId}
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.4
-
- Max
- Low
- true
-
-
-
- analyze-compile
- compile
-
- check
-
-
-
-
-
- org.apache.maven.plugins
- maven-failsafe-plugin
- 3.0.0-M3
-
org.apache.maven.plugins
maven-compiler-plugin
- 3.8.1
-
-
- default-compile
-
- compile
-
-
- 11
-
- 11
-
-
-
- default-testCompile
-
- 11
-
-
-
- multi-release-compile-16
-
- compile
-
-
- 16
-
- ${project.basedir}/src/main/java16
-
- true
-
-
-
+ ${maven-compiler-plugin.version}
- -proc:none
-Xlint:all
@@ -413,13 +318,10 @@
org.apache.maven.plugins
maven-jar-plugin
- 3.0.2
+ ${maven-jar-plugin.version}
${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
- true
-
@@ -427,7 +329,7 @@
org.codehaus.mojo
buildnumber-maven-plugin
- 1.4
+ ${buildnumber-maven-plugin.version}
{0,date,MM/dd/yyyy hh:mm aa}
@@ -446,42 +348,15 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.2.0
+ ${maven-javadoc-plugin.version}
- Yasson
- ${basedir}/src/main/java/org/eclipse/yasson
-
- --add-modules
- jakarta.json.bind,jakarta.json
-
-
+ ]]>
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 3.0.1
-
-
- attach-sources
-
- jar-no-fork
-
-
-
org.apache.felix
maven-bundle-plugin
- 5.1.1
+ ${maven-bundle-plugin.version}
osgi-bundle
@@ -514,7 +389,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 3.0.0-M3
+ ${maven-surefire-plugin.version}
default-test
@@ -549,7 +424,7 @@
- --limit-modules java.base,java.logging,java.sql,jakarta.json.bind,jakarta.json,java.management,jdk.localedata
+ --limit-modules java.base,java.logging,java.sql,jakarta.json.bind,jakarta.json,java.management,jdk.localedata,org.eclipse.parsson,org.eclipse.yasson
**/JavaxNamingExcludedTest.class
@@ -562,7 +437,7 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 3.0.0-M2
+ ${maven-enforcer-plugin.version}
enforce-versions
@@ -574,10 +449,10 @@
- [11,)
+ [17,)
- [3.3.9,)
+ [3.6.0,)
@@ -586,7 +461,7 @@
org.codehaus.mojo
build-helper-maven-plugin
- 3.0.0
+ ${build-helper-maven-plugin.version}
add-resource
@@ -612,33 +487,19 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.1.0
+ ${maven-checkstyle-plugin.version}
etc/checkstyle.xml
etc/checkstyle-suppressions.xml
- UTF-8
true
true
false
-
-
- com.puppycrawl.tools
- checkstyle
- 8.29
-
-
- com.sun
- tools
-
-
-
-
org.glassfish.copyright
glassfish-copyright-maven-plugin
- 2.3
+ ${glassfish-copyright-maven-plugin.version}
etc/copyright.txt
etc/copyright-exclude.txt
@@ -691,14 +552,4 @@
-
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.4
-
-
-
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index f6c0ace2b..12366c5db 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -11,7 +11,7 @@
*/
/**
- * Eclipse implementation of the JSONB-API.
+ * Yasson, the implementation of the Jakarta JSON Binding.
*/
module org.eclipse.yasson {
requires jakarta.json;
diff --git a/src/main/java/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java b/src/main/java/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java
index bcf0b14c6..2f3d2dc44 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, 2023 Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -22,6 +22,8 @@
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.
@@ -34,25 +36,38 @@ private ClassMultiReleaseExtension() {
}
static boolean shouldTransformToPropertyName(Method method) {
- return true;
+ return !method.getDeclaringClass().isRecord();
}
static boolean isSpecialAccessorMethod(Method method, Map classProperties) {
- return false;
+ 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 false;
+ return clazz.isRecord();
}
public static Optional 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/src/main/java/org/eclipse/yasson/internal/JsonBinding.java b/src/main/java/org/eclipse/yasson/internal/JsonBinding.java
index cd4764a3a..fb185deb0 100644
--- a/src/main/java/org/eclipse/yasson/internal/JsonBinding.java
+++ b/src/main/java/org/eclipse/yasson/internal/JsonBinding.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -91,7 +91,7 @@ public T fromJson(Reader reader, Type type) throws JsonbException {
public T fromJson(InputStream stream, Class clazz) throws JsonbException {
DeserializationContextImpl unmarshaller = new DeserializationContextImpl(jsonbContext);
try (JsonParser parser = inputStreamParser(stream)) {
- return deserialize(clazz, inputStreamParser(stream), unmarshaller);
+ return deserialize(clazz, parser, unmarshaller);
}
}
@@ -99,7 +99,7 @@ public T fromJson(InputStream stream, Class clazz) throws JsonbException
public T fromJson(InputStream stream, Type type) throws JsonbException {
DeserializationContextImpl unmarshaller = new DeserializationContextImpl(jsonbContext);
try (JsonParser parser = inputStreamParser(stream)) {
- return deserialize(type, inputStreamParser(stream), unmarshaller);
+ return deserialize(type, parser, unmarshaller);
}
}
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 2b062bf06..000000000
--- a/src/main/java16/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2021, 2023 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 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 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/src/test/java/org/eclipse/yasson/defaultmapping/SecurityManagerTest.java b/src/test/java/org/eclipse/yasson/defaultmapping/SecurityManagerTest.java
deleted file mode 100644
index 029e55402..000000000
--- a/src/test/java/org/eclipse/yasson/defaultmapping/SecurityManagerTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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
- * 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.defaultmapping;
-
-import org.junit.jupiter.api.*;
-
-import org.eclipse.yasson.serializers.model.Crate;
-
-import jakarta.json.bind.Jsonb;
-import jakarta.json.bind.JsonbBuilder;
-import jakarta.json.bind.JsonbConfig;
-import jakarta.json.bind.annotation.JsonbProperty;
-import jakarta.json.bind.config.PropertyVisibilityStrategy;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.math.BigDecimal;
-
-/**
- * Created by Roman Grigoriadi (roman.grigoriadi@oracle.com) on 28/04/2017.
- */
-
-public class SecurityManagerTest {
-
- static final String classesDir = SecurityManagerTest.class.getProtectionDomain().getCodeSource().getLocation().getFile();
-
- @BeforeAll
- public static void setUp() {
- System.setProperty("java.security.policy", classesDir + "test.policy");
- System.setProperty("java.security.debug", "failure");
- System.setSecurityManager(new SecurityManager());
- }
-
- @AfterAll
- public static void tearDown() {
- System.setSecurityManager(null);
- }
-
- @Test
- public void testWithSecurityManager() {
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyVisibilityStrategy(new PropertyVisibilityStrategy() {
- @Override
- public boolean isVisible(Field field) {
- return Modifier.isPublic(field.getModifiers()) || field.getName().equals("privateProperty");
- }
-
- @Override
- public boolean isVisible(Method method) {
- return Modifier.isPublic(method.getModifiers());
- }
- }));
-
- Pojo pojo = new Pojo();
- pojo.setStrProperty("string propery");
- Crate crate = new Crate();
- crate.crateBigDec = BigDecimal.TEN;
- crate.crateStr = "crate string";
- pojo.setCrate(crate);
-
- String result = jsonb.toJson(pojo);
- }
-
-
-
- public static class Pojo {
-
- //causes .setAccessible(true) in combination with custom visibility strategy
- private String privateProperty;
-
- @JsonbProperty("property1")
- private String strProperty;
-
- @JsonbProperty("property2")
- private Crate crate;
-
- public String getStrProperty() {
- return strProperty;
- }
-
- public void setStrProperty(String strProperty) {
- this.strProperty = strProperty;
- }
-
- public Crate getCrate() {
- return crate;
- }
-
- public void setCrate(Crate crate) {
- this.crate = crate;
- }
- }
-}
diff --git a/src/test/java/org/eclipse/yasson/internal/cdi/JndiBeanManager.java b/src/test/java/org/eclipse/yasson/internal/cdi/JndiBeanManager.java
index 86986244a..9087ef962 100644
--- a/src/test/java/org/eclipse/yasson/internal/cdi/JndiBeanManager.java
+++ b/src/test/java/org/eclipse/yasson/internal/cdi/JndiBeanManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -39,6 +39,7 @@
import jakarta.enterprise.inject.spi.ProducerFactory;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -163,6 +164,11 @@ public Context getContext(Class extends Annotation> scopeType) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
+ public Collection getContexts(Class extends Annotation> aClass) {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
@Override
public ELResolver getELResolver() {
throw new UnsupportedOperationException("Not implemented");
@@ -242,4 +248,14 @@ public Event