Bug 104664

Summary: [compiler] repeat mode is broken in the batch compiler
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
Proposed fix none

Description Olivier Thomann CLA 2005-07-21 10:28:13 EDT
Using -repeat 5 with the batch compiler is broken when jar files are used on the
classpath.

java.lang.IllegalStateException: zip file closed
   at java.util.zip.ZipFile.ensureOpen(ZipFile.java:519)
   at java.util.zip.ZipFile.entries(ZipFile.java:407)
   at
org.eclipse.jdt.internal.compiler.batch.ClasspathJar.isPackage(ClasspathJar.java:59)
   at
org.eclipse.jdt.internal.compiler.batch.ClasspathJar.findClass(ClasspathJar.java:40)
   at
org.eclipse.jdt.internal.compiler.batch.FileSystem.findClass(FileSystem.java:147)
   at
org.eclipse.jdt.internal.compiler.batch.FileSystem.findType(FileSystem.java:171)
   at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createPackage(LookupEnvironment.java:517)
   at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:83)
   at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:144)
   at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:292)
   at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:315)
   at
org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:2692)
   at
org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1151)[repetition 2/5]
 
   at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1048)
   at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1040)
   at org.eclipse.jdt.core.tools.compiler.Compile.main(Compile.java:19)

The first compilation resets the internal zip file of the ClasspathJar object.
Comment 1 Olivier Thomann CLA 2005-07-21 10:32:03 EDT
Created attachment 25132 [details]
Proposed fix

I simply use the zipFile internally. The zipFile is created again using the
file in the second iteration.
Comment 2 Olivier Thomann CLA 2005-07-21 11:04:50 EDT
I am working on a better patch.
Comment 3 Olivier Thomann CLA 2005-07-21 11:16:13 EDT
Created attachment 25135 [details]
Proposed fix

New patch. The zip file is created in an initialize method. This is called only
when the library is retrieved, so this doesn't penalize any subsequent calls to
isPackage(...) or findClass(...).
Comment 4 Olivier Thomann CLA 2005-07-25 10:26:08 EDT
Fixed and released in HEAD.
Regression test in
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test033
Comment 5 Olivier Thomann CLA 2005-07-25 11:16:44 EDT
Backported to 3.1 maintenance stream.
Comment 6 Jerome Lanneluc CLA 2005-08-11 10:33:31 EDT
Verified with 3.2 M1
Comment 7 Maxime Daniel CLA 2005-09-21 09:16:07 EDT
Verified for 3.2 M2 with build I20050920-0010.
Comment 8 David Audel CLA 2005-09-26 12:38:33 EDT
Verified using M20050923-1430 for 3.1.1