Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibraryInfo fail for Java >= 11 #53

Open
nagassaki opened this issue Apr 6, 2021 · 2 comments
Open

LibraryInfo fail for Java >= 11 #53

nagassaki opened this issue Apr 6, 2021 · 2 comments

Comments

@nagassaki
Copy link

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;

}
@kovadam69
Copy link

Check out this, which works properly, and also loads proper completions:

#51

@Hasnatrasool163
Copy link

working on linux. after update to this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants