113 jmodFile.close(); 114 } 115 } 116 117 private void ensureOpen() { 118 if (jmodFile == null) { 119 try { 120 open(); 121 } catch(IOException ioe){ 122 throw new UncheckedIOException(ioe); 123 } 124 } 125 } 126 127 private EntryType toEntryType(JmodFile.Section section) { 128 switch (section) { 129 case CLASSES: 130 return EntryType.CLASS_OR_RESOURCE; 131 case CONFIG: 132 return EntryType.CONFIG; 133 case NATIVE_LIBS: 134 return EntryType.NATIVE_LIB; 135 case NATIVE_CMDS: 136 return EntryType.NATIVE_CMD; 137 case HEADER_FILES: 138 return EntryType.HEADER_FILE; 139 case MAN_PAGES: 140 return EntryType.MAN_PAGE; 141 default: 142 throw new InternalError("unexpected entry: " + section); 143 } 144 } 145 146 private Entry toEntry(JmodFile.Entry entry) { 147 EntryType type = toEntryType(entry.section()); 148 String name = entry.name(); 149 String path = entry.section().jmodDir() + "/" + name; 150 151 // Entry.path() contains the kind of file native, conf, bin, ... 152 // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg 153 String resourceName = name; 154 if (type != EntryType.CLASS_OR_RESOURCE) { 155 resourceName = path; 156 } 157 158 return new JmodEntry(path, resourceName, type, entry); 159 } 160 } | 113 jmodFile.close(); 114 } 115 } 116 117 private void ensureOpen() { 118 if (jmodFile == null) { 119 try { 120 open(); 121 } catch(IOException ioe){ 122 throw new UncheckedIOException(ioe); 123 } 124 } 125 } 126 127 private EntryType toEntryType(JmodFile.Section section) { 128 switch (section) { 129 case CLASSES: 130 return EntryType.CLASS_OR_RESOURCE; 131 case CONFIG: 132 return EntryType.CONFIG; 133 case HEADER_FILES: 134 return EntryType.HEADER_FILE; 135 case LEGAL_NOTICES: 136 return EntryType.LEGAL_NOTICE; 137 case MAN_PAGES: 138 return EntryType.MAN_PAGE; 139 case NATIVE_LIBS: 140 return EntryType.NATIVE_LIB; 141 case NATIVE_CMDS: 142 return EntryType.NATIVE_CMD; 143 default: 144 throw new InternalError("unexpected entry: " + section); 145 } 146 } 147 148 private Entry toEntry(JmodFile.Entry entry) { 149 EntryType type = toEntryType(entry.section()); 150 String prefix = entry.section().jmodDir(); 151 String name = entry.name(); 152 String path = prefix + "/" + name; 153 String resourceName = name; 154 155 // The resource name represents the path of ResourcePoolEntry 156 // and its subpath defines the ultimate path to be written 157 // to the image relative to the directory corresponding to that 158 // resource type. 159 // 160 // For classes and resources, the resource name does not have 161 // a prefix (<package>/<name>). They will be written to the jimage. 162 // 163 // For other kind of entries, it will keep the section name as 164 // the prefix for unique identification. The subpath (taking 165 // out the section name) is the pathname to be written to the 166 // corresponding directory in the image. 167 // 168 if (type == EntryType.LEGAL_NOTICE) { 169 // legal notices are written to per-module directory 170 resourceName = prefix + "/" + moduleName + "/" + name; 171 } else if (type != EntryType.CLASS_OR_RESOURCE) { 172 resourceName = path; 173 } 174 175 return new JmodEntry(path, resourceName, type, entry); 176 } 177 } |