Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,33 +189,33 @@ public synchronized void createJarFile() throws IOException {
this.outputFile.delete();
}

final JarOutputStream jos = new JarOutputStream(new FileOutputStream(this.outputFile), new Manifest());
final Iterator<Class<?>> it = this.classSet.iterator();
while (it.hasNext()) {
try ( JarOutputStream jos = new JarOutputStream(new FileOutputStream(this.outputFile), new Manifest())) {
final Iterator<Class<?>> it = this.classSet.iterator();
while (it.hasNext()) {

final Class<?> clazz = it.next();
final String entry = clazz.getName().replace('.', '/') + CLASS_EXTENSION;
final Class<?> clazz = it.next();
final String entry = clazz.getName().replace('.', '/') + CLASS_EXTENSION;

jos.putNextEntry(new JarEntry(entry));
jos.putNextEntry(new JarEntry(entry));

String name = clazz.getName();
int n = name.lastIndexOf('.');
String className = null;
if (n > -1) {
className = name.substring(n + 1, name.length());
}
//Using the part after last dot instead of class.getSimpleName() could resolve the problem of inner class.
final InputStream classInputStream = clazz.getResourceAsStream(className + CLASS_EXTENSION);
String name = clazz.getName();
int n = name.lastIndexOf('.');
String className = null;
if (n > -1) {
className = name.substring(n + 1, name.length());
}
//Using the part after last dot instead of class.getSimpleName() could resolve the problem of inner class.
final InputStream classInputStream = clazz.getResourceAsStream(className + CLASS_EXTENSION);

int num = classInputStream.read(buf);
while (num != -1) {
jos.write(buf, 0, num);
num = classInputStream.read(buf);
}
int num = classInputStream.read(buf);
while (num != -1) {
jos.write(buf, 0, num);
num = classInputStream.read(buf);
}

classInputStream.close();
jos.closeEntry();
classInputStream.close();
jos.closeEntry();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close() is now never called.

jos.close();
}
}