11

I want to debug a static inner class, which is actually a Callable. Whenever I try to set a conditional breakpoint in Eclipse I get the breakpoint error:

The type com.sun.source.tree.Tree$Kind cannot be resolved. It is indirectly referenced from required .class files.

What is causing this error? Is it a bug in the class/package that uses com.sun.source.tree.Tree$Kind but does not provide it? How do I find out which class it is? How do I resolve it?


An example expression which should be correct is: return mRtx.getNode().getNodeKey() == 74;

I have changed it to mRtx.getNode().getNodeKey() == 74 but still the same error. Recently I've found the bug and simply used:

 if (mRtx.getNode().getNodeKey() == 74) {
     System.out.println("bla");
 }

and set a "normal" breakpoint on the "sysout" statement just in case someone has the same problem.

Flexo
  • 87,323
  • 22
  • 191
  • 272
Johannes
  • 2,021
  • 2
  • 23
  • 40

3 Answers3

3

I am not sure on how I would reproduce it as your description is not exactly telling much.

The com.sun.source.tree package is included in tools.jar, which is part of JDK but not of JRE, so make sure you run your Eclipse in JDK (JAVA_HOME variable?), maybe try setting projects JRE to a JDK folder.

I also think that the Compiler API was introduced in Java 6, so check if you are not using a lower version.

MarianP
  • 2,719
  • 18
  • 17
  • Thanks for the answer (+1). If jamesDrinkard hadn't shown me the great site http://java.syntaxerrors.info, I would have given you the +50. – DaveFar Sep 27 '11 at 21:15
  • On my machine, I had to manually add the tools.jar from my java installation (even though I was using a JDK): Window > Preferences > Installed JREs, select an JDK, hit "edit" and add the tools.jar from the lib-subfolder if it does not exist yet. – evandor Dec 18 '14 at 15:17
2

Maybe you should try to edit the debugger's source lookup.

To do this, go to debug perspective, in the debug view (where the stack is normally shown) right click on the terminated run, and choose 'Edit Source Lookup...'.

Then you can add a lookup place. In this case you should maybe add the tools.jar that is in the jre folder.

qwertzguy
  • 15,699
  • 9
  • 63
  • 66
  • Thank you. This solved the issue for me. It only asks to "choose" the 2 (the unmanaged source is another one that comes as a linked source in the project set up, but not included in the run path) but it's manageable. – Dima R. Mar 31 '17 at 16:27
1

The compiler can't find the type, that is the root issue, but in my thinking, this should only be a compile time error, but by implication from what I read, it's a run time error. Is that correct?

Here is are some tips:

http://java.syntaxerrors.info/index.php?title=Cannot_resolve_type

Indirectly referenced from required .class file

Maybe you could post more code or use "control + T" in Eclipse on the class to look at the type hierarchy, I would like to know what other classes are referenced.

HTH,

James

Community
  • 1
  • 1
James Drinkard
  • 15,342
  • 16
  • 114
  • 137