Skip to content

Commit 666bf74

Browse files
authored
Merge pull request #410 from noahboerger/feature/jdk-17
Upgrade to JDK 17
2 parents 680c381 + 716ceb4 commit 666bf74

File tree

149 files changed

+2613
-5259
lines changed

Some content is hidden

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

149 files changed

+2613
-5259
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Set up Maven Central Repository
4747
uses: actions/setup-java@v4
4848
with:
49-
java-version: 8
49+
java-version: 17
5050
distribution: "adopt"
5151
- uses: s4u/maven-settings-action@v3.0.0
5252
with:
@@ -58,7 +58,7 @@ jobs:
5858
"password": "${{ secrets.GH_PACKAGES_PASSWORD }}"
5959
}]
6060
- name: Test
61-
run: mvn package -DskipTests
61+
run: mvn package
6262
test-sonar-package:
6363
name: Run Trevas tests with coverage & sonar checks
6464
# Trevas main repo commit branch or merged PR

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If you want to contribute, see this [guide](docs/CONTRIBUTING.md).
2828

2929
## Requirements
3030

31-
Open JDK 8+ is required.
31+
Open JDK 17 + is required.
3232

3333
## References
3434

docs/docs/introduction/index-introduction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ import Video from '@theme/Video';
4343

4444
## Technical description
4545

46-
Trevas provides VTL engines for different execution contexts, in particular a Java 11 engine and an [Apache Spark](https://spark.apache.org/) engine.
46+
Trevas provides VTL engines for different execution contexts, in particular a Java 17 engine and an [Apache Spark](https://spark.apache.org/) engine.
4747

4848
Trevas engines are based on the [JSR 223](https://jcp.org/en/jsr/detail?id=223) specification (Scripting for the Java Platform), which describes the use of scripting languages in Java.

docs/i18n/fr/docusaurus-plugin-content-docs/current/introduction/index-introduction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ import Video from '@theme/Video';
4343

4444
## Description technique
4545

46-
Trevas fournit des moteurs VTL pour différents environnemens d'exécution, notamment un moteur Java 11 et un moteur [Apache Spark](https://spark.apache.org/).
46+
Trevas fournit des moteurs VTL pour différents environnemens d'exécution, notamment un moteur Java 17 et un moteur [Apache Spark](https://spark.apache.org/).
4747

4848
Les moteurs Trevas se basent sur la spécification [JSR 223](https://jcp.org/en/jsr/detail?id=223) qui décrit l'utilisation de langages de scripts en Java.

docs/i18n/no/docusaurus-plugin-content-docs/current/introduction/index-introduction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ import Video from '@theme/Video';
4343

4444
## Teknisk beskrivelse
4545

46-
Trevas leverer VTL-motorer for ulike driftsmiljøer, inkludert en Java 11-motor og en [Apache Spark](https://spark.apache.org/) motor.
46+
Trevas leverer VTL-motorer for ulike driftsmiljøer, inkludert en Java 17-motor og en [Apache Spark](https://spark.apache.org/) motor.
4747

4848
Trevas-motorer er basert på [JSR 223](https://jcp.org/en/jsr/detail?id=223) spesifikasjonen som beskriver bruken av skriptspråk i Java.

pom.xml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@
6969
</distributionManagement>
7070

7171
<properties>
72-
<jdk.version>1.8</jdk.version>
72+
<jdk.version>17</jdk.version>
7373
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
74-
<jacoco.version>0.8.7</jacoco.version>
74+
<jacoco.version>0.8.13</jacoco.version>
7575
<sonar.coverage.jacoco.xmlReportPaths>
7676
${project.basedir}/coverage/target/site/jacoco-aggregate/jacoco.xml
7777
</sonar.coverage.jacoco.xmlReportPaths>
78+
<maven.compiler.source>${jdk.version}</maven.compiler.source>
79+
<maven.compiler.target>${jdk.version}</maven.compiler.target>
7880
</properties>
7981

8082
<dependencies>
@@ -110,7 +112,7 @@
110112
<configuration>
111113
<rules>
112114
<requireJavaVersion>
113-
<version>1.8</version>
115+
<version>17.0.0</version>
114116
</requireJavaVersion>
115117
<requireMavenVersion>
116118
<version>3.3.9</version>
@@ -171,16 +173,20 @@
171173
<artifactId>sonar-maven-plugin</artifactId>
172174
<version>3.9.1.2184</version>
173175
</plugin>
176+
<plugin>
177+
<groupId>org.apache.maven.plugins</groupId>
178+
<artifactId>maven-compiler-plugin</artifactId>
179+
</plugin>
174180
</plugins>
175181
<pluginManagement>
176182
<plugins>
177183
<plugin>
178184
<groupId>org.apache.maven.plugins</groupId>
179185
<artifactId>maven-compiler-plugin</artifactId>
180-
<version>3.13.0</version>
186+
<version>3.14.0</version>
181187
<configuration>
182-
<target>${jdk.version}</target>
183-
<source>${jdk.version}</source>
188+
<release>${jdk.version}</release>
189+
<testRelease>${jdk.version}</testRelease>
184190
</configuration>
185191
</plugin>
186192
</plugins>
@@ -220,7 +226,7 @@
220226
<artifactId>maven-javadoc-plugin</artifactId>
221227
<version>3.8.0</version>
222228
<configuration>
223-
<source>8</source>
229+
<source>${jdk.version}</source>
224230
<detectJavaApiLink>false</detectJavaApiLink>
225231
<doclint>none</doclint>
226232
</configuration>
@@ -280,7 +286,7 @@
280286
<artifactId>maven-javadoc-plugin</artifactId>
281287
<version>3.7.0</version>
282288
<configuration>
283-
<source>8</source>
289+
<source>${jdk.version}</source>
284290
<detectJavaApiLink>false</detectJavaApiLink>
285291
<doclint>none</doclint>
286292
</configuration>

vtl-csv/src/main/java/fr/insee/vtl/csv/CSVDataset.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package fr.insee.vtl.csv;
22

33
import fr.insee.vtl.model.Dataset;
4-
import fr.insee.vtl.model.utils.Java8Helpers;
54
import org.supercsv.cellprocessor.Optional;
65
import org.supercsv.cellprocessor.ParseBool;
76
import org.supercsv.cellprocessor.ParseDouble;
@@ -27,8 +26,8 @@ public class CSVDataset implements Dataset {
2726
public CSVDataset(DataStructure structure, Reader csv) throws IOException {
2827
this.structure = structure;
2928
this.csvReader = new CsvMapReader(csv, CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE);
30-
String[] columns = this.csvReader.getHeader(true);
31-
if (!this.structure.keySet().containsAll(Java8Helpers.listOf(columns))) {
29+
var columns = this.csvReader.getHeader(true);
30+
if (!this.structure.keySet().containsAll(List.of(columns))) {
3231
throw new RuntimeException("missing columns in CSV");
3332
}
3433
}
@@ -69,8 +68,8 @@ public List<DataPoint> getDataPoints() {
6968
if (this.data == null) {
7069
this.data = new ArrayList<>();
7170
try {
72-
String[] header = getNameMapping();
73-
CellProcessor[] processors = getProcessors();
71+
var header = getNameMapping();
72+
var processors = getProcessors();
7473
Map<String, Object> datum;
7574
while ((datum = this.csvReader.read(header, processors)) != null) {
7675
this.data.add(new DataPoint(this.structure, datum));

vtl-engine/pom.xml

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,10 @@
4444
<artifactId>commons-text</artifactId>
4545
<version>1.10.0</version>
4646
</dependency>
47-
<!-- Because of safety mirror -->
4847
<dependency>
49-
<groupId>org.projectlombok</groupId>
50-
<artifactId>lombok</artifactId>
51-
<version>1.18.34</version>
52-
</dependency>
53-
<dependency>
54-
<groupId>org.jetbrains</groupId>
55-
<artifactId>annotations</artifactId>
56-
<version>20.1.0</version>
48+
<groupId>com.github.hervian</groupId>
49+
<artifactId>safety-mirror</artifactId>
50+
<version>4.0.1</version>
5751
</dependency>
5852
</dependencies>
5953
<build>
@@ -77,21 +71,6 @@
7771
</execution>
7872
</executions>
7973
</plugin>
80-
<plugin>
81-
<groupId>org.apache.maven.plugins</groupId>
82-
<artifactId>maven-compiler-plugin</artifactId>
83-
<configuration>
84-
<source>8</source>
85-
<target>8</target>
86-
<annotationProcessorPaths>
87-
<path>
88-
<groupId>org.projectlombok</groupId>
89-
<artifactId>lombok</artifactId>
90-
<version>1.18.34</version>
91-
</path>
92-
</annotationProcessorPaths>
93-
</configuration>
94-
</plugin>
9574
</plugins>
9675
</build>
9776

vtl-engine/src/main/java/fr/insee/vtl/engine/TemporalFunctions.java

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package fr.insee.vtl.engine;
22

3+
import fr.insee.vtl.engine.exceptions.VtlRuntimeException;
4+
import fr.insee.vtl.model.exceptions.VtlScriptException;
35
import org.threeten.extra.Interval;
46
import org.threeten.extra.PeriodDuration;
57

8+
import javax.script.ScriptEngine;
9+
import javax.script.ScriptEngineManager;
610
import java.time.*;
7-
import java.time.temporal.ChronoUnit;
11+
import java.time.temporal.*;
812

913
/**
1014
* This comment explains the temporal functionality supported by Trevas, as defined in the VTL 2.0 specification.
@@ -184,19 +188,19 @@ public static PeriodDuration period_indicator(Interval timePeriod) {
184188
public static Interval timeshift(Interval time, Long n) {
185189
OffsetDateTime from = time.getStart().atOffset(ZoneOffset.UTC);
186190
OffsetDateTime to = time.getEnd().atOffset(ZoneOffset.UTC);
187-
PeriodDuration dur = PeriodDuration.between(from, to)
191+
var dur = PeriodDuration.between(from, to)
188192
.multipliedBy(n.intValue());
189193
return Interval.of(from.plus(dur.getPeriod()).toInstant(), to.plus(dur.getPeriod()).toInstant());
190194
}
191195

192196
public static ZonedDateTime at_zone(Instant op, String zone) {
193-
ZoneId zid = ZoneId.of(zone);
197+
var zid = ZoneId.of(zone);
194198
return op.atZone(zid);
195199
}
196200

197201

198202
private static Interval truncate_time(Interval op, ChronoUnit unit, ZoneId zone) {
199-
Instant start = truncate_time(op.getStart(), unit, zone);
203+
var start = truncate_time(op.getStart(), unit, zone);
200204
return Interval.of(start, unit.getDuration());
201205
}
202206

@@ -209,25 +213,18 @@ public static Interval truncate_time(Interval op, String unit) {
209213
}
210214

211215
private static Instant truncate_time(Instant op, ChronoUnit unit, ZoneId zone) {
212-
ZonedDateTime zonedOp = op.atZone(zone);
213-
switch (unit) {
214-
case DAYS:
215-
return zonedOp.truncatedTo(ChronoUnit.DAYS).toInstant();
216-
case MONTHS:
217-
return zonedOp.withDayOfMonth(1)
218-
.truncatedTo(ChronoUnit.DAYS).toInstant();
219-
case YEARS:
220-
return zonedOp.withDayOfYear(1)
221-
.truncatedTo(ChronoUnit.DAYS).toInstant();
222-
case HOURS:
223-
return zonedOp.truncatedTo(ChronoUnit.HOURS).toInstant();
224-
case MINUTES:
225-
return zonedOp.truncatedTo(ChronoUnit.MINUTES).toInstant();
226-
case SECONDS:
227-
return zonedOp.truncatedTo(ChronoUnit.SECONDS).toInstant();
228-
default:
229-
throw new IllegalArgumentException("Unsupported unit: " + unit);
230-
}
216+
var zonedOp = op.atZone(zone);
217+
return switch (unit) {
218+
case DAYS -> zonedOp.truncatedTo(ChronoUnit.DAYS).toInstant();
219+
case MONTHS -> zonedOp.withDayOfMonth(1)
220+
.truncatedTo(ChronoUnit.DAYS).toInstant();
221+
case YEARS -> zonedOp.withDayOfYear(1)
222+
.truncatedTo(ChronoUnit.DAYS).toInstant();
223+
case HOURS -> zonedOp.truncatedTo(ChronoUnit.HOURS).toInstant();
224+
case MINUTES -> zonedOp.truncatedTo(ChronoUnit.MINUTES).toInstant();
225+
case SECONDS -> zonedOp.truncatedTo(ChronoUnit.SECONDS).toInstant();
226+
default -> throw new IllegalArgumentException("Unsupported unit: " + unit);
227+
};
231228
}
232229

233230
public static Instant truncate_time(Instant op, String unit, String zone) {
@@ -244,26 +241,19 @@ public static ZonedDateTime truncate_time(ZonedDateTime op, String unit) {
244241
}
245242

246243
public static OffsetDateTime truncate_time(OffsetDateTime op, String unit) {
247-
ZonedDateTime zoned = op.toZonedDateTime();
244+
var zoned = op.toZonedDateTime();
248245
return truncate_time(zoned.toInstant(), toChronoUnit(unit), zoned.getZone()).atOffset(op.getOffset());
249246
}
250247

251248
private static ChronoUnit toChronoUnit(String unit) {
252-
switch (unit.toLowerCase()) {
253-
case "day":
254-
return ChronoUnit.DAYS;
255-
case "month":
256-
return ChronoUnit.MONTHS;
257-
case "year":
258-
return ChronoUnit.YEARS;
259-
case "hour":
260-
return ChronoUnit.HOURS;
261-
case "minute":
262-
return ChronoUnit.MINUTES;
263-
case "second":
264-
return ChronoUnit.SECONDS;
265-
default:
266-
throw new IllegalArgumentException("Unsupported unit: " + unit);
267-
}
249+
return switch (unit.toLowerCase()) {
250+
case "day" -> ChronoUnit.DAYS;
251+
case "month" -> ChronoUnit.MONTHS;
252+
case "year" -> ChronoUnit.YEARS;
253+
case "hour" -> ChronoUnit.HOURS;
254+
case "minute" -> ChronoUnit.MINUTES;
255+
case "second" -> ChronoUnit.SECONDS;
256+
default -> throw new IllegalArgumentException("Unsupported unit: " + unit);
257+
};
268258
}
269259
}

vtl-engine/src/main/java/fr/insee/vtl/engine/VtlNativeMethods.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
package fr.insee.vtl.engine;
22

3-
import fr.insee.vtl.engine.utils.safetymirror.Fun;
3+
import com.github.hervian.reflection.Fun;
44
import fr.insee.vtl.engine.visitors.expression.*;
55
import fr.insee.vtl.engine.visitors.expression.functions.ComparisonFunctionsVisitor;
66
import fr.insee.vtl.engine.visitors.expression.functions.DistanceFunctionsVisitor;
77
import fr.insee.vtl.engine.visitors.expression.functions.NumericFunctionsVisitor;
88
import fr.insee.vtl.engine.visitors.expression.functions.StringFunctionsVisitor;
9-
import fr.insee.vtl.model.utils.Java8Helpers;
109
import org.threeten.extra.Interval;
1110
import org.threeten.extra.PeriodDuration;
1211

1312
import java.lang.reflect.Method;
14-
import java.time.Instant;
15-
import java.time.OffsetDateTime;
16-
import java.time.ZonedDateTime;
13+
import java.time.*;
14+
import java.time.temporal.ChronoUnit;
1715
import java.util.Set;
1816

1917
public class VtlNativeMethods {
2018

21-
public static final Set<Method> NATIVE_METHODS = Java8Helpers.setOf(
19+
public static final Set<Method> NATIVE_METHODS = Set.of(
2220
// NumericFunctionsVisitor
2321
Fun.toMethod(NumericFunctionsVisitor::ceil),
2422
Fun.toMethod(NumericFunctionsVisitor::floor),

0 commit comments

Comments
 (0)