--- old/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java 2016-12-07 23:01:38.000000000 -0800 +++ new/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java 2016-12-07 23:01:37.000000000 -0800 @@ -30,6 +30,11 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -68,12 +73,13 @@ * JMOD sections */ public static enum Section { - NATIVE_LIBS("native"), - NATIVE_CMDS("bin"), CLASSES("classes"), CONFIG("conf"), HEADER_FILES("include"), - MAN_PAGES("man"); + LEGAL_NOTICES("legal"), + MAN_PAGES("man"), + NATIVE_LIBS("native"), + NATIVE_CMDS("bin"); private final String jmodDir; private Section(String jmodDir) { @@ -85,7 +91,6 @@ * this section */ public String jmodDir() { return jmodDir; } - } /** @@ -107,7 +112,7 @@ } this.zipEntry = e; - this.section = section(name); + this.section = section(name.substring(0, i)); this.name = name.substring(i+1); } @@ -141,26 +146,21 @@ return section.jmodDir() + "/" + name; } + /* + * A map from the jmodDir name to Section + */ + static final Map NAME_TO_SECTION = + Arrays.stream(Section.values()) + .collect(Collectors.toMap(Section::jmodDir, Function.identity())); + static Section section(String name) { - int i = name.indexOf('/'); - String s = name.substring(0, i); - switch (s) { - case "native": - return Section.NATIVE_LIBS; - case "bin": - return Section.NATIVE_CMDS; - case "classes": - return Section.CLASSES; - case "conf": - return Section.CONFIG; - case "include": - return Section.HEADER_FILES; - case "man": - return Section.MAN_PAGES; - default: - throw new IllegalArgumentException("invalid section: " + s); + if (!NAME_TO_SECTION.containsKey(name)) { + throw new IllegalArgumentException("invalid section: " + name); + } + return NAME_TO_SECTION.get(name); } + } private final Path file;