Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
matrix:
distribution: ['zulu']
os: [ubuntu-latest, windows-latest, macos-latest]
version: [ 11, 17, 21, 22 ]
version: [ 17, 21, 24 ]
steps:
- uses: actions/checkout@v5
with:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.0.0
------------------

* Java 17 or greater is now required.

3.2.0 (2025-05-28)
------------------

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public class Lookup {
}
```

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

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

## Requirements ##

This API requires Java 11 or greater.
This API requires Java 17 or greater.

## Contributing ##

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<release>11</release>
<source>11</source>
<target>11</target>
<release>17</release>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion sample/Benchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static void bench(Reader r, int count, int seed) throws IOException {
for (int i = 0; i < count; i++) {
random.nextBytes(address);
InetAddress ip = InetAddress.getByAddress(address);
Map t = r.get(ip, Map.class);
Map<String, Object> t = r.get(ip, Map.class);
if (TRACE) {
if (i % 50000 == 0) {
System.out.println(i + " " + ip);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/maxmind/db/CHMCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CHMCache implements NodeCache {
private static final int DEFAULT_CAPACITY = 4096;

private final int capacity;
private final ConcurrentHashMap<CacheKey, DecodedValue> cache;
private final ConcurrentHashMap<CacheKey<?>, DecodedValue> cache;
private boolean cacheFull = false;

/**
Expand All @@ -36,7 +36,7 @@ public CHMCache(int capacity) {
}

@Override
public DecodedValue get(CacheKey key, Loader loader) throws IOException {
public DecodedValue get(CacheKey<?> key, Loader loader) throws IOException {
DecodedValue value = cache.get(key);
if (value == null) {
value = loader.load(key);
Expand Down
60 changes: 4 additions & 56 deletions src/main/java/com/maxmind/db/CacheKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,9 @@
* of the value.
*
* @param <T> the type of value
* @param offset the offset of the value in the database file
* @param cls the class of the value
* @param type the type of the value
*/
public final class CacheKey<T> {
private final int offset;
private final Class<T> cls;
private final java.lang.reflect.Type type;

CacheKey(int offset, Class<T> cls, java.lang.reflect.Type type) {
this.offset = offset;
this.cls = cls;
this.type = type;
}

int getOffset() {
return this.offset;
}

Class<T> getCls() {
return this.cls;
}

java.lang.reflect.Type getType() {
return this.type;
}

@Override
public boolean equals(Object o) {
if (o == null) {
return false;
}

CacheKey other = (CacheKey) o;

if (this.offset != other.offset) {
return false;
}

if (this.cls == null) {
if (other.cls != null) {
return false;
}
} else if (!this.cls.equals(other.cls)) {
return false;
}

if (this.type == null) {
return other.type == null;
}
return this.type.equals(other.type);
}

@Override
public int hashCode() {
int result = offset;
result = 31 * result + (cls == null ? 0 : cls.hashCode());
result = 31 * result + (type == null ? 0 : type.hashCode());
return result;
}
public record CacheKey<T>(int offset, Class<T> cls, java.lang.reflect.Type type) {
}
39 changes: 6 additions & 33 deletions src/main/java/com/maxmind/db/CachedConstructor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,10 @@
import java.lang.reflect.Constructor;
import java.util.Map;

final class CachedConstructor<T> {
private final Constructor<T> constructor;
private final Class<?>[] parameterTypes;
private final java.lang.reflect.Type[] parameterGenericTypes;
private final Map<String, Integer> parameterIndexes;

CachedConstructor(
Constructor<T> constructor,
Class<?>[] parameterTypes,
java.lang.reflect.Type[] parameterGenericTypes,
Map<String, Integer> parameterIndexes
) {
this.constructor = constructor;
this.parameterTypes = parameterTypes;
this.parameterGenericTypes = parameterGenericTypes;
this.parameterIndexes = parameterIndexes;
}

Constructor<T> getConstructor() {
return this.constructor;
}

Class<?>[] getParameterTypes() {
return this.parameterTypes;
}

java.lang.reflect.Type[] getParameterGenericTypes() {
return this.parameterGenericTypes;
}

Map<String, Integer> getParameterIndexes() {
return this.parameterIndexes;
}
record CachedConstructor<T>(
Constructor<T> constructor,
Class<?>[] parameterTypes,
java.lang.reflect.Type[] parameterGenericTypes,
Map<String, Integer> parameterIndexes
) {
}
29 changes: 1 addition & 28 deletions src/main/java/com/maxmind/db/CtrlData.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
package com.maxmind.db;

final class CtrlData {
private final Type type;
private final int ctrlByte;
private final int offset;
private final int size;

CtrlData(Type type, int ctrlByte, int offset, int size) {
this.type = type;
this.ctrlByte = ctrlByte;
this.offset = offset;
this.size = size;
}

public Type getType() {
return this.type;
}

public int getCtrlByte() {
return this.ctrlByte;
}

public int getOffset() {
return this.offset;
}

public int getSize() {
return this.size;
}
record CtrlData(Type type, int ctrlByte, int offset, int size) {
}
Loading
Loading