/** * Gets the unique instance of this class. This is only allowed in * very limited situations. */ public static Unsafe getUnsafe() { /* * Only code on the bootclasspath is allowed to get at the * Unsafe instance. */ ClassLoader calling = VMStack.getCallingClassLoader(); if ((calling != null) && (calling != Unsafe.class.getClassLoader())) { throw new SecurityException("Unsafe access denied"); } return THE_ONE; }
/** * Returns the first ClassLoader on the call stack that isn't either of * the passed-in ClassLoaders. */ public static ClassLoader getClosestUserClassLoader(ClassLoader bootstrap, ClassLoader system) { Class<?>[] stackClasses = VMStack.getClasses(-1); for (Class<?> stackClass : stackClasses) { ClassLoader loader = stackClass.getClassLoader(); if (loader != null && loader != bootstrap && loader != system) { return loader; } } return null; }
callerClassLoader = VMStack.getClosestUserClassLoader(bootstrapLoader, systemLoader);
try { caller = VMStack.getStackClass2(); // android-changed modifiers = field.getModifiers();
try { caller = VMStack.getStackClass2(); // android-changed modifiers = field.getModifiers();
/** * Returns a {@code Class} object which represents the class with the * given name. The name should be the name of a non-primitive class, as described in * the {@link Class class definition}. * Primitive types can not be found using this method; use {@code int.class} or {@code Integer.TYPE} instead. * * <p>If the class has not yet been loaded, it is loaded and initialized * first. This is done through either the class loader of the calling class * or one of its parent class loaders. It is possible that a static initializer is run as * a result of this call. * * @param className * the name of the non-primitive-type class to find. * @return the named {@code Class} instance. * @throws ClassNotFoundException * if the requested class can not be found. * @throws LinkageError * if an error occurs during linkage * @throws ExceptionInInitializerError * if an exception occurs during static initialization of a * class. */ public static Class<?> forName(String className) throws ClassNotFoundException { return forName(className, true, VMStack.getCallingClassLoader()); }
try { caller = VMStack.getStackClass2(); // android-changed
/** * Returns the first ClassLoader on the call stack that isn't either of * the passed-in ClassLoaders. */ public static ClassLoader getClosestUserClassLoader(ClassLoader bootstrap, ClassLoader system) { Class<?>[] stackClasses = VMStack.getClasses(-1); for (Class<?> stackClass : stackClasses) { ClassLoader loader = stackClass.getClassLoader(); if (loader != null && loader != bootstrap && loader != system) { return loader; } } return null; }
callerClassLoader = VMStack.getClosestUserClassLoader(bootstrapLoader, systemLoader);
/** * Loads and links the dynamic library that is identified through the * specified path. This method is similar to {@link #loadLibrary(String)}, * but it accepts a full path specification whereas {@code loadLibrary} just * accepts the name of the library to load. * * @param pathName * the path of the file to be loaded. */ public static void load(String pathName) { Runtime.getRuntime().load(pathName, VMStack.getCallingClassLoader()); }
try { caller = VMStack.getStackClass2(); // android-changed modifiers = field.getModifiers();
/** * Returns the first ClassLoader on the call stack that isn't either of * the passed-in ClassLoaders. */ public static ClassLoader getClosestUserClassLoader(ClassLoader bootstrap, ClassLoader system) { Class<?>[] stackClasses = VMStack.getClasses(-1); for (Class<?> stackClass : stackClasses) { ClassLoader loader = stackClass.getClassLoader(); if (loader != null && loader != bootstrap && loader != system) { return loader; } } return null; }
callerClassLoader = VMStack.getClosestUserClassLoader(bootstrapLoader, systemLoader);
/** * Loads and links the library with the specified name. The mapping of the * specified library name to the full path for loading the library is * implementation-dependent. * * @param libName * the name of the library to load. * @throws UnsatisfiedLinkError * if the library could not be loaded. */ public static void loadLibrary(String libName) { Runtime.getRuntime().loadLibrary(libName, VMStack.getCallingClassLoader()); }
try { caller = VMStack.getStackClass2(); // android-changed
/** * Returns the first ClassLoader on the call stack that isn't either of * the passed-in ClassLoaders. */ public static ClassLoader getClosestUserClassLoader(ClassLoader bootstrap, ClassLoader system) { Class<?>[] stackClasses = VMStack.getClasses(-1); for (Class<?> stackClass : stackClasses) { ClassLoader loader = stackClass.getClassLoader(); if (loader != null && loader != bootstrap && loader != system) { return loader; } } return null; }
callerClassLoader = VMStack.getClosestUserClassLoader(bootstrapLoader, systemLoader);
/** * Loads and links the library with the specified name. The mapping of the * specified library name to the full path for loading the library is * implementation-dependent. * * @param libName * the name of the library to load. * @throws UnsatisfiedLinkError * if the library can not be loaded. */ public void loadLibrary(String libName) { loadLibrary(libName, VMStack.getCallingClassLoader()); }
try { caller = VMStack.getStackClass2(); // android-changed modifiers = field.getModifiers();
/** * Returns the first ClassLoader on the call stack that isn't either of * the passed-in ClassLoaders. */ public static ClassLoader getClosestUserClassLoader(ClassLoader bootstrap, ClassLoader system) { Class<?>[] stackClasses = VMStack.getClasses(-1); for (Class<?> stackClass : stackClasses) { ClassLoader loader = stackClass.getClassLoader(); if (loader != null && loader != bootstrap && loader != system) { return loader; } } return null; }