Bug 149126 - IllegalArgumentException in ASTConverter
Summary: IllegalArgumentException in ASTConverter
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-29 06:23 EDT by Jerome Lanneluc CLA
Modified: 2008-03-25 08:29 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2006-06-29 06:23:51 EDT
I20060627 + latest JDT Core

Create the following CU in jdt.core.tests.model:
/*******************************************************************************
 * Copyright (c) 2000, 2006 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.core.tests.model;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;

public class TestCharset extends Charset {

	public TestCharset(String canonicalName, String[] aliases) {
		super(canonicalName, aliases);
	}
	
	public boolean contains(Charset cs) {
		return cs == this;
	}

	public CharsetDecoder newDecoder() {
		return new CharsetDecoder(this, 2.0, 2.0) {
			CharsetDecoder(CharSet
			protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
				return null;
			}
		};;
	}

	public CharsetEncoder newEncoder() {
		return null;
	}

}

Observe: You get the following exception when the AST is being created:
!ENTRY org.eclipse.jdt.ui 4 0 2006-06-29 12:23:21.439
!MESSAGE Error in JDT Core during AST creation
!STACK 0
java.lang.IllegalArgumentException
        at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2599)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:430)
        at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:318)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2284)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1541)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2341)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2412)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:511)
        at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:179)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2666)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1249)
        at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:253)
        at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:856)
        at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:630)
        at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:605)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
        at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:600)
        at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:514)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.getClipboardData(ClipboardOperationAction.java:397)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.doCutCopyWithImportsOperation(ClipboardOperationAction.java:323)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.internalDoOperation(ClipboardOperationAction.java:279)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction$1.run(ClipboardOperationAction.java:248)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.run(ClipboardOperationAction.java:246)
        at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
        at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:229)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
        at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3375)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2995)
        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:149)
        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:400)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        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 Olivier Thomann CLA 2006-06-29 10:44:51 EDT
David,

This is another case of recovery that has not completed properly.
                        CharsetDecoder(CharSet
                        protected CoderResult decodeLoop(ByteBuffer in,

When trying to retrieve the end position of the method declaration name (CharsetDecoder in this case), the recovery scanner doesn't return any token.
It is at the beginning of the identifier and it seems to return EOF. I would expect to get an identifier token.
Comment 2 Olivier Thomann CLA 2006-06-29 10:46:00 EDT
Added disabled regression test
org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2._test0652 in HEAD.
Comment 3 David Audel CLA 2008-03-19 08:25:45 EDT
This bug doesn't occur in 3.4.

I close this bug as WORKSFORME.

I enabled and updated ASTConverterTestAST3_2.test0652()
Comment 4 Jerome Lanneluc CLA 2008-03-25 08:29:52 EDT
Verified for 3.4M6 using I20080325-0100