Skip to content

Commit b6a29e1

Browse files
authored
Merge pull request #285 from maxmind/greg/eng-2665
Require Java 17+
2 parents 99dceab + bd42688 commit b6a29e1

File tree

17 files changed

+89
-198
lines changed

17 files changed

+89
-198
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
matrix:
1010
distribution: ['zulu']
1111
os: [ubuntu-latest, windows-latest, macos-latest]
12-
version: [ 11, 17, 21, 22 ]
12+
version: [ 17, 21, 24 ]
1313
steps:
1414
- uses: actions/checkout@v5
1515
with:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.0.0
5+
------------------
6+
7+
* Java 17 or greater is now required.
8+
49
3.2.0 (2025-05-28)
510
------------------
611

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public class Lookup {
120120
}
121121
```
122122

123-
You can also use the reader object to iterate over the database.
124-
The `reader.networks()` and `reader.networksWithin()` methods can
123+
You can also use the reader object to iterate over the database.
124+
The `reader.networks()` and `reader.networksWithin()` methods can
125125
be used for this purpose.
126126

127127
```java
@@ -207,7 +207,7 @@ specific to this reader, please [contact MaxMind support](https://www.maxmind.co
207207

208208
## Requirements ##
209209

210-
This API requires Java 11 or greater.
210+
This API requires Java 17 or greater.
211211

212212
## Contributing ##
213213

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@
147147
<artifactId>maven-compiler-plugin</artifactId>
148148
<version>3.14.0</version>
149149
<configuration>
150-
<release>11</release>
151-
<source>11</source>
152-
<target>11</target>
150+
<release>17</release>
151+
<source>17</source>
152+
<target>17</target>
153153
</configuration>
154154
</plugin>
155155
<plugin>

sample/Benchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private static void bench(Reader r, int count, int seed) throws IOException {
4545
for (int i = 0; i < count; i++) {
4646
random.nextBytes(address);
4747
InetAddress ip = InetAddress.getByAddress(address);
48-
Map t = r.get(ip, Map.class);
48+
Map<String, Object> t = r.get(ip, Map.class);
4949
if (TRACE) {
5050
if (i % 50000 == 0) {
5151
System.out.println(i + " " + ip);

src/main/java/com/maxmind/db/CHMCache.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class CHMCache implements NodeCache {
1313
private static final int DEFAULT_CAPACITY = 4096;
1414

1515
private final int capacity;
16-
private final ConcurrentHashMap<CacheKey, DecodedValue> cache;
16+
private final ConcurrentHashMap<CacheKey<?>, DecodedValue> cache;
1717
private boolean cacheFull = false;
1818

1919
/**
@@ -36,7 +36,7 @@ public CHMCache(int capacity) {
3636
}
3737

3838
@Override
39-
public DecodedValue get(CacheKey key, Loader loader) throws IOException {
39+
public DecodedValue get(CacheKey<?> key, Loader loader) throws IOException {
4040
DecodedValue value = cache.get(key);
4141
if (value == null) {
4242
value = loader.load(key);

src/main/java/com/maxmind/db/CacheKey.java

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,9 @@
66
* of the value.
77
*
88
* @param <T> the type of value
9+
* @param offset the offset of the value in the database file
10+
* @param cls the class of the value
11+
* @param type the type of the value
912
*/
10-
public final class CacheKey<T> {
11-
private final int offset;
12-
private final Class<T> cls;
13-
private final java.lang.reflect.Type type;
14-
15-
CacheKey(int offset, Class<T> cls, java.lang.reflect.Type type) {
16-
this.offset = offset;
17-
this.cls = cls;
18-
this.type = type;
19-
}
20-
21-
int getOffset() {
22-
return this.offset;
23-
}
24-
25-
Class<T> getCls() {
26-
return this.cls;
27-
}
28-
29-
java.lang.reflect.Type getType() {
30-
return this.type;
31-
}
32-
33-
@Override
34-
public boolean equals(Object o) {
35-
if (o == null) {
36-
return false;
37-
}
38-
39-
CacheKey other = (CacheKey) o;
40-
41-
if (this.offset != other.offset) {
42-
return false;
43-
}
44-
45-
if (this.cls == null) {
46-
if (other.cls != null) {
47-
return false;
48-
}
49-
} else if (!this.cls.equals(other.cls)) {
50-
return false;
51-
}
52-
53-
if (this.type == null) {
54-
return other.type == null;
55-
}
56-
return this.type.equals(other.type);
57-
}
58-
59-
@Override
60-
public int hashCode() {
61-
int result = offset;
62-
result = 31 * result + (cls == null ? 0 : cls.hashCode());
63-
result = 31 * result + (type == null ? 0 : type.hashCode());
64-
return result;
65-
}
13+
public record CacheKey<T>(int offset, Class<T> cls, java.lang.reflect.Type type) {
6614
}

src/main/java/com/maxmind/db/CachedConstructor.java

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,10 @@
33
import java.lang.reflect.Constructor;
44
import java.util.Map;
55

6-
final class CachedConstructor<T> {
7-
private final Constructor<T> constructor;
8-
private final Class<?>[] parameterTypes;
9-
private final java.lang.reflect.Type[] parameterGenericTypes;
10-
private final Map<String, Integer> parameterIndexes;
11-
12-
CachedConstructor(
13-
Constructor<T> constructor,
14-
Class<?>[] parameterTypes,
15-
java.lang.reflect.Type[] parameterGenericTypes,
16-
Map<String, Integer> parameterIndexes
17-
) {
18-
this.constructor = constructor;
19-
this.parameterTypes = parameterTypes;
20-
this.parameterGenericTypes = parameterGenericTypes;
21-
this.parameterIndexes = parameterIndexes;
22-
}
23-
24-
Constructor<T> getConstructor() {
25-
return this.constructor;
26-
}
27-
28-
Class<?>[] getParameterTypes() {
29-
return this.parameterTypes;
30-
}
31-
32-
java.lang.reflect.Type[] getParameterGenericTypes() {
33-
return this.parameterGenericTypes;
34-
}
35-
36-
Map<String, Integer> getParameterIndexes() {
37-
return this.parameterIndexes;
38-
}
6+
record CachedConstructor<T>(
7+
Constructor<T> constructor,
8+
Class<?>[] parameterTypes,
9+
java.lang.reflect.Type[] parameterGenericTypes,
10+
Map<String, Integer> parameterIndexes
11+
) {
3912
}
Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,4 @@
11
package com.maxmind.db;
22

3-
final class CtrlData {
4-
private final Type type;
5-
private final int ctrlByte;
6-
private final int offset;
7-
private final int size;
8-
9-
CtrlData(Type type, int ctrlByte, int offset, int size) {
10-
this.type = type;
11-
this.ctrlByte = ctrlByte;
12-
this.offset = offset;
13-
this.size = size;
14-
}
15-
16-
public Type getType() {
17-
return this.type;
18-
}
19-
20-
public int getCtrlByte() {
21-
return this.ctrlByte;
22-
}
23-
24-
public int getOffset() {
25-
return this.offset;
26-
}
27-
28-
public int getSize() {
29-
return this.size;
30-
}
3+
record CtrlData(Type type, int ctrlByte, int offset, int size) {
314
}

0 commit comments

Comments
 (0)