/*
* Copyright (C) 2016 The Android Open Source Project
*
* 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.
*/
import java.io.File;
import java.lang.reflect.Method;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws Exception {
// Check whether we get the BootClassLoader (not null).
ClassLoader bootClassLoader = Object.class.getClassLoader();
if (bootClassLoader == null) {
throw new IllegalStateException("Expected non-null classloader for Object");
}
// Try to load libarttest(d) with the BootClassLoader. First construct the
// filename. It's in NATIVELOADER_DEFAULT_NAMESPACE_LIBS, so it's accessible
// simply through the file name.
String libName = System.mapLibraryName(args[0]);
// Then call an internal function that accepts the classloader. Do not use load(), as it
// is deprecated and only there for backwards compatibility, and prints a warning to the
// log that we'd have to strip (it contains the pid).
Method m = Runtime.class.getDeclaredMethod("nativeLoad", String.class, ClassLoader.class);
m.setAccessible(true);
Object result = m.invoke(Runtime.getRuntime(), libName, bootClassLoader);
if (result != null) {
throw new IllegalStateException(result.toString());
}
System.out.println("Success.");
}
}
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet am 2026-11-24)
¤
*© Formatika GbR, Deutschland