Bug 75568 - ajc changes classfile timestamps even if compilation fails (regression)
Summary: ajc changes classfile timestamps even if compilation fails (regression)
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 1.2.1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-04 10:12 EDT by Per S Hustad CLA
Modified: 2004-10-21 04:32 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 Per S Hustad CLA 2004-10-04 10:12:39 EDT
It appears that ajc 1.2 updates a classfile timestamps even if the compilation 
fails. This breaks the integration with the Ant build system. E.g. using the 
ant "javac" task with the Ajc11CompilerAdapter interface, the compilation may 
fail on the first attempt and succeed on the second attempt, - because ajc has 
touched the timestamp and Ant hence decides that nothing needs to be recompiled.

This did not happen in ajc 1.1.

To reproduce:
1. In the examples/observer folder, run a build:
 ajc -sourceroots . 
2. Edit the "Demo.java" class and insert the line "DONT COMPILE"
3. Run the compilation again. The compiler displays the correct error message 
but the Demo.class file has been updated with the compile-time timestamp.
Comment 1 Matthew Webster CLA 2004-10-08 05:51:43 EDT
I do not see this problem using ajc (rather than the Ant task). The behaviour 
would now seem to be consistent with javac i.e. we compile what we can. The 
timestamps remain unchanged for the classes that fail to be compiled. It is 
not peculiar to "-sourceroots" e.g. "ajc observer/*.java" has the same effect. 
When the syntax error in Demo.java is corrected everything is rebuilt.

It seems the problem may lie in the adapter.
Comment 2 Per S Hustad CLA 2004-10-08 07:48:10 EDT
I still cannot see that ajc is consistent with javac. E.g. create a standard 
java class, e.g. class Test {}  and store it in "Test.java". Then compile with 
javac:
$ javac Test.java
$ ls --full-time Test.class 
 -rwxrwxrwx    1 t539956  mkpasswd      182 Fri Oct 08 13:25:29 2004 Test.class*

Then insert some syntax errors in Test.java and recompile with javac
$ javac Test.java
Test.java:2: <identifier> expected
  DONT_COMPILE;
              ^
Test.java:2: cannot resolve symbol
symbol  : class DONT_COMPILE  
location: class Test
  DONT_COMPILE;
  ^
2 errors
$ ls --full-time Test.class 
-rwxrwxrwx    1 t539956  mkpasswd      182 Fri Oct 08 13:25:29 2004 Test.class*

I.e. javac has not changed the Test.class timestamp
Now compile with ajc:

$ ajc Test.java
C:\aspectj1.2\doc\examples\Test.java:2 [error] Syntax error on 
token "DONT_COMPILE", VariableDeclarator expected after this token
DONT_COMPILE;
^^^^^^^^^

1 error
$ ls --full-time Test.class  
-rwxrwxrwx    1 t539956  mkpasswd      410 Fri Oct 08 13:28:40 2004 Test.class*

Summary: ajc has changed the Test.class timestamp while javac has not. 
Comment 3 Andrew Clement CLA 2004-10-14 07:03:12 EDT
I believe this is due to the lack of support for '-proceedOnError' which is
claimed to be a supported flag.  It seems to be defaulting to *ON* which means
we write out files even if things go wrong.  I am just adding support for it now
so it will default to OFF unless you specify -proceedOnError.
Comment 4 Andrew Clement CLA 2004-10-14 09:06:48 EDT
Two bugs:

1) -proceedOnError is defaulting to ON regardless of what you pass in.
2) -proceedOnError is ignored when deciding whether to do weaving.  We should go
into weaving even if there were compile errors *if* proceedOnError was set (see
bug 74245).

I have modified the options processing to take account of -proceedOnError - the
value is stored in the buildconfig object.  I have also changed the decision
about whether to weave to check the proceedOnError setting. 

Fix checked in, waiting for build.
Comment 5 Andrew Clement CLA 2004-10-19 04:29:47 EDT
Fix available.

BUILD COMPLETE -  build.383
Date of build: 10/18/2004 23:39:49
Time to build: 113 minutes 41 seconds
Last changed: 10/18/2004 13:04:09
Latest good AspectJ jar available at:
download.eclipse.org/technology/ajdt/dev/aspectj-DEVELOPMENT.jar
Comment 6 Adrian Colyer CLA 2004-10-21 04:32:26 EDT
Fix released as part of AspectJ 1.2.1