Bug 131791 - M5 - Refresh of a single directory can result in compilation problems when using annotation processor
Summary: M5 - Refresh of a single directory can result in compilation problems when us...
Status: RESOLVED DUPLICATE of bug 135729
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-14 14:40 EST by Kahli Burke CLA
Modified: 2007-07-29 09:19 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kahli Burke CLA 2006-03-14 14:40:57 EST
I have a project using JAX-WS, and I use an ant task to run the annotation processor against my web service source and generate the server side artifacts.  I have the ant task configured to produce both the source code and compiled classes.  For example, assume I have the following package structure:

com.example.echo
    Echo.java
    BeanObject.java
com.example.echo.jaxws
    <Generated Source>

Lets assume that the Echo class has a web method that returns a BeanObject.  When I add a web method to Echo and run my ant task to run the annotation processor, code is generated and placed into com.example.echo.jaxws.  That generated code will import BeanObject.  The code is also compiled into the build directory, and the BeanObject class will also get recompiled by the annotation processor.

At this point, if I refresh the entire project, I have no problems and will see any new classes generated by the annotation processor.  But if I refresh any of the subdirectories, I get errors like "com.example.echo.BeanObj cannot be resolved to a type" coming from the generated classes. This occurs regardless of whether any new classes have been generated.   It seems that simply the recompilation through the annotation processor is enough the cause a problem.  If I compare the compiled class files (one compiled by eclipse, the other by apt) the files are the same size but diff reports them as different.

Once the project is in this state, a refresh of the entire project will not fix it, the only way to correct it is to clean and rebuild the project.

This did not occur in earlier versions, I tested with 3.2M4 and 3.1.2.
Comment 1 Olivier Thomann CLA 2006-03-14 14:44:32 EST
Moving to JDT/APT
Comment 2 Jess Garms CLA 2006-03-24 14:52:04 EST
It sounds like this may be a bug in JDT rather than APT. Are you using the APT support in Eclipse, or simply executing apt.exe (part of the JDK) from within ant?
Comment 3 Kahli Burke CLA 2006-03-24 14:58:11 EST
Yes, I think it would apply to the JDT. I'm not using the annotation processor within Eclipse, I'm running apt through an ant build outside of Eclipse, and then I get this problem with I refresh the package where code has been generated/compiled by apt.
Comment 4 Olivier Thomann CLA 2006-03-24 15:00:53 EST
Moving back to JDT/Core.

What do you mean by "If I compare the compiled class files (one compiled by eclipse, the other by
apt) the files are the same size but diff reports them as different." ?
How are they different ?
Comment 5 Kahli Burke CLA 2006-03-24 15:14:30 EST
I just mean that the class files are not identical when compiled by apt vs. Eclipse.  This may not be relevant, I'm not sure.

 APT generates the source code and also compiles the source.  If I do a clean build through Eclipse, then Eclipse will be compiling that source.  If I save the compiled class file, and then run my apt ant task, the file will be recompiled.  If I compare the saved Eclipse compiled file with the apt compiled file using diff, they aren't the same.  The modification timestamps would also not be the same, obviously.  This may just have to do with the differences in the compilers, where both would generate valid bytecode they might not be identical.  The file sizes are the same however.  As far as the specific differences in the files, I'm not very knowledgeable about the structure of the classfile/bytecode.  I noticed that certain structures such as the InnerClass table were in different positions, but I don't know what the consequences of that would be, if any. 

I thought this might have something to do with Eclipse not recognizing those classes when I perform the refresh, but this is just speculation.

I can provide a test case if it would make things easier, I just didn't want to attach here because the file would be rather large, there are a lot of library jars that would need to be included for the JAXWS framework.
Comment 6 Olivier Thomann CLA 2006-03-27 23:23:59 EST
Yes, please. I would be interested by a reproducable test case.
Thanks.
Comment 7 Olivier Thomann CLA 2006-04-04 12:26:44 EDT
I cannot reproduce with 3.2M6.
Do you still have the issue on your side?
Comment 8 Kahli Burke CLA 2006-04-06 17:05:22 EDT
I just tested with 3.2M6 and I still have the same problem.  If anything is unclear about the steps to reproduce let me know and I'll clarify.  Also, I don't know that this would make any difference, but I'm testing on MacOS.  I can try over on a linux machine and see if the problem occurs there. 
Comment 9 Olivier Thomann CLA 2006-04-06 20:30:03 EDT
yes, please. Try on Linux. I don't have an easy access to a Mac.
However I do have a linux box.
I tried the steps as described in the attachment you sent me and I could not reproduce.
Comment 10 Kahli Burke CLA 2006-04-06 21:05:06 EDT
I can reproduce on Linux with 3.2M6 as well.  Just to be clear here are the steps that reproduce the problem for me:

1. Get the project built correctly in eclipse (clean and rebuild).  Make sure Build Automatically is enabled.
2. Run the build-server-java ant task (I tried in eclipse or from the command line and got the same results)
3. Right click on com.example.jaxws.echo.impl.jaxws and select refresh. 
4. You should get build errors.
Comment 11 Kahli Burke CLA 2006-04-06 21:07:46 EDT
I had to change the build.xml slightly to get the ant task to work correctly on linux:

Here is what I used for the jaxws.classpath:

<path id="jaxws.classpath">
  <fileset dir="${lib}">
    <include name="*.jar"/>
  </fileset>
  <fileset dir="${java.home}/lib" includes="tools.jar"/>
</path>
Comment 12 Olivier Thomann CLA 2006-04-10 12:03:20 EDT
When I run it under Linux, I get:
build-server-java:
      [apt] warning: Annotation types without processors: [javax.annotation.Resource]
      [apt] 1 warning
      [apt] warning: Annotation types without processors: [javax.xml.bind.annotation.XmlRootElement, javax.xml.bind.annotation.XmlAccessorType, javax.xml.bind.annotation.XmlType, javax.xml.bind.annotation.XmlElement]
      [apt] 1 warning

Not sure this is expected. And once I do the refresh, no errors appear.
Could you please give me the error that your got?
I used N20060410-0010.

Your problem looks like bug 135729. This was supposed to be fixed in M6. It is weird that I cannot reproduce, but you can do it.

Would you have specific settings in your workspace? Would it be possible that instead of providing simply the project, you provide a workspace that contains only the project and in which you can reproduce this issue ?

Thanks.
Comment 13 Kahli Burke CLA 2006-04-21 13:25:58 EDT
I'm almost certain after reading about bug 135729 that they are the same issue.  As I read it, that issue has been reproduced and is not fixed in 3.2M6, but scheduled for a release candidate.  If you need anything more from me at this time, let me know.  

Thank you.
Comment 14 Olivier Thomann CLA 2006-04-21 13:27:06 EDT

*** This bug has been marked as a duplicate of 135729 ***
Comment 15 Eclipse Webmaster CLA 2007-07-29 09:19:17 EDT
Changing OS from Mac OS to Mac OS X as per bug 185991