Skip to content

Commit 56310f5

Browse files
committed
add support for java17+
1 parent efefeae commit 56310f5

File tree

4 files changed

+50
-16
lines changed

4 files changed

+50
-16
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,43 @@
106106
</plugins>
107107
</reporting>
108108

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

121-
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
122158
<dependency>
123159
<groupId>net.java.dev.jna</groupId>
124160
<artifactId>jna</artifactId>
125161
<version>5.12.1</version>
126162
</dependency>
127163

128-
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
129164
<dependency>
130165
<groupId>net.java.dev.jna</groupId>
131166
<artifactId>jna-platform</artifactId>
132167
<version>5.12.1</version>
133168
</dependency>
134169

135-
<!-- https://mvnrepository.com/artifact/junit/junit -->
136170
<dependency>
137171
<groupId>junit</groupId>
138172
<artifactId>junit</artifactId>
139173
<version>4.13.2</version>
140174
<scope>test</scope>
141175
</dependency>
142176

143-
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
144177
<dependency>
145178
<groupId>org.mockito</groupId>
146179
<artifactId>mockito-core</artifactId>
147180
<version>3.12.4</version>
148181
<scope>test</scope>
149182
</dependency>
150183

151-
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
152184
<dependency>
153185
<groupId>org.assertj</groupId>
154186
<artifactId>assertj-core</artifactId>
155187
<version>3.27.7</version>
156188
<scope>test</scope>
157189
</dependency>
158190

159-
<!-- https://mvnrepository.com/artifact/org.openjdk.jmh -->
160191
<dependency>
161192
<groupId>org.openjdk.jmh</groupId>
162193
<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)