diff --git a/platform/core-impl/src/com/intellij/ide/plugins/cl/PluginClassLoader.java b/platform/core-impl/src/com/intellij/ide/plugins/cl/PluginClassLoader.java index ae65d00e209f..7a6c876b780c 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/cl/PluginClassLoader.java +++ b/platform/core-impl/src/com/intellij/ide/plugins/cl/PluginClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,17 +23,13 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.lang.UrlClassLoader; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import sun.misc.CompoundEnumeration; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; import java.net.URL; -import java.util.Collection; -import java.util.Enumeration; -import java.util.List; -import java.util.ListIterator; +import java.util.*; /** * @author Eugene Zhuravlev @@ -170,12 +166,12 @@ public class PluginClassLoader extends UrlClassLoader { @Override public Enumeration findResources(final String name) throws IOException { - final Enumeration[] resources = new Enumeration[myParents.length + 1]; + @SuppressWarnings("unchecked") Enumeration[] resources = new Enumeration[myParents.length + 1]; resources[0] = super.findResources(name); for (int idx = 0; idx < myParents.length; idx++) { resources[idx + 1] = fetchResources(myParents[idx], name); } - return new CompoundEnumeration(resources); + return new DeepEnumeration(resources); } @SuppressWarnings("UnusedDeclaration") @@ -201,8 +197,8 @@ public class PluginClassLoader extends UrlClassLoader { private static URL fetchResource(ClassLoader cl, String resourceName) { try { - final Method findResourceMethod = getFindResourceMethod(cl.getClass(), "findResource"); - return (URL)findResourceMethod.invoke(cl, resourceName); + Method findResource = getFindResourceMethod(cl.getClass(), "findResource"); + return findResource != null ? (URL)findResource.invoke(cl, resourceName) : null; } catch (Exception e) { Logger.getInstance(PluginClassLoader.class).error(e); @@ -210,10 +206,11 @@ public class PluginClassLoader extends UrlClassLoader { } } - private static Enumeration fetchResources(ClassLoader cl, String resourceName) { + private static Enumeration fetchResources(ClassLoader cl, String resourceName) { try { - final Method findResourceMethod = getFindResourceMethod(cl.getClass(), "findResources"); - return findResourceMethod == null ? null : (Enumeration)findResourceMethod.invoke(cl, resourceName); + Method findResources = getFindResourceMethod(cl.getClass(), "findResources"); + @SuppressWarnings("unchecked") Enumeration e = findResources == null ? null : (Enumeration)findResources.invoke(cl, resourceName); + return e; } catch (Exception e) { Logger.getInstance(PluginClassLoader.class).error(e); @@ -244,4 +241,31 @@ public class PluginClassLoader extends UrlClassLoader { public String toString() { return "PluginClassLoader[" + myPluginId + ", " + myPluginVersion + "]"; } -} + + private static class DeepEnumeration implements Enumeration { + private final Enumeration[] myEnumerations; + private int myIndex = 0; + + public DeepEnumeration(Enumeration[] enumerations) { + myEnumerations = enumerations; + } + + @Override + public boolean hasMoreElements() { + while (myIndex < myEnumerations.length) { + Enumeration e = myEnumerations[myIndex]; + if (e != null && e.hasMoreElements()) return true; + myIndex++; + } + return false; + } + + @Override + public URL nextElement() { + if (!hasMoreElements()) { + throw new NoSuchElementException(); + } + return myEnumerations[myIndex].nextElement(); + } + } +} \ No newline at end of file diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbImagePanel.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbImagePanel.java index cd79a38f3e23..fe3e73141b99 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbImagePanel.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbImagePanel.java @@ -3,10 +3,10 @@ package org.jetbrains.plugins.ipnb.editor.panels.code; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.components.JBLabel; +import com.intellij.util.Base64; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.ipnb.editor.IpnbEditorUtil; import org.jetbrains.plugins.ipnb.format.cells.output.IpnbImageOutputCell; -import sun.misc.BASE64Decoder; import javax.imageio.ImageIO; import javax.swing.*; @@ -28,7 +28,7 @@ public class IpnbImagePanel extends IpnbCodeOutputPanel { final JBLabel label = new JBLabel(); if (!StringUtil.isEmptyOrSpaces(png)) { try { - byte[] btDataFile = new BASE64Decoder().decodeBuffer(png); + byte[] btDataFile = Base64.decode(png); BufferedImage image = ImageIO.read(new ByteArrayInputStream(btDataFile)); label.setIcon(new ImageIcon(image)); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/RenameUtil.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/RenameUtil.java index 38ae3ed4e3d2..541c65bd5fe2 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/RenameUtil.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/RenameUtil.java @@ -21,12 +21,12 @@ import com.intellij.psi.PsiFileFactory; import com.intellij.psi.PsiManager; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.HashSet; -import com.sun.org.apache.xerces.internal.util.XML11Char; import org.intellij.plugins.relaxNG.compact.RncElementTypes; import org.intellij.plugins.relaxNG.compact.RncFileType; import org.intellij.plugins.relaxNG.compact.RncTokenTypes; import org.intellij.plugins.relaxNG.compact.psi.RncFile; import org.intellij.plugins.relaxNG.compact.psi.RncGrammar; +import org.jdom.Verifier; import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -71,10 +71,8 @@ public class RenameUtil { if (name == null) { return false; } - if (XML11Char.isXML11ValidNCName(name)) { - return true; - } - return name.length() >= 2 && name.startsWith("\\") && XML11Char.isXML11ValidNCName(name.substring(1)); + return Verifier.checkXMLName(name) == null || + name.length() >= 2 && name.charAt(0) == '\\' && Verifier.checkXMLName(name.substring(1)) == null; } public static boolean isKeyword(String name) {