Bug 95538 - Operation not supported in JLS2 AST from resolving MethodBinding
Summary: Operation not supported in JLS2 AST from resolving MethodBinding
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 RC1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-17 08:59 EDT by Rob Grzywinski CLA
Modified: 2005-06-01 08:04 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 Rob Grzywinski CLA 2005-05-17 08:59:07 EDT
I haven't done a full examination of the problem but when I switched from 3.1M6
to 3.1M7 my app is now throwing:

java.lang.UnsupportedOperationException: Operation not supported in JLS2 AST
	at org.eclipse.jdt.core.dom.ASTNode.unsupportedIn2(ASTNode.java:1758)
	at
org.eclipse.jdt.core.dom.SingleVariableDeclaration.isVarargs(SingleVariableDeclaration.java:553)
	at
org.eclipse.jdt.core.dom.MethodBinding.getUnresolvedJavaElement(MethodBinding.java:182)
	at org.eclipse.jdt.core.dom.MethodBinding.getJavaElement(MethodBinding.java:161)

It seems that lines 180 - 185 of org.eclipse.jdt.core.dom.MethodBinding were
added between 3.1M6 and 3.1M7:

	String typeSig = Util.getSignature(type);
	int arrayDim = parameter.getExtraDimensions();
	if (parameter.isVarargs())
		arrayDim++;
	if (arrayDim > 0)
		typeSig = Signature.createArraySignature(typeSig, arrayDim);


When using a JLS2 AST from:

   org.eclipse.jdt.core.dom.ASTParser.newParser(AST.JLS2)

calling IMethodBinding.getJavaElement() causes an exception to be thrown.

It seems that AST.JLS2 is now deprecated but that shouldn't mean that
functionality that depends on it is broken?  My application specifically
excludes 1.5 (JLS3) functionality so am I forced to use JLS3 and deal with the
consequences?
Comment 1 Olivier Thomann CLA 2005-05-17 11:27:31 EDT
I will investigate it.
Comment 2 Olivier Thomann CLA 2005-05-17 11:29:07 EDT
JLS3 doesn't mean it is for 1.5 code only. JLS3 can be used for any kind of
code. This is a bug, but you should definitely move your code to JLS3.
Comment 3 Rob Grzywinski CLA 2005-05-17 11:45:34 EDT
I know that I have to move to JLS3 eventually but I was hoping to put it off as
long as possible.  I was using JLS2 to allow me to cull out a number of things
that I didn't want to have to think about yet.  

I guess that now is as good a time as any to get off my lazy keister.

Is JLS2 a priority for 3.1?  I'm assuming "yes" for backwards compatibility.
Comment 4 Olivier Thomann CLA 2005-05-17 11:49:30 EDT
I would say yes. JLS2 should work.
Comment 5 Olivier Thomann CLA 2005-05-17 13:57:10 EDT
Added a protection for JLS3.
isVarargs() is only used if the api level is greater or equals to JLS3.
Fixed and released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverterTest2.test0606
Comment 6 Frederic Fusier CLA 2005-05-27 08:15:20 EDT
Verified for 3.1 RC1 with build I20050527-0010.
Comment 7 Rob Grzywinski CLA 2005-06-01 08:04:14 EDT
Confirm verified in 3.1 RC1

Thanks!