Skip to content
Open
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
12 changes: 11 additions & 1 deletion java/src/main/java/org/astonbitecode/j4rs/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
public class Utils {

private static boolean IsAndroid;
private static ClassLoader classloader = ClassLoader.getSystemClassLoader();

static {
try {
Expand Down Expand Up @@ -57,7 +58,7 @@ public static Class<?> forNameEnhanced(final String className) throws ClassNotFo
return void.class;
default:
if (!IsAndroid) {
return Class.forName(className, true, ClassLoader.getSystemClassLoader());
return Class.forName(className, true, classloader);
} else {
return Class.forName(className);
}
Expand Down Expand Up @@ -87,4 +88,13 @@ public static String throwableToString(Throwable throwable) {
return "Cannot create String out of a null Throwable";
}
}

/** When the System ClassLoader is not able to load or retrieve your desired class,
* then use this method to update the behavior of Utils.forNameEnhanced()
*
* @param cl a ClassLoader with access to your class of interest.
*/
public static void setClassloader(ClassLoader cl) {
classloader = cl;
}
}
Loading