Skip to content

Commit

Permalink
Fix for windows scan of jar files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thrameos committed Jan 3, 2021
1 parent 3195514 commit 9ee5de7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions native/java/org/jpype/classloader/DynamicClassLoader.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.jpype.classloader;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
Expand All @@ -14,7 +14,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
Expand All @@ -26,8 +25,6 @@
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;

public class DynamicClassLoader extends ClassLoader
{
Expand Down Expand Up @@ -207,17 +204,17 @@ public void scanJar(Path p1)
try ( JarFile jf = new JarFile(p1.toFile()))
{
Enumeration<JarEntry> entries = jf.entries();
Path abs = p1.toAbsolutePath();
URI abs = p1.toAbsolutePath().toUri();
Set urls = new java.util.HashSet();
while (entries.hasMoreElements())
{
JarEntry next = entries.nextElement();
String name = next.getName();

// Skip over META-INF
if (name.startsWith("META-INF/"))
continue;

if (next.isDirectory())
{
// If we find a directory entry then the jar has directories already
Expand All @@ -232,15 +229,15 @@ public void scanJar(Path p1)
if (i == -1)
break;
String name2 = name.substring(0, i);

i++;

// Already have an entry no problem
if (urls.contains(name2))
continue;

// Add a new entry for the missing directory
String jar = "jar:file:" + abs + "!/" + name2 + "/";
String jar = "jar:" + abs + "!/" + name2 + "/";
urls.add(name2);
this.addResource(name2, new URL(jar));
}
Expand Down

0 comments on commit 9ee5de7

Please sign in to comment.