src/share/classes/org/openjdk/jigsaw/RepositoryCatalog.java
Print this page
*** 27,37 ****
import java.io.*;
import java.lang.module.*;
import java.util.*;
! import static org.openjdk.jigsaw.Repository.ModuleType;
import static org.openjdk.jigsaw.FileConstants.ModuleFile.HashType;
/**
* <p> A {@linkplain Repository module repository's} catalog </p>
--- 27,37 ----
import java.io.*;
import java.lang.module.*;
import java.util.*;
! import static org.openjdk.jigsaw.Repository.ModuleFileType;
import static org.openjdk.jigsaw.FileConstants.ModuleFile.HashType;
/**
* <p> A {@linkplain Repository module repository's} catalog </p>
*** 48,71 ****
throws IOException;
public abstract void gatherModuleIds(String moduleName, Set<ModuleId> mids)
throws IOException;
public abstract byte[] readModuleInfoBytes(ModuleId mid)
throws IOException;
static class Entry {
! final ModuleType type;
final byte[] mibs;
final long csize;
final long usize;
final HashType hashType;
final byte[] hash;
! Entry(ModuleType t, byte[] m, long cs, long us, HashType ht, byte[] h) {
type = t;
mibs = m;
csize = cs;
usize = us;
hashType = ht;
hash = h;
--- 48,79 ----
throws IOException;
public abstract void gatherModuleIds(String moduleName, Set<ModuleId> mids)
throws IOException;
+ public abstract void gatherModuleIds(String moduleName,
+ ModuleArchitecture modArch,
+ Set<ModuleId> mids)
+ throws IOException;
+
public abstract byte[] readModuleInfoBytes(ModuleId mid)
throws IOException;
static class Entry {
! final ModuleFileType type;
! final ModuleArchitecture modArch;
final byte[] mibs;
final long csize;
final long usize;
final HashType hashType;
final byte[] hash;
! Entry(ModuleFileType t, ModuleArchitecture modArch,
! byte[] m, long cs, long us, HashType ht, byte[] h) {
type = t;
+ this.modArch = modArch;
mibs = m;
csize = cs;
usize = us;
hashType = ht;
hash = h;
*** 73,86 ****
}
abstract void add(Entry e);
! public void add(ModuleType t, byte[] mibs, long cs, long us,
! HashType hashType, byte[] hash)
{
! add(new Entry(t, mibs, cs, us, hashType, hash));
}
public abstract boolean remove(ModuleId mid);
abstract Entry get(ModuleId mid);
--- 81,94 ----
}
abstract void add(Entry e);
! public void add(ModuleFileType t, ModuleArchitecture modArch, byte[] mibs,
! long cs, long us, HashType hashType, byte[] hash)
{
! add(new Entry(t, modArch, mibs, cs, us, hashType, hash));
}
public abstract boolean remove(ModuleId mid);
abstract Entry get(ModuleId mid);
*** 105,119 ****
mids.addAll(modules.keySet());
}
@Override
public void gatherModuleIds(String moduleName, Set<ModuleId> mids) {
for (ModuleId mid : moduleForViewId.keySet()) {
! if (moduleName == null || mid.name().equals(moduleName))
mids.add(mid);
}
}
@Override
public byte[] readModuleInfoBytes(ModuleId mid) {
Entry e = modules.get(moduleForViewId.get(mid));
return (e != null) ? e.mibs : null;
--- 113,138 ----
mids.addAll(modules.keySet());
}
@Override
public void gatherModuleIds(String moduleName, Set<ModuleId> mids) {
+ gatherModuleIds(moduleName, ModuleArchitecture.ANY, mids);
+ }
+
+ @Override
+ public void gatherModuleIds(String moduleName,
+ ModuleArchitecture modArch,
+ Set<ModuleId> mids)
+ {
for (ModuleId mid : moduleForViewId.keySet()) {
! if (moduleName == null || mid.name().equals(moduleName)) {
! Entry entry = get(mid);
! if (entry.modArch.equals(modArch))
mids.add(mid);
}
}
+ }
@Override
public byte[] readModuleInfoBytes(ModuleId mid) {
Entry e = modules.get(moduleForViewId.get(mid));
return (e != null) ? e.mibs : null;
*** 182,191 ****
--- 201,212 ----
out.writeInt(modules.size());
for (Map.Entry<ModuleId,Entry> me : modules.entrySet()) {
out.writeUTF(me.getKey().toString()); // ## Redundant
Entry e = me.getValue();
out.writeUTF(e.type.getFileNameExtension());
+ out.writeUTF(e.modArch.os());
+ out.writeUTF(e.modArch.arch());
out.writeLong(e.csize);
out.writeLong(e.usize);
out.writeShort(e.hashType.value());
out.writeShort(e.hash.length);
out.write(e.hash);
*** 208,228 ****
FileHeader fh = fileHeader();
fh.read(in);
int nms = in.readInt();
for (int i = 0; i < nms; i++) {
ModuleId mid = jms.parseModuleId(in.readUTF());
! ModuleType t = ModuleType.fromFileNameExtension(in.readUTF());
long cs = in.readLong();
long us = in.readLong();
HashType ht = HashType.valueOf(in.readShort());
int nb = in.readShort();
byte[] hash = new byte[nb];
in.readFully(hash);
nb = in.readShort();
byte[] mibs = new byte[nb];
in.readFully(mibs);
! modules.put(mid, new Entry(t, mibs, cs, us, ht, hash));
}
int nmids = in.readInt();
for (int i = 0; i < nmids; i++) {
ModuleId id = jms.parseModuleId(in.readUTF());
ModuleId mid = jms.parseModuleId(in.readUTF());
--- 229,251 ----
FileHeader fh = fileHeader();
fh.read(in);
int nms = in.readInt();
for (int i = 0; i < nms; i++) {
ModuleId mid = jms.parseModuleId(in.readUTF());
! ModuleFileType t = ModuleFileType.fromFileNameExtension(in.readUTF());
! ModuleArchitecture modArch = ModuleArchitecture.create(in.readUTF(),
! in.readUTF());
long cs = in.readLong();
long us = in.readLong();
HashType ht = HashType.valueOf(in.readShort());
int nb = in.readShort();
byte[] hash = new byte[nb];
in.readFully(hash);
nb = in.readShort();
byte[] mibs = new byte[nb];
in.readFully(mibs);
! modules.put(mid, new Entry(t, modArch, mibs, cs, us, ht, hash));
}
int nmids = in.readInt();
for (int i = 0; i < nmids; i++) {
ModuleId id = jms.parseModuleId(in.readUTF());
ModuleId mid = jms.parseModuleId(in.readUTF());