vendredi 28 juillet 2023

Reflective access to *** is forbidden when targeting API 33 and above

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?





Aucun commentaire:

Enregistrer un commentaire