Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell visualvm where to find my source code?

Tags:

java

visualvm

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?

like image 343
Nathaniel J. Smith Avatar asked Jul 07 '14 19:07

Nathaniel J. Smith


People also ask

Where is VisualVM EXE located?

What is VisualVM. It is a tool automatically available after JDK is installed. The executable file could be found on your <JDK installation folder>/bin as displayed below. In order to measure the performance of your application, it is necessary for the application to be recognized by VisualVM first.

Where can I find VisualVM in JDK?

To find the location of your Java VisualVM userdir, choose Help > About from the main menu and click Details in the About Java VisualVM window.

Is VisualVM open source?

VisualVM is an open source tool to monitor JVM instances of each running JVM application. Its built-in features can be further enhanced by installing plugins. The users of Oracle JDK or OpenJDK 9 can download this open source tool from https://visualvm.github.io/index.html.


1 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.

like image 187
alphaloop Avatar answered Nov 04 '22 10:11

alphaloop