0

I need to access the bootClassPathUrlHandlers in the VMClassLoader class using reflection but I am getting this error: "Reflective access to bootClassPathUrlHandlers is forbidden when targeting API 33 and above".

If I ignore it and run the app anyway I get this runtime exception: java.lang.NoSuchFieldException: No field bootClassPathUrlHandlers in class Ljava/lang/VMClassLoader; (declaration of 'java.lang.VMClassLoader' appears in /apex/com.android.art/javalib/core-libart.jar)

This is the part of code that I am using:

            Class cVMClassLoader = Class.forName("java.lang.VMClassLoader");
            Field vHandlers = cVMClassLoader.getDeclaredField("bootClassPathUrlHandlers");
            vHandlers.setAccessible(true);

            Object[] handlers = (Object[]) vHandlers.get(null);

How can I access it?

na29
  • 45
  • 6
  • 1
    https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces https://androidreverse.wordpress.com/2020/05/02/android-api-restriction-bypass-for-all-android-versions/ https://stackoverflow.com/questions/55970137/bypass-androids-hidden-api-restrictions – emandt Jul 28 '23 at 14:37
  • Does this answer your question? [Bypass Android's hidden API restrictions](https://stackoverflow.com/questions/55970137/bypass-androids-hidden-api-restrictions) – Johannes Kuhn Jul 29 '23 at 18:13

0 Answers0