Community
Participate
Working Groups
-sourcepath support is ok for directory, but it doesn't seem to work for jar or zip files.
In org.eclipse.jdt.internal.compiler.batch.ClasspathJar, we are only looking for .class files. Never for source files. org.eclipse.jdt.internal.compiler.batch.ClasspathDirectory is correctly checking source files and class files.
-sourcepath sourcepath Specify the source code path to search for class or interface definitions. As with the user class path, source path entries are separated by semicolons (;) and can be directories, JAR archives, or ZIP archives. If packages are used, the local path name within the directory or archive must reflect the package name. Note: Classes found through the classpath are subject to automatic recompilation if their sources are found.
Created attachment 37664 [details] Proposed fix To verify, try to compile the following code: public class X extends p.Bar { } where p.Bar is located within a zip or a jar file and you run the batch using: D:/tests_sources/X.java -d d:\tests_sources -classpath d:\tests_sources -sourcepath d:\tests_sources\lib.zip -time -g -1.5 -preserveAllLocals
Maxime and Philippe, Let me know if you believe that this should be fixed. The attached patch works well and in fact javac 1.5 doesn't handle this case well and javac 6.0 fails to create p.Bar in the right folder. It creates a folder called "lib.zip(p" in which it puts Bar.class. So at runtime, the class p.Bar is not found.
javac 1.5 compiles referenced types in place. If you use the following setup: src/Used.java User.java public class User { Used m; } and do javac -sourcepath src User.java, you get the following new files: src/Used.class User.class I believe that this would call for a clarification of the use of the -sourcepath option if it were to accept archives (notwithstanding its interaction with other options).
Fixing this would make -sourcepath compatible with what javac supports (in theory). -sourcepath sourcepath Specify the source code path to search for class or interface definitions. As with the user class path, source path entries are separated by semicolons (;) and can be directories, JAR archives, or ZIP archives. If packages are used, the local path name within the directory or archive must reflect the package name. Note that classes found through the classpath are subject to automatic recompilation if their sources are found. It could be convenient to compile using a zip that contains the source code. Might be slower though.
Philippe, Do you want this to be fixed? Technically we are ok with the description in the print usage of the batch compiler, but this is not equivalent to the same option for javac. So to have a better compatibility between the two compilers, it could be a plus. If we don't fix it, we might verify that elements on the -sourcepath option are directories and reject jar/zip files.
Maxime, Could you please review the patch?
+1 for 3.2RC1
Created attachment 38355 [details] New patch Maxime, This new patch defines a subclass of ClasspathJar called ClasspathSourceJar to handle the case of the -sourcepath. I also updated the print usage. All generated files are put in the output folder. This makes a more consistent behavior. I will release if all tests passed.
Created attachment 38356 [details] Regression tests updated Updated BatchCompilerTests
Fixed and released in HEAD.
(In reply to comment #8) > Maxime, > > Could you please review the patch? > I think I would have a couple of questions. Would you sametime me this afternoon?
Verified for 3.2 RC1 using build I20060413-0010