RSTALanguageSupport
RSTALanguageSupport copied to clipboard
LibraryInfo fail for Java >= 11
I tried to run the org.fife.rsta.ac.demo.DemoApp
class in AdoptOpenJDK 11.0.9.101, but a null pointer exception is thrown. I debugged the code and found the problem.
In the org.fife.rsta.ac.java.buildpath.LibraryInfo
class, the getJreJarInfo()
method looks for the rt.jar
file, but in Java 11 and later this file has been changed to jrt-fs.jar
.
I fixed this problem locally for Windows 10, but I don't know the behavior of this change on other OS:
public static LibraryInfo getJreJarInfo(File jreHome) {
LibraryInfo info = null;
File mainJar = new File(jreHome, "lib/rt.jar"); // Sun JRE's
File sourceZip;
if (mainJar.isFile()) { // Sun JRE's
sourceZip = new File(jreHome, "src.zip");
if (!sourceZip.isFile()) {
// Might be a JRE inside a JDK
sourceZip = new File(jreHome, "../src.zip");
}
} else { // Might be OS X
mainJar = new File(jreHome, "../Classes/classes.jar");
// ${java.home}/src.jar is the common location on OS X.
sourceZip = new File(jreHome, "src.jar");
}
//////////////////////////////////////////////////
if (!mainJar.isFile()) { // Java 11 and later
mainJar = new File(jreHome, "lib/jrt-fs.jar");
sourceZip = new File(jreHome, "src.zip");
}
//////////////////////////////////////////////////
if (mainJar.isFile()) {
info = new JarLibraryInfo(mainJar);
if (sourceZip.isFile()) { // Make sure our last guess actually exists
info.setSourceLocation(new ZipSourceLocation(sourceZip));
}
} else {
System.err.println("[ERROR]: Cannot locate JRE jar in " + jreHome.getAbsolutePath());
mainJar = null;
}
return info;
}
Check out this, which works properly, and also loads proper completions:
https://github.com/bobbylight/RSTALanguageSupport/issues/51
working on linux. after update to this code.