Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.badlogic.gdx.jnigen.loader;

/** Loader for native libraries in Android. */
public interface AndroidLibraryLoader {

/** Loads a native library. */
void load(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public class SharedLibraryLoader {
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.

@Override
public void load(String name) {
System.loadLibrary(name);
}
};

/** Sets a custom library loader for Android. */
public static void setAndroidLibraryLoader(AndroidLibraryLoader loader) {
androidLibraryLoader = loader;
}

private String nativesJar;

public SharedLibraryLoader () {
Expand Down Expand Up @@ -95,7 +107,7 @@ public void load (String libraryName) {
String platformName = mapLibraryName(libraryName);
try {
if (HostDetection.os == Os.Android)
System.loadLibrary(platformName);
androidLibraryLoader.load(platformName);
else
loadFile(platformName);
setLoaded(libraryName);
Expand Down