jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java
changeset 39308 f6517755057f
parent 36511 9d0388c6b336
child 41352 f9844bad9052
equal deleted inserted replaced
39307:35eab41d2df1 39308:f6517755057f
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.tools.jlink.internal;
    26 package jdk.tools.jlink.internal;
    27 
    27 
    28 import jdk.tools.jlink.internal.JarArchive;
       
    29 import java.nio.file.Path;
    28 import java.nio.file.Path;
    30 import java.util.Objects;
    29 import java.util.Objects;
    31 import jdk.tools.jlink.internal.Archive.Entry.EntryType;
    30 import jdk.tools.jlink.internal.Archive.Entry.EntryType;
    32 
    31 
    33 /**
    32 /**
    34  * An Archive backed by a jmod file.
    33  * An Archive backed by a jmod file.
    35  */
    34  */
    36 public class JmodArchive extends JarArchive {
    35 public class JmodArchive extends JarArchive {
    37 
    36 
    38     private static final String JMOD_EXT = ".jmod";
    37     private static final String JMOD_EXT    = ".jmod";
    39     private static final String MODULE_NAME = "module";
    38     private static final String MODULE_NAME = "module";
    40     private static final String MODULE_INFO = "module-info.class";
    39     private static final String MODULE_INFO = "module-info.class";
    41     private static final String CLASSES     = "classes";
    40     private static final String CLASSES     = "classes";
    42     private static final String NATIVE_LIBS = "native";
    41     private static final String NATIVE_LIBS = "native";
    43     private static final String NATIVE_CMDS = "bin";
    42     private static final String NATIVE_CMDS = "bin";
    44     private static final String CONFIG      = "conf";
    43     private static final String CONFIG      = "conf";
    45 
    44 
    46     public JmodArchive(String mn, Path jmod) {
    45     public JmodArchive(String mn, Path jmod) {
    47         super(mn, jmod);
    46         super(mn, jmod);
    48         String filename = Objects.requireNonNull(jmod.getFileName()).toString();
    47         String filename = Objects.requireNonNull(jmod.getFileName()).toString();
    49         if (!filename.endsWith(JMOD_EXT))
    48         if (!filename.endsWith(JMOD_EXT)) {
    50             throw new UnsupportedOperationException("Unsupported format: " + filename);
    49             throw new UnsupportedOperationException("Unsupported format: " + filename);
       
    50         }
    51     }
    51     }
    52 
    52 
    53     @Override
    53     @Override
    54     EntryType toEntryType(String entryName) {
    54     EntryType toEntryType(String entryName) {
    55         String section = getSection(entryName.replace('\\', '/'));
    55         String section = getSection(entryName.replace('\\', '/'));
    63             case CONFIG:
    63             case CONFIG:
    64                 return EntryType.CONFIG;
    64                 return EntryType.CONFIG;
    65             case MODULE_NAME:
    65             case MODULE_NAME:
    66                 return EntryType.MODULE_NAME;
    66                 return EntryType.MODULE_NAME;
    67             default:
    67             default:
    68                 //throw new InternalError("unexpected entry: " + name + " " + zipfile.toString()); //TODO
       
    69                 throw new InternalError("unexpected entry: " + section);
    68                 throw new InternalError("unexpected entry: " + section);
    70         }
    69         }
    71     }
    70     }
    72 
    71 
    73     private static String getSection(String entryName) {
    72     private static String getSection(String entryName) {