Skip to content

Commit 1fdbf90

Browse files
committed
Use Java 17
* Set default release version to 17 * Enable Error prone with Nullaway
1 parent f4ade0d commit 1fdbf90

Some content is hidden

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

68 files changed

+516
-304
lines changed

codegen/generators/java.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Generator
55
# Automatic Code generation overrides for the Java programming language
66
class Java < Base
77
def array_type_for(type_name)
8-
"java.util.List<#{type_name}>"
8+
"List<#{type_name}>"
99
end
1010

1111
def format_description(raw_description, indent_string: '')

codegen/templates/java.java.erb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<%= class_name(key) %>.java
33
package io.cucumber.messages.types;
44

5+
import org.jspecify.annotations.Nullable;
6+
7+
import java.util.List;
58
import java.util.ArrayList;
69
import java.util.Objects;
710
import java.util.Optional;
@@ -17,10 +20,12 @@ import static java.util.Objects.requireNonNull;
1720
<%- end -%>
1821
*/
1922
// Generated code
20-
@SuppressWarnings("unused")
23+
@SuppressWarnings({"unused", "JavaLangClash"})
2124
public final class <%= class_name(key) %> {
22-
<%- schema['properties'].each do |property_name, property| -%>
23-
private final <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>;
25+
<%- schema['properties'].each do |property_name, property|
26+
nullable = !(schema['required'] || []).index(property_name)
27+
-%>
28+
private final <% if nullable -%>@Nullable <%- end -%><%= type_for(class_name(key), property_name, property) -%> <%= property_name %>;
2429
<%- end -%>
2530
<%- if (schema['required'] || []).empty? -%>
2631
<%- schema['properties'].each do |(property_name, property)| -%>
@@ -44,8 +49,10 @@ public final class <%= class_name(key) %> {
4449
<%- end -%>
4550

4651
public <%= class_name(key) %>(
47-
<%- schema['properties'].each_with_index do |(property_name, property), index| -%>
48-
<%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%>
52+
<%- schema['properties'].each_with_index do |(property_name, property), index|
53+
nullable = !(schema['required'] || []).index(property_name)
54+
-%>
55+
<% if nullable -%>@Nullable <%- end -%><%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%>
4956
<%- end -%>
5057
) {
5158
<%- schema['properties'].each do |(property_name, property)|

java/.mvn/jvm.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
3+
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
4+
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
5+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
6+
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
7+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
8+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
9+
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
10+
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED

java/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>io.cucumber</groupId>
77
<artifactId>cucumber-parent</artifactId>
8-
<version>4.5.0</version>
8+
<version>5.0.0-SNAPSHOT</version>
99
</parent>
1010
<artifactId>messages</artifactId>
1111
<version>30.1.1-SNAPSHOT</version>
@@ -53,6 +53,13 @@
5353
</dependencyManagement>
5454

5555
<dependencies>
56+
57+
<dependency>
58+
<groupId>org.jspecify</groupId>
59+
<artifactId>jspecify</artifactId>
60+
<version>1.0.0</version>
61+
</dependency>
62+
5663
<dependency>
5764
<groupId>com.fasterxml.jackson.core</groupId>
5865
<artifactId>jackson-databind</artifactId>

java/src/generated/java/io/cucumber/messages/types/Attachment.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.cucumber.messages.types;
22

3+
import org.jspecify.annotations.Nullable;
4+
5+
import java.util.List;
36
import java.util.ArrayList;
47
import java.util.Objects;
58
import java.util.Optional;
@@ -23,32 +26,32 @@
2326
* is captured in `TestResult`.
2427
*/
2528
// Generated code
26-
@SuppressWarnings("unused")
29+
@SuppressWarnings({"unused", "JavaLangClash"})
2730
public final class Attachment {
2831
private final String body;
2932
private final AttachmentContentEncoding contentEncoding;
30-
private final String fileName;
33+
private final @Nullable String fileName;
3134
private final String mediaType;
32-
private final Source source;
33-
private final String testCaseStartedId;
34-
private final String testStepId;
35-
private final String url;
36-
private final String testRunStartedId;
37-
private final String testRunHookStartedId;
38-
private final Timestamp timestamp;
35+
private final @Nullable Source source;
36+
private final @Nullable String testCaseStartedId;
37+
private final @Nullable String testStepId;
38+
private final @Nullable String url;
39+
private final @Nullable String testRunStartedId;
40+
private final @Nullable String testRunHookStartedId;
41+
private final @Nullable Timestamp timestamp;
3942

4043
public Attachment(
4144
String body,
4245
AttachmentContentEncoding contentEncoding,
43-
String fileName,
46+
@Nullable String fileName,
4447
String mediaType,
45-
Source source,
46-
String testCaseStartedId,
47-
String testStepId,
48-
String url,
49-
String testRunStartedId,
50-
String testRunHookStartedId,
51-
Timestamp timestamp
48+
@Nullable Source source,
49+
@Nullable String testCaseStartedId,
50+
@Nullable String testStepId,
51+
@Nullable String url,
52+
@Nullable String testRunStartedId,
53+
@Nullable String testRunHookStartedId,
54+
@Nullable Timestamp timestamp
5255
) {
5356
this.body = requireNonNull(body, "Attachment.body cannot be null");
5457
this.contentEncoding = requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null");

java/src/generated/java/io/cucumber/messages/types/Background.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.cucumber.messages.types;
22

3+
import org.jspecify.annotations.Nullable;
4+
5+
import java.util.List;
36
import java.util.ArrayList;
47
import java.util.Objects;
58
import java.util.Optional;
@@ -11,21 +14,21 @@
1114
* Represents the Background message in <a href=https://github.com/cucumber/messages>Cucumber's message protocol</a>
1215
*/
1316
// Generated code
14-
@SuppressWarnings("unused")
17+
@SuppressWarnings({"unused", "JavaLangClash"})
1518
public final class Background {
1619
private final Location location;
1720
private final String keyword;
1821
private final String name;
1922
private final String description;
20-
private final java.util.List<Step> steps;
23+
private final List<Step> steps;
2124
private final String id;
2225

2326
public Background(
2427
Location location,
2528
String keyword,
2629
String name,
2730
String description,
28-
java.util.List<Step> steps,
31+
List<Step> steps,
2932
String id
3033
) {
3134
this.location = requireNonNull(location, "Background.location cannot be null");
@@ -55,7 +58,7 @@ public String getDescription() {
5558
return description;
5659
}
5760

58-
public java.util.List<Step> getSteps() {
61+
public List<Step> getSteps() {
5962
return steps;
6063
}
6164

java/src/generated/java/io/cucumber/messages/types/Ci.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.cucumber.messages.types;
22

3+
import org.jspecify.annotations.Nullable;
4+
5+
import java.util.List;
36
import java.util.ArrayList;
47
import java.util.Objects;
58
import java.util.Optional;
@@ -13,18 +16,18 @@
1316
* CI environment
1417
*/
1518
// Generated code
16-
@SuppressWarnings("unused")
19+
@SuppressWarnings({"unused", "JavaLangClash"})
1720
public final class Ci {
1821
private final String name;
19-
private final String url;
20-
private final String buildNumber;
21-
private final Git git;
22+
private final @Nullable String url;
23+
private final @Nullable String buildNumber;
24+
private final @Nullable Git git;
2225

2326
public Ci(
2427
String name,
25-
String url,
26-
String buildNumber,
27-
Git git
28+
@Nullable String url,
29+
@Nullable String buildNumber,
30+
@Nullable Git git
2831
) {
2932
this.name = requireNonNull(name, "Ci.name cannot be null");
3033
this.url = url;

java/src/generated/java/io/cucumber/messages/types/Comment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.cucumber.messages.types;
22

3+
import org.jspecify.annotations.Nullable;
4+
5+
import java.util.List;
36
import java.util.ArrayList;
47
import java.util.Objects;
58
import java.util.Optional;
@@ -13,7 +16,7 @@
1316
* A comment in a Gherkin document
1417
*/
1518
// Generated code
16-
@SuppressWarnings("unused")
19+
@SuppressWarnings({"unused", "JavaLangClash"})
1720
public final class Comment {
1821
private final Location location;
1922
private final String text;

java/src/generated/java/io/cucumber/messages/types/DataTable.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.cucumber.messages.types;
22

3+
import org.jspecify.annotations.Nullable;
4+
5+
import java.util.List;
36
import java.util.ArrayList;
47
import java.util.Objects;
58
import java.util.Optional;
@@ -11,14 +14,14 @@
1114
* Represents the DataTable message in <a href=https://github.com/cucumber/messages>Cucumber's message protocol</a>
1215
*/
1316
// Generated code
14-
@SuppressWarnings("unused")
17+
@SuppressWarnings({"unused", "JavaLangClash"})
1518
public final class DataTable {
1619
private final Location location;
17-
private final java.util.List<TableRow> rows;
20+
private final List<TableRow> rows;
1821

1922
public DataTable(
2023
Location location,
21-
java.util.List<TableRow> rows
24+
List<TableRow> rows
2225
) {
2326
this.location = requireNonNull(location, "DataTable.location cannot be null");
2427
this.rows = unmodifiableList(new ArrayList<>(requireNonNull(rows, "DataTable.rows cannot be null")));
@@ -28,7 +31,7 @@ public Location getLocation() {
2831
return location;
2932
}
3033

31-
public java.util.List<TableRow> getRows() {
34+
public List<TableRow> getRows() {
3235
return rows;
3336
}
3437

java/src/generated/java/io/cucumber/messages/types/DocString.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.cucumber.messages.types;
22

3+
import org.jspecify.annotations.Nullable;
4+
5+
import java.util.List;
36
import java.util.ArrayList;
47
import java.util.Objects;
58
import java.util.Optional;
@@ -11,16 +14,16 @@
1114
* Represents the DocString message in <a href=https://github.com/cucumber/messages>Cucumber's message protocol</a>
1215
*/
1316
// Generated code
14-
@SuppressWarnings("unused")
17+
@SuppressWarnings({"unused", "JavaLangClash"})
1518
public final class DocString {
1619
private final Location location;
17-
private final String mediaType;
20+
private final @Nullable String mediaType;
1821
private final String content;
1922
private final String delimiter;
2023

2124
public DocString(
2225
Location location,
23-
String mediaType,
26+
@Nullable String mediaType,
2427
String content,
2528
String delimiter
2629
) {

0 commit comments

Comments
 (0)