Search code examples
javajava-17

How to check source code libraries of openJDK?


I have installed openJDK 17. Then I have unzipped file lib/src.zip. There are a lot of directories and I cannot find packages like java.lang or java.util. How can I find it?

I have tried to use search and so on. Also, I know that I can use IntelJ or Eclipse for it, but I want to do it without IDEs


Solution

  • The top-level directories of Java's src.zip are - since Java 9 - the modules. The package java.lang is part of the module java.base. You can find the sources of classes in java.lang in java.base/java/lang inside the zip.

    For module names, the directory name is the full module name, while for package names, each . separated part represents a nested directory (java.lang -> java/lang, java.lang.annotation -> java/lang/annotation, etc.). For example, the sources of java.lang.String are in the file java.base/java/lang/String.java

    Depending on what your end goal is, it might make more sense to clone the GitHub repository of OpenJDK: