Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 276598

Summary: [OLE] NPE in OLE code
Product: [Eclipse Project] Platform Reporter: Jonathan Camilleri <camilleri.jon>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: ericwill, Olivier_Thomann, remy.suen, Silenio_Quarti
Version: 3.4.2Keywords: triaged
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Source code and video demo of problem
none
log file
none
Source code none

Description Jonathan Camilleri CLA 2009-05-16 15:08:59 EDT
Created attachment 136102 [details]
Source code and video demo of problem

Build ID: Build id: M20090211-1700

Steps To Reproduce:
See video and source code for further information.  Note that video requires TeamViewer (http://www.teamviewer.com/index.aspx) to be able to open the video file.


More information:
OS: Windows Server 2008 64 bit
Comment 1 Jonathan Camilleri CLA 2009-05-16 15:13:11 EDT
Comment on attachment 136102 [details]
Source code and video demo of problem

NOTE: Please ignore the file named ReflectionPlayground.rar within the attachment.
Comment 2 Remy Suen CLA 2009-05-16 15:38:30 EDT
(In reply to comment #0)
> Created an attachment (id=136102) [details]
> Source code and video demo of problem
> 
> Build ID: Build id: M20090211-1700
> 
> Steps To Reproduce:
> See video and source code for further information.  Note that video requires
> TeamViewer (http://www.teamviewer.com/index.aspx) to be able to open the video
> file.

Jonathan, some of us uses Linux and this third-party TeamViewer application does not seem to run on Linux. Please provide reproducible steps in text.

I noticed that there is an error about an NPE in your rar file. Can you attach your workspace's log file? See workspace/.metadata/.log.
Comment 3 Jonathan Camilleri CLA 2009-05-16 16:26:05 EDT
Well, I'm trying to type in Vector in the IDE, and, even though I inserted the import statement at the top of the source file, Eclipse just "does not recognize it".  The funny thing about this error is that it is ad-hoc and happens when declaring a Vector within a static void:

import java.util.*   
//this should let the IDE know that Vector can be used, right?

class X
{
...
static void main {....}
...

static void myMethod (Object someValue)
{
//I try to type 'Vector' and an error is displayed: Vector cannot be resolved.
  Vector<?> myVector = new Vector<?>;
}


}

I'll try to get a linux box and screen capturing software for UX when something weird happens with my Windows box; hope not too soon :)


Comment 4 Jonathan Camilleri CLA 2009-05-16 16:27:50 EDT
Created attachment 136105 [details]
log file
Comment 5 Remy Suen CLA 2009-05-16 16:38:50 EDT
I suppose ECJ's error message could be improved. I've tried this on I20090513-2000.

import java.util.Vector;

public class ArrayGrowTest {

	void printArray() {
		Vector<?> v = new Vector<?>();
	}

}

The code above gives 'Cannot instantiate the type Vector<?>' which isn't very helpful.

javac seems to do a better job.

/opt/sun-jdk-1.5.0.17/bin/javac ArrayGrowTest.java 
ArrayGrowTest.java:6: unexpected type
found   : ?
required: class or interface without bounds
                Vector<?> v = new Vector<?>();
                                        ^
1 error
Comment 6 Jonathan Camilleri CLA 2009-05-17 04:20:32 EDT
Sorry. Well I was doing something like this in the video ..
...
import java.util.*;
class myClass
...

public int[] growArray (Object someContainer)
{
  Vector ... when I typed vector an error is displayed: Vector cannot be resolved.

{
...
Comment 7 Jonathan Camilleri CLA 2009-05-17 07:58:58 EDT
I had a similar problem to this one on a different code snippet:
...
import java.lang.reflect.*; //this should be fine
import java.lang.reflect.Method; //added this just in case...
...
@SuppressWarnings("unchecked")
	public static void runMethod (Class<?> cl, String methodName){
		Class _cl = cl.getClass().getClass();
		Method[] _methods = _cl.getClass().getMethods();
		
		if (_methods.equals(methodName))
			Method _methodToRun = new Method();
                    //Errors displayed:
// 1. _methodToRun cannot be resolved
// 2. Method cannot be resolved
// 3. Type mismatch: cannot convert from Method to Method[].  The suggestion to change type of methods to Method is incorrect, because
_cl.getClass().getMethods() returns a Method[] not a Method (subtle).

java.lang.reflect.Method _methods = new Method();


                        
	}
...

Comment 8 Jonathan Camilleri CLA 2009-05-17 07:59:55 EDT
Created attachment 136125 [details]
Source code
Comment 9 Jonathan Camilleri CLA 2009-05-17 08:02:47 EDT
I had a little coding mistake in my previous comment since I used an existing variable name.  It would be helpful if the IDE displayed 'variable already in use', which I believe sometimes it does when I do this mistake.

@SuppressWarnings("unchecked")
	public static void runMethod (Class<?> cl, String methodName){
		Class _cl = cl.getClass().getClass();
		Method[] _methods = _cl.getClass().getMethods();
		
		if (_methods.equals(methodName))
			Method _mymethods = new Method();
	}
Comment 10 Olivier Thomann CLA 2009-05-17 10:00:41 EDT
When you get the error, is your code syntactically correct ?
Comment 11 Jonathan Camilleri CLA 2009-05-17 10:08:58 EDT
I thought this bug reporting tool regarded Eclipse.  I think so.
Comment 12 Olivier Thomann CLA 2009-07-22 13:53:30 EDT
(In reply to comment #5)
> The code above gives 'Cannot instantiate the type Vector<?>' which isn't very
> helpful.
Maybe. But this doesn't say that the type cannot be resolved as far as I know.

(In reply to comment #8)
> Created an attachment (id=136125) [details]
> Source code
I don't get any error with this code.
Comment 13 Olivier Thomann CLA 2009-07-22 13:57:27 EDT
The NPE comes from SWT code.
Moving to Platform/SWT
Comment 14 Felipe Heidrich CLA 2009-07-28 12:27:07 EDT
Olivier, were you able to reproduce this bug?
Comment 15 Olivier Thomann CLA 2009-07-28 12:36:22 EDT
Felipe,

I moved the bug in SWT because of this exception in the .log file.
java.lang.NullPointerException
	at org.eclipse.swt.ole.win32.OleAutomation.<init>(OleAutomation.java:122)
	at org.eclipse.ui.internal.editorsupport.win32.OleEditor.handleWord(OleEditor.java:404)
	at org.eclipse.ui.internal.editorsupport.win32.OleEditor.oleActivate(OleEditor.java:650)
	at org.eclipse.ui.internal.editorsupport.win32.OleEditor.activateClient(OleEditor.java:212)
	at org.eclipse.ui.internal.editorsupport.win32.OleEditor.access$3(OleEditor.java:210)
	at org.eclipse.ui.internal.editorsupport.win32.OleEditor$4.partActivated(OleEditor.java:165)
	at org.eclipse.ui.internal.PartListenerList$1.run(PartListenerList.java:72)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:880)
	at org.eclipse.ui.internal.PartListenerList.fireEvent(PartListenerList.java:57)
	at org.eclipse.ui.internal.PartListenerList.firePartActivated(PartListenerList.java:70)
	at org.eclipse.ui.internal.PartService.firePartActivated(PartService.java:186)
	at org.eclipse.ui.internal.PartService.setActivePart(PartService.java:305)
	at org.eclipse.ui.internal.WorkbenchPagePartList.fireActivePartChanged(WorkbenchPagePartList.java:56)
	at org.eclipse.ui.internal.PartList.setActivePart(PartList.java:126)
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3491)
	at org.eclipse.ui.internal.WorkbenchPage.activate(WorkbenchPage.java:610)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2832)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2729)
	at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2721)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2673)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2668)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2652)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2643)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:646)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:605)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:318)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:160)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:228)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:207)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	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:386)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)


I didn't get it myself.
Comment 16 Felipe Heidrich CLA 2009-07-30 11:43:41 EDT
Did you notice this:

!ENTRY org.eclipse.jdt.ui 4 10001 2009-05-15 20:19:35.701
!MESSAGE Internal Error
!STACK 1
org.eclipse.core.runtime.CoreException: The fix 'Add type parameters to 'Class'' generated a null change.
	at org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.createChange(CompilationUnitRewriteOperationsFix.java:104)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal.createTextChange(FixCorrectionProposal.java:151)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal.createChange(CUCorrectionProposal.java:392)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal.getChange(ChangeCorrectionProposal.java:253)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal.performChange(ChangeCorrectionProposal.java:109)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal.performChange(CUCorrectionProposal.java:326)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal.apply(CUCorrectionProposal.java:304)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal.apply(FixCorrectionProposal.java:183)
	at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.apply(AbstractAnnotationHover.java:498)
	at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.access$2(AbstractAnnotationHover.java:480)
	at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$5.widgetSelected(AbstractAnnotationHover.java:473)


-------
This is probably the exception that is affecting Jonathan.

Comment 17 Olivier Thomann CLA 2009-07-30 12:17:27 EDT
I didn't get any details once I reported that I cannot reproduce the issue.
I could not get the NPE.

Jonathan, please open a new bug report with good steps to reproduce. Not a team viewer video. The source code didn't let me reproduce the issue.
Comment 18 Jonathan Camilleri CLA 2009-07-30 12:42:06 EDT
Sorry, but it's been a while and I don't remember the details of this issue.
Comment 19 Eric Williams CLA 2017-07-28 10:18:42 EDT
(In reply to Jonathan Camilleri from comment #18)
> Sorry, but it's been a while and I don't remember the details of this issue.

Based on this, closing. Please feel free to re-open if the issue persists.