Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333073

Summary: [jar exporter] Cannot retrieve CRC and compressed size of files within eclipse-created jar-file from an external application.
Product: [Eclipse Project] JDT Reporter: Evgeny Avtsin <ewa>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED NOT_ECLIPSE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, markus.kell.r, ob1.eclipse, prakash
Version: 3.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Evgeny Avtsin CLA 2010-12-22 06:27:24 EST
Build Identifier: 3.5.1

I have a problem by retrieving data about files within eclipse-generated jar-file.
ZipEntry::getCompressedSize() and ZipEntry::getCrc() do no return appropriate values.
It seems data is stored in an extended local header.

I believe API for reading compressed data should be published since Eclipse is an open source project...



Reproducible: Always

Steps to Reproduce:
1.Select the java project
2.Export -> Java -> Runnable Java file
3.Read the content via the java's ZipEntry: CRC and Size aren't retrieved. At the same time WinZip shows the proper values.
Comment 1 Prakash Rangaraj CLA 2010-12-22 11:32:08 EST
Oleg,
    Why is this assigned to PDE Build? Shouldn't this go to JDT UI?
Comment 2 Oleg Besedin CLA 2010-12-22 11:56:50 EST
Ops, you are right: the dialog is 
 FatJarPackageWizard (from org.eclipse.jdt.internal.ui.jarpackagerfat),
uses 
 UnpackFatJarBuilder (from org.eclipse.jdt.internal.ui.jarpackagerfat)
Comment 3 Dani Megert CLA 2010-12-22 12:27:20 EST
Can you please explain what you try to do?
Comment 4 Evgeny Avtsin CLA 2010-12-23 06:17:05 EST
(In reply to comment #3)
> Can you please explain what you try to do?

I should show the content of jar-file to the user of my java application: file name, CRC, size etc. In eclipse-generated jar-files some data is stored in extended local header instead of basic header and ZipEntry cannot retrieve it.

I need to know structure of extended header of jar-file for parsing the return value of ZipEntry::getExtra() to get size and CRC values.
Comment 5 Evgeny Avtsin CLA 2010-12-29 09:16:13 EST
I digged into the problem. Since the extra field is not used in JarWriter4.java, it seems jar-files are creating incomplete or including incompatible data. 

What version of Java is used for building Eclipse?
Comment 6 Dani Megert CLA 2011-01-03 06:09:49 EST
Using 3.7 M4 with Oracle 1.6 JRE I added
public class Test {
	public static void main(String[] args) {

	}
}
and exported it as 'JAR file' and as 'Runnable JAR file'. Both created JARs have the CRC and compressed size information when looking at the included files e.g. via WinZip.
Comment 7 Evgeny Avtsin CLA 2011-02-03 09:14:42 EST
The issue is caused by a bug in java.util.zip.ZipInputStream: ZipEntry items are creating incomplete.
The same jar-file is reading fine by java.util.zip.ZipFile.
Comment 8 Markus Keller CLA 2011-02-03 10:18:53 EST
(In reply to comment #7)
Thanks for the feedback. Please file a bug against your JDK.
Comment 9 Evgeny Avtsin CLA 2011-02-08 10:41:47 EST
The bug report #7015881 was opened in Oracle Bug Database. 
It's still hidden due to "security reasons".