Skip to content

Commit 7f8b2b7

Browse files
committed
add support for java17+
1 parent faae4f1 commit 7f8b2b7

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

.github/workflows/maven.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ jobs:
1313
strategy:
1414
matrix:
1515
java:
16-
- '8'
17-
- '11'
18-
#- '17'
16+
# Java LTS versions
17+
- '8' # 2030/12
18+
- '11' # 2032/01
19+
- '17' # 2029/09
20+
- '21' # 2031/09
1921
name: Java ${{ matrix.Java }} sample
2022
steps:
2123
- uses: actions/checkout@v2

pom.xml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
<artifactId>maven-surefire-plugin</artifactId>
6262
<version>2.22.2</version>
6363
<configuration>
64-
<!-- <parallel>all</parallel> &lt;!&ndash; Run tests in parallel&ndash;&gt;-->
65-
<!-- <useUnlimitedThreads>true</useUnlimitedThreads>-->
6664
<rerunFailingTestsCount>10</rerunFailingTestsCount>
6765
<argLine>-Xms1g -Xmx1g</argLine>
6866
</configuration>
@@ -107,6 +105,43 @@
107105
</plugins>
108106
</reporting>
109107

108+
<profiles>
109+
<profile>
110+
<id>java-12-plus-reflection</id>
111+
<activation>
112+
<jdk>[12,)</jdk>
113+
</activation>
114+
<build>
115+
<plugins>
116+
<plugin>
117+
<groupId>org.apache.maven.plugins</groupId>
118+
<artifactId>maven-surefire-plugin</artifactId>
119+
<configuration>
120+
<argLine> --add-opens java.base/java.nio=ALL-UNNAMED </argLine>
121+
</configuration>
122+
</plugin>
123+
124+
<plugin>
125+
<groupId>org.codehaus.mojo</groupId>
126+
<artifactId>exec-maven-plugin</artifactId>
127+
<executions>
128+
<execution>
129+
<id>run-benchmarks</id>
130+
<configuration>
131+
<arguments>
132+
<argument>--add-opens=java.base/java.nio=ALL-UNNAMED</argument>
133+
<argument>-classpath</argument>
134+
<classpath/>
135+
<argument>org.openjdk.jmh.Main</argument>
136+
</arguments>
137+
</configuration>
138+
</execution>
139+
</executions>
140+
</plugin>
141+
</plugins>
142+
</build>
143+
</profile>
144+
</profiles>
110145
<dependencies>
111146
<dependency>
112147
<groupId>no.fiken.oss.junixsocket</groupId>
@@ -119,45 +154,39 @@
119154
<version>1.0.2</version>
120155
</dependency>
121156

122-
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
123157
<dependency>
124158
<groupId>net.java.dev.jna</groupId>
125159
<artifactId>jna</artifactId>
126160
<version>5.12.1</version>
127161
</dependency>
128162

129-
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
130163
<dependency>
131164
<groupId>net.java.dev.jna</groupId>
132165
<artifactId>jna-platform</artifactId>
133166
<version>5.12.1</version>
134167
</dependency>
135168

136-
<!-- https://mvnrepository.com/artifact/junit/junit -->
137169
<dependency>
138170
<groupId>junit</groupId>
139171
<artifactId>junit</artifactId>
140172
<version>4.13.2</version>
141173
<scope>test</scope>
142174
</dependency>
143175

144-
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
145176
<dependency>
146177
<groupId>org.mockito</groupId>
147178
<artifactId>mockito-core</artifactId>
148179
<version>3.12.4</version>
149180
<scope>test</scope>
150181
</dependency>
151182

152-
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
153183
<dependency>
154184
<groupId>org.assertj</groupId>
155185
<artifactId>assertj-core</artifactId>
156186
<version>3.23.1</version>
157187
<scope>test</scope>
158188
</dependency>
159189

160-
<!-- https://mvnrepository.com/artifact/org.openjdk.jmh -->
161190
<dependency>
162191
<groupId>org.openjdk.jmh</groupId>
163192
<artifactId>jmh-core</artifactId>

src/main/java/bwapi/UnsafeTools.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ private static Object getOrCrash(final Class<?> className, final Object object,
2121
return result;
2222

2323
} catch (final Exception e) { // or crash...
24-
e.printStackTrace();
25-
System.exit(-1);
26-
return null;
24+
throw new RuntimeException(e);
2725
}
2826
}
2927

src/test/java/bwapi/ClientDataBenchmark.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ public static class EmptyState {
1818

1919
@Setup(Level.Invocation)
2020
public void setup() {
21+
WrappedBuffer wrappedBuffer = new WrappedBuffer(ClientData.GameData.SIZE);
2122
game = new Game();
22-
game.botClientData().setBuffer(new WrappedBuffer(ClientData.GameData.SIZE));
23+
game.botClientData().setBuffer(wrappedBuffer);
24+
client = new Client(wrappedBuffer);
2325
strings = buildStrings();
2426
}
25-
2627
}
2728

2829
@State(Scope.Thread)
@@ -33,9 +34,11 @@ public static class FilledWithStrings {
3334

3435
@Setup(Level.Invocation)
3536
public void setup() {
36-
data = client.liveClientData().gameData();
37+
WrappedBuffer wrappedBuffer = new WrappedBuffer(ClientData.GameData.SIZE);
3738
game = new Game();
38-
game.botClientData().setBuffer(new WrappedBuffer(ClientData.GameData.SIZE));
39+
game.botClientData().setBuffer(wrappedBuffer);
40+
client = new Client(wrappedBuffer);
41+
data = game.botClientData().gameData();
3942
String[] strings = buildStrings();
4043
for (String s : strings) {
4144
GameDataUtils.addString(client.liveClientData().gameData(), s);

0 commit comments

Comments
 (0)