Bug 132813 - [compiler] NPE in Javadoc.resolve(Javadoc.java:196) + log swamped
Summary: [compiler] NPE in Javadoc.resolve(Javadoc.java:196) + log swamped
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 132665 132815 132846 132877 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-22 04:54 EST by Dani Megert CLA
Modified: 2006-03-28 11:11 EST (History)
2 users (show)

See Also:


Attachments
Test case (1.81 KB, patch)
2006-03-22 11:11 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2006-03-22 04:54:09 EST
I20060321-1210

Found several times in .log and since it writes out the source the .log grows extremely.

!ENTRY org.eclipse.jdt.core 4 4 2006-03-22 09:58:12.483
!MESSAGE Exception occurred during problem detection:
----------------------------------- SOURCE BEGIN -------------------------------------
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.ui.actions;

import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.Assert;

import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;

import org.eclipse.jdt.ui.PreferenceConstants;

import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.search.SearchMessages;

/**
 * Action group that adds the Java search actions to a context menu and
 * the global menu bar.
 * 
 * <p>
 * This class may be instantiated; it is not intended to be subclassed.
 * </p>
 * 
 * @since 2.0
 */
public class fil extends ActionGroup {

	private JavaEditor fEditor;

	private ReferencesSearchGroup fReferencesGroup;
	private ReadReferencesSearchGroup fReadAccessGroup;
	private WriteReferencesSearchGroup fWriteAccessGroup;
	private DeclarationsSearchGroup fDeclarationsGroup;
	private ImplementorsSearchGroup fImplementorsGroup;
	private OccurrencesSearchGroup fOccurrencesGroup;
	
	
	/**
	 * Creates a new <code>JavaSearchActionGroup</code>. The group 
	 * requires that the selection provided by the part's selection provider 
	 * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
	 * 
	 * @param part the view part that owns this action group
	 */
	public JavaSearchActionGroup(IViewPart part) {
		this(part.getViewSite());
	}
	
	/**
	 * Creates a new <code>JavaSearchActionGroup</code>. The group 
	 * requires that the selection provided by the page's selection provider 
	 * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
	 * 
	 * @param page the page that owns this action group
	 */
	public JavaSearchActionGroup(Page page) {
		this(page.getSite());
	}

	/**
	 * Note: This constructor is for internal use only. Clients should not call this constructor.
	 * @param editor the Java editor
	 */
	public JavaSearchActionGroup(JavaEditor editor) {
		Assert.isNotNull(editor);
		fEditor= editor;
		
		fReferencesGroup= new ReferencesSearchGroup(fEditor);
		fReadAccessGroup= new ReadReferencesSearchGroup(fEditor);
		fWriteAccessGroup= new WriteReferencesSearchGroup(fEditor);
		fDeclarationsGroup= new DeclarationsSearchGroup(fEditor);
		fImplementorsGroup= new ImplementorsSearchGroup(fEditor);
		fOccurrencesGroup= new OccurrencesSearchGroup(fEditor);
	}

	private JavaSearchActionGroup(IWorkbenchSite site) {
		fReferencesGroup= new ReferencesSearchGroup(site);
		fReadAccessGroup= new ReadReferencesSearchGroup(site);
		fWriteAccessGroup= new WriteReferencesSearchGroup(site);
		fDeclarationsGroup= new DeclarationsSearchGroup(site);
		fImplementorsGroup= new ImplementorsSearchGroup(site);
		fOccurrencesGroup= new OccurrencesSearchGroup(site);
	}

	/* 
	 * Method declared on ActionGroup.
	 */
	public void setContext(ActionContext context) {
		fReferencesGroup.setContext(context);
		fDeclarationsGroup.setContext(context);
		fImplementorsGroup.setContext(context);
		fReadAccessGroup.setContext(context);
		fWriteAccessGroup.setContext(context);
		fOccurrencesGroup.setContext(context);
	}

	/* 
	 * Method declared on ActionGroup.
	 */
	public void fillActionBars(IActionBars actionBar) {
		super.fillActionBars(actionBar);
		fReferencesGroup.fillActionBars(actionBar);
		fDeclarationsGroup.fillActionBars(actionBar);
		fImplementorsGroup.fillActionBars(actionBar);
		fReadAccessGroup.fillActionBars(actionBar);
		fWriteAccessGroup.fillActionBars(actionBar);
		fOccurrencesGroup.fillActionBars(actionBar);
	}
	
	/* 
	 * Method declared on ActionGroup.
	 */
	public void fillContextMenu(IMenuManager menu) {
		super.fillContextMenu(menu);
		
		if(PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SEARCH_USE_REDUCED_MENU)) {
			fReferencesGroup.fillContextMenu(menu);
			fDeclarationsGroup.fillContextMenu(menu);

			if (fEditor == null) {
				fImplementorsGroup.fillContextMenu(menu);
				fReadAccessGroup.fillContextMenu(menu);
				fWriteAccessGroup.fillContextMenu(menu);
			}
			fOccurrencesGroup.fillContextMenu(menu);

		} else {
			IMenuManager target= menu;
			IMenuManager searchSubMenu= null;
			if (fEditor != null) {
				String groupName= SearchMessages.group_search; 
				searchSubMenu= new MenuManager(groupName, ITextEditorActionConstants.GROUP_FIND);
				searchSubMenu.add(new GroupMarker(ITextEditorActionConstants.GROUP_FIND));
				target= searchSubMenu;
			}
			
			fReferencesGroup.fillContextMenu(target);
			fDeclarationsGroup.fillContextMenu(target);
			fImplementorsGroup.fillContextMenu(target);
			fReadAccessGroup.fillContextMenu(target);
			fWriteAccessGroup.fillContextMenu(target);
			fOccurrencesGroup.fillContextMenu(target);
			
			if (searchSubMenu != null)
				searchSubMenu.add(new Separator());
			
			// no other way to find out if we have added items.
			if (searchSubMenu != null && searchSubMenu.getItems().length > 2) {		
				menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, searchSubMenu);
			}
		}
	}	

	/* 
	 * Method declared on ActionGroup.
	 */
	public void dispose() {
		fReferencesGroup.dispose();
		fDeclarationsGroup.dispose();
		fImplementorsGroup.dispose();
		fReadAccessGroup.dispose();
		fWriteAccessGroup.dispose();
		fOccurrencesGroup.dispose();

		super.dispose();
	}
}

----------------------------------- SOURCE END -------------------------------------
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.ast.Javadoc.resolve(Javadoc.java:196)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveJavadoc(AbstractMethodDeclaration.java:420)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:401)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1049)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1096)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:354)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:687)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:184)
	at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:181)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:229)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:503)
	at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:990)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:131)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:71)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:720)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:779)
	at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1117)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:97)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:82)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:145)
	at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:94)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:75)
	at org.eclipse.jdt.internal.ui.text.JavaReconciler.process(JavaReconciler.java:339)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:204)
Comment 1 Frederic Fusier CLA 2006-03-22 07:43:47 EST
Type declaration name has been modified ('fil' instead 'JavaSearchActionGroup')
=> all constructors are converted into methods with a null return type.
Javadoc resolution was not protected against this because it should not be called in this case (method binding was expected to be null)...

Here's a smaller test case to reproduce the problem:
Test.java:
    public class X {
        /**	 */ 
        public Test() {}
        /**	 */
        public test() {}
    }

Tracking resolution shows that SourceTypeBinding.methods() misses to reset binding for invalid method Test() but do it correctly for test() method...

Changing line 1088 (in SourceTypeBinding v_647):
    continue nextMethod; // methods with same selector are contiguous
with:
    break nextSibling; // methods with same selector are contiguous
fixes the problem...

Philippe, do you agree with this fix?
Comment 2 Philipe Mulet CLA 2006-03-22 10:39:20 EST
Actually, the binding should still be nulled out in this case, likely a regression introduced recently when sorting bindings.
Comment 3 Frederic Fusier CLA 2006-03-22 11:11:24 EST
Created attachment 36749 [details]
Test case

Apply this patch on org.eclipse.jdt.core.test.compiler project.
It adds a test on JavadocBugTests to verify that NPE does no longer occur.
Comment 4 Philipe Mulet CLA 2006-03-22 11:20:38 EST
I think Frederic's fix is the right one.
Will release it. 
Frederic pls add a testcase.
Comment 5 Frederic Fusier CLA 2006-03-22 11:27:11 EST
Patch applied in HEAD.

All JDT/Core and JDT/UI tests pass.
Comment 6 Philipe Mulet CLA 2006-03-22 11:53:42 EST
*** Bug 132815 has been marked as a duplicate of this bug. ***
Comment 7 Philipe Mulet CLA 2006-03-22 11:54:27 EST
Added LookupTest#test059
Comment 8 David Audel CLA 2006-03-22 12:07:55 EST
*** Bug 132665 has been marked as a duplicate of this bug. ***
Comment 9 Olivier Thomann CLA 2006-03-22 12:16:06 EST
*** Bug 132846 has been marked as a duplicate of this bug. ***
Comment 10 Olivier Thomann CLA 2006-03-22 13:45:57 EST
*** Bug 132877 has been marked as a duplicate of this bug. ***
Comment 11 David Audel CLA 2006-03-23 10:17:36 EST
Added SnippetCompletionTests_1_5#testCodeSnippetAssistForBug132665

see bug 132665 commment 3
Comment 12 Olivier Thomann CLA 2006-03-28 11:11:54 EST
Verified using I20060328-0010 for 3.2M6