-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds module-info and upgrades source code to java 8
- Loading branch information
Showing
26 changed files
with
294 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Check java class version | ||
on: | ||
push: | ||
branches: | ||
- "*" | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
build: | ||
name: Build and check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: 'zulu' # Alternative distribution options are available. | ||
- name: Cache Maven packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
- name: Build and check | ||
run: | | ||
mvn -P sonar package | ||
cd java8Test | ||
mvn package | ||
echo "checking ../javaluator-demo/target/javaluator-demo.jar" | ||
java -jar target/javaReleaseTest.jar ../javaluator-demo/target/javaluator-demo.jar 52 | ||
# Let check the library itself in case demo pom points to an older release of the library | ||
OUT="$(ls ../javaluator/target/javaluator*.jar | grep -v javadoc.jar | grep -v sources.jar)" | ||
echo "checking $OUT" | ||
java -jar target/javaReleaseTest.jar $OUT 52 | ||
OUT="$(ls ../javaluator-examples/target/javaluator-examples*.jar | grep -v javadoc.jar | grep -v sources.jar)" | ||
echo "checking $OUT" | ||
java -jar target/javaReleaseTest.jar $OUT 52 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This folder contains a program used by 'java8Check.yml' workflow to check if generated classes are compatible with a java 8 (the exact release is defined in the workflow) virtual machine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<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> | ||
<parent> | ||
<groupId>com.fathzer</groupId> | ||
<artifactId>parent-pom</artifactId> | ||
<version>1.0.8</version> | ||
<relativePath></relativePath> | ||
</parent> | ||
<artifactId>java-release-test</artifactId> | ||
<version>0.0.1</version> | ||
<name>java-release-test</name> | ||
<description>A program that tests a jar contains classes compatible with a | ||
specific java release.</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.source.skip>true</maven.source.skip> | ||
<maven.javadoc.skip>true</maven.javadoc.skip> | ||
<maven.install.skip>true</maven.install.skip> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.4.1</version> | ||
<configuration> | ||
<finalName>javaReleaseTest</finalName> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>com.fathzer.java.release.Check</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
47 changes: 47 additions & 0 deletions
47
java8Test/src/main/java/com/fathzer/java/release/Check.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.fathzer.java.release; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.function.Predicate; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipInputStream; | ||
|
||
public class Check { | ||
private static final String CLASS_SUFFIX = ".class"; | ||
|
||
public static void main(String[] args) { | ||
try { | ||
if (args.length!=2) { | ||
throw new IllegalArgumentException("This program requires two arguments: a jar file path and a maximum class level"); | ||
} | ||
final File jar = new File(args[0]); | ||
final int maxRelease = Integer.parseInt(args[1]); | ||
new Check().check(jar, maxRelease, s->s.endsWith("-info.class")); | ||
System.out.println("ok"); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
System.exit(1); | ||
} | ||
} | ||
|
||
private void check(File jar, int maxRelease, Predicate<String> ignored) throws IOException { | ||
try (ZipInputStream zip = new ZipInputStream(new FileInputStream(jar))) { | ||
final DataInputStream data = new DataInputStream(zip); | ||
for (ZipEntry entry = zip.getNextEntry(); entry!=null; entry = zip.getNextEntry()) { | ||
if (!entry.isDirectory() && entry.getName().endsWith(CLASS_SUFFIX) && !ignored.test(entry.getName())) { | ||
if (zip.skip(6)!=6) { | ||
throw new IOException("End of file reached before major class version"); | ||
} | ||
final int release = data.readUnsignedShort(); | ||
if (release>maxRelease) { | ||
throw new IllegalArgumentException("The major class version of "+entry.getName()+" is "+release); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module javaluator.demo { | ||
requires javaluator; | ||
requires java.desktop; | ||
requires ajlib; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.