Bug 43883

Summary: Compile fails on Win2k but works on Linux box
Product: [Tools] AspectJ Reporter: kasi gaadu <kasigaadu>
Component: CompilerAssignee: Jim Hugunin <jim-aj>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P4 CC: kasigaadu, matthew_webster
Version: 1.1.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Test Aspect which has the static variable
none
RMI interface
none
RMI Server / implementation none

Description kasi gaadu CLA 2003-09-29 21:39:13 EDT
Hi,
   I have a RMI server program which sets a static variable value in my aspect 
dynamically. The program does not compile when run on Win2K box. But, the same 
program(s) compile perfectly (and I could run it as well) on RedHat Linux8.0. 

I am attaching my test programs to this bug report. 

The Compilation errors are: 

--------------------------------------------------------------------------------
C:\proj\FirstAspect\first\aspect\SetMethodImpl.java:26 The method setMethodName
(String) is undefined for the type Test
tstObj.setMethodName(method);
       ^^^^^^^^^^^^^
C:\proj\FirstAspect\first\aspect\SetMethodImpl.java:28 tstObj.methodName cannot 
be resolved or is not a field
System.out.println("MethodName: " + tstObj.methodName);
                                    ^^^^^^^^^^^^^^^^^

2 errors

--------------------------------------------------------------------------------
Comment 1 kasi gaadu CLA 2003-09-29 21:40:14 EDT
Created attachment 6280 [details]
Test Aspect which has the static variable
Comment 2 kasi gaadu CLA 2003-09-29 21:43:28 EDT
Created attachment 6281 [details]
RMI interface
Comment 3 kasi gaadu CLA 2003-09-29 21:44:03 EDT
Created attachment 6282 [details]
RMI Server / implementation
Comment 4 Matthew Webster CLA 2003-11-10 08:16:18 EST
The sample as supplied won't compile. This is because the SetMethodImpl 
constructor is trying to directly instantiate the aspect Test which gives the 
following error:

	The constructor Test() is not visible

The fact that you were able to get past this and fail later plus the fact that 
you get different behaviour in differnet environments leads me to believe that 
this is a configuration problem i.e. that you have another version of Test on 
your classpath.

Another observation is the invocation of a static method using an instance is 
generally frowned upon. You should use the class instead i.e.

    Test.methodName()

This would obviate the need to obtain an instance of the aspect.

Jim I recommend closing this bug.
Comment 5 Jim Hugunin CLA 2004-03-18 13:00:19 EST
I agree with Matthew's analysis and I'm marking this invalid.  You shouldn't 
be able to directly call the constructor of an aspect.  The fact that this 
works on one system suggests a configuration problem.  You can fix your 
program by removing the "new Test()" constructor call.  If the error persists 
after this fix, please reopen the bug.