compliment icon indicating copy to clipboard operation
compliment copied to clipboard

utils/classes-on-classpath can return non-classes

Open vemv opened this issue 1 year ago • 5 comments

Context

In refactor-nrepl I use utils/classes-on-classpath for building a certain feature.

I do believe the issue is practical for Compliment users as well.

Brief

classes-on-classpath can return classes that cannot be imported. They certainly look like classes, but they cannot be imported into the environment, so they seem useless as completion candidates.

Examples

("org.graalvm.compiler.hotspot.management.HotSpotGraalManagement"
 "jdk.tools.jaotc.AOTBackend"
 "sun.jvm.hotspot.BsdVtblAccess"
 "com.sun.java.swing.ui.CommonMenuBar")

Repro

(->> (into []
             (comp (keep (fn [class-name]
                           (when-not (or (-> class-name (string/replace "." "/") (str ".java") io/resource)
                                         (-> class-name (string/replace "." "/") (str ".class") io/resource))
                             class-name)))
                   (distinct))
             (reduce into [] (vals (dissoc (compliment.utils/classes-on-classpath)
                                           ""))))
       (group-by first )
       vals
       (map (partial take 5)))

I don't exactly know atm what these classes have in common, perhaps something comes to mind to you?

Cheers - V

vemv avatar Jul 24 '23 09:07 vemv