Skip to content

Commit

Permalink
fix(core): JARs may not have a manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Feb 8, 2023
1 parent 411a524 commit 645aa2e
Showing 1 changed file with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
Expand All @@ -35,24 +33,11 @@
* @since 0.1.0
*/
public class JarUtils {
private static final Map<String, Integer> JDK_TO_MAJOR_VERSION_NUMBER_MAPPING = new LinkedHashMap<>();

static {
for (int i = 6; i < 35; i++) {
JDK_TO_MAJOR_VERSION_NUMBER_MAPPING.put(String.valueOf(i), 44 + i);
}
}

public static Integer javaVersionToBytecodeVersion(String jv) {
return JDK_TO_MAJOR_VERSION_NUMBER_MAPPING.get(jv);
}

public static Optional<Manifest> getManifest(JarFile jarFile) {
try {
return Optional.of(jarFile.getManifest());
return Optional.ofNullable(jarFile.getManifest());
} catch (IOException e) {
return Optional.empty();
// throw new JarvizException(RB.$("ERROR_READING_JAR_MANIFEST", jarFile.getName()));
}
}

Expand Down

0 comments on commit 645aa2e

Please sign in to comment.