本文整理汇总了Java中com.intellij.util.lang.UrlClassLoader类的典型用法代码示例。如果您正苦于以下问题:Java UrlClassLoader类的具体用法?Java UrlClassLoader怎么用?Java UrlClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UrlClassLoader类属于com.intellij.util.lang包,在下文中一共展示了UrlClassLoader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDirURL
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
@NotNull
@Override
protected URL getDirURL() {
if (urlDir != null) {
return urlDir;
}
final URL pageURL = myLoader.getResource(DESCRIPTION_FOLDER + "/" + myDescriptionDirectoryName + "/" + DESCRIPTION_FILE_NAME);
if (LOG.isDebugEnabled()) {
LOG.debug("Path:" + DESCRIPTION_FOLDER + "/" + myDescriptionDirectoryName);
LOG.debug("URL:" + pageURL);
}
if (pageURL != null) {
try {
final String url = pageURL.toExternalForm();
urlDir = UrlClassLoader.internProtocol(new URL(url.substring(0, url.lastIndexOf('/'))));
return urlDir;
}
catch (MalformedURLException e) {
LOG.error(e);
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PostfixTemplateMetaData.java
示例2: getIntentionDescriptionDirURL
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
@Nullable
private static URL getIntentionDescriptionDirURL(ClassLoader aClassLoader, String intentionFolderName) {
final URL pageURL = aClassLoader.getResource(INTENTION_DESCRIPTION_FOLDER + "/" + intentionFolderName + "/" + DESCRIPTION_FILE_NAME);
if (LOG.isDebugEnabled()) {
LOG.debug("Path:" + "intentionDescriptions/" + intentionFolderName);
LOG.debug("URL:" + pageURL);
}
if (pageURL != null) {
try {
final String url = pageURL.toExternalForm();
return UrlClassLoader.internProtocol(new URL(url.substring(0, url.lastIndexOf('/'))));
}
catch (MalformedURLException e) {
LOG.error(e);
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IntentionActionMetaData.java
示例3: createCompilationClassLoader
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
@NotNull
private JointCompilationClassLoader createCompilationClassLoader(Collection<String> compilationClassPath) throws MalformedURLException {
ClassLoader parent = obtainParentLoader(compilationClassPath);
return new JointCompilationClassLoader(UrlClassLoader.build().
urls(toUrls(compilationClassPath)).parent(parent).allowLock().
useCache(ourLoaderCachePool, new UrlClassLoader.CachingCondition() {
@Override
public boolean shouldCacheData(@NotNull URL url) {
try {
String file = FileUtil.toCanonicalPath(new File(url.toURI()).getPath());
for (String output : myOutputs) {
if (FileUtil.startsWith(output, file)) {
return false;
}
}
return true;
}
catch (URISyntaxException e) {
LOG.info(e);
return false;
}
}
}));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:InProcessGroovyc.java
示例4: addURL
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
public void addURL(UrlClassLoader classLoader, URL u) throws Exception {
if (classLoader != null) {
System.out.println("Classloader loaded successfully: " + classLoader);
} else {
System.err.println("Cannot load system classloader!");
}
Class sysclass = UrlClassLoader.class;
try {
Method method = sysclass.getDeclaredMethod("addURL", parameters);
method.setAccessible(true);
method.invoke(classLoader, new Object[]{u});
} catch (Exception e) {
System.err.println("Error, could not add URL " + u.getPath() + " to classloader!");
e.printStackTrace();
throw e;
}
}
开发者ID:cr4igo,项目名称:firstspiritlanguagesupport,代码行数:21,代码来源:FirstSpiritClassPathHack.java
示例5: getIntentionDescriptionDirURL
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
@Nullable
private static URL getIntentionDescriptionDirURL(ClassLoader aClassLoader, String intentionFolderName) {
final URL pageURL = aClassLoader.getResource(INTENTION_DESCRIPTION_FOLDER + "/" + intentionFolderName+"/"+ DESCRIPTION_FILE_NAME);
if (LOG.isDebugEnabled()) {
LOG.debug("Path:"+"intentionDescriptions/" + intentionFolderName);
LOG.debug("URL:"+pageURL);
}
if (pageURL != null) {
try {
final String url = pageURL.toExternalForm();
return UrlClassLoader.internProtocol(new URL(url.substring(0, url.lastIndexOf('/'))));
}
catch (MalformedURLException e) {
LOG.error(e);
}
}
return null;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:IntentionActionMetaData.java
示例6: initClassloader
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
public static UrlClassLoader initClassloader(final List<URL> classpathElements, boolean updatePlugins) throws Exception {
PathManager.loadProperties();
addParentClasspath(classpathElements);
addIDEALibraries(classpathElements);
addAdditionalClassPath(classpathElements);
filterClassPath(classpathElements);
UrlClassLoader newClassLoader = new UrlClassLoader(classpathElements, null, true, true);
// prepare plugins
if (updatePlugins && !isLoadingOfExternalPluginsDisabled()) {
try {
StartupActionScriptManager.executeActionScript();
}
catch (IOException e) {
Main.showMessage("Plugin Installation Error", e);
}
}
Thread.currentThread().setContextClassLoader(newClassLoader);
return newClassLoader;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:ClassloaderUtil.java
示例7: computeWhiteList
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
public static Map<String, Set<String>> computeWhiteList(final File toolsApiJarFile) {
try {
final THashMap<String, Set<String>> map = new THashMap<String, Set<String>>();
ClassLoader loader = new UrlClassLoader(Collections.singletonList(toolsApiJarFile.toURI().toURL()), AppEngineSdkUtil.class.getClassLoader());
final Class<?> whiteListClass = Class.forName("com.google.apphosting.runtime.security.WhiteList", true, loader);
final Set<String> classes = (Set<String>) whiteListClass.getMethod("getWhiteList").invoke(null);
for (String qualifiedName : classes) {
final String packageName = StringUtil.getPackageName(qualifiedName);
Set<String> classNames = map.get(packageName);
if (classNames == null) {
classNames = new THashSet<String>();
map.put(packageName, classNames);
}
classNames.add(StringUtil.getShortName(qualifiedName));
}
return map;
}
catch (Exception e) {
LOG.error(e);
return Collections.emptyMap();
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:AppEngineSdkUtil.java
示例8: getDirURL
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
@Override
protected URL getDirURL() {
if (urlDir != null) {
return urlDir;
}
final URL pageURL = myLoader.getResource(DESCRIPTION_FOLDER + "/" + myDescriptionDirectoryName + "/" + DESCRIPTION_FILE_NAME);
if (LOG.isDebugEnabled()) {
LOG.debug("Path:" + DESCRIPTION_FOLDER + "/" + myDescriptionDirectoryName);
LOG.debug("URL:" + pageURL);
}
if (pageURL != null) {
try {
final String url = pageURL.toExternalForm();
urlDir = UrlClassLoader.internProtocol(new URL(url.substring(0, url.lastIndexOf('/'))));
return urlDir;
}
catch (MalformedURLException e) {
LOG.error(e);
}
}
return null;
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:PostfixTemplateMetaData.java
示例9: createUsersClassLoader
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
public static ClassLoader createUsersClassLoader(JavaTestConfigurationBase configuration)
{
Module module = configuration.getConfigurationModule().getModule();
List<URL> urls = new ArrayList<>();
PathsList pathsList = ReadAction.compute(() -> (module == null || configuration.getTestSearchScope() == TestSearchScope.WHOLE_PROJECT ? OrderEnumerator.orderEntries(configuration.getProject
()) : OrderEnumerator.orderEntries(module)).runtimeOnly().recursively().getPathsList()); //include jdk to avoid NoClassDefFoundError for classes inside tools.jar
for(VirtualFile file : pathsList.getVirtualFiles())
{
try
{
urls.add(VfsUtilCore.virtualToIoFile(file).toURI().toURL());
}
catch(MalformedURLException ignored)
{
LOG.info(ignored);
}
}
return UrlClassLoader.build().allowLock().useCache().urls(urls).get();
}
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:TestClassCollector.java
示例10: reloadIfNecessary
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
/**
* There is a possible case that methods of particular object should be executed with classpath different from the one implied
* by the current class' class loader. External system offers {@link ParametersEnhancer#enhanceLocalProcessing(List)} method
* for defining that custom classpath.
* <p/>
* It's also possible that particular implementation of {@link ParametersEnhancer} is compiled using dependency to classes
* which are provided by the {@link ParametersEnhancer#enhanceLocalProcessing(List) expanded classpath}. E.g. a class
* <code>'A'</code> might use method of class <code>'B'</code> and 'A' is located at the current (system/plugin) classpath but
* <code>'B'</code> is not. We need to reload <code>'A'</code> using its expanded classpath then, i.e. create new class loaded
* with that expanded classpath and load <code>'A'</code> by it.
* <p/>
* This method allows to do that.
*
* @param clazz custom classpath-aware class which instance should be created (is assumed to have a no-args constructor)
* @param <T> target type
* @return newly created instance of the given class loaded by custom classpath-aware loader
* @throws IllegalAccessException as defined by reflection processing
* @throws InstantiationException as defined by reflection processing
* @throws NoSuchMethodException as defined by reflection processing
* @throws InvocationTargetException as defined by reflection processing
* @throws ClassNotFoundException as defined by reflection processing
*/
@NotNull
public static <T extends ParametersEnhancer> T reloadIfNecessary(@NotNull final Class<T> clazz)
throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException, ClassNotFoundException
{
T instance = clazz.newInstance();
List<URL> urls = ContainerUtilRt.newArrayList();
instance.enhanceLocalProcessing(urls);
if (urls.isEmpty()) {
return instance;
}
final ClassLoader baseLoader = clazz.getClassLoader();
Method method = baseLoader.getClass().getMethod("getUrls");
if (method != null) {
//noinspection unchecked
urls.addAll((Collection<? extends URL>)method.invoke(baseLoader));
}
UrlClassLoader loader = new UrlClassLoader(UrlClassLoader.build().urls(urls).parent(baseLoader.getParent())) {
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
if (name.equals(clazz.getName())) {
return super.loadClass(name, resolve);
}
else {
try {
return baseLoader.loadClass(name);
}
catch (ClassNotFoundException e) {
return super.loadClass(name, resolve);
}
}
}
};
//noinspection unchecked
return (T)loader.loadClass(clazz.getName()).newInstance();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:59,代码来源:ExternalSystemApiUtil.java
示例11: initClassLoader
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
@NotNull
public static ClassLoader initClassLoader(boolean updatePlugins) throws MalformedURLException {
PathManager.loadProperties();
Collection<URL> classpath = new LinkedHashSet<URL>();
addParentClasspath(classpath);
addIDEALibraries(classpath);
addAdditionalClassPath(classpath);
UrlClassLoader.Builder builder = UrlClassLoader.build()
.urls(filterClassPath(new ArrayList<URL>(classpath)))
.allowLock()
.usePersistentClasspathIndexForLocalClassDirectories()
.useCache();
if (Boolean.valueOf(System.getProperty(PROPERTY_ALLOW_BOOTSTRAP_RESOURCES, "true"))) {
builder.allowBootstrapResources();
}
UrlClassLoader newClassLoader = builder.get();
// prepare plugins
if (updatePlugins && !isLoadingOfExternalPluginsDisabled()) {
try {
StartupActionScriptManager.executeActionScript();
}
catch (IOException e) {
Main.showMessage("Plugin Installation Error", e);
}
}
Thread.currentThread().setContextClassLoader(newClassLoader);
return newClassLoader;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:BootstrapClassLoaderUtil.java
示例12: createClassLoader
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
@NotNull
private static ClassLoader createClassLoader() throws MalformedURLException, URISyntaxException {
Collection<URL> classpath = Sets.newLinkedHashSet();
addParentClassPath(classpath);
addIdeaLibraries(classpath);
addAdditionalClassPath(classpath);
UrlClassLoader.Builder builder = UrlClassLoader.build()
.urls(filterClassPath(Lists.newArrayList(classpath)))
.allowLock(false)
.usePersistentClasspathIndexForLocalClassDirectories()
.useCache();
if (SystemProperties.getBooleanProperty(PROPERTY_ALLOW_BOOTSTRAP_RESOURCES, true)) {
builder.allowBootstrapResources();
}
UrlClassLoader newClassLoader = builder.get();
// prepare plugins
try {
StartupActionScriptManager.executeActionScript();
}
catch (IOException e) {
Main.showMessage("Plugin Installation Error", e);
}
Thread.currentThread().setContextClassLoader(newClassLoader);
return newClassLoader;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:IdeTestApplication.java
示例13: getClassPathEntries
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
@Override
protected Collection getClassPathEntries() {
final Collection entries = super.getClassPathEntries();
final Module[] modules = ModuleManager.getInstance(myProject).getModules();
for (Module module : modules) {
final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
if (extension != null) {
final VirtualFile outputFile = extension.getCompilerOutputPath();
try {
if (outputFile != null) {
final URL outputURL = VfsUtilCore.virtualToIoFile(outputFile).toURI().toURL();
entries.add(new ClassPathEntry(outputFile.getPath(), UrlClassLoader.build().urls(outputURL).get()));
}
if (myCurrentSuite.isTrackTestFolders()) {
final VirtualFile testOutput = extension.getCompilerOutputPathForTests();
if (testOutput != null) {
final URL testOutputURL = VfsUtilCore.virtualToIoFile(testOutput).toURI().toURL();
entries.add(new ClassPathEntry(testOutput.getPath(), UrlClassLoader.build().urls(testOutputURL).get()));
}
}
}
catch (MalformedURLException e1) {
LOG.error(e1);
}
}
}
return entries;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:IdeaClassFinder.java
示例14: main
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
public static void main(String[] args, String mainClass, String methodName, List<URL> classpathElements) throws Exception {
UrlClassLoader newClassLoader = ClassloaderUtil.initClassloader(classpathElements, args.length == 0);
WindowsCommandLineProcessor.ourMirrorClass = Class.forName(WindowsCommandLineProcessor.class.getName(), true, newClassLoader);
Class<?> klass = Class.forName(PLUGIN_MANAGER, true, newClassLoader);
Method startMethod = klass.getDeclaredMethod("start", String.class, String.class, String[].class);
startMethod.setAccessible(true);
startMethod.invoke(null, mainClass, methodName, args);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:Bootstrap.java
示例15: composeUserClassLoader
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
private static UrlClassLoader composeUserClassLoader(Project project) {
final List<URL> urls = new ArrayList<URL>();
final List<String> list = OrderEnumerator.orderEntries(project).recursively().runtimeOnly().getPathsList().getPathList();
for (String path : list) {
try {
urls.add(new File(FileUtil.toSystemIndependentName(path)).toURI().toURL());
}
catch (MalformedURLException e1) {
LOG.info(e1);
}
}
return new UrlClassLoader(urls, null);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:JavaFxInjectPageLanguageIntention.java
示例16: composeUserClassLoader
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
private static UrlClassLoader composeUserClassLoader(Project project) {
final List<URL> urls = new ArrayList<URL>();
final List<String> list = OrderEnumerator.orderEntries(project).recursively().runtimeOnly().getPathsList().getPathList();
for (String path : list) {
try {
urls.add(new File(FileUtil.toSystemIndependentName(path)).toURI().toURL());
}
catch (MalformedURLException e1) {
LOG.info(e1);
}
}
return UrlClassLoader.build().urls(urls).get();
}
开发者ID:consulo,项目名称:consulo-javafx,代码行数:15,代码来源:JavaFxInjectPageLanguageIntention.java
示例17: reloadIfNecessary
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
/**
* There is a possible case that methods of particular object should be executed with classpath different from the one implied
* by the current class' class loader. External system offers {@link ParametersEnhancer#enhanceLocalProcessing(List)} method
* for defining that custom classpath.
* <p>
* It's also possible that particular implementation of {@link ParametersEnhancer} is compiled using dependency to classes
* which are provided by the {@link ParametersEnhancer#enhanceLocalProcessing(List) expanded classpath}. E.g. a class
* <code>'A'</code> might use method of class <code>'B'</code> and 'A' is located at the current (system/plugin) classpath but
* <code>'B'</code> is not. We need to reload <code>'A'</code> using its expanded classpath then, i.e. create new class loaded
* with that expanded classpath and load <code>'A'</code> by it.
* <p>
* This method allows to do that.
*
* @param clazz custom classpath-aware class which instance should be created (is assumed to have a no-args constructor)
* @param <T> target type
* @return newly created instance of the given class loaded by custom classpath-aware loader
* @throws IllegalAccessException as defined by reflection processing
* @throws InstantiationException as defined by reflection processing
* @throws NoSuchMethodException as defined by reflection processing
* @throws InvocationTargetException as defined by reflection processing
* @throws ClassNotFoundException as defined by reflection processing
*/
@Nonnull
public static <T extends ParametersEnhancer> T reloadIfNecessary(@Nonnull final Class<T> clazz)
throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException, ClassNotFoundException {
T instance = clazz.newInstance();
List<URL> urls = ContainerUtilRt.newArrayList();
instance.enhanceLocalProcessing(urls);
if (urls.isEmpty()) {
return instance;
}
final ClassLoader baseLoader = clazz.getClassLoader();
Method method = baseLoader.getClass().getMethod("getUrls");
if (method != null) {
//noinspection unchecked
urls.addAll((Collection<? extends URL>)method.invoke(baseLoader));
}
UrlClassLoader loader = new UrlClassLoader(UrlClassLoader.build().urls(urls).parent(baseLoader.getParent())) {
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
if (name.equals(clazz.getName())) {
return super.loadClass(name, resolve);
}
else {
try {
return baseLoader.loadClass(name);
}
catch (ClassNotFoundException e) {
return super.loadClass(name, resolve);
}
}
}
};
//noinspection unchecked
return (T)loader.loadClass(clazz.getName()).newInstance();
}
开发者ID:consulo,项目名称:consulo,代码行数:58,代码来源:ExternalSystemApiUtil.java
示例18: addPlatformLoaderParentIfOnJdk9
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
public static void addPlatformLoaderParentIfOnJdk9(@Nonnull UrlClassLoader.Builder builder) {
if (SystemInfo.IS_AT_LEAST_JAVA9) {
// on Java 8, 'tools.jar' is on a classpath; on Java 9, its classes are available via the platform loader
try {
ClassLoader platformCl = (ClassLoader)ClassLoader.class.getMethod("getPlatformClassLoader").invoke(null);
builder.parent(platformCl);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:ClassLoaderUtil.java
示例19: hasLoadedClass
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
private static boolean hasLoadedClass(@Nonnull String className, ClassLoader loader) {
if (loader instanceof UrlClassLoader) return ((UrlClassLoader)loader).hasLoadedClass(className);
// it can be an UrlClassLoader loaded by another class loader, so instanceof doesn't work
try {
return (Boolean)loader.getClass().getMethod("hasLoadedClass", String.class).invoke(loader, className);
}
catch (Exception e) {
return false;
}
}
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:PluginManagerCore.java
示例20: ResourceTextDescriptor
import com.intellij.util.lang.UrlClassLoader; //导入依赖的package包/类
public ResourceTextDescriptor(@NotNull URL url) {
myUrl = UrlClassLoader.internProtocol(url);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ResourceTextDescriptor.java
注:本文中的com.intellij.util.lang.UrlClassLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论