Java: Add test for Java 16 target when only Java 17+ is available

This commit is contained in:
idrissrio
2025-10-30 09:23:50 +01:00
parent fcc54c1470
commit 7dab2bef69
4 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>maven-java16-with-higher-jdk</artifactId>
<version>1.0-SNAPSHOT</version>
<name>maven-java16-with-higher-jdk</name>
<description>Test case: Java 16 target when only Java 17+ is available.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>16</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,3 @@
pom.xml
src/main/java/com/example/App.java
target/maven-archiver/pom.properties

View File

@@ -0,0 +1,15 @@
package com.example;
import java.util.List;
/**
* Simple class using Java 16 features (e.g.,records).
*/
public class App {
public static void main(String[] args) {
Person person = new Person("Bob", 42);
System.out.println(person);
}
}
record Person(String name, int age) {}

View File

@@ -0,0 +1,2 @@
def test(codeql, java):
codeql.database.create()