Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Memory Analyzer » java.lang.NoClassDefFoundError: org/eclipse/mat/ui/snapshot/editor/ISnapshotEditorInput(Trying to create a MAT Plugin to display Android Bitmaps as Images)
java.lang.NoClassDefFoundError: org/eclipse/mat/ui/snapshot/editor/ISnapshotEditorInput [message #878201] Mon, 28 May 2012 20:22 Go to next message
Spear Hend is currently offline Spear HendFriend
Messages: 1
Registered: May 2012
Junior Member
I am working to create a Eclipse MAT plugin that will display as an Image the contents of android.graphics.Bitmap from a HPROF dump.

Please see attached Screenshot.

index.php/fa/9932/0/

In attached screenshot, we have:

Item 1 - The button the user clicks to show the Image version of the Bitmap object
Item 2 - The Bitmap object selected by the user.
Item 3 - The InspectorView, that displays attributes of the selected Object.

Since InspectorView has access to 60% of the data I need to display the Bitmap, I referred to InspectorView.java and modeled my plugin based off it.

+------------+
| plugin.xml |
+------------+

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension point="org.eclipse.mat.ui.editorContributions">
      <contribution class="mat.showbitmap.EditorContributor" editorClass="org.eclipse.mat.ui.snapshot.editor.HeapEditor" sequenceNr="2"/>
   </extension>
	
</plugin>


This allows my plugin to add the Icon to the toolbar. However, IMultiPaneEditorContributer is internal and its use is restricted. I chose to ignore this warning.

For now, let us not worry about the static MultiPaneEditor mEditor.

+------------------------+
| EditorContributor.java |
+------------------------+

package mat.showbitmap;

import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.mat.ui.editor.IMultiPaneEditorContributor;
import org.eclipse.mat.ui.editor.MultiPaneEditor;

public class EditorContributor implements IMultiPaneEditorContributor {
   
   UiAction uiAction = new UiAction();
   
   public static MultiPaneEditor mEditor = null;
   
   public void contributeToToolbar(IToolBarManager aManager) {
      aManager.add(uiAction);
      aManager.add(new Separator());
   }

   public void dispose() {
   }

   public void init(MultiPaneEditor aEditor) {
      dispose();
      mEditor = aEditor;
      System.out.println("Editor is new " + mEditor);
   }
 
}


+---------------+
| UiAction.java |
+---------------+

package mat.showbitmap;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mat.query.IContextObject;
import org.eclipse.mat.ui.editor.AbstractEditorPane;
import org.eclipse.mat.ui.snapshot.editor.ISnapshotEditorInput;
import org.eclipse.ui.IEditorInput;

public class UiAction extends Action {

   public UiAction() {
      super(Messages.SBUIAct_Icon_Text, Activator.getImageDescriptor(Activator.SHOW_BITMAP_ICON));
      setToolTipText(Messages.SBUIAct_Icon_Tooltip);
   }
   
   @Override
   public void run() {
      super.run();
      if (null == EditorContributor.mEditor) {
         return;
      }
      AbstractEditorPane activePane = EditorContributor.mEditor.getActiveEditor();
      System.out.println("Current pane " + activePane);
      if (!(activePane instanceof ISelectionProvider) || (null == activePane)) {
         return;
      }
      ISelectionProvider selProv = (ISelectionProvider)activePane;
      ISelection sel = selProv.getSelection();
      if (null == sel) {
         return;
      }
      System.out.println("Current selection " + sel);
      IContextObject objectSet = null;

      if (sel instanceof IStructuredSelection) {
         Object object = ((IStructuredSelection)sel).getFirstElement();
         if (object instanceof IContextObject) {
            objectSet = (IContextObject) object;
         }
      }
      if (null == objectSet) {
         return;
      }
      int objectId = objectSet.getObjectId();
      System.out.println("Object id " + objectId);

      IEditorInput input = EditorContributor.mEditor.getPaneEditorInput();
      System.out.println("Input is " + input);
      if (null == input || !(input instanceof ISnapshotEditorInput)) {
         return;
      }
      ISnapshotEditorInput editorInput = (ISnapshotEditorInput)input;
      System.out.println("Editor Input is " + editorInput);
   }
}

The trouble starts when I try to use ISnapshotEditorInput. I get a Runtime error.

java.lang.NoClassDefFoundError: org/eclipse/mat/ui/snapshot/editor/ISnapshotEditorInput
	at mat.showbitmap.UiAction.run(UiAction.java:52)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.ClassNotFoundException: org.eclipse.mat.ui.snapshot.editor.ISnapshotEditorInput
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	... 30 more


Here are my questions:

1. What is the best way to implement a plugin that can show the Image representation of an android.graphics.Bitmap? Am I on the right track or are there better ways?
2. IMultiPaneEditorContributor appears to be Internal. Is it advisable to use this interface in my plugin.
3. Why am I getting the NoClassDefFoundError? Is it because of a classpath problem or my plugin cannot access ISnapshotEditorInput? I did nothing special for IMultiPaneEditorContributor and it appears to be working fine.

Please let me know.
Re: java.lang.NoClassDefFoundError: org/eclipse/mat/ui/snapshot/editor/ISnapshotEditorInput [message #878338 is a reply to message #878201] Tue, 29 May 2012 05:32 Go to previous message
Andrew Johnson is currently offline Andrew JohnsonFriend
Messages: 205
Registered: July 2009
Senior Member
1.I'm not sure. This is how SWT images are displayed, but it isn't directly extensible Bugzilla 258224: InspectorView enhancement to render ImageData and RGBs.
A slightly similar suggestion is Bugzilla 274369: Add SWT smarts to inspector

2.None of the UI code is an API, so can be freely changed by the committers in releases or service updates.
If it is just for your own use, and you are prepared to rewrite it whenever MAT changes, then you could use it, but you aren't supposed to complain when that happens.

3.
IMultiPaneEditorContributor is in the package org.eclipse.mat.ui.editor
This is exported via the manifest.mf, though is not intended for public access, which is why you got a warning
org.eclipse.mat.ui.editor;x-friends:="org.eclipse.mat.chart.ui,org.eclipse.mat.ui.rcp",

ISnapshotEditorInput is in the package org.eclipse.mat.ui.snapshot.editor
which is not exported via the manifest.mf
Previous Topic:My plugin is not loaded
Next Topic:Some Paths to GC root not found?
Goto Forum:
  


Current Time: Thu Sep 19 14:56:52 GMT 2024

Powered by FUDForum. Page generated in 0.03762 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top