本文整理汇总了Java中sun.misc.Launcher类的典型用法代码示例。如果您正苦于以下问题:Java Launcher类的具体用法?Java Launcher怎么用?Java Launcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Launcher类属于sun.misc包,在下文中一共展示了Launcher类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: instantiateJPMMLModel
import sun.misc.Launcher; //导入依赖的package包/类
private Evaluator instantiateJPMMLModel() {
PMML pmml = null;
try {
pmml = IOUtil.unmarshal(Launcher.class.getResource("/predictionModel-PMML.xml").openStream());
} catch (Exception e) {
e.printStackTrace();
}
PMMLManager pmmlManager = new PMMLManager(pmml);
Evaluator evaluator = (Evaluator) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
return evaluator;
}
示例2: invokeMethod
import sun.misc.Launcher; //导入依赖的package包/类
private void invokeMethod(String className, URL url, String methodName, String args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
final ClassLoader appClassLoader = Launcher.getLauncher().getClassLoader();
final Class<?> agentClass = appClassLoader.loadClass(className);
Method method = null;
Object[] invokeArgs = null;
try {
method = lookupMainOrAgentClass(agentClass, methodName, new Class<?>[] {String.class, Instrumentation.class});
invokeArgs = new Object[2];
invokeArgs[1] = InstrumentationManager.createInstrumentation();
} catch (NoSuchMethodException ex) {
method = lookupMainOrAgentClass(agentClass, methodName, new Class<?>[] {String.class});
invokeArgs = new Object[1];
}
invokeArgs[0] = args;
InstrumentationManager.registerAgent(url);
method.invoke(null, invokeArgs);
}
示例3: shouldCoverAllFunctionsFromJDKPackage
import sun.misc.Launcher; //导入依赖的package包/类
/**
* see test name.
*/
@Test
public void shouldCoverAllFunctionsFromJDKPackage() throws Exception {
final Reflections reflections = new Reflections( "java.util.function", Launcher.getBootstrapClassPath().getURLs() );
final Set<Class<?>> jdkFunctions = reflections.getTypesAnnotatedWith( FunctionalInterface.class );
final Set<Class<?>> serializableFunctions = serializableFunctions();
final Set<Class<?>> notFoundJdkFunctions = new HashSet<>();
for ( final Class<?> jdkFunction : jdkFunctions ) {
final Class<?> correspondingSerializableFunction =
findSerializableVariantOf( jdkFunction.getSimpleName(), serializableFunctions );
if ( correspondingSerializableFunction == null ) {
notFoundJdkFunctions.add( jdkFunction );
}
}
assertThat( String.format( "Not covered ( %s ): %s ", notFoundJdkFunctions.size(), notFoundJdkFunctions ),
notFoundJdkFunctions.isEmpty() );
}
示例4: handle
import sun.misc.Launcher; //导入依赖的package包/类
@Override
void handle(String className, URL[] urls, String agentArgs)
throws IOException, ClassNotFoundException, InvocationTargetException, IllegalAccessException, NoSuchMethodException {
for (URL url : urls) {
addURLToAppClassLoader.invoke(Launcher.getLauncher().getClassLoader(), url);
}
invokeMethod(className, urls[0], "premain", agentArgs);
}
示例5: test
import sun.misc.Launcher; //导入依赖的package包/类
public void test(String path) throws Exception {
final File jarFile = getJarFile(null);
if(jarFile.isFile()) { // Run with JAR file
final JarFile jar = new JarFile(jarFile);
final Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
while(entries.hasMoreElements()) {
final String name = entries.nextElement().getName();
if (name.startsWith(path + "/")) { //filter according to the path
System.out.println(name);
}
}
jar.close();
} else { // Run with IDE
final URL url = Launcher.class.getResource("/" + path);
if (url != null) {
try {
final File apps = new File(url.toURI());
for (File app : apps.listFiles()) {
System.out.println(app);
}
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
}
示例6: initSystemClassLoader
import sun.misc.Launcher; //导入依赖的package包/类
private static synchronized void initSystemClassLoader() {
if (!sclSet) {
if (scl != null)
throw new IllegalStateException("recursive call");
sun.misc.Launcher l = sun.misc.Launcher.getLauncher();
if (l != null) {
Throwable oops = null;
scl = l.getClassLoader();
try {
PrivilegedExceptionAction a;
a = new SystemClassLoaderAction(scl);
scl = (ClassLoader) AccessController.doPrivileged(a);
} catch (PrivilegedActionException pae) {
oops = pae.getCause();
if (oops instanceof InvocationTargetException) {
oops = oops.getCause();
}
}
if (oops != null) {
if (oops instanceof Error) {
throw (Error) oops;
} else {
// wrap the exception
throw new Error(oops);
}
}
}
sclSet = true;
}
}
示例7: Launcher_clinit
import sun.misc.Launcher; //导入依赖的package包/类
@ALIAS(declaringClass = Launcher.class, name = "<clinit>")
private static native void Launcher_clinit();
示例8: loadMainClass
import sun.misc.Launcher; //导入依赖的package包/类
private Class<?> loadMainClass() throws IOException, ClassNotFoundException {
final ClassLoader appClassLoader = Launcher.getLauncher().getClassLoader();
return appClassLoader.loadClass(mainClassName);
}
示例9: shouldUseOpaqueButtons
import sun.misc.Launcher; //导入依赖的package包/类
static boolean shouldUseOpaqueButtons() {
final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader();
if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true;
return false;
}
示例10: getBootstrapClassPath
import sun.misc.Launcher; //导入依赖的package包/类
static URLClassPath getBootstrapClassPath() {
if (bootstrapClassPath == null) {
bootstrapClassPath = sun.misc.Launcher.getBootstrapClassPath();
}
return bootstrapClassPath;
}
示例11: getBootstrapsResources
import sun.misc.Launcher; //导入依赖的package包/类
/**
* Implementation of parent {@link URLClassLoader} and {@link ClassLoader}
* class method for filter parent ClassLoader and current
* {@link ClassLoader}'s resources
*
* @return {@link Enumeration}
*/
static Enumeration<Resource> getBootstrapsResources(String name) {
return Launcher.getBootstrapClassPath().getResources(name);
}