Skip to content

Allow overriding Android library loading logic#78

Open
fourlastor wants to merge 2 commits intolibgdx:masterfrom
fourlastor-forks:configure-library-loader
Open

Allow overriding Android library loading logic#78
fourlastor wants to merge 2 commits intolibgdx:masterfrom
fourlastor-forks:configure-library-loader

Conversation

@fourlastor
Copy link
Contributor

@fourlastor fourlastor commented Nov 12, 2024

This PR adds the ability to configure how SharedLibraryLoader loads libraries in Android. This is to allow libraries to be loaded in different ways, for example by using ReLinker.

Initial discussion in libgdx/gdx-liftoff#158, where I was suggested this is a better place for the configuration to exist, as it's also used in other projects (for example box2d bindings).

@tommyettinger
Copy link
Member

This is an interesting one, and doesn't look like much as-is, but being able to painlessly use ReLinker for any native libraries that use gdx-jnigen would be great. It seems like Android has had a need for ReLinker to avoid some nasty library loading bugs for a long time.

static private final HashSet<String> loadedLibraries = new HashSet<>();
static private final Random random = new Random();

static private AndroidLibraryLoader androidLibraryLoader = new AndroidLibraryLoader() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pointing out that this could use a method reference if we can use language level 8.

Copy link
Member

@tommyettinger tommyettinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any possible breakage here; this is only an extension point for other code to use. And I think that other code could really benefit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants