Skip to content

Commit f8af878

Browse files
committed
fix for locating class files, refs #67
1 parent 677f789 commit f8af878

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

SublimeJava.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,16 @@ public Class<?> loadClass(String name)
529529
// However, as the default class loader does not reload classes that have changed
530530
// we use the handle to the class to try and get it's actual .class definition
531531
// which we then define in THIS ClassLoader subclass. Hence: dynamic class reloading :)
532-
InputStream s1 = c.getResourceAsStream(c.getName() + ".class");
533-
if (s1 == null)
534-
return c;
535-
s = new DataInputStream(s1);
536-
int len = s.available();
537-
byte[] data = new byte[len];
538-
s.readFully(data);
539-
return defineClass(name, data, 0, len);
532+
String path = ClassLoader.getSystemResource(c.getName().replaceAll("\\.", String.valueOf(File.separatorChar)) + ".class").getFile();
533+
File f = new File(path);
534+
if (!f.exists()) {
535+
return c;
536+
}
537+
int len = (int) f.length();
538+
byte[] data = new byte[len];
539+
s = new DataInputStream(new FileInputStream(f));
540+
s.readFully(data);
541+
return defineClass(name, data, 0, len);
540542
}
541543
catch (Exception e)
542544
{

0 commit comments

Comments
 (0)