4343import java .nio .file .Files ;
4444import java .nio .file .Path ;
4545import java .util .ArrayList ;
46- import java .util .Collections ;
4746import java .util .Enumeration ;
4847import java .util .HashMap ;
4948import java .util .HashSet ;
50- import java .util .LinkedHashSet ;
5149import java .util .LinkedList ;
5250import java .util .List ;
5351import java .util .Map ;
5452import java .util .Scanner ;
55- import java .util .Set ;
5653import java .util .jar .JarEntry ;
5754import java .util .jar .JarFile ;
5855import java .util .regex .Matcher ;
7269 * without pulling in the Swing script editor.
7370 * </p>
7471 * <p>
75- * By default the index scans the runtime classpath ({@code java.class.path}), the
76- * JRE/JDK home, and (on Java 9+) the runtime image's own modules. Applications that load classes from elsewhere (e.g. an ImageJ
77- * {@code jars/} directory) can contribute additional roots via
78- * {@link #addRoots(String...)} <em>before</em> the index is first built; this
79- * keeps application-specific paths out of this neutral utility.
72+ * The index scans the runtime classpath ({@code java.class.path}), the
73+ * JRE/JDK home, and (on Java 9+) the runtime image's own modules.
8074 * </p>
8175 *
8276 * @author Albert Cardona
@@ -100,26 +94,12 @@ public final class ClassIndex {
10094 private static final HashMap <String , String > scijava_javadoc_URLs =
10195 new HashMap <>();
10296
103- /** Extra roots (jar files or directories) contributed by applications. */
104- private static final Set <String > extraRoots = new LinkedHashSet <>();
105-
10697 private static boolean ready = false ;
10798
10899 private ClassIndex () {
109100 // prevent instantiation of static utility class
110101 }
111102
112- /**
113- * Registers additional roots (jar files, or directories scanned recursively
114- * for jars) to include when the index is built. Has no effect once the index
115- * has been built.
116- */
117- public static void addRoots (final String ... roots ) {
118- synchronized (class_urls ) {
119- Collections .addAll (extraRoots , roots );
120- }
121- }
122-
123103 /** The default roots: the JRE/JDK home plus each classpath entry. */
124104 private static List <String > defaultRoots () {
125105 final List <String > roots = new ArrayList <>();
@@ -137,9 +117,7 @@ private static List<String> defaultRoots() {
137117 public static void ensureCache () {
138118 synchronized (class_urls ) {
139119 if (!class_urls .isEmpty ()) return ;
140- final List <String > roots = defaultRoots ();
141- roots .addAll (extraRoots );
142- class_urls .putAll (findAllClasses (roots ));
120+ class_urls .putAll (findAllClasses (defaultRoots ()));
143121 findRuntimeClasses (class_urls );
144122 // Soft attempt at getting all packages (will get them wrong if
145123 // multiple jars share the same packages).
@@ -162,7 +140,7 @@ public static boolean isCacheReady() {
162140 }
163141
164142 /** Builds the cache of SciJava javadoc aggregator sub-URLs, if not done. */
165- public static void ensureSciJavaSubURLCache () {
143+ private static void ensureSciJavaSubURLCache () {
166144 synchronized (scijava_javadoc_URLs ) {
167145 if (!scijava_javadoc_URLs .isEmpty ()) return ;
168146 Scanner scanner = null ;
@@ -191,7 +169,7 @@ public static void ensureSciJavaSubURLCache() {
191169 }
192170 }
193171
194- public static HashMap <String , JarProperties > findClassDocumentationURLs (
172+ private static HashMap <String , JarProperties > findClassDocumentationURLs (
195173 final String s )
196174 {
197175 ensureCache ();
@@ -305,7 +283,7 @@ public static HashMap<String, ArrayList<String>> findDocumentationForClass(
305283 }
306284
307285 /** Properties of a jar file: its display name and documentation URLs. */
308- public static final class JarProperties {
286+ private static final class JarProperties {
309287
310288 public final ArrayList <String > urls ;
311289 public String name ;
@@ -376,7 +354,7 @@ private static String className(final String entry) {
376354 *
377355 * @param roots jar files, or directories scanned recursively for jars
378356 */
379- public static HashMap <String , JarProperties > findAllClasses (
357+ private static HashMap <String , JarProperties > findAllClasses (
380358 final List <String > roots )
381359 {
382360 // Find all jar files.
@@ -507,7 +485,7 @@ public static ArrayList<String> findSimpleClassNamesStartingWith(
507485 }
508486
509487 /** Builds an HTML link to the SciJava javadoc for the given class. */
510- public static String getJavaDocLink (final Class <?> c ) {
488+ private static String getJavaDocLink (final Class <?> c ) {
511489 final String name = c .getCanonicalName ();
512490 final String pkg = getDocPackage (name );
513491 if (pkg == null ) return name ;
0 commit comments