I'm running VisualVM to profile a simple Java application. When I double-click on a method in the profiling pane (hoping to get more details on it), then it says "No source found for class ....". I know where the source is. How do I tell VisualVM where to look?
-
Just a guess, but what if you put the .java files next to the .class files on the classpath? Or if they're in a jar, bundle source and classes so they're next to each other. – David Ehrmann Jul 07 '14 at 19:30
-
I tried adding the .java files to my main .jar file alongside the .class files, but it didn't help. – Nathaniel J. Smith Jul 07 '14 at 20:32
2 Answers
I took a stack dump of the VisualVM process while it was displaying that error dialog, and it seems that the problem lies in the class org.netbeans.modules.profiler.api.GoToSource, in the method openSourceImpl
.
This method tries to load the source using any registered implementations of the GoToSourceProvider
service provider interface, and displays the error message if none of them manage to display the source code in question.
My guess is that the current, default version of VisualVM doesn't have any GoToSourceProviders
registered, and therefore will always fail to look-up source code.
From the package name it appears that GoToSourceProvider
is an SPI for the profiler module, but I wasn't able to find any documentation on how to implement this SPI, and it doesn't seem to be part of the VisualVM extension points.

- 1,127
- 12
- 22
-
1Sounds like this is an oversight when cutting out the profiler from Netbeans to make the stand alone VisualVM. – Thorbjørn Ravn Andersen Aug 23 '17 at 13:55
Hello something virtually same like VisualVM is implemented in NetBeans IDE (I'm using 8.0.2). You just click Profile->Project Profile
. Showing you source code upon clicking is working there. But unfortunately there is no more detailed info which lines of code takes most time.
For that I will modify code and I will count manually using
long beg = System.nanoTime()
lineISuspect
sum += System.nanoTime() - beg;

- 3,566
- 2
- 34
- 40