Skip to content

Commit

Permalink
Use standard Java's UncheckedIOException in JRTUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell authored and jukzi committed Sep 18, 2024
1 parent 1dab088 commit b7e519d
Showing 1 changed file with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URI;
import java.nio.channels.ClosedByInterruptException;
import java.nio.file.DirectoryStream;
Expand Down Expand Up @@ -132,11 +133,11 @@ public static JrtFileSystem getJrtSystem(File image, String release) throws IOEx
// Needs better error handling downstream? But for now, make sure
// a dummy JrtFileSystem is not created.
String errorMessage = "Error: failed to create JrtFileSystem from " + image; //$NON-NLS-1$
throw new RuntimeIOException(errorMessage, e);
throw new UncheckedIOException(errorMessage, e);
}
});
return system;
} catch (RuntimeIOException e) {
} catch (UncheckedIOException e) {
throw e.getCause();
}
}
Expand All @@ -154,11 +155,11 @@ public static FileSystem getJrtFileSystem(Path path) throws IOException {
try {
return FileSystems.newFileSystem(JRTUtil.JRT_URI, Map.of("java.home", p.toString())); //$NON-NLS-1$
} catch (IOException e) {
throw new RuntimeIOException(e);
throw new UncheckedIOException(e);
}
});
return fs;
} catch (RuntimeIOException e) {
} catch (UncheckedIOException e) {
throw e.getCause();
}
}
Expand Down Expand Up @@ -201,12 +202,12 @@ public static CtSym getCtSym(Path jdkHome) throws IOException {
try {
return new CtSym(x);
} catch (IOException e) {
throw new RuntimeIOException(e);
throw new UncheckedIOException(e);
}
}
return current;
});
} catch (RuntimeIOException rio) {
} catch (UncheckedIOException rio) {
throw rio.getCause();
}
return ctSym;
Expand Down Expand Up @@ -415,23 +416,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)

}

final class RuntimeIOException extends RuntimeException {
private static final long serialVersionUID = 1L;

public RuntimeIOException(String message, IOException cause) {
super(message, cause);
}

public RuntimeIOException(IOException cause) {
super(cause);
}

@Override
public synchronized IOException getCause() {
return (IOException) super.getCause();
}
}

class Jdk {
final Path path;
final String release;
Expand All @@ -444,10 +428,10 @@ public Jdk(File jrt) throws IOException {
try {
return readJdkReleaseFile(p);
} catch (IOException e) {
throw new RuntimeIOException(e);
throw new UncheckedIOException(e);
}
});
} catch (RuntimeIOException rio) {
} catch (UncheckedIOException rio) {
throw rio.getCause();
}
}
Expand Down

0 comments on commit b7e519d

Please sign in to comment.