Bug 84296 - [jdt-parser] Missleading error message on missing variable idientifier
Summary: [jdt-parser] Missleading error message on missing variable idientifier
Status: RESOLVED WONTFIX
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-02 18:24 EST by Eric Bodden CLA
Modified: 2005-09-21 12:43 EDT (History)
0 users

See Also:


Attachments
Eclipse project producing the error (6.02 KB, application/zip)
2005-02-02 18:25 EST, Eric Bodden CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Bodden CLA 2005-02-02 18:24:29 EST
In the current 20050202 build, type resolution seems to be broken:

The attached project gives the error "ConstantArguments cannot be resolved" 
although the class resides in the same package as the importing aspect. Even 
full qualification and an (actually unnecessary import) do not work.
Comment 1 Eric Bodden CLA 2005-02-02 18:25:00 EST
Created attachment 17640 [details]
Eclipse project producing the error
Comment 2 Andrew Clement CLA 2005-02-03 05:54:48 EST
Hmmm.  The failing code looks like this from the ConstantArgumentsAspect around
advice:

Object around(): constantArgumentMethods() {        

Signature sig =
     thisJoinPointStaticPart.getSignature();
Class c = sig.getDeclaringType();
MethodSignature msig =
     (MethodSignature)thisJoinPointStaticPart.getSignature();
Method m = c.getMethod(sig.getName(), msig.getParameterTypes());
ConstantArguments = (ConstantArguments) m.getAnnotation(ConstantArguments.class);
              
        
Shouldn't that last line read:

ConstantArguments annotation = 
  (ConstantArguments) m.getAnnotation(ConstantArguments.class);

The message is refering to the fact that ConstantArguments is not defined as a
field.
Comment 3 Eric Bodden CLA 2005-02-03 06:35:03 EST
(In reply to comment #2)
> Shouldn't that last line read:
> 
> ConstantArguments annotation = 
>   (ConstantArguments) m.getAnnotation(ConstantArguments.class);

Ah, oh course you are right. Anyway in that case I find the error message really 
missleading because it should say something like "identifier expected" rather 
than "ConstantArguments cannot be resonved".
Comment 4 Adrian Colyer CLA 2005-03-23 09:32:57 EST
more parser fun for aj5m3...
Comment 5 Adrian Colyer CLA 2005-09-21 12:43:07 EDT
We behave in exactly the same way as the Eclipse 3.1 JDT compiler on this
program. It's not around advice related. The program:

public class PoorErrorMessage {
	
	void aMethod() {
		Foo = getFoo(); // note missing identifier
	}
	
	Foo getFoo() { return null; }
}

class Foo {}

gives the same message "Foo cannot be resolved".

I think this is a reasonable message for the compiler to issue, the statement is
a well-formed Java statement assigning the result of a call to getFoo to a
variable called "Foo". Since there is no variable "Foo" in scope, you get the
resulting message. The only point of confusion here is that you used a type name
as the "variable" name - but I still contend the message is reasonable. You
could raise a JDT bug if you disagree, and if they fix it we will pick up that
fix in a future version of AspectJ