Workaround for http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4466485

<p>This workaround is not working for file resources in jars. You will get a
NullPointerException because the URL cannot be converted to URI.
331356
private static File getFile(URL resourceUrl) {
    try {
      return new File(new URI(resourceUrl.toString()).getPath());
    } catch (URISyntaxException e) {
      throw new RuntimeException(e);
    } catch (NullPointerException npe) {
      LOG.error("NullPointerException is thrown. Resource url: {} ", resourceUrl);
      throw new RuntimeException(npe);
    }
  }
564814
@Override
    public List<URL> getJarFileUrls() {
        List<URL> urls = new ArrayList<>();
        for (String url : persistenceUnitXml.getJarFile()) {
            try {
                urls.add(new URL(url));
            } catch (MalformedURLException e) {
                LOGGER.error("Cannot create an URL object from {}", url, e);
            }
        }
        return urls;
    }
152811
public static Uri getFileUri(Activity activity, File file) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            return FileProvider.getUriForFile(activity, activity.getPackageName() + ".file.path.share", file);
        }
        return Uri.fromFile(file);
    }
1203766
private static boolean isJarURL(final URL rootDirResource) {

        final String protocol = rootDirResource.getProtocol();

        /**
         * Determine whether the given URL points to a resource in a jar file, that is, has protocol "jar", "zip",
         * "wsjar" or "code-source".
         * <p>
         * "zip" and "wsjar" are used by BEA WebLogic Server and IBM WebSphere, respectively, but can be treated like
         * jar files. The same applies to "code-source" URLs on Oracle OC4J, provided that the path contains a jar
         * separator.
         * *
         */
        return "jar".equals(protocol) || "zip".equals(protocol) || "wsjar".equals(protocol)
                || ("code-source".equals(protocol) && rootDirResource.getPath().contains(JAR_URL_SEPARATOR));

    }
6710
public URL getResourceURL(String filepath, URL urlCodeBase, String version, ClassLoader classLoader) throws RuntimeException
    {
        if (filepath == null)
            return null;
        if (File.separatorChar != '/')
            filepath = filepath.replace(File.separatorChar, '/'); // Just in case I get a window's path

        boolean isResource = true;
        if (urlCodeBase != null)
        	if ("file".equalsIgnoreCase(urlCodeBase.getProtocol()))
        		isResource = false;
        URL url = null;
        try {
        	if (isResource)
        		if (classLoader != null)
        		{
        			url = classLoader.getResource(filepath);
        			if (url == null)
        			    if (filepath.startsWith("/"))
        			        url = classLoader.getResource(filepath.substring(1));    // Classpaths shouldn't start with root
        		}
        } catch (Exception e) {
            // Keep trying
        }

        if (url == null)
        {
        	if (isResource)
        		if (this.getClassFinder(null) != null)
        			url = this.getClassFinder(null).findResourceURL(filepath, version);	// Try to find this class in the obr repos
        }

        if (url == null)
        {
            try
            {
                if (urlCodeBase != null)
                    url = new URL(urlCodeBase, filepath);
            } catch(MalformedURLException ex) {
                // Keep trying
            } catch (Exception e) {
                // Keep trying
            }
        }
        return url;
    }
1317161
@Override
  public URL getURL() throws IOException {
    URL url = this.servletContext.getResource(this.path);
    if (url == null) { throw new FileNotFoundException(getDescription()
        + " cannot be resolved to URL because it does not exist"); }
    return url;
  }
1072777
protected void init(IRI uri) throws IOException, MalformedURLException {
        if (!uri.getScheme().equals("data")) {
            throw new IllegalArgumentException("The input did not start with data:.");
        }

        if (uri.getRawFragment() != null) {
            throw new MalformedURLException("Fragment is not allowed for data: URIs according to RFC 2397. But if strictly comply with RFC 3986, ignore this error.");
        }

        InputStream is = new PercentDecodingReaderInputStream(new StringReader(uri.getRawPath()));
        StringBuilder sb = new StringBuilder();
        State state = State.AT_START;
        int i = 0; // string counter
        for (;;i++) {
            int b = is.read();
            if (b == -1) {
                throw new MalformedURLException("Premature end of URI.");
            }
            if (b >= 0x80) {
                throw new MalformedURLException("Non-ASCII character in MIME type part of the data URI.");                
            }
            char c = (char) b;
            sb.append(c);
            switch (state) {
                case AT_START:
                    if (isTokenChar(c)) {
                        state = State.IN_SUPERTYPE;
                        continue;
                    } else if (c == ';') {
                        sb.setLength(0);
                        sb.append("text/plain;");
                        state = State.SEMICOLON_SEEN;
                        continue;
                    } else if (c == ',') {
                        contentType = "text/plain;charset=US-ASCII";
                        inputStream = is;
                        return;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected a token character or a semicolon but saw ",
                                        c, " instead.");
                    }
                case IN_SUPERTYPE:
                    if (isTokenChar(c)) {
                        continue;
                    } else if (c == '/') {
                        state = State.AT_SUBTYPE_START;
                        continue;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected a token character or \u201C/\u201D but saw ",
                                        c, " instead.");
                    }
                case AT_SUBTYPE_START:
                    if (isTokenChar(c)) {
                        state = State.IN_SUBTYPE;
                        continue;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected a token character but saw ",
                                        c, " instead.");
                    }
                case IN_SUBTYPE:
                    if (isTokenChar(c)) {
                        continue;
                    } else if (c == ';') {
                        state = State.SEMICOLON_SEEN;
                        continue;
                    } else if (isWhitespace(c)) {
                        state = State.WS_BEFORE_SEMICOLON;
                        continue;
                    } else if (c == ',') {
                        contentType = sb.substring(0, sb.length() - 1);
                        inputStream = is;
                        return;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected a token character, whitespace, a semicolon or a comma but saw ",
                                        c, " instead.");
                    }
                case WS_BEFORE_SEMICOLON:
                    if (isWhitespace(c)) {
                        continue;
                    } else if (c == ';') {
                        state = State.SEMICOLON_SEEN;
                        continue;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected whitespace or a semicolon but saw ",
                                        c, " instead.");
                    }
                case SEMICOLON_SEEN:
                    if (isWhitespace(c)) {
                        continue;
                    } else if (isTokenChar(c)) {
                        state = State.IN_PARAM_NAME;
                        continue;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected whitespace or a token character but saw ",
                                        c, " instead.");
                    }
                case IN_PARAM_NAME:
                    if (isTokenChar(c)) {
                        continue;
                    } else if (c == '=') {
                        state = State.EQUALS_SEEN;
                        continue;
                    } else if (c == ',') {
                        // let's see if we had ;base64,
                        int baseFirst = sb.length() - 8;
                        if (baseFirst >= 0 && ";base64,".equals(sb.substring(baseFirst, sb.length()))) {
                            contentType = sb.substring(0, baseFirst);
                            inputStream = new Base64InputStream(is);
                            return;
                        }
                    } else {
                        throw newDatatypeException(i, 
                                "Expected an equals sign, a comma or a token character but saw ",
                                        c, " instead.");
                    }
                case EQUALS_SEEN:
                    if (c == '\"') {
                        state = State.IN_QUOTED_STRING;
                        continue;
                    } else if (isTokenChar(c)) {
                        state = State.IN_UNQUOTED_STRING;
                        continue;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected a double quote or a token character but saw ",
                                        c, " instead.");
                    }
                case IN_QUOTED_STRING:
                    if (c == '\\') {
                        state = State.IN_QUOTED_PAIR;
                        continue;
                    } else if (c == '\"') {
                        state = State.CLOSE_QUOTE_SEEN;
                        continue;
                    } else if (isQDTextChar(c)) {
                        continue;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected a non-control ASCII character but saw ",
                                        c, " instead.");
                    }
                case IN_QUOTED_PAIR:
                    if (c <= 127) {
                        state = State.IN_QUOTED_STRING;
                        continue;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected an ASCII character but saw ",
                                        c, " instead.");
                    }
                case CLOSE_QUOTE_SEEN:
                    if (c == ';') {
                        state = State.SEMICOLON_SEEN;
                        continue;
                    } else if (isWhitespace(c)) {
                        state = State.WS_BEFORE_SEMICOLON;
                        continue;
                    } else if (c == ',') {
                        contentType = sb.substring(0, sb.length() - 1);
                        inputStream = is;
                        return;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected an ASCII character but saw ",
                                        c, " instead.");
                    }
                case IN_UNQUOTED_STRING:
                    if (isTokenChar(c)) {
                        continue;
                    } else if (c == ';') {
                        state = State.SEMICOLON_SEEN;
                        continue;
                    } else if (isWhitespace(c)) {
                        state = State.WS_BEFORE_SEMICOLON;
                        continue;
                    } else if (c == ',') {
                        contentType = sb.substring(0, sb.length() - 1);
                        inputStream = is;
                        return;
                    } else {
                        throw newDatatypeException(i, 
                                "Expected a token character, whitespace, a semicolon, or a comma but saw ",
                                        c, " instead.");
                    }
            }
        }

    }
462594
private String getContent(TreeLogger logger, String path, String src)
      throws UnableToCompleteException {
    HttpURLConnection connection = null;
    InputStream in = null;
    try {
      if (!src.matches("(?i)https?://.*")) {
        String file = path + "/" + src;
        in = this.getClass().getClassLoader().getResourceAsStream(file);
        if (in == null) {
          // If we didn't find the resource relative to the package, assume it is absolute.
          file = src;
          in = this.getClass().getClassLoader().getResourceAsStream(file); 
        }
        if (in != null) {
          logger.log(TreeLogger.INFO, getClass().getSimpleName()
              + " - importing external javascript: " + file);
        } else {
          logger.log(TreeLogger.ERROR, "Unable to read javascript file: " + file);
        }
      } else {
        logger.log(TreeLogger.INFO, getClass().getSimpleName()
            + " - downloading external javascript: " + src);
        URL url = new URL(src);
        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
        connection.setRequestProperty("Host", url.getHost());
        connection.setConnectTimeout(3000);
        connection.setReadTimeout(3000);

        int status = connection.getResponseCode();
        if (status != HttpURLConnection.HTTP_OK) {
          logger.log(TreeLogger.ERROR, "Server Error: " + status + " "
              + connection.getResponseMessage());
          throw new UnableToCompleteException();
        }

        String encoding = connection.getContentEncoding();
        in = connection.getInputStream();
        if ("gzip".equalsIgnoreCase(encoding)) {
          in = new GZIPInputStream(in);
        } else if ("deflate".equalsIgnoreCase(encoding)) {
          in = new InflaterInputStream(in);
        }
      }

      return inputStreamToString(in);
    } catch (IOException e) {
      logger.log(TreeLogger.ERROR, "Error: " + e.getMessage());
      throw new UnableToCompleteException();
    } finally {
      if (connection != null) {
        connection.disconnect();
      }
    }
  }
1257581
public static URL getURL(File file) {
		Assert.notNull(file, "File is null !");
		try {
			return file.toURI().toURL();
		} catch (MalformedURLException e) {
			throw new UtilException(e, "Error occured when get URL!");
		}
	}
645463
@Override
    public Resource createResource(URI uri) {
        DroolsFactoryImpl.init();
        BpsimFactoryImpl.init();
        JBPMBpmn2ResourceImpl result = new JBPMBpmn2ResourceImpl(uri);
        ExtendedMetaData extendedMetadata = new XmlExtendedMetadata();
        result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
                                           extendedMetadata);
        result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
                                           extendedMetadata);

        result.getDefaultSaveOptions().put(XMLResource.OPTION_SAVE_TYPE_INFORMATION,
                                           new OnlyContainmentTypeInfo());

        result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
                                           Boolean.TRUE);
        result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
                                           Boolean.TRUE);

        result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER,
                                           Boolean.TRUE);

        result.getDefaultSaveOptions().put(XMLResource.OPTION_ELEMENT_HANDLER,
                                           new ElementHandlerImpl(true));

        result.getDefaultSaveOptions().put(XMLResource.OPTION_ENCODING,
                                           "UTF-8");
        result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE,
                                           new ArrayList<Object>());
        result.getDefaultSaveOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,
                                           true);
        result.getDefaultSaveOptions().put(XMLResource.OPTION_PROCESS_DANGLING_HREF,
                                           XMLResource.OPTION_PROCESS_DANGLING_HREF_RECORD);

        return result;
    }
745144
private void generateURIForMethod(SQLiteDatabaseSchema schema, List<FieldSpec> listFieldAlias, Set<String> alreadyUsedName, Converter<String, String> format, Pair<String, ContentEntry> entry,
			SQLiteModelMethod method) {
		if (method == null)
			return;
		String alias = "URI_" + entry.value1.pathCostant.substring(0, entry.value1.pathCostant.lastIndexOf("_")).replace("PATH_", "") + "_" + format.convert(method.getName());
		if (!alreadyUsedName.contains(alias)) {
			String contentUri = schema.contentProviderUri().replace("*", "[*]") + "/" + entry.value1.uriTemplate.replace("*", "[*]");
			String contentUriWithParameter = method.contentProviderUri().replace("*", "[*]");

			listFieldAlias.add(FieldSpec.builder(Uri.class, alias, Modifier.STATIC, Modifier.FINAL, Modifier.PUBLIC).addJavadoc("<h2>URI standard</h2>\n<pre>$L</pre></p>\n", contentUri)
					.addJavadoc("<h2>URI with parameters</h2>\n<pre>$L</pre>\n\n", contentUriWithParameter)
					.addJavadoc("<p>Method associated to this URI is {@link $LImpl#$L}</p>\n", method.getParent().getName(), method.contentProviderMethodName)
					.initializer(CodeBlock.of("URI_" + entry.value1.pathCostant)).build());
			alreadyUsedName.add(alias);
		}
	}
1282389
public static void openFile(
		ServletContext servletContext,
		HttpServletRequest request,
		HttpServletResponse response,
		DomainName domain,
		Path book,
		final Path path
	) throws ServletException, IOException, SkipPageException {
		// Only allow from localhost and when open enabled
		if(!isAllowed(servletContext, request)) {
			response.sendError(HttpServletResponse.SC_FORBIDDEN);
			throw ServletUtil.SKIP_PAGE_EXCEPTION;
		} else {
			final String[] command;
			ResourceRef resourceRef = ResourceRefResolver.getResourceRef(servletContext, request, domain, book, path.toString());
			Book bookObj = SemanticCMS.getInstance(servletContext).getBook(resourceRef.getBookRef());
			if(bookObj.isAccessible()) throw new FileNotFoundException("Book is inaccessible: " + resourceRef);
			ResourceStore resourceStore = bookObj.getResources();
			if(!resourceStore.isAvailable()) throw new FileNotFoundException("Resource store is unavailable: " + resourceRef);
			java.io.File resourceFile = resourceStore.getResource(resourceRef.getPath()).getFile();
			if(resourceFile == null) throw new FileNotFoundException("Resource is not a local file: " + resourceRef);
			if(resourceFile.isDirectory()) {
				command = new String[] {
					// TODO: What is good windows path?
					//isWindows()
					//	? "C:\\Program Files (x86)\\OpenOffice 4\\program\\swriter.exe"
					"/usr/bin/konqueror",
					resourceFile.getCanonicalPath()
				};
			} else {
				// Open the file with the appropriate application based on extension
				String extension = FileUtils.getExtension(resourceFile.getName()).toLowerCase(Locale.ROOT);
				// Check registered file openers first
				FileOpener fileOpener;
				synchronized(fileOpenersLock) {
					@SuppressWarnings("unchecked")
					Map<String,FileOpener> fileOpeners = (Map<String,FileOpener>)servletContext.getAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
					if(fileOpeners != null) {
						fileOpener = fileOpeners.get(extension);
					} else {
						fileOpener = null;
					}
				}
				if(fileOpener != null) {
					command = fileOpener.getCommand(resourceFile);
				} else {
					// Use default behavior
					switch(extension) {
						case "gif" :
						case "jpg" :
						case "jpeg" :
						case "png" :
							command = new String[] {
								isWindows()
									? "C:\\Program Files (x86)\\OpenOffice 4\\program\\swriter.exe"
									: "/usr/bin/gwenview",
								resourceFile.getCanonicalPath()
							};
							break;
						case "doc" :
						case "docx" :
						case "odt" :
							command = new String[] {
								isWindows()
									? "C:\\Program Files (x86)\\OpenOffice 4\\program\\swriter.exe"
									: "/usr/bin/libreoffice",
								"--writer",
								resourceFile.getCanonicalPath()
							};
							break;
						case "csv" :
						case "ods" :
						case "sxc" :
						case "xls" :
							command = new String[] {
								isWindows()
									? "C:\\Program Files (x86)\\OpenOffice 4\\program\\scalc.exe"
									: "/usr/bin/libreoffice",
								"--calc",
								resourceFile.getCanonicalPath()
							};
							break;
						case "pdf" :
							command = new String[] {
								isWindows()
									? "C:\\Program Files (x86)\\Adobe\\Reader 11.0\\Reader\\AcroRd32.exe"
									: "/usr/bin/okular",
								resourceFile.getCanonicalPath()
							};
							break;
						case "c" :
						case "csh" :
						case "h" :
						case "java" :
						case "jsp" :
						case "jspx" :
						case "sh" :
						case "txt" :
						case "xml" :
							if(isWindows()) {
								command = new String[] {
									"C:\\Program Files\\NetBeans 7.4\\bin\\netbeans64.exe",
									"--open",
									resourceFile.getCanonicalPath()
								};
							} else {
								command = new String[] {
									//"/usr/bin/kwrite",
									"/opt/netbeans-8.0.2/bin/netbeans",
									"--jdkhome",
									getJdkPath(),
									"--open",
									resourceFile.getCanonicalPath()
								};
							}
							break;
						case "dia" :
							command = new String[] {
								isWindows()
									? "C:\\Program Files (x86)\\Dia\\bin\\diaw.exe"
									: "/usr/bin/dia",
								resourceFile.getCanonicalPath()
							};
							break;
						case "zip" :
							if(isWindows()) {
								command = new String[] {
									resourceFile.getCanonicalPath()
								};
							} else {
								command = new String[] {
									"/usr/bin/konqueror",
									resourceFile.getCanonicalPath()
								};
							}
							break;
						case "mp3" :
						case "wma" :
							command = new String[] {
								isWindows()
									? "C:\\Program Files\\VideoLAN\\VLC.exe"
									: "/usr/bin/vlc",
								resourceFile.getCanonicalPath()
							};
							break;
						default :
							throw new IllegalArgumentException("Unsupprted file type by extension: " + extension);
					}
				}
			}
			// Start the process
			final Process process = Runtime.getRuntime().exec(command);
			// Result is watched in the background only
			// Java 1.8: Lambda
			new Thread(
				new Runnable() {
					@Override
					public void run() {
						try {
							final ProcessResult result = ProcessResult.getProcessResult(process);
							int exitVal = result.getExitVal();
							if(exitVal != 0) {
								logger.log(Level.SEVERE, "Non-zero exit status from \"{0}\": {1}", new Object[]{path, exitVal});
							}
							String stdErr = result.getStderr();
							if(!stdErr.isEmpty()) {
								logger.log(Level.SEVERE, "Standard error from \"{0}\":\n{1}", new Object[]{path, stdErr});
							}
							if(logger.isLoggable(Level.INFO)) {
								String stdOut = result.getStdout();
								if(!stdOut.isEmpty()) {
									logger.log(Level.INFO, "Standard output from \"{0}\":\n{1}", new Object[]{path, stdOut});
								}
							}
						} catch(IOException e) {
							logger.log(Level.SEVERE, null, e);
						}
					}
				}
			).start();
		}
	}
1370966
private URL findJarForResource(URL url) {
        // 如果URL的文件部分本身是一个URL，那么该URL可能指向JAR
        try {
            long startTime = System.currentTimeMillis();
            while (true) {
                url = new URL(url.getFile());
                if (System.currentTimeMillis() - startTime > MAX_LIMIT) {
                    break;
                }
            }
        } catch (MalformedURLException expected) {
            // This will happen at some point and serves as a break in the loop
        }

        // Look for the .jar extension and chop off everything after that
        StringBuilder jarUrl = new StringBuilder(url.toExternalForm());
        int index = jarUrl.lastIndexOf(".jar");
        if (index >= 0) {
            jarUrl.setLength(index + 4);
        } else {
            return null;
        }

        // Try to open and test it
        try {
            URL testUrl = new URL(jarUrl.toString());
            if (this.isJar(testUrl)) {
                return testUrl;
            }

            // WebLogic fix: check if the URL's file exists in the filesystem.
            jarUrl.replace(0, jarUrl.length(), testUrl.getFile());
            File file = new File(jarUrl.toString());

            // File name might be URL-encoded
            if (!file.exists()) {
                file = new File(URLEncoder.encode(jarUrl.toString(), "UTF-8"));
            }

            if (file.exists()) {
                testUrl = file.toURI().toURL();
                if (isJar(testUrl)) {
                    return testUrl;
                }
            }
        } catch (MalformedURLException e) {
            log.warn("Invalid JAR URL: " + jarUrl);
        } catch (UnsupportedEncodingException e) {
            throw new ZealotException("Unsupported encoding?  UTF-8?  That's unpossible.");
        }

        return null;
    }
998075
private IDataSource getDataSource(HttpServletRequest request) throws DataSourceNotFoundException {
        String contextPath = request.getContextPath();
        String requestURI = request.getRequestURI();

        String path = contextPath == null
                ? requestURI
                : requestURI.substring(contextPath.length());

        if (path.equals("/") || path.isEmpty()) {
            final String baseURL = FragmentRequestParserBase.extractBaseURL(request, config);
            return new IndexDataSource(baseURL, dataSources);
        }

        String dataSourceName = path.substring(1);
        IDataSource dataSource = dataSources.get(dataSourceName);
        if (dataSource == null) {
            throw new DataSourceNotFoundException(dataSourceName);
        }
        return dataSource;
    }
382628
@Override
    public Facelet getViewMetadataFacelet(FacesContext facesContext, String uri) 
        throws IOException
    {
        URL url = (URL) _relativeLocations.get(uri);
        if (url == null)
        {
            url = resolveURL(facesContext, getBaseUrl(), uri);
            ViewResource viewResource = (ViewResource) facesContext.getAttributes().get(
                FaceletFactory.LAST_RESOURCE_RESOLVED);
            if (url != null)
            {
                if (viewResource != null)
                {
                    // If a view resource has been used to resolve a resource, the cache is in
                    // the ResourceHandler implementation. No need to cache in _relativeLocations.
                }
                else
                {
                    Map<String, URL> newLoc = new HashMap<String, URL>(_relativeLocations);
                    newLoc.put(uri, url);
                    _relativeLocations = newLoc;
                }
            }
            else
            {
                throw new IOException("'" + uri + "' not found.");
            }
        }
        return this.getViewMetadataFacelet(url);
    }
34175
protected final boolean tryResource(String directory, String fileName){
		String path = directory + "/" + fileName;
		if(directory==null){
			path = fileName;
		}

		URL url;
		ClassLoader loader = Thread.currentThread().getContextClassLoader();
		url = loader.getResource(path);
		if(url==null){
			loader = AbstractFileInfo.class.getClassLoader();
			url = loader.getResource(path);
		}
		if(url==null){
			this.errors.addError("could not get Resource URL");
			return false;
		}

		this.url = url;
		this.fullFileName = FilenameUtils.getName(fileName);

		if(directory!=null){
			this.setRootPath = directory;
		}

		return true;
	}
475916
@Override
    @Trivial
    public void open() throws ClassSource_Exception {
        String methodName = "open";
        if ( tc.isEntryEnabled() ) {
            String msg = MessageFormat.format(
                "[ {0} ] State [ {1} ]",
                new Object[] { getHashText(), Integer.valueOf(opens) });
            Tr.entry(tc, methodName, msg);
        }

        if ( (opens < 0) ||
             ((opens == 0) && (jarFile != null)) ||
             ((opens > 0) && (jarFile == null)) ) {

            Tr.warning(tc, "ANNO_CLASSSOURCE_JAR_STATE_BAD", getHashText(), getJarPath(), Integer.valueOf(opens));

            String eMsg = "[ " + getHashText() + " ]" +
                " Failed to open [ " + getJarPath() + " ]" +
                " Count of opens [ " + opens + " ]" +
                " Jar state [ " + jarFile + " ]";
            throw getFactory().newClassSourceException(eMsg);
        }

        opens++;

        if ( jarFile == null ) {
            try {
                jarFile = UtilImpl_FileUtils.createJarFile(jarPath); // throws IOException
            } catch ( IOException e ) {
                Tr.warning(tc, "ANNO_CLASSSOURCE_OPEN4_EXCEPTION", getHashText(), jarPath);
                String eMsg = "[ " + getHashText() + " ] Failed to open [ " + jarPath + " ]";
                throw getFactory().wrapIntoClassSourceException(CLASS_NAME, methodName, eMsg, e);
            }

            if ( tc.isEntryEnabled() ) {
                Tr.exit(tc, methodName, MessageFormat.format("[ {0} ] RETURN (new open)", getHashText()));
            }

        } else {
            if ( tc.isEntryEnabled() ) {
                Tr.exit(tc, methodName, MessageFormat.format("[ {0} ] RETURN (already open)", getHashText()));
            }
        }
    }