How to Tell Where Eclipse Finds a Class?

I’m debugging a weird class loading issue in XOM. Some of my unit tests can find the Crimson parser. Some can’t. I don’t know why. In Eclipse, I can press F3 and it locates both the class and corresponding source for this jar. But where did it find it? is there any way to see where (i.e. path in the file system) that class came from?

3 Responses to “How to Tell Where Eclipse Finds a Class?”

  1. Luís Miranda Says:

    Try this: highlight the class name, then select Open Type from the Navigate menu. When you select a class name from the list, the JAR / source directory is displayed near the bottom of the Open Type dialogue.

  2. Elliotte Rusty Harold Says:

    Thanks. That did the trick. Looks like it’s coming from the Java 1.4.2 class libraries. Now the next question is how those are ending up in my classpath, and how this only happens for some of the unit tests but not others. Still digging…

  3. Lorenzo Gatti Says:

    If there are multiple copies of one class in the workspace, Open Type (Ctrl-T) shows all of them with their location, which is only a partial clarification. It happens to me all the time because I access many projects both as sources for modification and as read-only JARs (not as project dependencies) from other projects.

    I’d rather recommend Open Declaration (F3) and related commands, since they respect the imports of the source file you start from and the classpath of the enclosing project.

    However, there is no direct relationship between Eclipse’s model and the runtime classpath of your tests; XML-related libraries, with their balkanized JARs, obsolete packages, multiple versions and complicated loading mechanisms, are a common source of race conditions (the class that is loaded first determines subsequent classloading).

Leave a Reply