com.ibm.wala.util.io.RtJar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.ibm.wala.util Show documentation
Show all versions of com.ibm.wala.util Show documentation
T. J. Watson Libraries for Analysis
The newest version!
package com.ibm.wala.util.io;
import com.ibm.wala.util.PlatformUtil;
import com.ibm.wala.util.collections.ArrayIterator;
import com.ibm.wala.util.collections.FilterIterator;
import com.ibm.wala.util.collections.MapIterator;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Iterator;
import java.util.jar.JarFile;
import org.jspecify.annotations.NullUnmarked;
public class RtJar {
@NullUnmarked
public static JarFile getRtJar(Iterator x) {
while (x.hasNext()) {
JarFile JF = x.next();
switch (Paths.get(JF.getName()).getFileName().toString()) {
case "core.jar":
case "java.base.jmod":
case "rt.jar":
return JF;
case "classes.jar":
if (PlatformUtil.onMacOSX()) return JF;
// $FALL-THROUGH$
default:
}
}
return null;
}
public static void main(String[] args) {
@SuppressWarnings("resource")
JarFile rt =
getRtJar(
new MapIterator<>(
new FilterIterator<>(
new ArrayIterator<>(
System.getProperty("sun.boot.class.path").split(File.pathSeparator)),
t -> t.endsWith(".jar")),
object -> {
try {
return new JarFile(object);
} catch (IOException e) {
throw new RuntimeException(e);
}
}));
System.err.println(rt.getName());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy