Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reflect-config.json required to support graalvm native-image build. #427

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bfg
Copy link

@bfg bfg commented Mar 29, 2024

This PR, together with maxmind/MaxMind-DB-Reader-java#166 adds full native-image support in geoip2-java.

Previously application, incorportaing geoip2-java threw exception when attempt was made to resolve some address:

com.maxmind.db.ConstructorNotFoundException: No constructor on class com.maxmind.geoip2.model.CityResponse with the MaxMindDbConstructor annotation was found.
        at com.maxmind.db.Decoder.findConstructor(Decoder.java:473)
        at com.maxmind.db.Decoder.decodeMapIntoObject(Decoder.java:394)
        at com.maxmind.db.Decoder.decodeMap(Decoder.java:341)
        at com.maxmind.db.Decoder.decodeByType(Decoder.java:162)
        at com.maxmind.db.Decoder.decode(Decoder.java:151)
        at com.maxmind.db.Decoder.decode(Decoder.java:76)
        at com.maxmind.db.Reader.resolveDataPointer(Reader.java:413)
        at com.maxmind.db.Reader.getRecord(Reader.java:185)
        at com.maxmind.geoip2.DatabaseReader.get(DatabaseReader.java:280)
        at com.maxmind.geoip2.DatabaseReader.getCity(DatabaseReader.java:365)
        at com.maxmind.geoip2.DatabaseReader.tryCity(DatabaseReader.java:359)

NOTE: This PR requires new release of maxmind/MaxMind-DB-Reader-java with native-image support.

@oschwald
Copy link
Member

oschwald commented Apr 1, 2024

This config seems very likely to break as we add new classes. I see GraalVM issue on wildcard support, apparently filed by users of this library. It seems unlikely that will be added any time soon, but maybe there is a way to add a test to prevent future breakage.

Although I don't know much about native images, from the discussion on that issue, I assume it is possible to specify the config in the application including the library rather than including it here. Without an automated way to ensure that we do not accidentally break applications as we add new classes, I am inclined to hold off on merging this.

@bfg
Copy link
Author

bfg commented Apr 2, 2024

hey @oschwald, you're right, this PR comes from my app that uses geoip2-java and gets compiled into native binary. Currently, the only 3rd library used in the app, that requires separate, custom reflect-config.json is geoip2-java 🤷; I wanted to improve the situation and developer UX and supplied a patch so that everyone can benefit from it.

And yes, sure, library maintainers need to continously maintain native-image references when they add/remove classes.

AWS SDK2 example:

The best way to make sure that last commit didn't break native-image compatibility is by having a native-image test, see aws sdk2 example

@oschwald
Copy link
Member

oschwald commented Apr 2, 2024

Thanks for the information. I think I would want a test to exist before merging this, as without it, we are unlikely to provide the kind of support that users of the library could rely on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants