Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339647 - Running MAT screws up Java perspective in Eclipse
Summary: Running MAT screws up Java perspective in Eclipse
Status: RESOLVED WONTFIX
Alias: None
Product: MAT
Classification: Tools
Component: Core (show other bugs)
Version: 1.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-11 03:08 EST by Peter De Maeyer CLA
Modified: 2012-04-20 10:41 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter De Maeyer CLA 2011-03-11 03:08:31 EST
When I run MAT, and start Eclipse thereafter, the Java perspective is all screwed up. The package explorer view and others are gone, the Eclipse workbench has been infected with whatever hprof file I had last loaded in MAT.

To make matters worse, "reset perspective" does not restore the perspective to the original state. Somehow MAT managed to screw up the default settings for the Java perspective as well.

The only option left for me is to remove all .eclipse settings folders and start over customizing all the settings. Very unfortunate. Basically using MAT is no option for me, which is too bad 'coz I liked its features.

Peter
Comment 1 Krum Tsvetkov CLA 2011-03-11 03:22:41 EST
This sounds pretty embarrassing. Let's try to collect all the details and get this reproducible. There are many people using MAT in the IDE and so far there were no complaints.
- What version of Eclipse are you installing MAT in (3.6, 3.7, 4.x) ?
- Which version of MAT do you install and where do you take it from - did you take a zipped update site, the update site, etc, some zip from the Hudson server...
- Can you describe some steps to reproduce this? My assumption is: install MAT features -> open Memory Analysis perspective -> open a hprof -> switch back to Java perspective... Is this correct?
- Can you attach the eclipse log?

If you can't provide all of this, then provide just some of the things. I'll be interested to investigate this.
Comment 2 Peter De Maeyer CLA 2011-03-11 10:42:43 EST
I've done some more investigating, and this is what I found:

Steps to reproduce:
- Unzip MAT in ~/mat (I mean the standalone MAT app, not the Eclipse plugin)
- Create a Gnome shortcut (launcher) for it, point it at the "~/mat/MemoryAnalyzer" executable
- Start MAT using the Gnome shortcut -> it screws with the ~/workspace/.metadata directory to store its perspective in, which happens to be my default Eclipse workspace
- Start Eclipse after that -> since the ~/workspace/.metadata directory got screwed over by MAT, the Java perspective is now totally screwed up as well. Other workspaces are still good, only the ~/workspace is broken.

I also found out that when I start MAT from the command line, from _within_ the ~/mat/ directory itself, there is no problem. MAT then creates its own separate workspace ~/mat/workspace.

So the issue actually is only present if you launch MAT with your home directory as working directory. The workaround is to convince the Gnome launcher to use a different working directory, which is easier said than done since Gnome doesn't have a nice GUI that lets you set a working directory. However it's possible if you alter the execution command like so:

 sh -c "cd ~/mat && ./MemoryAnalyzer"

The above command cd's to the ~/mat directory before starting MAT.
Comment 3 Krum Tsvetkov CLA 2011-03-11 10:58:05 EST
Ok, then the problem is that if there is an already existing workspace in the user home directory, then MAT overwrites something and corrupts it. I'll try to reproduce this and will try to see if there is some way to prevent it.
Comment 4 Andrew Johnson CLA 2011-03-12 05:31:41 EST
I haven't tested this but you could also try:

~/mat/MemoryAnalyzer -data ~/mat/MemoryAnalyzer/workspace

to select the workspace.
Comment 5 Peter De Maeyer CLA 2011-03-14 02:56:04 EDT
(In reply to comment #4)
> I haven't tested this but you could also try:
> 
> ~/mat/MemoryAnalyzer -data ~/mat/MemoryAnalyzer/workspace
> 
> to select the workspace.

I tested it, and this is also a good workaround. Note that you can't use the '~' symbol for home directory in a gnome launcher, so the command actually becomes something like this:

 /home/peter/mat/MemoryAnalyzer -data /home/peter/mat/workspace
Comment 6 Andrew Johnson CLA 2011-03-22 13:07:03 EDT
This seems to be an important file.
.metadata\.plugins\org.eclipse.ui.workbench\workbench.xml
saving it before opening MAT, then restoring it after opening MAT means that the Eclipse workbench looks normal.

I get 
<Java>
<<Java>>
<<<Java>>>
perspectives created each time I switch between MAT and Eclipse.

Switching back to MAT loses the File > Open Heap Dump and Acquire Heap Dump menu options.

With Eclipse, does switching perspectives using
Window > Open Perspective > Other... > Java(default)
sort things out?
Comment 7 Andrew Johnson CLA 2012-04-20 10:41:03 EDT
I think you should be able to clean it up by switching perspectives to Java (as above) and then deleting the spurious perspectives:
Windows > Preferences > General > Perspectives
then delete the <Java>, <<Java>>, <<Java EE>> perspectives.

I don't see an easy way to solve this one.