private void loadTypeFromUrl(URL url) throws IOException
      {
          // Handle a class file:
          String protocol = url.getProtocol();
          if ("file".equals(protocol))
          {
              File file = new File(
                  URLDecoder.decode(url.getFile(), "UTF8"));
              if (!file.isDirectory())
                  loadTypeFromFile(file);
          }

          // Handle a JAR file:
          else if ("jar".equals(protocol))
          {
              JarURLConnection con =
                  (JarURLConnection)url.openConnection();
              loadTypeFromZipEntry(con.getJarFile(),  con.getJarEntry());
          }
      }

Just to clarify, as I have not used these particular APIs:

Does this allow the enhancer to get a read/write File handle for a URL
that's in the classpath?

Yes, if there is no permission restriction.

And if it's a jar file, does it allow the  enhancer to replace files
within it?

Craig

As far as I know you cannot replace an entry in a jar file using the
standard Java API. You can however, override the file with a new
complete jar file.

Ilan

Reply via email to