Bug 87900 - Error 'Requesting Java AST from selection': Bug in the Java AST parser
Summary: Error 'Requesting Java AST from selection': Bug in the Java AST parser
Status: VERIFIED FIXED
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.1 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-14 00:38 EST by Reinier Zwitserloot CLA
Modified: 2005-03-30 19:05 EST (History)
0 users

See Also:


Attachments
The test case (also found in the first comment). (1.29 KB, text/plain)
2005-03-14 00:42 EST, Reinier Zwitserloot CLA
no flags Details
My eclipse settings (project uses 'default' settings). (241.23 KB, application/octet-stream)
2005-03-14 00:46 EST, Reinier Zwitserloot CLA
no flags Details
Test case ready to compile (1.14 KB, text/plain)
2005-03-14 09:16 EST, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Reinier Zwitserloot CLA 2005-03-14 00:38:39 EST
Tested in version: 3.1M5

I get an error with the message:
An internal error occurred during: "Requesting Java AST from selection".

There does not seem to be a way to get more information.

This error keeps showing up anytime I make any action (including moving around) 
inside the java source editor. Unfortunately I have to dump a rather large 
source file in here; it seems that removing just about anything else from this 
dump causes the error to no longer happen.

To 'activate' the bug, remove the // before the linke 'private transient'.

-----------source file to reproduce the bug:
package org.eden.swt;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipFile;

public class Skin
{
	private String fSkinLocation;
	private boolean fSkinLocationIsZip;
	//private transient   //remove the first doubleslash on this line and the 
error happends.
	
	private Skin()
	{
		//intentionally left blank
	}
	
	public static Skin makeSkin(String pSkinLocation)
	  throws IOException
	{
		Skin lNew = new Skin();
		File lFile;
		
		lNew.fSkinLocation = pSkinLocation;
		lFile = new File(lNew.fSkinLocation);
		
		if ( !lFile.exists() ) {
			throw new FileNotFoundException(
			  "Skin '" + pSkinLocation + "' not found.");
		}
		
		lNew.fSkinLocationIsZip = !lFile.isDirectory();
		
		return lNew;
	}
	
	public static void setTempDirectory(String pTemp)
	{
		sTempDirectory = pTemp;
	}
	
	private InputStream getResource(String pResourceName)
	  throws IOException
	{
		if ( fSkinLocationIsZip ) {
			return getResourceFromZip(pResourceName);
		} else {
			return getResourceFromDir(pResourceName);
		}
	}
	
	private InputStream getResourceFromZip(String pResourceName)
	  throws IOException
	{
		ZipFile lZipFile;
		
		lZipFile = new ZipFile(fSkinLocation);
	}
}
-----------------

in case it's neccessary: properties of the project:

Builders: Just the usual java builder, nothing else.

build path: SWT (the jar from org.eclipse.swt.win32_3.1.0, java 1.5.1 system 
library.

java compiler: JDK compliance levels: 5.0 default settings. If need be I can 
list the entire java compiler settings (all 50+ of em). Assuming for now that 
isn't it.
Comment 1 Reinier Zwitserloot CLA 2005-03-14 00:42:58 EST
Created attachment 18757 [details]
The test case (also found in the first comment).
Comment 2 Reinier Zwitserloot CLA 2005-03-14 00:46:08 EST
Created attachment 18758 [details]
My eclipse settings (project uses 'default' settings).

These are the settings of my eclipse. The project uses all 'default' settings.
As the settings, especially 'Java, Compiler' have marked effects on at least
the outlook of the editor (what's a warning, what's an error, etcetera), this
may be useful for trying to reproduce the bug.
Comment 3 Olivier Thomann CLA 2005-03-14 09:16:02 EST
AccTransient is the same value than AccVarArgs. A method cannot be transient. We
should not preserve the AccTransient modifier.
The illegal modifier for method is properly handled, but the code blows up when
we try to generate the method.

java.lang.ArrayIndexOutOfBoundsException: -1
	at
org.eclipse.jdt.internal.compiler.ast.Statement.generateArguments(Statement.java:59)
	at
org.eclipse.jdt.internal.compiler.ast.AllocationExpression.generateCode(AllocationExpression.java:115)
	at
org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.generateCode(LocalDeclaration.java:106)
	at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:218)
	at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:165)
	at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:562)
	at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:616)
	at
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:182)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:516)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335)
	at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:2388)
	at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1112)
	at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1009)
	at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1001)
	at org.eclipse.jdt.core.tools.compiler.Compile.main(Compile.java:19)
Comment 4 Olivier Thomann CLA 2005-03-14 09:16:49 EST
Created attachment 18761 [details]
Test case ready to compile
Comment 5 Kent Johnson CLA 2005-03-14 14:56:35 EST
Added Varargs test027 to detect for collision case.
Comment 6 Olivier Thomann CLA 2005-03-30 19:05:34 EST
Verified in 20050330-0500