Skip to content

Commit 14e68b6

Browse files
authored
JDK 11 compile target reverted (#645)
JDK 11 compile target reverted Signed-off-by: David Kral <[email protected]>
1 parent 5fcac65 commit 14e68b6

File tree

5 files changed

+163
-25
lines changed

5 files changed

+163
-25
lines changed

Diff for: .github/workflows/maven.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
strategy:
2323
matrix:
24-
java_version: [ 17, 21 ]
24+
java_version: [ 11, 17, 21 ]
2525

2626
steps:
2727
- name: Checkout for build
@@ -30,9 +30,9 @@ jobs:
3030
fetch-depth: 0
3131
- name: Set up compile JDK
3232
uses: actions/setup-java@v4
33-
with:
33+
with: #Compile java needs to be the highest to ensure proper compilation of the multi-release jar
3434
distribution: 'temurin'
35-
java-version: ${{ matrix.java_version }}
35+
java-version: 17
3636
cache: 'maven'
3737
- name: Copyright
3838
run: bash etc/copyright.sh

Diff for: pom.xml

+81-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
<properties>
3636
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<maven.compiler.release>17</maven.compiler.release>
37+
<maven.compiler.release>11</maven.compiler.release>
3838
<maven.compiler.testRelease>${maven.compiler.release}</maven.compiler.testRelease>
3939

4040
<!--Dependencies-->
@@ -298,6 +298,50 @@
298298
</plugins>
299299
</build>
300300
</profile>
301+
<profile>
302+
<id>jdk16</id>
303+
<activation>
304+
<jdk>[16,)</jdk>
305+
</activation>
306+
<build>
307+
<plugins>
308+
<plugin>
309+
<groupId>org.apache.maven.plugins</groupId>
310+
<artifactId>maven-compiler-plugin</artifactId>
311+
<executions>
312+
<execution>
313+
<id>default-testCompile</id>
314+
<configuration>
315+
<release>16</release>
316+
<testRelease>16</testRelease>
317+
<compileSourceRoots>
318+
<compileSourceRoot>${project.basedir}/src/test/java</compileSourceRoot>
319+
<compileSourceRoot>${project.basedir}/src/test/java16</compileSourceRoot>
320+
</compileSourceRoots>
321+
</configuration>
322+
</execution>
323+
</executions>
324+
</plugin>
325+
<plugin>
326+
<groupId>org.apache.maven.plugins</groupId>
327+
<artifactId>maven-failsafe-plugin</artifactId>
328+
<executions>
329+
<execution>
330+
<goals>
331+
<goal>integration-test</goal>
332+
<goal>verify</goal>
333+
</goals>
334+
</execution>
335+
</executions>
336+
<configuration>
337+
<includes>
338+
<include>**/RecordTest.java</include>
339+
</includes>
340+
</configuration>
341+
</plugin>
342+
</plugins>
343+
</build>
344+
</profile>
301345
</profiles>
302346

303347
<build>
@@ -309,6 +353,38 @@
309353
<artifactId>maven-compiler-plugin</artifactId>
310354
<version>${maven-compiler-plugin.version}</version>
311355
<!-- defaults for compile and testCompile -->
356+
<executions>
357+
<execution>
358+
<id>default-compile</id>
359+
<goals>
360+
<goal>compile</goal>
361+
</goals>
362+
<configuration>
363+
<release>11</release>
364+
<source>11</source>
365+
<target>11</target>
366+
</configuration>
367+
</execution>
368+
<execution>
369+
<id>default-testCompile</id>
370+
<configuration>
371+
<release>11</release>
372+
</configuration>
373+
</execution>
374+
<execution>
375+
<id>multi-release-compile-16</id>
376+
<goals>
377+
<goal>compile</goal>
378+
</goals>
379+
<configuration>
380+
<release>16</release>
381+
<compileSourceRoots>
382+
<compileSourceRoot>${project.basedir}/src/main/java16</compileSourceRoot>
383+
</compileSourceRoots>
384+
<multiReleaseOutput>true</multiReleaseOutput>
385+
</configuration>
386+
</execution>
387+
</executions>
312388
<configuration>
313389
<compilerArgs>
314390
<arg>-Xlint:all</arg>
@@ -322,6 +398,9 @@
322398
<configuration>
323399
<archive>
324400
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
401+
<manifestEntries>
402+
<Multi-Release>true</Multi-Release>
403+
</manifestEntries>
325404
</archive>
326405
</configuration>
327406
</plugin>
@@ -449,7 +528,7 @@
449528
<configuration>
450529
<rules>
451530
<requireJavaVersion>
452-
<version>[17,)</version>
531+
<version>[11,)</version>
453532
</requireJavaVersion>
454533
<requireMavenVersion>
455534
<version>[3.6.0,)</version>

Diff for: src/main/java/org/eclipse/yasson/internal/ClassMultiReleaseExtension.java

+3-18
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
import org.eclipse.yasson.internal.model.JsonbCreator;
2424
import org.eclipse.yasson.internal.model.Property;
25-
import org.eclipse.yasson.internal.properties.MessageKeys;
26-
import org.eclipse.yasson.internal.properties.Messages;
2725

2826
/**
2927
* Search for instance creator from other sources.
@@ -36,38 +34,25 @@ private ClassMultiReleaseExtension() {
3634
}
3735

3836
static boolean shouldTransformToPropertyName(Method method) {
39-
return !method.getDeclaringClass().isRecord();
37+
return true;
4038
}
4139

4240
static boolean isSpecialAccessorMethod(Method method, Map<String, Property> classProperties) {
43-
return isRecord(method.getDeclaringClass())
44-
&& method.getParameterCount() == 0
45-
&& !void.class.equals(method.getReturnType())
46-
&& classProperties.containsKey(method.getName());
41+
return false;
4742
}
4843

4944
static JsonbCreator findCreator(Class<?> clazz,
5045
Constructor<?>[] declaredConstructors,
5146
AnnotationIntrospector introspector,
5247
PropertyNamingStrategy propertyNamingStrategy) {
53-
if (clazz.isRecord()) {
54-
if (declaredConstructors.length == 1) {
55-
return introspector.createJsonbCreator(declaredConstructors[0], null, clazz, propertyNamingStrategy);
56-
}
57-
}
5848
return null;
5949
}
6050

6151
public static boolean isRecord(Class<?> clazz) {
62-
return clazz.isRecord();
52+
return false;
6353
}
6454

6555
public static Optional<JsonbException> exceptionToThrow(Class<?> clazz) {
66-
if (clazz.isRecord()) {
67-
if (clazz.getDeclaredConstructors().length > 1) {
68-
return Optional.of(new JsonbException(Messages.getMessage(MessageKeys.RECORD_MULTIPLE_CONSTRUCTORS, clazz)));
69-
}
70-
}
7156
return Optional.empty();
7257
}
7358

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2021, 2024 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0,
7+
* or the Eclipse Distribution License v. 1.0 which is available at
8+
* http://www.eclipse.org/org/documents/edl-v10.php.
9+
*
10+
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11+
*/
12+
13+
package org.eclipse.yasson.internal;
14+
15+
import java.lang.reflect.Constructor;
16+
import java.lang.reflect.Method;
17+
import java.util.Map;
18+
import java.util.Optional;
19+
20+
import jakarta.json.bind.JsonbException;
21+
import jakarta.json.bind.config.PropertyNamingStrategy;
22+
23+
import org.eclipse.yasson.internal.model.JsonbCreator;
24+
import org.eclipse.yasson.internal.model.Property;
25+
import org.eclipse.yasson.internal.properties.MessageKeys;
26+
import org.eclipse.yasson.internal.properties.Messages;
27+
28+
/**
29+
* Search for instance creator from other sources.
30+
* Mainly intended to add extensibility for different java versions and new features.
31+
*/
32+
public class ClassMultiReleaseExtension {
33+
34+
private ClassMultiReleaseExtension() {
35+
throw new IllegalStateException("This class cannot be instantiated");
36+
}
37+
38+
static boolean shouldTransformToPropertyName(Method method) {
39+
return !method.getDeclaringClass().isRecord();
40+
}
41+
42+
static boolean isSpecialAccessorMethod(Method method, Map<String, Property> classProperties) {
43+
return isRecord(method.getDeclaringClass())
44+
&& method.getParameterCount() == 0
45+
&& !void.class.equals(method.getReturnType())
46+
&& classProperties.containsKey(method.getName());
47+
}
48+
49+
static JsonbCreator findCreator(Class<?> clazz,
50+
Constructor<?>[] declaredConstructors,
51+
AnnotationIntrospector introspector,
52+
PropertyNamingStrategy propertyNamingStrategy) {
53+
if (clazz.isRecord()) {
54+
if (declaredConstructors.length == 1) {
55+
return introspector.createJsonbCreator(declaredConstructors[0], null, clazz, propertyNamingStrategy);
56+
}
57+
}
58+
return null;
59+
}
60+
61+
public static boolean isRecord(Class<?> clazz) {
62+
return clazz.isRecord();
63+
}
64+
65+
public static Optional<JsonbException> exceptionToThrow(Class<?> clazz) {
66+
if (clazz.isRecord()) {
67+
if (clazz.getDeclaredConstructors().length > 1) {
68+
return Optional.of(new JsonbException(Messages.getMessage(MessageKeys.RECORD_MULTIPLE_CONSTRUCTORS, clazz)));
69+
}
70+
}
71+
return Optional.empty();
72+
}
73+
74+
}

Diff for: yasson-tck/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<yasson.version>3.0.4-SNAPSHOT</yasson.version>
1515
<jakarta.json.bind.version>3.0.1</jakarta.json.bind.version>
1616
<jakarta.json.version>2.1.3</jakarta.json.version>
17-
<maven.compiler.source>17</maven.compiler.source>
18-
<maven.compiler.target>17</maven.compiler.target>
17+
<maven.compiler.source>11</maven.compiler.source>
18+
<maven.compiler.target>11</maven.compiler.target>
1919
</properties>
2020

2121
<!-- TODO: Temporarily enable snapshot repository -->

0 commit comments

Comments
 (0)