Skip to content

Commit

Permalink
Report Jar version (#66)
Browse files Browse the repository at this point in the history
* Report Jar version

fixes: #47

* Refactor ImplJarFile
  • Loading branch information
big-andy-coates authored Nov 15, 2023
1 parent d64bd56 commit 10da5f4
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 222 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ tasks.check {
}

tasks.register("buildTestIncludes") {
description = "Build include files needed to generate the Jekyll website";
description = "Build include files needed to generate the Jekyll website"
dependsOn(runFunctionalTests, runBenchmarkSmokeTest, extractImplementations)
}

Expand Down
7 changes: 0 additions & 7 deletions config/spotbugs/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,4 @@
<!-- Discussion: https://github.com/spotbugs/spotbugs/issues/2627 -->
<Bug pattern="PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES"/>
</Match>

<Match>
<!-- Disable this check as throwing from a constructor is a common pattern and totally fine as long as no finalizer is used. -->
<!-- Finalizers are a dead pattern -->
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
</Match>

</FindBugsFilter>
4 changes: 3 additions & 1 deletion docs/_docs/1. implementations.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ against the underlying [<i class="fab fa-fw fa-github"/>&nbsp; GitHub Repo](http
"Supported Schema Versions",
"Language",
"Licence",
"Version tested",
"Minimum Java Version",
"Jar size",
"Jar size",
"Project activity"
],
"data": implData.filter(row => row.shortName !== "Jackson").map(row => [
Expand All @@ -47,6 +48,7 @@ against the underlying [<i class="fab fa-fw fa-github"/>&nbsp; GitHub Repo](http
row.supported.join(', '),
row.language,
row.licence,
row.version,
row.minJavaVersion,
Math.ceil(row.jarSize / 1024) + ' KB',
row.inactive ?? 'Active'
Expand Down
9 changes: 5 additions & 4 deletions docs/_docs/4. other considerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ While this micro-site focuses on the functionality and performance of the valida
Things to also consider are:

- Is the project in active development? When was its last release?
The `Project activity` column on the [Libraries under test table]({% link _docs/1. implementations.md %}) attempts to show this,
but relies on someone updating the site if a project beings inactive.
Projects that aren't active come with their own set of issues, especially around bug & security fixes, or dependency updates.
The following projects under test seem to be inactive at the time of writing:
- `Justify`: Last released Nov, 2020.
- `Medeia`: Last released Jun, 2019.
- `Everit`: Deprecated. Replaced by the `Skema` implementation.
- What dependencies does it bring in? Less being more.
For example, Vert.x brings in Netty as a dependency, which seems unnecessary.
- Size of the library's jar file and its dependencies.
The `Jar size` column on the [Libraries under test table]({% link _docs/1. implementations.md %}) shows the size of the library's primary jar,
but does not _yet_ include the size of any other dependencies this brings in.
- Is the implementation fit for purpose.
For example, the `Snow` implementation documents itself as a reference implementation.
(This may go some way to explain its poor performance).
Another example is the `Vertx` implementation, which doesn't seem to provide anyway to control how remote references are loaded.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public String toString() {
}
}

class MetaData {
final class MetaData {

public static final String ACTIVE_PROJECT = "";
public static final Pattern SHORT_NAME_PATTERN = Pattern.compile("[A-Za-z0-9]+");
Expand All @@ -99,8 +99,7 @@ class MetaData {
private final Set<SchemaSpec> supported;
private final URL url;
private final Color color;
private final long jarSize;
private final String minJavaVersion;
private final ImplJarFile implJarFile;
private final String inactiveMsg;

/**
Expand Down Expand Up @@ -143,10 +142,7 @@ public MetaData(
throw new RuntimeException(e);
}
this.color = requireNonNull(color, "color");
this.jarSize =
ImplJarFile.jarSizeForClass(
requireNonNull(typeFromImplementation, "typeFromImplementation"));
this.minJavaVersion = ImplJarFile.jarMinJavaVersion(typeFromImplementation);
this.implJarFile = new ImplJarFile(typeFromImplementation);
this.inactiveMsg = requireNonNull(inactiveMsg, "inactiveMsg").trim();

if (longName.isBlank()) {
Expand Down Expand Up @@ -200,12 +196,17 @@ public String color() {

@JsonProperty("jarSize")
public long jarSize() {
return jarSize;
return implJarFile.jarSize();
}

@JsonProperty("version")
public String version() {
return implJarFile.jarVersion();
}

@JsonProperty("minJavaVersion")
public String minJavaVersion() {
return minJavaVersion;
return implJarFile.minJavaVersion();
}

@JsonProperty("inactive")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,9 @@ private SpecVersion schemaVersion(final SchemaSpec spec) {
}
return ver;
}

// Final, empty finalize method stops spotbugs CT_CONSTRUCTOR_THROW
@Override
@SuppressWarnings({"deprecation", "Finalize"})
protected final void finalize() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ private static class ImplementationState {
SchemaSpec.DRAFT_2020_12,
new AdditionalSchemas(Map.of(), Path.of("")))
: null;

if (validator07 == null && validator2020 == null) {
throw new UnsupportedOperationException(
"Benchmark code needs enhancing to cover this case.");
}
}

public TestModel roundTrip(final ModelState model, final SchemaSpec version) {
Expand All @@ -244,8 +239,16 @@ public TestModel roundTrip(final ModelState model, final SchemaSpec version) {
private Implementation.JsonValidator validator(final SchemaSpec version) {
switch (version) {
case DRAFT_07:
if (validator07 == null) {
throw new UnsupportedOperationException(
"Implementation does not support " + version);
}
return validator07;
case DRAFT_2020_12:
if (validator2020 == null) {
throw new UnsupportedOperationException(
"Implementation does not support " + version);
}
return validator2020;
default:
throw new UnsupportedOperationException(
Expand Down
Loading

0 comments on commit 10da5f4

Please sign in to comment.