Bug 236164 - JDT + Ant: Unexpected behavior in J2SE 1.6.4
Summary: JDT + Ant: Unexpected behavior in J2SE 1.6.4
Status: VERIFIED NOT_ECLIPSE
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: 3.7 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-06 23:38 EDT by Dop Sun CLA
Modified: 2010-08-03 06:00 EDT (History)
4 users (show)

See Also:


Attachments
Sample project for bug: 236164 (353.88 KB, application/octet-stream)
2010-04-23 08:57 EDT, Dop Sun CLA
no flags Details
Build.xml that is using the Eclipse compiler and use a verbose mode (1.23 KB, text/plain)
2010-07-20 15:37 EDT, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dop Sun CLA 2008-06-06 23:38:14 EDT
Build ID: I20080530-1730

Steps To Reproduce:
1.Create a simple Java project, which contains two packages A and B. Classes in Package B depends on classes defined in package A.
2. Using a Ant build file, which builds packages A into jar A, and package B in Jar B.
3.The problem is: if package A depends on 3rd party jars, and package B only depends Jar A. Now, the issue is the 3rd party jars needs to be in class path while compiling package B.

I have tested in the J2SE 1.6.3 and 1.6.4. It works perfect fine in 1.6.3, means while switching to 1.6.3, Package B can be compiled with reference to jar containing package A only (no need to add the 3rd party libraries for compilation).

I have checked the log files, it looks like while doing the compilation, it recompiles all source codes it depends (provided that the source codes are all in the same project).

More information:
I guess this is the issue with the J2SE build, it's not fair to put it as Eclipse or Ant issue. But since 1.6.4 is recommended in the target operation environment list of 3.4 work plan. This may be an issue.

The issue appears in Build id: I20080530-1730 also.
Comment 1 Dop Sun CLA 2008-06-07 00:13:50 EDT
Tried using J2SE 1.6.6, the issue appears either. This may be the issue with the J2SE build since 1.6.4.

The question is: Eclipse has its own compiler or using the stand compiler?

Workaround of this may be:
While compiling, put all dependencies to build package B. But while packing the jar files, excludes the classes files created during compilation.

Looks a little bit strange, but it can work.
Comment 2 Jerome Lanneluc CLA 2008-06-09 06:55:26 EDT
Could you please provide an example project and the corresponding Ant build file that show the problem?
Comment 3 Philipe Mulet CLA 2008-06-09 07:05:46 EDT
Re: comment 1
> The question is: Eclipse has its own compiler or using the stand compiler?

Eclipse defines its own Java compiler used by the IDE. For Ant scripts, you need to toggle a property to use it, if not you are likely using the default javac tool.

For instructions on how to use it in Ant task, please read section "Using the ant javac adapter" at http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm
Comment 4 Jerome Lanneluc CLA 2008-06-09 07:33:54 EDT
(In reply to comment #3)
> Re: comment 1
> > The question is: Eclipse has its own compiler or using the stand compiler?
> 
> Eclipse defines its own Java compiler used by the IDE. For Ant scripts, you
> need to toggle a property to use it, if not you are likely using the default
> javac tool.
> 
> For instructions on how to use it in Ant task, please read section "Using the
> ant javac adapter" at
> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm
> 
To clarify this point, I changed the Java builder section in Java Development User Guide to:
The Java builder builds Java programs using its own compiler (the Eclipse Compiler for Java) that implements the Java Language Specification.  The Java builder can build programs incrementally as individual Java files are saved. Note that the Eclipse Compiler for Java can also be invoked using Ant as described in the Using the ant javac adapter section of Compiling Java code



Comment 5 Kent Johnson CLA 2008-11-10 09:34:44 EST
Please attach the sample projects & the ant script.
Comment 6 Olivier Thomann CLA 2010-04-22 14:19:07 EDT
Closing as WORKSFORME.
No news. Timed out!
Comment 7 Dop Sun CLA 2010-04-23 08:57:29 EDT
Created attachment 165903 [details]
Sample project for bug: 236164

Drag the build.xml into the Ant view:

* buildA: it can run successfully to create a.jar into the ./libs folder
* buildAll: it can run successfully to create a.jar and b.jar into the ./libs folder
* buildB: this is where the issue is: if execute the buildA (i.e. run buildA separately), then run buildB, it will fail. But if add the 
<pathelement path="./libs/log4j-1.2.15.jar"/>
into the classpath, it will be successfully.

The interesting is: if we run buildAll, it can success (even without extra class path entry)
Comment 8 Olivier Thomann CLA 2010-04-23 09:00:32 EDT
reopening for investigation.
Comment 9 Dop Sun CLA 2010-04-23 09:01:15 EDT
I don't know whether i received email before but ignored or filtered by my email rules (outlook), I did not follow this issue.

Thanks for follow up this issue. I just uploaded the sample project for re-creating the issue.

Very sorry for this, hope it's not too late.
Comment 10 Frederic Fusier CLA 2010-04-26 13:39:05 EDT
It seems to have been resolved by mistake, hence reopened again...
Comment 11 Olivier Thomann CLA 2010-07-20 15:36:08 EDT
This is not related to Eclipse as is as you are not even calling the Eclipse compiler.
You can debug it by using the build.xml I will attach to the bug report.
Basically the problem comes from the fact that as soon as ClassA is retrieved from source you need the log4j jar on the classpath.
Closing as NOT_ECLIPSE.
Comment 12 Olivier Thomann CLA 2010-07-20 15:37:23 EDT
Created attachment 174785 [details]
Build.xml that is using the Eclipse compiler and use a verbose mode

You need to run this script from within Eclipse using the same JRE as the workspace (see the tabs in the launching configuration).
Comment 13 Satyam Kandula CLA 2010-08-03 06:00:29 EDT
Verified for 3.7M1