Iterate through all JDK classes

I am making a code editor and I am working on autocomplete. I want to programmatically get a list of all the classes that come with the JDK.

Examples include:

java.io.File java.util.ArrayList javax.swing.Action 

I found ways to get classes for a specific package. For example, I can get all classes starting with com.mypackage.foo . The problem is that I'm trying to get classes that were loaded using Bootstrap ClassLoader . And in the OSX JDK, this class loader appears as null . For example, if I do String.class.getClassLoader() , i.e. null .

Any ideas?

+6
source share
1 answer

You can open rt.jar with java.util.jar.JarFile and iterate over its entries. Here's how to get the URL for rt.jar: URL url = Object.class.getResource("String.class");

+2
source

Source: https://habr.com/ru/post/986404/


All Articles