Bug 137623 - Exception calculating java content assist
Summary: Exception calculating java content assist
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.2 RC2   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-19 18:57 EDT by Brock Janiczak CLA
Modified: 2006-04-28 14:58 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (3.55 KB, patch)
2006-04-21 04:42 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brock Janiczak CLA 2006-04-19 18:57:43 EDT
Version: 3.2.0
Build id: I20060413-1718

While trying to activate content assist, i got the attached exception.  Try activating code assist after "int." in the following sample:

public class Test {

	public boolean foo() {
		boolean retValue;
		Class fieldClass = null;
		Object value = null;

		if(fieldClass.isPrimitive())
		{
			if(((fieldClass==int.) && (value.getClass().getName() == "java.lang.Integer")) 
					|| ((fieldClass.getName()=="char") && (value.getClass().getName() == "java.lang.Character")) 
					|| ((fieldClass.getName()=="short") && (value.getClass().getName() == "java.lang.Short")) 
					|| ((fieldClass.getName()=="boolean") && (value.getClass().getName() == "java.lang.Boolean")) 
					|| ((fieldClass.getName()=="byte") && (value.getClass().getName() == "java.lang.Byte")) 
					|| ((fieldClass.getName()=="long") && (value.getClass().getName() == "java.lang.Long")) 
					|| ((fieldClass.getName()=="double") && (value.getClass().getName() == "java.lang.Double")) 
					|| ((fieldClass.getName()=="float") && (value.getClass().getName() == "java.lang.Float")) 
			)
			{
				retValue=true;
			}

		}
		return retValue;
	}
}


java.lang.NegativeArraySizeException
at org.eclipse.jdt.internal.compiler.parser.Parser.getUnspecifiedReferenceOptimized(Parser.java:8306)
at org.eclipse.jdt.internal.codeassist.impl.AssistParser.getUnspecifiedReferenceOptimized(AssistParser.java:961)
at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.getUnspecifiedReferenceOptimized(CompletionParser.java:3422)
at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.buildMoreCompletionContext(CompletionParser.java:663)
at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.attachOrphanCompletionNode(CompletionParser.java:424)
at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.updateRecoveryState(CompletionParser.java:3772)
at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError(Parser.java:9915)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:8784)
at org.eclipse.jdt.internal.codeassist.impl.AssistParser.parseBlockStatements(AssistParser.java:1313)
at org.eclipse.jdt.internal.codeassist.impl.AssistParser.parseBlockStatements(AssistParser.java:1166)
at org.eclipse.jdt.internal.codeassist.impl.Engine.parseBlockStatements(Engine.java:292)
at org.eclipse.jdt.internal.codeassist.impl.Engine.parseBlockStatements(Engine.java:255)
at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1747)
at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:123)
at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:313)
at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:306)
at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals(JavaCompletionProposalComputer.java:213)
at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.computeCompletionProposals(JavaCompletionProposalComputer.java:193)
at org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposalComputer.computeCompletionProposals(JavaTypeCompletionProposalComputer.java:73)
at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:285)
at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:252)
at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:212)
at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:181)
at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1577)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:448)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$15(CompletionProposalPopup.java:445)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:380)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:374)
at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:346)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3323)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2969)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169)
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.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 1 David Audel CLA 2006-04-20 08:09:32 EDT
Smaller test case:

public class Test {
        public boolean foo() {
                if(this.equals(null))
                {
                        (zzz==int.
                }
        }
}
   
Comment 2 David Audel CLA 2006-04-21 04:42:04 EDT
Created attachment 39149 [details]
Proposed fix
Comment 3 David Audel CLA 2006-04-21 04:47:24 EDT
Philippe - Do you want this fix for 3.2RC2 ?

A negative value is in the identifierLengthStack stack. This negative value mean a base type. CompletionParser try to use this value as an array index.
Comment 4 Philipe Mulet CLA 2006-04-21 08:45:32 EDT
+1 for 3.2RC2
Comment 5 David Audel CLA 2006-04-21 08:59:52 EDT
Fix released and test added
  CompletionParserTest2#test0166()
Comment 6 Olivier Thomann CLA 2006-04-28 14:58:41 EDT
Verified with I20060427-1600 for 3.2RC2