Bug 182360 - Only Jar and Zip files allowed for java.io.File in ClasspathContainers using
Summary: Only Jar and Zip files allowed for java.io.File in ClasspathContainers using
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 104157 154032 223414 (view as bug list)
Depends on:
Blocks: 227738
  Show dependency tree
 
Reported: 2007-04-13 13:06 EDT by Jason Sholl CLA
Modified: 2008-08-25 05:52 EDT (History)
6 users (show)

See Also:


Attachments
Proposed fix and regression tests (153.56 KB, patch)
2008-04-18 10:41 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Sholl CLA 2007-04-13 13:06:52 EDT
There is a breaking limitation preventing customer ClasspathContainers from including non .jar or .zip files.  The breakdown is coming from the call to org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(String name) from ClasspathEntry.validateClasspathEntry() on line 1674:

} else if (!org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(file.getName())) {

I think this line should be removed to allow classpath containers more flexibility in deciding what are valid archives.

WTP contains a classpath container used for resolving J2EE references within J2EE projects.  There are several types of J2EE modules, one of which is called a Connector.  Connectors have a spec requirement to be archived into .rar files.  Thus, if WTP's J2EE classpath container attempts to resolve a .rar file, it  fails because the above code generates an error similar to:

Illegal type of archive for required library: 'D:\workspaces\runtime-workspace-WTP_153-binaryprojects\AnEAR\EarContent\C1.rar' in project C2

The J2EE classpath container reads the MANIFEST.MF file for the module and resolves Class-Path:

Because there is no limitation on what a user can specify for their classpath it is conceivable someone might add just about anything.  Thus, this is why I request the above check removed (as to rather adding an some sort of extension for adding additional types).
Comment 1 Jerome Lanneluc CLA 2007-04-16 05:25:45 EDT
Will look at this for 3.4
Comment 2 Brian Lima CLA 2007-04-18 18:12:11 EDT
This issue causes a number of error messages to show up in the problems view when RARs are included in the classpath container.  For a large J2EE application including a RAR file is occasionally unavoidable.  I understand that it is possible to change the preference setting for the build path to allow the compiler to still build projects but the end result is that false errors show up and cause confusion.  While this may not be a big problem in a small application, a large J2EE application that is shipped to a number of customers is a different story.  Having to explain why there are errors in their workspace immediately after setup isn't a good thing.  It makes the application look bad and when the customer is told to ignore it because it's an Eclipse defect, that also looks bad. 

Can this defect be looked at for the 3.2 maintenance stream so that RAD v7 can pick up the change in it's own maintenance stream?
Comment 3 Philipe Mulet CLA 2007-04-18 20:18:13 EDT
This request is a feature request. Normally we wouldn't put a new feature in a maintenance release. So it will depend on the nature of the change implied. 

Beyond the Util method change, we need to be able to open a RAR file.
Is there standard API for reading RAR file contents ? Our approach is to only allow supported scenarii (i.e. JAR and ZIP archives).


Comment 4 Brian Lima CLA 2007-04-19 13:27:16 EDT
This type of RAR file is just a JAR file with a different extension so existing APIs to read JAR files should work.
Comment 5 Philipe Mulet CLA 2007-04-23 12:54:04 EDT
This isn't always the case that a RAR is a plain JAR (think winrar).
Now, we could let clients decide the extensions for Java archives (and not restrict to only JAR and ZIP); i.e. if you want other ones, then you would configure them, and be responsible for ensuring they are properly used.

I am thinking of a similar API as the one we added to let users configure the file extension for JAVA source files.

@see JavaCore#getJavaLikeExtensions()
Comment 6 Brian Lima CLA 2007-04-26 18:15:30 EDT
Since .RAR could be easily added to the preference for a Java Archive that does sound like it could work in my scenario specifically and also in the more general case.
Comment 7 David Slubicki CLA 2008-04-01 22:25:57 EDT
Hello, 
Is there any update on the status of this request?  Is it still being considered for inclusion in 3.4?
Thanks
Comment 8 Jerome Lanneluc CLA 2008-04-10 10:50:25 EDT
*** Bug 223414 has been marked as a duplicate of this bug. ***
Comment 9 Brian Lima CLA 2008-04-10 11:06:02 EDT
I'd certainly like to see this fixed as it impacts the product I work on.
Comment 10 Jerome Lanneluc CLA 2008-04-10 11:06:43 EDT
I will try to have a look at this for 3.4M7. Note that at this stage of the release, we will only be able to support .rar files that are actually archives (ie. files that can be read using java.util.zip.ZipFile).

In 3.5, we can imagine being able to decode .rar files that are not archives by providing an extension point that a client could implement to decode the .rar files.
Comment 11 Jason Sholl CLA 2008-04-10 14:47:13 EDT
All we need is support for java.util.zip.ZipFile.  

I don't think you even need to worry about the extension point.  If the Java VM doesn't support other encoding types, eclipse shouldn't support them either.  The code wouldn't work at runtime outside eclipse.
Comment 12 Eugene Kuleshov CLA 2008-04-10 15:00:45 EDT
(In reply to comment #11)
> All we need is support for java.util.zip.ZipFile.

I also agree with that. However, please note that those archives can have practically arbitrary file extensions (.rar, .par and .ejb3 can be used by some app servers), but they all still use same ZipFile format.
Comment 13 Jerome Lanneluc CLA 2008-04-18 10:41:14 EDT
Created attachment 96606 [details]
Proposed fix and regression tests
Comment 14 Jerome Lanneluc CLA 2008-04-18 11:31:43 EDT
(In reply to comment #13)
To clarify, with this fix any file can now be put on the build path (the batch compiler will still reject .java and .class files that are classpath entries though).
If the file is not a ZipFile, it will appear with no children in the Package Explorer and JDT tools will behave as if it was not present. Otherwise, if the file is a ZipFile, it will behave exactly as if it was a .zip or .jar file.
Comment 15 Jerome Lanneluc CLA 2008-04-21 10:44:22 EDT
Fix and tests released for 3.4M7
Comment 16 Maxime Daniel CLA 2008-04-28 10:23:43 EDT
Tested extensions .rar, .dummy, .java and .class with build I20080427-2000.
Also tested .dummy directly as an external archive, and through a user library.

Question: what is the rationale for having the batch compiler behave differently? (Comparing with javac 1.6, the latter accepts archives which name ends with .class and .java on its classpath.)
Comment 17 Jerome Lanneluc CLA 2008-04-28 10:50:08 EDT
I guess this is because I didn't know that javac 6 relaxed its limitations (javac 1.5.0 ignores .java files on the classpath). So it sounds like we should check the compliance. Can you please enter a separate bug report?
Comment 18 Maxime Daniel CLA 2008-04-29 03:46:24 EDT
In fact, javac 1.5 ignores .dummy, .class and .rar files as well... Which means that our new behavior matches neither javac 1.5 nor javac 1.6 behavior.

Opened bug 229236 to track the specifics of the batch compiler.
Comment 19 Maxime Daniel CLA 2008-04-29 03:47:24 EDT
Verified for 3.4 M7 using build I20080427-2000.
Comment 20 Jerome Lanneluc CLA 2008-08-13 10:18:37 EDT
*** Bug 154032 has been marked as a duplicate of this bug. ***
Comment 21 Jerome Lanneluc CLA 2008-08-25 05:52:46 EDT
*** Bug 104157 has been marked as a duplicate of this bug. ***