Skip to content

Commit 10bd12b

Browse files
authored
Bootstrap tests (#410)
* Initial changes to make this load inside https://github.com/QuiltMC/quilt-loader-bootstrap This requires QuiltMC/quilt-parsers#4 * Remove maven local from the buildscript * Update quilt-parsers to 0.3.0
1 parent c6b90a2 commit 10bd12b

File tree

12 files changed

+409
-18
lines changed

12 files changed

+409
-18
lines changed

src/main/java/org/quiltmc/loader/impl/filesystem/QuiltJoinedFileSystemProvider.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@
5959
@SuppressWarnings("unchecked") // TODO make more specific
6060
@QuiltLoaderInternal(QuiltLoaderInternalType.LEGACY_EXPOSED)
6161
public final class QuiltJoinedFileSystemProvider extends FileSystemProvider {
62-
public QuiltJoinedFileSystemProvider() {}
62+
public QuiltJoinedFileSystemProvider() {
63+
if (instance == null) {
64+
instance = this;
65+
}
66+
}
6367

6468
public static final String SCHEME = "quilt.jfs";
6569

70+
private static QuiltJoinedFileSystemProvider instance;
6671
private static final Map<String, WeakReference<QuiltJoinedFileSystem>> ACTIVE_FILESYSTEMS = new HashMap<>();
6772

6873
static {
@@ -108,12 +113,25 @@ static synchronized void closeFileSystem(QuiltJoinedFileSystem fs) {
108113
}
109114

110115
public static QuiltJoinedFileSystemProvider instance() {
116+
QuiltJoinedFileSystemProvider found = findInstance();
117+
if (found != null) {
118+
return found;
119+
}
120+
throw new IllegalStateException("Unable to load QuiltJoinedFileSystemProvider via services!");
121+
}
122+
123+
public static QuiltJoinedFileSystemProvider findInstance() {
124+
if (instance != null) {
125+
return instance;
126+
}
127+
111128
for (FileSystemProvider provider : FileSystemProvider.installedProviders()) {
112129
if (provider instanceof QuiltJoinedFileSystemProvider) {
113130
return (QuiltJoinedFileSystemProvider) provider;
114131
}
115132
}
116-
throw new IllegalStateException("Unable to load QuiltJoinedFileSystemProvider via services!");
133+
134+
return instance;
117135
}
118136

119137
@Override

src/main/java/org/quiltmc/loader/impl/filesystem/QuiltMemoryFileSystemProvider.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.net.URI;
2121
import java.nio.file.FileStore;
2222
import java.nio.file.FileSystem;
23-
import java.nio.file.FileSystemNotFoundException;
2423
import java.nio.file.Path;
2524
import java.nio.file.spi.FileSystemProvider;
2625
import java.util.Map;
@@ -30,20 +29,39 @@
3029

3130
@QuiltLoaderInternal(QuiltLoaderInternalType.LEGACY_EXPOSED)
3231
public final class QuiltMemoryFileSystemProvider extends QuiltMapFileSystemProvider<QuiltMemoryFileSystem, QuiltMemoryPath> {
33-
public QuiltMemoryFileSystemProvider() {}
32+
public QuiltMemoryFileSystemProvider() {
33+
if (instance == null) {
34+
instance = this;
35+
}
36+
}
3437

3538
public static final String SCHEME = "quilt.mfs";
3639

40+
private static QuiltMemoryFileSystemProvider instance;
41+
3742
static final String READ_ONLY_EXCEPTION = "This FileSystem is read-only";
3843
static final QuiltFSP<QuiltMemoryFileSystem> PROVIDER = new QuiltFSP<>(SCHEME);
3944

4045
public static QuiltMemoryFileSystemProvider instance() {
46+
QuiltMemoryFileSystemProvider found = findInstance();
47+
if (found != null) {
48+
return found;
49+
}
50+
throw new IllegalStateException("Unable to load QuiltMemoryFileSystemProvider via services!");
51+
}
52+
53+
public static QuiltMemoryFileSystemProvider findInstance() {
54+
if (instance != null) {
55+
return instance;
56+
}
57+
4158
for (FileSystemProvider provider : FileSystemProvider.installedProviders()) {
4259
if (provider instanceof QuiltMemoryFileSystemProvider) {
4360
return (QuiltMemoryFileSystemProvider) provider;
4461
}
4562
}
46-
throw new IllegalStateException("Unable to load QuiltMemoryFileSystemProvider via services!");
63+
64+
return instance;
4765
}
4866

4967
@Override

src/main/java/org/quiltmc/loader/impl/filesystem/QuiltUnifiedFileSystemProvider.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,39 @@
4040

4141
@QuiltLoaderInternal(QuiltLoaderInternalType.NEW_INTERNAL)
4242
public class QuiltUnifiedFileSystemProvider extends QuiltMapFileSystemProvider<QuiltUnifiedFileSystem, QuiltUnifiedPath> {
43-
public QuiltUnifiedFileSystemProvider() {}
43+
public QuiltUnifiedFileSystemProvider() {
44+
if (instance == null) {
45+
instance = this;
46+
}
47+
}
4448

4549
public static final String SCHEME = "quilt.ufs";
4650

4751
static final String READ_ONLY_EXCEPTION = "This FileSystem is read-only";
4852
static final QuiltFSP<QuiltUnifiedFileSystem> PROVIDER = new QuiltFSP<>(SCHEME);
4953

54+
private static QuiltUnifiedFileSystemProvider instance;
55+
5056
public static QuiltUnifiedFileSystemProvider instance() {
57+
QuiltUnifiedFileSystemProvider found = findInstance();
58+
if (found != null) {
59+
return found;
60+
}
61+
throw new IllegalStateException("Unable to load QuiltUnifiedFileSystemProvider via services!");
62+
}
63+
64+
public static QuiltUnifiedFileSystemProvider findInstance() {
65+
if (instance != null) {
66+
return instance;
67+
}
68+
5169
for (FileSystemProvider provider : FileSystemProvider.installedProviders()) {
5270
if (provider instanceof QuiltUnifiedFileSystemProvider) {
5371
return (QuiltUnifiedFileSystemProvider) provider;
5472
}
5573
}
56-
throw new IllegalStateException("Unable to load QuiltUnifiedFileSystemProvider via services!");
74+
75+
return instance;
5776
}
5877

5978
@Override

src/main/java/org/quiltmc/loader/impl/filesystem/QuiltZipFileSystemProvider.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,37 @@
2929

3030
@QuiltLoaderInternal(QuiltLoaderInternalType.NEW_INTERNAL)
3131
public class QuiltZipFileSystemProvider extends QuiltMapFileSystemProvider<QuiltZipFileSystem, QuiltZipPath> {
32+
public QuiltZipFileSystemProvider() {
33+
if (instance == null) {
34+
instance = this;
35+
}
36+
}
3237

3338
public static final String SCHEME = "quilt.zfs";
3439
static final String READ_ONLY_EXCEPTION = "This FileSystem is read-only";
3540
static final QuiltFSP<QuiltZipFileSystem> PROVIDER = new QuiltFSP<>(SCHEME);
41+
private static QuiltZipFileSystemProvider instance;
3642

3743
public static QuiltZipFileSystemProvider instance() {
44+
QuiltZipFileSystemProvider found = findInstance();
45+
if (found != null) {
46+
return found;
47+
}
48+
throw new IllegalStateException("Unable to load QuiltZipFileSystemProvider via services!");
49+
}
50+
51+
public static QuiltZipFileSystemProvider findInstance() {
52+
if (instance != null) {
53+
return instance;
54+
}
55+
3856
for (FileSystemProvider provider : FileSystemProvider.installedProviders()) {
3957
if (provider instanceof QuiltZipFileSystemProvider) {
4058
return (QuiltZipFileSystemProvider) provider;
4159
}
4260
}
43-
throw new IllegalStateException("Unable to load QuiltZipFileSystemProvider via services!");
61+
62+
return instance;
4463
}
4564

4665
@Override

src/main/java/org/quiltmc/loader/impl/filesystem/quilt/jfs/Handler.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.net.URL;
2424
import java.net.URLConnection;
2525
import java.net.URLStreamHandler;
26-
import java.nio.file.Files;
27-
import java.nio.file.Path;
2826

2927
import org.quiltmc.loader.impl.filesystem.QuiltJoinedFileSystem;
3028
import org.quiltmc.loader.impl.filesystem.QuiltJoinedFileSystemProvider;
@@ -36,7 +34,7 @@
3634
@QuiltLoaderInternal(QuiltLoaderInternalType.LEGACY_EXPOSED)
3735
public class Handler extends URLStreamHandler {
3836
@Override
39-
protected URLConnection openConnection(URL u) throws IOException {
37+
public URLConnection openConnection(URL u) throws IOException {
4038
QuiltJoinedPath path;
4139
try {
4240
path = QuiltJoinedFileSystemProvider.instance().getPath(u.toURI());
@@ -58,7 +56,7 @@ public InputStream getInputStream() throws IOException {
5856
}
5957

6058
@Override
61-
protected InetAddress getHostAddress(URL u) {
59+
public InetAddress getHostAddress(URL u) {
6260
return null;
6361
}
6462
}

src/main/java/org/quiltmc/loader/impl/filesystem/quilt/mfs/Handler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@QuiltLoaderInternal(QuiltLoaderInternalType.LEGACY_EXPOSED)
3535
public class Handler extends URLStreamHandler {
3636
@Override
37-
protected URLConnection openConnection(URL u) throws IOException {
37+
public URLConnection openConnection(URL u) throws IOException {
3838
QuiltMemoryPath path;
3939
try {
4040
path = QuiltMemoryFileSystemProvider.instance().getPath(u.toURI());
@@ -56,7 +56,7 @@ public InputStream getInputStream() throws IOException {
5656
}
5757

5858
@Override
59-
protected InetAddress getHostAddress(URL u) {
59+
public InetAddress getHostAddress(URL u) {
6060
return null;
6161
}
6262
}

src/main/java/org/quiltmc/loader/impl/filesystem/quilt/ufs/Handler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@QuiltLoaderInternal(QuiltLoaderInternalType.NEW_INTERNAL)
3535
public class Handler extends URLStreamHandler {
3636
@Override
37-
protected URLConnection openConnection(URL u) throws IOException {
37+
public URLConnection openConnection(URL u) throws IOException {
3838
QuiltUnifiedPath path;
3939
try {
4040
path = QuiltUnifiedFileSystemProvider.instance().getPath(u.toURI());
@@ -56,7 +56,7 @@ public InputStream getInputStream() throws IOException {
5656
}
5757

5858
@Override
59-
protected InetAddress getHostAddress(URL u) {
59+
public InetAddress getHostAddress(URL u) {
6060
return null;
6161
}
6262
}

src/main/java/org/quiltmc/loader/impl/filesystem/quilt/zfs/Handler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@QuiltLoaderInternal(QuiltLoaderInternalType.LEGACY_EXPOSED)
3535
public class Handler extends URLStreamHandler {
3636
@Override
37-
protected URLConnection openConnection(URL u) throws IOException {
37+
public URLConnection openConnection(URL u) throws IOException {
3838
QuiltZipPath path;
3939
try {
4040
path = QuiltZipFileSystemProvider.instance().getPath(u.toURI());
@@ -56,7 +56,7 @@ public InputStream getInputStream() throws IOException {
5656
}
5757

5858
@Override
59-
protected InetAddress getHostAddress(URL u) {
59+
public InetAddress getHostAddress(URL u) {
6060
return null;
6161
}
6262
}

0 commit comments

Comments
 (0)