• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UncheckedException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.gradle.internal.UncheckedException的典型用法代码示例。如果您正苦于以下问题:Java UncheckedException类的具体用法?Java UncheckedException怎么用?Java UncheckedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UncheckedException类属于org.gradle.internal包,在下文中一共展示了UncheckedException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getClasspathForClass

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public static File getClasspathForClass(Class<?> targetClass) {
    URI location;
    try {
        CodeSource codeSource = targetClass.getProtectionDomain().getCodeSource();
        if (codeSource != null && codeSource.getLocation() != null) {
            location = codeSource.getLocation().toURI();
            if (location.getScheme().equals("file")) {
                return new File(location);
            }
        }
        if (targetClass.getClassLoader() != null) {
            String resourceName = targetClass.getName().replace('.', '/') + ".class";
            URL resource = targetClass.getClassLoader().getResource(resourceName);
            if (resource != null) {
                return getClasspathForResource(resource, resourceName);
            }
        }
        throw new GradleException(String.format("Cannot determine classpath for class %s.", targetClass.getName()));
    } catch (URISyntaxException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:ClasspathUtil.java


示例2: send

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public void send(String title, String message) {
    String isRunning = "\ntell application \"System Events\"\n"
        + "set isRunning to count of (every process whose bundle identifier is \"com.Growl.GrowlHelperApp\") > 0\n"
        + "end tell\n" + "return isRunning\n";
    try {
        Object value = engine.eval(isRunning);
        if (value.equals(0)) {
            throw new AnnouncerUnavailableException("Growl is not running.");
        }
        final File icon = iconProvider.getIcon(48, 48);
        String iconDef = icon != null ? "image from location ((POSIX file \"" + icon.getAbsolutePath() + "\") as string) as alias" : "";
        String script = "\ntell application id \"com.Growl.GrowlHelperApp\"\n"
            + "register as application \"Gradle\" all notifications {\"Build Notification\"} default notifications {\"Build Notification\"}\n"
            + "notify with name \"Build Notification\" title \"" + escape(title) + "\" description \"" + escape(message)
            + "\" application name \"Gradle\"" + iconDef
            + "\nend tell\n";
        engine.eval(script);
    } catch (ScriptException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:AppleScriptBackedGrowlAnnouncer.java


示例3: execute

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public void execute(final WorkerProcessContext workerProcessContext) {
    LOGGER.info("{} started executing tests.", workerProcessContext.getDisplayName());

    completed = new CountDownLatch(1);

    System.setProperty(WORKER_ID_SYS_PROPERTY, workerProcessContext.getWorkerId().toString());

    DefaultServiceRegistry testServices = new TestFrameworkServiceRegistry(workerProcessContext);
    startReceivingTests(workerProcessContext, testServices);

    try {
        try {
            completed.await();
        } catch (InterruptedException e) {
            throw new UncheckedException(e);
        }
    } finally {
        LOGGER.info("{} finished executing tests.", workerProcessContext.getDisplayName());
        // Clean out any security manager the tests might have installed
        System.setSecurityManager(null);
        testServices.close();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:TestWorker.java


示例4: toStoppable

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private static Stoppable toStoppable(final Object object) {
    if (object instanceof Stoppable) {
        return (Stoppable) object;
    }
    if (object instanceof Closeable) {
        final Closeable closeable = (Closeable) object;
        return new Stoppable() {
            @Override
            public String toString() {
                return closeable.toString();
            }

            public void stop() {
                try {
                    closeable.close();
                } catch (IOException e) {
                    throw UncheckedException.throwAsUncheckedException(e);
                }
            }
        };
    }
    return NO_OP_STOPPABLE;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:CompositeStoppable.java


示例5: stop

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public void stop() {
    Throwable failure = null;
    try {
        for (Stoppable element : elements) {
            try {
                element.stop();
            } catch (Throwable throwable) {
                if (failure == null) {
                    failure = throwable;
                } else {
                    LOGGER.error(String.format("Could not stop %s.", element), throwable);
                }
            }
        }
    } finally {
        elements.clear();
    }

    if (failure != null) {
        throw UncheckedException.throwAsUncheckedException(failure);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:CompositeStoppable.java


示例6: getClasspath

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public static ClassPath getClasspath(ClassLoader classLoader) {
    final List<File> implementationClassPath = new ArrayList<File>();
    new ClassLoaderVisitor() {
        @Override
        public void visitClassPath(URL[] classPath) {
            for (URL url : classPath) {
                try {
                    implementationClassPath.add(new File(url.toURI()));
                } catch (URISyntaxException e) {
                    throw new UncheckedException(e);
                }
            }
        }
    }.visit(classLoader);
    return DefaultClassPath.of(implementationClassPath);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:ClasspathUtil.java


示例7: connectToCanceledDaemon

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private DaemonClientConnection connectToCanceledDaemon(Collection<DaemonInfo> busyDaemons, ExplainingSpec<DaemonContext> constraint) {
    DaemonClientConnection connection = null;
    final Pair<Collection<DaemonInfo>, Collection<DaemonInfo>> canceledBusy = partitionByState(busyDaemons, Canceled);
    final Collection<DaemonInfo> compatibleCanceledDaemons = getCompatibleDaemons(canceledBusy.getLeft(), constraint);
    if (!compatibleCanceledDaemons.isEmpty()) {
        LOGGER.info(DaemonMessages.WAITING_ON_CANCELED);
        CountdownTimer timer = Timers.startTimer(CANCELED_WAIT_TIMEOUT);
        while (connection == null && !timer.hasExpired()) {
            try {
                sleep(200);
                connection = connectToIdleDaemon(daemonRegistry.getIdle(), constraint);
            } catch (InterruptedException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    }
    return connection;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:DefaultDaemonConnector.java


示例8: stop

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public void stop() {
    lifecycleLock.lock();
    try {
        if (!stopped) {
            try {
                disconnectableInput.close();
            } catch (IOException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }

            forwardingExecuter.stop();
            stopped = true;
        }
    } finally {
        lifecycleLock.unlock();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:InputForwarder.java


示例9: getEffectiveManifest

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public DefaultManifest getEffectiveManifest() {
    ContainedVersionAnalyzer analyzer = analyzerFactory.create();
    DefaultManifest effectiveManifest = new DefaultManifest(null);
    try {
        setAnalyzerProperties(analyzer);
        Manifest osgiManifest = analyzer.calcManifest();
        java.util.jar.Attributes attributes = osgiManifest.getMainAttributes();
        for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
            effectiveManifest.attributes(WrapUtil.toMap(entry.getKey().toString(), (String) entry.getValue()));
        }
        effectiveManifest.attributes(this.getAttributes());
        for (Map.Entry<String, Attributes> ent : getSections().entrySet()) {
            effectiveManifest.attributes(ent.getValue(), ent.getKey());
        }
        if (classesDir != null) {
            long mod = classesDir.lastModified();
            if (mod > 0) {
                effectiveManifest.getAttributes().put(Analyzer.BND_LASTMODIFIED, mod);
            }
        }
    } catch (Exception e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
    return getEffectiveManifestInternal(effectiveManifest);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:DefaultOsgiManifest.java


示例10: openJarOutputStream

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private ZipOutputStream openJarOutputStream(File outputJar) {
    try {
        ZipOutputStream outputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outputJar), BUFFER_SIZE));
        outputStream.setLevel(0);
        return outputStream;
    } catch (IOException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:RuntimeShadedJarCreator.java


示例11: run

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private void run() {
    ClassLoaderUtils.disableUrlConnectionCaching();
    final Thread thread = Thread.currentThread();
    final ClassLoader previousContextClassLoader = thread.getContextClassLoader();
    final ClassLoader classLoader = new URLClassLoader(new DefaultClassPath(runSpec.getClasspath()).getAsURLArray(), null);
    thread.setContextClassLoader(classLoader);
    try {
        Object buildDocHandler = runAdapter.getBuildDocHandler(classLoader, runSpec.getClasspath());
        Object buildLink = runAdapter.getBuildLink(classLoader, runSpec.getProjectPath(), runSpec.getApplicationJar(), runSpec.getChangingClasspath(), runSpec.getAssetsJar(), runSpec.getAssetsDirs());
        runAdapter.runDevHttpServer(classLoader, classLoader, buildLink, buildDocHandler, runSpec.getHttpPort());
    } catch (Exception e) {
        throw UncheckedException.throwAsUncheckedException(e);
    } finally {
        thread.setContextClassLoader(previousContextClassLoader);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:PlayWorkerServer.java


示例12: readConfigMappings

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private static Map<String, List<String>> readConfigMappings(DependencyDescriptor dependencyDescriptor) {
    if (dependencyDescriptor instanceof DefaultDependencyDescriptor) {
        try {
            return (Map<String, List<String>>) DEPENDENCY_CONFIG_FIELD.get(dependencyDescriptor);
        } catch (IllegalAccessException e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
    }

    String[] modConfs = dependencyDescriptor.getModuleConfigurations();
    Map<String, List<String>> results = Maps.newLinkedHashMap();
    for (String modConf : modConfs) {
        results.put(modConf, Arrays.asList(dependencyDescriptor.getDependencyConfigurations(modConfs)));
    }
    return results;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:IvyModuleDescriptorConverter.java


示例13: putModuleDescriptor

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public LocallyAvailableResource putModuleDescriptor(ModuleComponentAtRepositoryKey component, final ModuleComponentResolveMetadata metadata) {
    String filePath = getFilePath(component);
    return metaDataStore.add(filePath, new Action<File>() {
        public void execute(File moduleDescriptorFile) {
            try {
                KryoBackedEncoder encoder = new KryoBackedEncoder(new FileOutputStream(moduleDescriptorFile));
                try {
                    moduleMetadataSerializer.write(encoder, metadata);
                } finally {
                    encoder.close();
                }
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:ModuleMetadataStore.java


示例14: stop

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public void stop() {
    lock.lock();
    try {
        stopped = true;
        while (!executing.isEmpty()) {
            try {
                condition.await();
            } catch (InterruptedException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
        this.connection = null;
    } finally {
        lock.unlock();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:LazyConsumerActionExecutor.java


示例15: getBuildDocHandler

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public Object getBuildDocHandler(ClassLoader docsClassLoader, Iterable<File> classpath) throws NoSuchMethodException, ClassNotFoundException, IOException, IllegalAccessException {
    Class<?> docHandlerFactoryClass = getDocHandlerFactoryClass(docsClassLoader);
    Method docHandlerFactoryMethod = docHandlerFactoryClass.getMethod("fromJar", JarFile.class, String.class);
    JarFile documentationJar = findDocumentationJar(classpath);
    try {
        return docHandlerFactoryMethod.invoke(null, documentationJar, "play/docs/content");
    } catch (InvocationTargetException e) {
        throw UncheckedException.unwrapAndRethrow(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:12,代码来源:DefaultVersionedPlayRunAdapter.java


示例16: execute

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
@Override
public void execute(WorkerProcessContext context) {
    stop = new CountDownLatch(1);
    final PlayRunWorkerClientProtocol clientProtocol = context.getServerConnection().addOutgoing(PlayRunWorkerClientProtocol.class);
    context.getServerConnection().addIncoming(PlayRunWorkerServerProtocol.class, this);
    context.getServerConnection().connect();
    final PlayAppLifecycleUpdate result = startServer();
    try {
        clientProtocol.update(result);
        stop.await();
    } catch (InterruptedException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    } finally {
        clientProtocol.update(PlayAppLifecycleUpdate.stopped());
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:PlayWorkerServer.java


示例17: dispatch

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public void dispatch(final T message) {
    lock.lock();
    try {
        while (state != State.Stopped && queue.size() >= maxQueueSize) {
            try {
                condition.await();
            } catch (InterruptedException e) {
                throw new UncheckedException(e);
            }
        }
        if (state == State.Stopped) {
            throw new IllegalStateException("Cannot dispatch message, as this message dispatch has been stopped. Message: " + message);
        }
        queue.add(message);
        condition.signalAll();
    } finally {
        lock.unlock();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:AsyncDispatch.java


示例18: stop

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
/**
 * Stops accepting new messages, and blocks until all queued messages have been dispatched.
 */
public void stop() {
    lock.lock();
    try {
        setState(State.Stopped);
        while (dispatchers > 0) {
            condition.await();
        }

        if (!queue.isEmpty()) {
            throw new IllegalStateException(
                    "Cannot wait for messages to be dispatched, as there are no dispatch threads running.");
        }
    } catch (InterruptedException e) {
        throw new UncheckedException(e);
    } finally {
        lock.unlock();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:22,代码来源:AsyncDispatch.java


示例19: SocketConnection

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
public SocketConnection(SocketChannel socket, MessageSerializer streamSerializer, StatefulSerializer<T> messageSerializer) {
    this.socket = socket;
    try {
        // NOTE: we use non-blocking IO as there is no reliable way when using blocking IO to shutdown reads while
        // keeping writes active. For example, Socket.shutdownInput() does not work on Windows.
        socket.configureBlocking(false);
        outstr = new SocketOutputStream(socket);
        instr = new SocketInputStream(socket);
    } catch (IOException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
    InetSocketAddress localSocketAddress = (InetSocketAddress) socket.socket().getLocalSocketAddress();
    localAddress = new SocketInetAddress(localSocketAddress.getAddress(), localSocketAddress.getPort());
    InetSocketAddress remoteSocketAddress = (InetSocketAddress) socket.socket().getRemoteSocketAddress();
    remoteAddress = new SocketInetAddress(remoteSocketAddress.getAddress(), remoteSocketAddress.getPort());
    objectReader = messageSerializer.newReader(streamSerializer.newDecoder(instr));
    encoder = streamSerializer.newEncoder(outstr);
    objectWriter = messageSerializer.newWriter(encoder);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:SocketConnection.java


示例20: remapClasses

import org.gradle.internal.UncheckedException; //导入依赖的package包/类
private void remapClasses(File scriptCacheDir, File relocalizedDir, RemappingScriptSource source) {
    ScriptSource origin = source.getSource();
    String className = origin.getClassName();
    if (!relocalizedDir.exists()) {
        relocalizedDir.mkdir();
    }
    File[] files = scriptCacheDir.listFiles();
    if (files != null) {
        for (File file : files) {
            String renamed = file.getName();
            if (renamed.startsWith(RemappingScriptSource.MAPPED_SCRIPT)) {
                renamed = className + renamed.substring(RemappingScriptSource.MAPPED_SCRIPT.length());
            }
            ClassWriter cv = new ClassWriter(0);
            BuildScriptRemapper remapper = new BuildScriptRemapper(cv, origin);
            try {
                ClassReader cr = new ClassReader(Files.toByteArray(file));
                cr.accept(remapper, 0);
                Files.write(cv.toByteArray(), new File(relocalizedDir, renamed));
            } catch (IOException ex) {
                throw UncheckedException.throwAsUncheckedException(ex);
            }
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:26,代码来源:FileCacheBackedScriptClassCompiler.java



注:本文中的org.gradle.internal.UncheckedException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BooleanHolder类代码示例发布时间:2022-05-23
下一篇:
Java Velocity类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap