Bug 62073 - false ambigous binding error (introduced in 1.2rc2)
Summary: false ambigous binding error (introduced in 1.2rc2)
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 1.5.0   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-13 07:31 EDT by attila lendvai CLA
Modified: 2006-05-30 04:13 EDT (History)
0 users

See Also:


Attachments
the file in question (5.29 KB, text/plain)
2004-05-13 07:34 EDT, attila lendvai CLA
no flags Details
the file that probably triggers it (1.65 KB, text/plain)
2004-05-13 07:39 EDT, attila lendvai CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description attila lendvai CLA 2004-05-13 07:31:55 EDT
QuestionGroupTreeViewScreen.java:29 error Ambiguous binding of type net.sf.
hibernate.Session.  Use one args(..) per matched join point

import com.netvisor.common.data_model_metadata.EntityMetadata.Property;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

see attached file.
Comment 1 attila lendvai CLA 2004-05-13 07:34:02 EDT
Created attachment 10592 [details]
the file in question

btw, i've encountered several aspectj compiler problems with importing/using
inner types. this one is an inner interface of an interface.
(EntityMetadata.Property)
Comment 2 attila lendvai CLA 2004-05-13 07:39:15 EDT
Created attachment 10593 [details]
the file that probably triggers it

well, it's not a false error, but reported at the wrong place... the problem is
here:

	Object around(Session connection): sessionableMethods()
		&& ((args(connection, ..)) || (args(connection))) 
	{

this aspect is in a jar file on the classpath and it's concretized by an aspect
while compiling. it open/closes hiebrnate connections automatically on demand.

but how else can i do the above match if it will remain like this?
Comment 3 Adrian Colyer CLA 2004-05-13 07:48:36 EDT
Thanks for trying out the new version so quickly. We'll look at the error 
message, but in the meantime you should be able to (re)write 

Object around(Session connection): sessionableMethods()
   && ((args(connection, ..)) || (args(connection))) 
{

as simply:

Object around(Session connection): sessionableMethods()
   && ((args(connection, ..)) 
{

since '..' matches zero or more arguments
Comment 4 Andrew Clement CLA 2004-05-13 08:23:22 EDT
Message was introduced for bug 61568.  The problem with the message is 
something that also occurs in bug 60015.  We have the right line number but 
the wrong file.
Comment 5 attila lendvai CLA 2004-05-13 09:07:49 EDT
"since '..' matches zero or more arguments"

negative. first i tried like that with an old aspectj, and as saw it doesn't 
work i added the extra || (args(connection)).

when the 1.2rc2 failed with the code i removed the extra args() and i end up 
with my old warning exception that the connection managed aspect doesn't work 
correctly.
Comment 6 attila lendvai CLA 2004-05-13 09:44:48 EDT
sorry for speeding again, i double checked rc1 and rc2 and it DOES work ok.

so, everything works fine except that the error message mentions the wrong file.
Comment 7 Andrew Clement CLA 2004-05-14 03:38:29 EDT
There is an unasserted rule in the message handling code (ours and the JDTs) 
that goes something like this:

If you log an error whilst processing a resource, the primary sourcelocation 
must be in that resource and not in some other resource.  

If you violate this rule you get the bizarre source contexts that this bug 
highlights.  It is a reasonable rule as when we log errors, we record them 
against the compilation result that the source location points to and when we 
have finished processing the resource we ask the infrastructure to 'accept' 
the compilation result and thats when the messages get put out.  

Suppose I am processing classes A and B, I finished processing A and there 
were no errors.  I'm now processing B, during that processing I find a problem 
that is actually because of something in A.  I cannot record my error against 
A because that has already been completely dealt with and anything I further 
record against it *wont get reported*.  In this situation the first source 
location for the error should be the 'thing' in B that causes you to realise 
there was a problem in A, and then the extra source location should point to A.

I have written some code to enforce this assertion and run the test harness - 
there were about 8 failures, and in every case there was a problem with the 
messages produced.  Usually the text is OK but the indication of where to look 
for the problem is garbage.

Comment 8 Andrew Clement CLA 2004-05-17 09:47:33 EDT
Fix checked in.  What I have done is:

- For this particular case, I report two source locations - firstly which line 
the variable binding was being attempted upon and secondly which line the 2nd 
args(..) was encountered.  This gives an error message like this:

C:\Eclipse\212\eclipse\aspectj_ws2\tests\bugs\DisjunctVarBinding_2.java:25 
error Ambiguous binding of type B using args(..) at this line.  Use one args
(..) per matched join point, see secondary source location for location of 
extraneous args(..)
foo(b,a); 
^^^^^^^^^^
	
see also: C:\Eclipse\212\eclipse\aspectj_ws2
\tests\bugs\DisjunctVarBinding_3.java:5

- To address the more general problem that we ought to 'assert', I have put 
some code into WeaverMessageHandler.handleMessage() that detects the situation 
of someone passing in the wrong primary source location and just avoids the 
processing that would lead to incorrect source context being reported (and so 
there is no problem with the error being logged against the wrong compilation 
result)

I will move this bug to a enhancement request for post 1.2 to look at sorting 
out the error handling properly, putting the assert in and properly fixing the 
places that pass in unhelpful source locations.

So, to sum up: With the fix in, you will get correct information, but with a 
little further work (too much to do before final) we can get you more 
information.
Comment 9 Adrian Colyer CLA 2005-03-22 09:03:21 EST
this bug seems to be with you from the commentary andy...
Comment 10 Andrew Clement CLA 2006-05-30 04:13:41 EDT
no updates for a while - I don't plan on doing more under this bug.  I know we've done quite a bit to 'loosen' restrictions on binding, I imagine the new pointcut rewriter in 1.5 will allow Attilas original pointcut now...