Search code examples
javaintellij-ideaintellij-15

Is com.sun.tools.javac.util available in openjdk 8?


I just installed OpenJDK 8 from Brew on my Mac. However, when I am using Pair: "import com.sun.tools.javac.util.Pair;", although IntelliJ did not report any error, it promotes an error that states that the:

error: package com.sun.tools.javac.util does not exist.

I remember that Java 8 contains Pair. Does OpenJDK 8 also contain a Pair? If no, which version of OpenJDK contains Pair?


Solution

  • You can find JDK sources here:

    https://hg.openjdk.java.net/jdk/jdk13/

    as far as I can tell, it's still there:

    > find . -name "Pair.java" | grep javac
    ./src/jdk.compiler/share/classes/com/sun/tools/javac/util/Pair.java
    

    It looks like your env related issue.

    enter image description here

    It also works perfectly fine with Java 1.8

    adoptopenjdk

    Default download from: https://adoptopenjdk.net

    enter image description here

    Amazon Corretto

    Default download from: https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/what-is-corretto-8.html

    enter image description here