author | jjh |
Wed, 15 Aug 2012 13:48:46 -0700 | |
changeset 13631 | dc1212c348f9 |
parent 13076 | cb848b70d7f4 |
child 14258 | 8d2148961366 |
permissions | -rw-r--r-- |
655
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
1 |
/* |
13631
dc1212c348f9
7191449: update copyright year to match last edit in jdk8 langtools repository
jjh
parents:
13076
diff
changeset
|
2 |
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. |
655
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
4 |
* |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
655
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
655
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
10 |
* |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
15 |
* accompanied this code). |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
16 |
* |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
20 |
* |
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
655
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
24 |
*/ |
1ebc7ce89018
6705945: com.sun.tools.javac.zip files do not have valid copyright
jjg
parents:
10
diff
changeset
|
25 |
|
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
26 |
package com.sun.tools.javac.file; |
10 | 27 |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
28 |
|
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
29 |
import java.io.File; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
30 |
import java.io.FileNotFoundException; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
31 |
import java.io.IOException; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
32 |
import java.io.RandomAccessFile; |
4073
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
33 |
import java.lang.ref.Reference; |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
34 |
import java.lang.ref.SoftReference; |
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
35 |
import java.util.ArrayList; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
36 |
import java.util.Arrays; |
865
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
37 |
import java.util.Calendar; |
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
38 |
import java.util.Collections; |
13076
cb848b70d7f4
7177701: error: Filling jar message during javax/imageio/metadata/IIOMetadataFormatImpl compilation
mcimadamore
parents:
8837
diff
changeset
|
39 |
import java.util.LinkedHashMap; |
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
40 |
import java.util.HashMap; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
41 |
import java.util.HashSet; |
10 | 42 |
import java.util.List; |
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
43 |
import java.util.Map; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
44 |
import java.util.Set; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
45 |
import java.util.zip.DataFormatException; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
46 |
import java.util.zip.Inflater; |
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
655
diff
changeset
|
47 |
import java.util.zip.ZipException; |
10 | 48 |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
49 |
import com.sun.tools.javac.file.RelativePath.RelativeDirectory; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
50 |
import com.sun.tools.javac.file.RelativePath.RelativeFile; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
51 |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
52 |
/** |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
53 |
* This class implements the building of index of a zip archive and access to |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
54 |
* its context. It also uses a prebuilt index if available. |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
55 |
* It supports invocations where it will serialize an optimized zip index file |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
56 |
* to disk. |
10 | 57 |
* |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
58 |
* In order to use a secondary index file, set "usezipindex" in the Options |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
59 |
* object when JavacFileManager is invoked. (You can pass "-XDusezipindex" on |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
60 |
* the command line.) |
10 | 61 |
* |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
62 |
* Location where to look for/generate optimized zip index files can be |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
63 |
* provided using "-XDcachezipindexdir=<directory>". If this flag is not |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
64 |
* provided, the default location is the value of the "java.io.tmpdir" system |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
65 |
* property. |
10 | 66 |
* |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
67 |
* If "-XDwritezipindexfiles" is specified, there will be new optimized index |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
68 |
* file created for each archive, used by the compiler for compilation, at the |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
69 |
* location specified by the "cachezipindexdir" option. |
10 | 70 |
* |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
71 |
* If system property nonBatchMode option is specified the compiler will use |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
72 |
* timestamp checking to reindex the zip files if it is needed. In batch mode |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
73 |
* the timestamps are not checked and the compiler uses the cached indexes. |
3380
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
1789
diff
changeset
|
74 |
* |
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
75 |
* <p><b>This is NOT part of any supported API. |
3380
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
1789
diff
changeset
|
76 |
* If you write code that depends on this, you do so at your own risk. |
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
1789
diff
changeset
|
77 |
* This code and its internal interfaces are subject to change or |
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
1789
diff
changeset
|
78 |
* deletion without notice.</b> |
10 | 79 |
*/ |
80 |
public class ZipFileIndex { |
|
81 |
private static final String MIN_CHAR = String.valueOf(Character.MIN_VALUE); |
|
82 |
private static final String MAX_CHAR = String.valueOf(Character.MAX_VALUE); |
|
83 |
||
84 |
public final static long NOT_MODIFIED = Long.MIN_VALUE; |
|
85 |
||
86 |
||
87 |
private static boolean NON_BATCH_MODE = System.getProperty("nonBatchMode") != null;// TODO: Use -XD compiler switch for this. |
|
88 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
89 |
private Map<RelativeDirectory, DirectoryEntry> directories = |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
90 |
Collections.<RelativeDirectory, DirectoryEntry>emptyMap(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
91 |
private Set<RelativeDirectory> allDirs = |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
92 |
Collections.<RelativeDirectory>emptySet(); |
10 | 93 |
|
94 |
// ZipFileIndex data entries |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
95 |
final File zipFile; |
4073
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
96 |
private Reference<File> absFileRef; |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
97 |
long zipFileLastModified = NOT_MODIFIED; |
10 | 98 |
private RandomAccessFile zipRandomFile; |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
99 |
private Entry[] entries; |
10 | 100 |
|
101 |
private boolean readFromIndex = false; |
|
102 |
private File zipIndexFile = null; |
|
103 |
private boolean triedToReadIndex = false; |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
104 |
final RelativeDirectory symbolFilePrefix; |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
105 |
private final int symbolFilePrefixLength; |
10 | 106 |
private boolean hasPopulatedData = false; |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
107 |
long lastReferenceTimeStamp = NOT_MODIFIED; |
10 | 108 |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
109 |
private final boolean usePreindexedCache; |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
110 |
private final String preindexedCacheLocation; |
10 | 111 |
|
112 |
private boolean writeIndex = false; |
|
113 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
114 |
private Map<String, SoftReference<RelativeDirectory>> relativeDirectoryCache = |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
115 |
new HashMap<String, SoftReference<RelativeDirectory>>(); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
116 |
|
10 | 117 |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
118 |
public synchronized boolean isOpen() { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
119 |
return (zipRandomFile != null); |
10 | 120 |
} |
121 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
122 |
ZipFileIndex(File zipFile, RelativeDirectory symbolFilePrefix, boolean writeIndex, |
10 | 123 |
boolean useCache, String cacheLocation) throws IOException { |
124 |
this.zipFile = zipFile; |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
125 |
this.symbolFilePrefix = symbolFilePrefix; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
126 |
this.symbolFilePrefixLength = (symbolFilePrefix == null ? 0 : |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
127 |
symbolFilePrefix.getPath().getBytes("UTF-8").length); |
10 | 128 |
this.writeIndex = writeIndex; |
129 |
this.usePreindexedCache = useCache; |
|
130 |
this.preindexedCacheLocation = cacheLocation; |
|
131 |
||
132 |
if (zipFile != null) { |
|
133 |
this.zipFileLastModified = zipFile.lastModified(); |
|
134 |
} |
|
135 |
||
136 |
// Validate integrity of the zip file |
|
137 |
checkIndex(); |
|
138 |
} |
|
139 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
140 |
@Override |
10 | 141 |
public String toString() { |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
142 |
return "ZipFileIndex[" + zipFile + "]"; |
10 | 143 |
} |
144 |
||
145 |
// Just in case... |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
146 |
@Override |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
147 |
protected void finalize() throws Throwable { |
10 | 148 |
closeFile(); |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
149 |
super.finalize(); |
10 | 150 |
} |
151 |
||
152 |
private boolean isUpToDate() { |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
153 |
if (zipFile != null |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
154 |
&& ((!NON_BATCH_MODE) || zipFileLastModified == zipFile.lastModified()) |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
155 |
&& hasPopulatedData) { |
10 | 156 |
return true; |
157 |
} |
|
158 |
||
159 |
return false; |
|
160 |
} |
|
161 |
||
162 |
/** |
|
163 |
* Here we need to make sure that the ZipFileIndex is valid. Check the timestamp of the file and |
|
164 |
* if its the same as the one at the time the index was build we don't need to reopen anything. |
|
165 |
*/ |
|
166 |
private void checkIndex() throws IOException { |
|
167 |
boolean isUpToDate = true; |
|
168 |
if (!isUpToDate()) { |
|
169 |
closeFile(); |
|
170 |
isUpToDate = false; |
|
171 |
} |
|
172 |
||
173 |
if (zipRandomFile != null || isUpToDate) { |
|
174 |
lastReferenceTimeStamp = System.currentTimeMillis(); |
|
175 |
return; |
|
176 |
} |
|
177 |
||
178 |
hasPopulatedData = true; |
|
179 |
||
180 |
if (readIndex()) { |
|
181 |
lastReferenceTimeStamp = System.currentTimeMillis(); |
|
182 |
return; |
|
183 |
} |
|
184 |
||
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
185 |
directories = Collections.<RelativeDirectory, DirectoryEntry>emptyMap(); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
186 |
allDirs = Collections.<RelativeDirectory>emptySet(); |
10 | 187 |
|
188 |
try { |
|
189 |
openFile(); |
|
190 |
long totalLength = zipRandomFile.length(); |
|
191 |
ZipDirectory directory = new ZipDirectory(zipRandomFile, 0L, totalLength, this); |
|
192 |
directory.buildIndex(); |
|
193 |
} finally { |
|
194 |
if (zipRandomFile != null) { |
|
195 |
closeFile(); |
|
196 |
} |
|
197 |
} |
|
198 |
||
199 |
lastReferenceTimeStamp = System.currentTimeMillis(); |
|
200 |
} |
|
201 |
||
202 |
private void openFile() throws FileNotFoundException { |
|
203 |
if (zipRandomFile == null && zipFile != null) { |
|
204 |
zipRandomFile = new RandomAccessFile(zipFile, "r"); |
|
205 |
} |
|
206 |
} |
|
207 |
||
208 |
private void cleanupState() { |
|
209 |
// Make sure there is a valid but empty index if the file doesn't exist |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
210 |
entries = Entry.EMPTY_ARRAY; |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
211 |
directories = Collections.<RelativeDirectory, DirectoryEntry>emptyMap(); |
10 | 212 |
zipFileLastModified = NOT_MODIFIED; |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
213 |
allDirs = Collections.<RelativeDirectory>emptySet(); |
10 | 214 |
} |
215 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
216 |
public synchronized void close() { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
217 |
writeIndex(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
218 |
closeFile(); |
10 | 219 |
} |
220 |
||
221 |
private void closeFile() { |
|
222 |
if (zipRandomFile != null) { |
|
223 |
try { |
|
224 |
zipRandomFile.close(); |
|
225 |
} catch (IOException ex) { |
|
226 |
} |
|
227 |
zipRandomFile = null; |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
/** |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
232 |
* Returns the ZipFileIndexEntry for a path, if there is one. |
10 | 233 |
*/ |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
234 |
synchronized Entry getZipIndexEntry(RelativePath path) { |
10 | 235 |
try { |
236 |
checkIndex(); |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
237 |
DirectoryEntry de = directories.get(path.dirname()); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
238 |
String lookFor = path.basename(); |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
239 |
return (de == null) ? null : de.getEntry(lookFor); |
10 | 240 |
} |
241 |
catch (IOException e) { |
|
242 |
return null; |
|
243 |
} |
|
244 |
} |
|
245 |
||
246 |
/** |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
247 |
* Returns a javac List of filenames within a directory in the ZipFileIndex. |
10 | 248 |
*/ |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
249 |
public synchronized com.sun.tools.javac.util.List<String> getFiles(RelativeDirectory path) { |
10 | 250 |
try { |
251 |
checkIndex(); |
|
252 |
||
253 |
DirectoryEntry de = directories.get(path); |
|
254 |
com.sun.tools.javac.util.List<String> ret = de == null ? null : de.getFiles(); |
|
255 |
||
256 |
if (ret == null) { |
|
257 |
return com.sun.tools.javac.util.List.<String>nil(); |
|
258 |
} |
|
259 |
return ret; |
|
260 |
} |
|
261 |
catch (IOException e) { |
|
262 |
return com.sun.tools.javac.util.List.<String>nil(); |
|
263 |
} |
|
264 |
} |
|
265 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
266 |
public synchronized List<String> getDirectories(RelativeDirectory path) { |
10 | 267 |
try { |
268 |
checkIndex(); |
|
269 |
||
270 |
DirectoryEntry de = directories.get(path); |
|
271 |
com.sun.tools.javac.util.List<String> ret = de == null ? null : de.getDirectories(); |
|
272 |
||
273 |
if (ret == null) { |
|
274 |
return com.sun.tools.javac.util.List.<String>nil(); |
|
275 |
} |
|
276 |
||
277 |
return ret; |
|
278 |
} |
|
279 |
catch (IOException e) { |
|
280 |
return com.sun.tools.javac.util.List.<String>nil(); |
|
281 |
} |
|
282 |
} |
|
283 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
284 |
public synchronized Set<RelativeDirectory> getAllDirectories() { |
10 | 285 |
try { |
286 |
checkIndex(); |
|
287 |
if (allDirs == Collections.EMPTY_SET) { |
|
13076
cb848b70d7f4
7177701: error: Filling jar message during javax/imageio/metadata/IIOMetadataFormatImpl compilation
mcimadamore
parents:
8837
diff
changeset
|
288 |
allDirs = new java.util.LinkedHashSet<RelativeDirectory>(directories.keySet()); |
10 | 289 |
} |
290 |
||
291 |
return allDirs; |
|
292 |
} |
|
293 |
catch (IOException e) { |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
294 |
return Collections.<RelativeDirectory>emptySet(); |
10 | 295 |
} |
296 |
} |
|
297 |
||
298 |
/** |
|
299 |
* Tests if a specific path exists in the zip. This method will return true |
|
300 |
* for file entries and directories. |
|
301 |
* |
|
302 |
* @param path A path within the zip. |
|
303 |
* @return True if the path is a file or dir, false otherwise. |
|
304 |
*/ |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
305 |
public synchronized boolean contains(RelativePath path) { |
10 | 306 |
try { |
307 |
checkIndex(); |
|
308 |
return getZipIndexEntry(path) != null; |
|
309 |
} |
|
310 |
catch (IOException e) { |
|
311 |
return false; |
|
312 |
} |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
313 |
} |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
314 |
|
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
315 |
public synchronized boolean isDirectory(RelativePath path) throws IOException { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
316 |
// The top level in a zip file is always a directory. |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
317 |
if (path.getPath().length() == 0) { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
318 |
lastReferenceTimeStamp = System.currentTimeMillis(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
319 |
return true; |
10 | 320 |
} |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
321 |
|
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
322 |
checkIndex(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
323 |
return directories.get(path) != null; |
10 | 324 |
} |
325 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
326 |
public synchronized long getLastModified(RelativeFile path) throws IOException { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
327 |
Entry entry = getZipIndexEntry(path); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
328 |
if (entry == null) |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
329 |
throw new FileNotFoundException(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
330 |
return entry.getLastModified(); |
10 | 331 |
} |
332 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
333 |
public synchronized int length(RelativeFile path) throws IOException { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
334 |
Entry entry = getZipIndexEntry(path); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
335 |
if (entry == null) |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
336 |
throw new FileNotFoundException(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
337 |
|
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
338 |
if (entry.isDir) { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
339 |
return 0; |
10 | 340 |
} |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
341 |
|
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
342 |
byte[] header = getHeader(entry); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
343 |
// entry is not compressed? |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
344 |
if (get2ByteLittleEndian(header, 8) == 0) { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
345 |
return entry.compressedSize; |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
346 |
} else { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
347 |
return entry.size; |
10 | 348 |
} |
349 |
} |
|
350 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
351 |
public synchronized byte[] read(RelativeFile path) throws IOException { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
352 |
Entry entry = getZipIndexEntry(path); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
353 |
if (entry == null) |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
354 |
throw new FileNotFoundException("Path not found in ZIP: " + path.path); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
355 |
return read(entry); |
10 | 356 |
} |
357 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
358 |
synchronized byte[] read(Entry entry) throws IOException { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
359 |
openFile(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
360 |
byte[] result = readBytes(entry); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
361 |
closeFile(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
362 |
return result; |
10 | 363 |
} |
364 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
365 |
public synchronized int read(RelativeFile path, byte[] buffer) throws IOException { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
366 |
Entry entry = getZipIndexEntry(path); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
367 |
if (entry == null) |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
368 |
throw new FileNotFoundException(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
369 |
return read(entry, buffer); |
10 | 370 |
} |
371 |
||
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
372 |
synchronized int read(Entry entry, byte[] buffer) |
10 | 373 |
throws IOException { |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
374 |
int result = readBytes(entry, buffer); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
375 |
return result; |
10 | 376 |
} |
377 |
||
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
378 |
private byte[] readBytes(Entry entry) throws IOException { |
10 | 379 |
byte[] header = getHeader(entry); |
380 |
int csize = entry.compressedSize; |
|
381 |
byte[] cbuf = new byte[csize]; |
|
382 |
zipRandomFile.skipBytes(get2ByteLittleEndian(header, 26) + get2ByteLittleEndian(header, 28)); |
|
383 |
zipRandomFile.readFully(cbuf, 0, csize); |
|
384 |
||
385 |
// is this compressed - offset 8 in the ZipEntry header |
|
386 |
if (get2ByteLittleEndian(header, 8) == 0) |
|
387 |
return cbuf; |
|
388 |
||
389 |
int size = entry.size; |
|
390 |
byte[] buf = new byte[size]; |
|
391 |
if (inflate(cbuf, buf) != size) |
|
392 |
throw new ZipException("corrupted zip file"); |
|
393 |
||
394 |
return buf; |
|
395 |
} |
|
396 |
||
397 |
/** |
|
398 |
* |
|
399 |
*/ |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
400 |
private int readBytes(Entry entry, byte[] buffer) throws IOException { |
10 | 401 |
byte[] header = getHeader(entry); |
402 |
||
403 |
// entry is not compressed? |
|
404 |
if (get2ByteLittleEndian(header, 8) == 0) { |
|
405 |
zipRandomFile.skipBytes(get2ByteLittleEndian(header, 26) + get2ByteLittleEndian(header, 28)); |
|
406 |
int offset = 0; |
|
407 |
int size = buffer.length; |
|
408 |
while (offset < size) { |
|
409 |
int count = zipRandomFile.read(buffer, offset, size - offset); |
|
410 |
if (count == -1) |
|
411 |
break; |
|
412 |
offset += count; |
|
413 |
} |
|
414 |
return entry.size; |
|
415 |
} |
|
416 |
||
417 |
int csize = entry.compressedSize; |
|
418 |
byte[] cbuf = new byte[csize]; |
|
419 |
zipRandomFile.skipBytes(get2ByteLittleEndian(header, 26) + get2ByteLittleEndian(header, 28)); |
|
420 |
zipRandomFile.readFully(cbuf, 0, csize); |
|
421 |
||
422 |
int count = inflate(cbuf, buffer); |
|
423 |
if (count == -1) |
|
424 |
throw new ZipException("corrupted zip file"); |
|
425 |
||
426 |
return entry.size; |
|
427 |
} |
|
428 |
||
429 |
//---------------------------------------------------------------------------- |
|
430 |
// Zip utilities |
|
431 |
//---------------------------------------------------------------------------- |
|
432 |
||
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
433 |
private byte[] getHeader(Entry entry) throws IOException { |
10 | 434 |
zipRandomFile.seek(entry.offset); |
435 |
byte[] header = new byte[30]; |
|
436 |
zipRandomFile.readFully(header); |
|
437 |
if (get4ByteLittleEndian(header, 0) != 0x04034b50) |
|
438 |
throw new ZipException("corrupted zip file"); |
|
439 |
if ((get2ByteLittleEndian(header, 6) & 1) != 0) |
|
440 |
throw new ZipException("encrypted zip file"); // offset 6 in the header of the ZipFileEntry |
|
441 |
return header; |
|
442 |
} |
|
443 |
||
444 |
/* |
|
445 |
* Inflate using the java.util.zip.Inflater class |
|
446 |
*/ |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
447 |
private SoftReference<Inflater> inflaterRef; |
10 | 448 |
private int inflate(byte[] src, byte[] dest) { |
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
449 |
Inflater inflater = (inflaterRef == null ? null : inflaterRef.get()); |
10 | 450 |
|
451 |
// construct the inflater object or reuse an existing one |
|
452 |
if (inflater == null) |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
453 |
inflaterRef = new SoftReference<Inflater>(inflater = new Inflater(true)); |
10 | 454 |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
455 |
inflater.reset(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
456 |
inflater.setInput(src); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
457 |
try { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
458 |
return inflater.inflate(dest); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
459 |
} catch (DataFormatException ex) { |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
460 |
return -1; |
10 | 461 |
} |
462 |
} |
|
463 |
||
464 |
/** |
|
465 |
* return the two bytes buf[pos], buf[pos+1] as an unsigned integer in little |
|
466 |
* endian format. |
|
467 |
*/ |
|
468 |
private static int get2ByteLittleEndian(byte[] buf, int pos) { |
|
469 |
return (buf[pos] & 0xFF) + ((buf[pos+1] & 0xFF) << 8); |
|
470 |
} |
|
471 |
||
472 |
/** |
|
473 |
* return the 4 bytes buf[i..i+3] as an integer in little endian format. |
|
474 |
*/ |
|
475 |
private static int get4ByteLittleEndian(byte[] buf, int pos) { |
|
476 |
return (buf[pos] & 0xFF) + ((buf[pos + 1] & 0xFF) << 8) + |
|
477 |
((buf[pos + 2] & 0xFF) << 16) + ((buf[pos + 3] & 0xFF) << 24); |
|
478 |
} |
|
479 |
||
480 |
/* ---------------------------------------------------------------------------- |
|
481 |
* ZipDirectory |
|
482 |
* ----------------------------------------------------------------------------*/ |
|
483 |
||
484 |
private class ZipDirectory { |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
485 |
private RelativeDirectory lastDir; |
10 | 486 |
private int lastStart; |
487 |
private int lastLen; |
|
488 |
||
489 |
byte[] zipDir; |
|
490 |
RandomAccessFile zipRandomFile = null; |
|
491 |
ZipFileIndex zipFileIndex = null; |
|
492 |
||
493 |
public ZipDirectory(RandomAccessFile zipRandomFile, long start, long end, ZipFileIndex index) throws IOException { |
|
494 |
this.zipRandomFile = zipRandomFile; |
|
495 |
this.zipFileIndex = index; |
|
8837 | 496 |
hasValidHeader(); |
497 |
findCENRecord(start, end); |
|
498 |
} |
|
10 | 499 |
|
8837 | 500 |
/* |
501 |
* the zip entry signature should be at offset 0, otherwise allow the |
|
502 |
* calling logic to take evasive action by throwing ZipFormatException. |
|
503 |
*/ |
|
504 |
private boolean hasValidHeader() throws IOException { |
|
505 |
final long pos = zipRandomFile.getFilePointer(); |
|
506 |
try { |
|
507 |
if (zipRandomFile.read() == 'P') { |
|
508 |
if (zipRandomFile.read() == 'K') { |
|
509 |
if (zipRandomFile.read() == 0x03) { |
|
510 |
if (zipRandomFile.read() == 0x04) { |
|
511 |
return true; |
|
512 |
} |
|
513 |
} |
|
514 |
} |
|
515 |
} |
|
516 |
} finally { |
|
517 |
zipRandomFile.seek(pos); |
|
518 |
} |
|
519 |
throw new ZipFormatException("invalid zip magic"); |
|
10 | 520 |
} |
521 |
||
522 |
/* |
|
523 |
* Reads zip file central directory. |
|
524 |
* For more details see readCEN in zip_util.c from the JDK sources. |
|
525 |
* This is a Java port of that function. |
|
526 |
*/ |
|
527 |
private void findCENRecord(long start, long end) throws IOException { |
|
528 |
long totalLength = end - start; |
|
529 |
int endbuflen = 1024; |
|
530 |
byte[] endbuf = new byte[endbuflen]; |
|
531 |
long endbufend = end - start; |
|
532 |
||
533 |
// There is a variable-length field after the dir offset record. We need to do consequential search. |
|
534 |
while (endbufend >= 22) { |
|
535 |
if (endbufend < endbuflen) |
|
536 |
endbuflen = (int)endbufend; |
|
537 |
long endbufpos = endbufend - endbuflen; |
|
538 |
zipRandomFile.seek(start + endbufpos); |
|
539 |
zipRandomFile.readFully(endbuf, 0, endbuflen); |
|
540 |
int i = endbuflen - 22; |
|
541 |
while (i >= 0 && |
|
542 |
!(endbuf[i] == 0x50 && |
|
543 |
endbuf[i + 1] == 0x4b && |
|
544 |
endbuf[i + 2] == 0x05 && |
|
545 |
endbuf[i + 3] == 0x06 && |
|
546 |
endbufpos + i + 22 + |
|
547 |
get2ByteLittleEndian(endbuf, i + 20) == totalLength)) { |
|
548 |
i--; |
|
549 |
} |
|
550 |
||
551 |
if (i >= 0) { |
|
552 |
zipDir = new byte[get4ByteLittleEndian(endbuf, i + 12) + 2]; |
|
553 |
zipDir[0] = endbuf[i + 10]; |
|
554 |
zipDir[1] = endbuf[i + 11]; |
|
8837 | 555 |
int sz = get4ByteLittleEndian(endbuf, i + 16); |
556 |
// a negative offset or the entries field indicates a |
|
557 |
// potential zip64 archive |
|
558 |
if (sz < 0 || get2ByteLittleEndian(zipDir, 0) == 0xffff) { |
|
559 |
throw new ZipFormatException("detected a zip64 archive"); |
|
560 |
} |
|
561 |
zipRandomFile.seek(start + sz); |
|
10 | 562 |
zipRandomFile.readFully(zipDir, 2, zipDir.length - 2); |
563 |
return; |
|
564 |
} else { |
|
565 |
endbufend = endbufpos + 21; |
|
566 |
} |
|
567 |
} |
|
568 |
throw new ZipException("cannot read zip file"); |
|
569 |
} |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
570 |
|
10 | 571 |
private void buildIndex() throws IOException { |
572 |
int entryCount = get2ByteLittleEndian(zipDir, 0); |
|
573 |
||
574 |
// Add each of the files |
|
575 |
if (entryCount > 0) { |
|
13076
cb848b70d7f4
7177701: error: Filling jar message during javax/imageio/metadata/IIOMetadataFormatImpl compilation
mcimadamore
parents:
8837
diff
changeset
|
576 |
directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>(); |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
577 |
ArrayList<Entry> entryList = new ArrayList<Entry>(); |
10 | 578 |
int pos = 2; |
579 |
for (int i = 0; i < entryCount; i++) { |
|
580 |
pos = readEntry(pos, entryList, directories); |
|
581 |
} |
|
582 |
||
583 |
// Add the accumulated dirs into the same list |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
584 |
for (RelativeDirectory d: directories.keySet()) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
585 |
// use shared RelativeDirectory objects for parent dirs |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
586 |
RelativeDirectory parent = getRelativeDirectory(d.dirname().getPath()); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
587 |
String file = d.basename(); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
588 |
Entry zipFileIndexEntry = new Entry(parent, file); |
10 | 589 |
zipFileIndexEntry.isDir = true; |
590 |
entryList.add(zipFileIndexEntry); |
|
591 |
} |
|
592 |
||
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
593 |
entries = entryList.toArray(new Entry[entryList.size()]); |
10 | 594 |
Arrays.sort(entries); |
595 |
} else { |
|
596 |
cleanupState(); |
|
597 |
} |
|
598 |
} |
|
599 |
||
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
600 |
private int readEntry(int pos, List<Entry> entryList, |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
601 |
Map<RelativeDirectory, DirectoryEntry> directories) throws IOException { |
10 | 602 |
if (get4ByteLittleEndian(zipDir, pos) != 0x02014b50) { |
603 |
throw new ZipException("cannot read zip file entry"); |
|
604 |
} |
|
605 |
||
606 |
int dirStart = pos + 46; |
|
607 |
int fileStart = dirStart; |
|
608 |
int fileEnd = fileStart + get2ByteLittleEndian(zipDir, pos + 28); |
|
609 |
||
610 |
if (zipFileIndex.symbolFilePrefixLength != 0 && |
|
611 |
((fileEnd - fileStart) >= symbolFilePrefixLength)) { |
|
612 |
dirStart += zipFileIndex.symbolFilePrefixLength; |
|
613 |
fileStart += zipFileIndex.symbolFilePrefixLength; |
|
614 |
} |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
615 |
// Force any '\' to '/'. Keep the position of the last separator. |
10 | 616 |
for (int index = fileStart; index < fileEnd; index++) { |
617 |
byte nextByte = zipDir[index]; |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
618 |
if (nextByte == (byte)'\\') { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
619 |
zipDir[index] = (byte)'/'; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
620 |
fileStart = index + 1; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
621 |
} else if (nextByte == (byte)'/') { |
10 | 622 |
fileStart = index + 1; |
623 |
} |
|
624 |
} |
|
625 |
||
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
626 |
RelativeDirectory directory = null; |
10 | 627 |
if (fileStart == dirStart) |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
628 |
directory = getRelativeDirectory(""); |
10 | 629 |
else if (lastDir != null && lastLen == fileStart - dirStart - 1) { |
630 |
int index = lastLen - 1; |
|
631 |
while (zipDir[lastStart + index] == zipDir[dirStart + index]) { |
|
632 |
if (index == 0) { |
|
633 |
directory = lastDir; |
|
634 |
break; |
|
635 |
} |
|
636 |
index--; |
|
637 |
} |
|
638 |
} |
|
639 |
||
640 |
// Sub directories |
|
641 |
if (directory == null) { |
|
642 |
lastStart = dirStart; |
|
643 |
lastLen = fileStart - dirStart - 1; |
|
644 |
||
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
645 |
directory = getRelativeDirectory(new String(zipDir, dirStart, lastLen, "UTF-8")); |
10 | 646 |
lastDir = directory; |
647 |
||
648 |
// Enter also all the parent directories |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
649 |
RelativeDirectory tempDirectory = directory; |
10 | 650 |
|
651 |
while (directories.get(tempDirectory) == null) { |
|
652 |
directories.put(tempDirectory, new DirectoryEntry(tempDirectory, zipFileIndex)); |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
653 |
if (tempDirectory.path.indexOf("/") == tempDirectory.path.length() - 1) |
10 | 654 |
break; |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
655 |
else { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
656 |
// use shared RelativeDirectory objects for parent dirs |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
657 |
tempDirectory = getRelativeDirectory(tempDirectory.dirname().getPath()); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
658 |
} |
10 | 659 |
} |
660 |
} |
|
661 |
else { |
|
662 |
if (directories.get(directory) == null) { |
|
663 |
directories.put(directory, new DirectoryEntry(directory, zipFileIndex)); |
|
664 |
} |
|
665 |
} |
|
666 |
||
667 |
// For each dir create also a file |
|
668 |
if (fileStart != fileEnd) { |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
669 |
Entry entry = new Entry(directory, |
10 | 670 |
new String(zipDir, fileStart, fileEnd - fileStart, "UTF-8")); |
671 |
||
672 |
entry.setNativeTime(get4ByteLittleEndian(zipDir, pos + 12)); |
|
673 |
entry.compressedSize = get4ByteLittleEndian(zipDir, pos + 20); |
|
674 |
entry.size = get4ByteLittleEndian(zipDir, pos + 24); |
|
675 |
entry.offset = get4ByteLittleEndian(zipDir, pos + 42); |
|
676 |
entryList.add(entry); |
|
677 |
} |
|
678 |
||
679 |
return pos + 46 + |
|
680 |
get2ByteLittleEndian(zipDir, pos + 28) + |
|
681 |
get2ByteLittleEndian(zipDir, pos + 30) + |
|
682 |
get2ByteLittleEndian(zipDir, pos + 32); |
|
683 |
} |
|
684 |
} |
|
685 |
||
686 |
/** |
|
687 |
* Returns the last modified timestamp of a zip file. |
|
688 |
* @return long |
|
689 |
*/ |
|
690 |
public long getZipFileLastModified() throws IOException { |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
691 |
synchronized (this) { |
10 | 692 |
checkIndex(); |
693 |
return zipFileLastModified; |
|
694 |
} |
|
695 |
} |
|
696 |
||
697 |
/** ------------------------------------------------------------------------ |
|
698 |
* DirectoryEntry class |
|
699 |
* -------------------------------------------------------------------------*/ |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
700 |
|
10 | 701 |
static class DirectoryEntry { |
702 |
private boolean filesInited; |
|
703 |
private boolean directoriesInited; |
|
704 |
private boolean zipFileEntriesInited; |
|
705 |
private boolean entriesInited; |
|
706 |
||
707 |
private long writtenOffsetOffset = 0; |
|
708 |
||
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
709 |
private RelativeDirectory dirName; |
10 | 710 |
|
711 |
private com.sun.tools.javac.util.List<String> zipFileEntriesFiles = com.sun.tools.javac.util.List.<String>nil(); |
|
712 |
private com.sun.tools.javac.util.List<String> zipFileEntriesDirectories = com.sun.tools.javac.util.List.<String>nil(); |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
713 |
private com.sun.tools.javac.util.List<Entry> zipFileEntries = com.sun.tools.javac.util.List.<Entry>nil(); |
10 | 714 |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
715 |
private List<Entry> entries = new ArrayList<Entry>(); |
10 | 716 |
|
717 |
private ZipFileIndex zipFileIndex; |
|
718 |
||
719 |
private int numEntries; |
|
720 |
||
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
721 |
DirectoryEntry(RelativeDirectory dirName, ZipFileIndex index) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
722 |
filesInited = false; |
10 | 723 |
directoriesInited = false; |
724 |
entriesInited = false; |
|
725 |
||
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
726 |
this.dirName = dirName; |
10 | 727 |
this.zipFileIndex = index; |
728 |
} |
|
729 |
||
730 |
private com.sun.tools.javac.util.List<String> getFiles() { |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
731 |
if (!filesInited) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
732 |
initEntries(); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
733 |
for (Entry e : entries) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
734 |
if (!e.isDir) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
735 |
zipFileEntriesFiles = zipFileEntriesFiles.append(e.name); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
736 |
} |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
737 |
} |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
738 |
filesInited = true; |
10 | 739 |
} |
740 |
return zipFileEntriesFiles; |
|
741 |
} |
|
742 |
||
743 |
private com.sun.tools.javac.util.List<String> getDirectories() { |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
744 |
if (!directoriesInited) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
745 |
initEntries(); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
746 |
for (Entry e : entries) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
747 |
if (e.isDir) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
748 |
zipFileEntriesDirectories = zipFileEntriesDirectories.append(e.name); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
749 |
} |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
750 |
} |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
751 |
directoriesInited = true; |
10 | 752 |
} |
753 |
return zipFileEntriesDirectories; |
|
754 |
} |
|
755 |
||
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
756 |
private com.sun.tools.javac.util.List<Entry> getEntries() { |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
757 |
if (!zipFileEntriesInited) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
758 |
initEntries(); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
759 |
zipFileEntries = com.sun.tools.javac.util.List.nil(); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
760 |
for (Entry zfie : entries) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
761 |
zipFileEntries = zipFileEntries.append(zfie); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
762 |
} |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
763 |
zipFileEntriesInited = true; |
10 | 764 |
} |
765 |
return zipFileEntries; |
|
766 |
} |
|
767 |
||
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
768 |
private Entry getEntry(String rootName) { |
10 | 769 |
initEntries(); |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
770 |
int index = Collections.binarySearch(entries, new Entry(dirName, rootName)); |
10 | 771 |
if (index < 0) { |
772 |
return null; |
|
773 |
} |
|
774 |
||
775 |
return entries.get(index); |
|
776 |
} |
|
777 |
||
778 |
private void initEntries() { |
|
779 |
if (entriesInited) { |
|
780 |
return; |
|
781 |
} |
|
782 |
||
783 |
if (!zipFileIndex.readFromIndex) { |
|
784 |
int from = -Arrays.binarySearch(zipFileIndex.entries, |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
785 |
new Entry(dirName, ZipFileIndex.MIN_CHAR)) - 1; |
10 | 786 |
int to = -Arrays.binarySearch(zipFileIndex.entries, |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
787 |
new Entry(dirName, MAX_CHAR)) - 1; |
10 | 788 |
|
789 |
for (int i = from; i < to; i++) { |
|
790 |
entries.add(zipFileIndex.entries[i]); |
|
791 |
} |
|
792 |
} else { |
|
793 |
File indexFile = zipFileIndex.getIndexFile(); |
|
794 |
if (indexFile != null) { |
|
795 |
RandomAccessFile raf = null; |
|
796 |
try { |
|
797 |
raf = new RandomAccessFile(indexFile, "r"); |
|
798 |
raf.seek(writtenOffsetOffset); |
|
799 |
||
800 |
for (int nFiles = 0; nFiles < numEntries; nFiles++) { |
|
801 |
// Read the name bytes |
|
802 |
int zfieNameBytesLen = raf.readInt(); |
|
803 |
byte [] zfieNameBytes = new byte[zfieNameBytesLen]; |
|
804 |
raf.read(zfieNameBytes); |
|
805 |
String eName = new String(zfieNameBytes, "UTF-8"); |
|
806 |
||
807 |
// Read isDir |
|
808 |
boolean eIsDir = raf.readByte() == (byte)0 ? false : true; |
|
809 |
||
810 |
// Read offset of bytes in the real Jar/Zip file |
|
811 |
int eOffset = raf.readInt(); |
|
812 |
||
813 |
// Read size of the file in the real Jar/Zip file |
|
814 |
int eSize = raf.readInt(); |
|
815 |
||
816 |
// Read compressed size of the file in the real Jar/Zip file |
|
817 |
int eCsize = raf.readInt(); |
|
818 |
||
819 |
// Read java time stamp of the file in the real Jar/Zip file |
|
820 |
long eJavaTimestamp = raf.readLong(); |
|
821 |
||
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
822 |
Entry rfie = new Entry(dirName, eName); |
10 | 823 |
rfie.isDir = eIsDir; |
824 |
rfie.offset = eOffset; |
|
825 |
rfie.size = eSize; |
|
826 |
rfie.compressedSize = eCsize; |
|
827 |
rfie.javatime = eJavaTimestamp; |
|
828 |
entries.add(rfie); |
|
829 |
} |
|
830 |
} catch (Throwable t) { |
|
831 |
// Do nothing |
|
832 |
} finally { |
|
833 |
try { |
|
4418 | 834 |
if (raf != null) { |
10 | 835 |
raf.close(); |
836 |
} |
|
837 |
} catch (Throwable t) { |
|
838 |
// Do nothing |
|
839 |
} |
|
840 |
} |
|
841 |
} |
|
842 |
} |
|
843 |
||
844 |
entriesInited = true; |
|
845 |
} |
|
846 |
||
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
847 |
List<Entry> getEntriesAsCollection() { |
10 | 848 |
initEntries(); |
849 |
||
850 |
return entries; |
|
851 |
} |
|
852 |
} |
|
853 |
||
854 |
private boolean readIndex() { |
|
855 |
if (triedToReadIndex || !usePreindexedCache) { |
|
856 |
return false; |
|
857 |
} |
|
858 |
||
859 |
boolean ret = false; |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
860 |
synchronized (this) { |
10 | 861 |
triedToReadIndex = true; |
862 |
RandomAccessFile raf = null; |
|
863 |
try { |
|
864 |
File indexFileName = getIndexFile(); |
|
865 |
raf = new RandomAccessFile(indexFileName, "r"); |
|
866 |
||
867 |
long fileStamp = raf.readLong(); |
|
868 |
if (zipFile.lastModified() != fileStamp) { |
|
869 |
ret = false; |
|
870 |
} else { |
|
13076
cb848b70d7f4
7177701: error: Filling jar message during javax/imageio/metadata/IIOMetadataFormatImpl compilation
mcimadamore
parents:
8837
diff
changeset
|
871 |
directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>(); |
10 | 872 |
int numDirs = raf.readInt(); |
873 |
for (int nDirs = 0; nDirs < numDirs; nDirs++) { |
|
874 |
int dirNameBytesLen = raf.readInt(); |
|
875 |
byte [] dirNameBytes = new byte[dirNameBytesLen]; |
|
876 |
raf.read(dirNameBytes); |
|
877 |
||
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
878 |
RelativeDirectory dirNameStr = getRelativeDirectory(new String(dirNameBytes, "UTF-8")); |
10 | 879 |
DirectoryEntry de = new DirectoryEntry(dirNameStr, this); |
880 |
de.numEntries = raf.readInt(); |
|
881 |
de.writtenOffsetOffset = raf.readLong(); |
|
882 |
directories.put(dirNameStr, de); |
|
883 |
} |
|
884 |
ret = true; |
|
885 |
zipFileLastModified = fileStamp; |
|
886 |
} |
|
887 |
} catch (Throwable t) { |
|
888 |
// Do nothing |
|
889 |
} finally { |
|
890 |
if (raf != null) { |
|
891 |
try { |
|
892 |
raf.close(); |
|
893 |
} catch (Throwable tt) { |
|
894 |
// Do nothing |
|
895 |
} |
|
896 |
} |
|
897 |
} |
|
898 |
if (ret == true) { |
|
899 |
readFromIndex = true; |
|
900 |
} |
|
901 |
} |
|
902 |
||
903 |
return ret; |
|
904 |
} |
|
905 |
||
906 |
private boolean writeIndex() { |
|
907 |
boolean ret = false; |
|
908 |
if (readFromIndex || !usePreindexedCache) { |
|
909 |
return true; |
|
910 |
} |
|
911 |
||
912 |
if (!writeIndex) { |
|
913 |
return true; |
|
914 |
} |
|
915 |
||
916 |
File indexFile = getIndexFile(); |
|
917 |
if (indexFile == null) { |
|
918 |
return false; |
|
919 |
} |
|
920 |
||
921 |
RandomAccessFile raf = null; |
|
922 |
long writtenSoFar = 0; |
|
923 |
try { |
|
924 |
raf = new RandomAccessFile(indexFile, "rw"); |
|
925 |
||
926 |
raf.writeLong(zipFileLastModified); |
|
927 |
writtenSoFar += 8; |
|
928 |
||
929 |
List<DirectoryEntry> directoriesToWrite = new ArrayList<DirectoryEntry>(); |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
930 |
Map<RelativeDirectory, Long> offsets = new HashMap<RelativeDirectory, Long>(); |
10 | 931 |
raf.writeInt(directories.keySet().size()); |
932 |
writtenSoFar += 4; |
|
933 |
||
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
934 |
for (RelativeDirectory dirName: directories.keySet()) { |
10 | 935 |
DirectoryEntry dirEntry = directories.get(dirName); |
936 |
||
937 |
directoriesToWrite.add(dirEntry); |
|
938 |
||
939 |
// Write the dir name bytes |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
940 |
byte [] dirNameBytes = dirName.getPath().getBytes("UTF-8"); |
10 | 941 |
int dirNameBytesLen = dirNameBytes.length; |
942 |
raf.writeInt(dirNameBytesLen); |
|
943 |
writtenSoFar += 4; |
|
944 |
||
945 |
raf.write(dirNameBytes); |
|
946 |
writtenSoFar += dirNameBytesLen; |
|
947 |
||
948 |
// Write the number of files in the dir |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1205
diff
changeset
|
949 |
List<Entry> dirEntries = dirEntry.getEntriesAsCollection(); |
10 | 950 |
raf.writeInt(dirEntries.size()); |
951 |
writtenSoFar += 4; |
|
952 |
||
953 |
offsets.put(dirName, new Long(writtenSoFar)); |
|
954 |
||
955 |
// Write the offset of the file's data in the dir |
|
956 |
dirEntry.writtenOffsetOffset = 0L; |
|
957 |
raf.writeLong(0L); |
|
958 |
writtenSoFar += 8; |
|
959 |
} |
|
960 |
||
961 |
for (DirectoryEntry de : directoriesToWrite) { |
|
962 |
// Fix up the offset in the directory table |
|
963 |
long currFP = raf.getFilePointer(); |
|
964 |
||
965 |
long offsetOffset = offsets.get(de.dirName).longValue(); |
|
966 |
raf.seek(offsetOffset); |
|
967 |
raf.writeLong(writtenSoFar); |
|
968 |
||
969 |
raf.seek(currFP); |
|
970 |
||
971 |
// Now write each of the files in the DirectoryEntry |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
972 |
List<Entry> list = de.getEntriesAsCollection(); |
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
973 |
for (Entry zfie : list) { |
10 | 974 |
// Write the name bytes |
975 |
byte [] zfieNameBytes = zfie.name.getBytes("UTF-8"); |
|
976 |
int zfieNameBytesLen = zfieNameBytes.length; |
|
977 |
raf.writeInt(zfieNameBytesLen); |
|
978 |
writtenSoFar += 4; |
|
979 |
raf.write(zfieNameBytes); |
|
980 |
writtenSoFar += zfieNameBytesLen; |
|
981 |
||
982 |
// Write isDir |
|
983 |
raf.writeByte(zfie.isDir ? (byte)1 : (byte)0); |
|
984 |
writtenSoFar += 1; |
|
985 |
||
986 |
// Write offset of bytes in the real Jar/Zip file |
|
987 |
raf.writeInt(zfie.offset); |
|
988 |
writtenSoFar += 4; |
|
989 |
||
990 |
// Write size of the file in the real Jar/Zip file |
|
991 |
raf.writeInt(zfie.size); |
|
992 |
writtenSoFar += 4; |
|
993 |
||
994 |
// Write compressed size of the file in the real Jar/Zip file |
|
995 |
raf.writeInt(zfie.compressedSize); |
|
996 |
writtenSoFar += 4; |
|
997 |
||
998 |
// Write java time stamp of the file in the real Jar/Zip file |
|
999 |
raf.writeLong(zfie.getLastModified()); |
|
1000 |
writtenSoFar += 8; |
|
1001 |
} |
|
1002 |
} |
|
1003 |
} catch (Throwable t) { |
|
1004 |
// Do nothing |
|
1005 |
} finally { |
|
1006 |
try { |
|
1007 |
if (raf != null) { |
|
1008 |
raf.close(); |
|
1009 |
} |
|
1010 |
} catch(IOException ioe) { |
|
1011 |
// Do nothing |
|
1012 |
} |
|
1013 |
} |
|
1014 |
||
1015 |
return ret; |
|
1016 |
} |
|
1017 |
||
1018 |
public boolean writeZipIndex() { |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
1019 |
synchronized (this) { |
10 | 1020 |
return writeIndex(); |
1021 |
} |
|
1022 |
} |
|
1023 |
||
1024 |
private File getIndexFile() { |
|
1025 |
if (zipIndexFile == null) { |
|
1026 |
if (zipFile == null) { |
|
1027 |
return null; |
|
1028 |
} |
|
1029 |
||
1030 |
zipIndexFile = new File((preindexedCacheLocation == null ? "" : preindexedCacheLocation) + |
|
1031 |
zipFile.getName() + ".index"); |
|
1032 |
} |
|
1033 |
||
1034 |
return zipIndexFile; |
|
1035 |
} |
|
1036 |
||
1037 |
public File getZipFile() { |
|
1038 |
return zipFile; |
|
1039 |
} |
|
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1040 |
|
4073
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1041 |
File getAbsoluteFile() { |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1042 |
File absFile = (absFileRef == null ? null : absFileRef.get()); |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1043 |
if (absFile == null) { |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1044 |
absFile = zipFile.getAbsoluteFile(); |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1045 |
absFileRef = new SoftReference<File>(absFile); |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1046 |
} |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1047 |
return absFile; |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1048 |
} |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3380
diff
changeset
|
1049 |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1050 |
private RelativeDirectory getRelativeDirectory(String path) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1051 |
RelativeDirectory rd; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1052 |
SoftReference<RelativeDirectory> ref = relativeDirectoryCache.get(path); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1053 |
if (ref != null) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1054 |
rd = ref.get(); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1055 |
if (rd != null) |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1056 |
return rd; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1057 |
} |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1058 |
rd = new RelativeDirectory(path); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1059 |
relativeDirectoryCache.put(path, new SoftReference<RelativeDirectory>(rd)); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1060 |
return rd; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1061 |
} |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1062 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1063 |
static class Entry implements Comparable<Entry> { |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1064 |
public static final Entry[] EMPTY_ARRAY = {}; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1065 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1066 |
// Directory related |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1067 |
RelativeDirectory dir; |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1068 |
boolean isDir; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1069 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1070 |
// File related |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1071 |
String name; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1072 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1073 |
int offset; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1074 |
int size; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1075 |
int compressedSize; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1076 |
long javatime; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1077 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1078 |
private int nativetime; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1079 |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1080 |
public Entry(RelativePath path) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1081 |
this(path.dirname(), path.basename()); |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1082 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1083 |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1084 |
public Entry(RelativeDirectory directory, String name) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1085 |
this.dir = directory; |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1086 |
this.name = name; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1087 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1088 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1089 |
public String getName() { |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1090 |
return new RelativeFile(dir, name).getPath(); |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1091 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1092 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1093 |
public String getFileName() { |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1094 |
return name; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1095 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1096 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1097 |
public long getLastModified() { |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1098 |
if (javatime == 0) { |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1099 |
javatime = dosToJavaTime(nativetime); |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1100 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1101 |
return javatime; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1102 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1103 |
|
865
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1104 |
// based on dosToJavaTime in java.util.Zip, but avoiding the |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1105 |
// use of deprecated Date constructor |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1106 |
private static long dosToJavaTime(int dtime) { |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1107 |
Calendar c = Calendar.getInstance(); |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1108 |
c.set(Calendar.YEAR, ((dtime >> 25) & 0x7f) + 1980); |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1109 |
c.set(Calendar.MONTH, ((dtime >> 21) & 0x0f) - 1); |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1110 |
c.set(Calendar.DATE, ((dtime >> 16) & 0x1f)); |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1111 |
c.set(Calendar.HOUR_OF_DAY, ((dtime >> 11) & 0x1f)); |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1112 |
c.set(Calendar.MINUTE, ((dtime >> 5) & 0x3f)); |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1113 |
c.set(Calendar.SECOND, ((dtime << 1) & 0x3e)); |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1114 |
c.set(Calendar.MILLISECOND, 0); |
21668f049d28
6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive
jjg
parents:
810
diff
changeset
|
1115 |
return c.getTimeInMillis(); |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1116 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1117 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1118 |
void setNativeTime(int natTime) { |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1119 |
nativetime = natTime; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1120 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1121 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1122 |
public boolean isDirectory() { |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1123 |
return isDir; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1124 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1125 |
|
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1126 |
public int compareTo(Entry other) { |
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1127 |
RelativeDirectory otherD = other.dir; |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1128 |
if (dir != otherD) { |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1129 |
int c = dir.compareTo(otherD); |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1130 |
if (c != 0) |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1131 |
return c; |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1132 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1133 |
return name.compareTo(other.name); |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1134 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1135 |
|
1205
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1136 |
@Override |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1137 |
public boolean equals(Object o) { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1138 |
if (!(o instanceof Entry)) |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1139 |
return false; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1140 |
Entry other = (Entry) o; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1141 |
return dir.equals(other.dir) && name.equals(other.name); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1142 |
} |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1143 |
|
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1144 |
@Override |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1145 |
public int hashCode() { |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1146 |
int hash = 7; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1147 |
hash = 97 * hash + (this.dir != null ? this.dir.hashCode() : 0); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1148 |
hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0); |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1149 |
return hash; |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1150 |
} |
b316e32eb90c
6508981: cleanup file separator handling in JavacFileManager
jjg
parents:
865
diff
changeset
|
1151 |
|
8223
638daa596494
6988106: javac report 'java.lang.IllegalMonitorStateException'
jjg
parents:
5847
diff
changeset
|
1152 |
@Override |
810
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1153 |
public String toString() { |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1154 |
return isDir ? ("Dir:" + dir + " : " + name) : |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1155 |
(dir + ":" + name); |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1156 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1157 |
} |
e4b6a6d206e6
6714365: refactor JavacFileManager to move nested classes to top level
jjg
parents:
731
diff
changeset
|
1158 |
|
8837 | 1159 |
/* |
1160 |
* Exception primarily used to implement a failover, used exclusively here. |
|
1161 |
*/ |
|
1162 |
||
1163 |
static final class ZipFormatException extends IOException { |
|
1164 |
private static final long serialVersionUID = 8000196834066748623L; |
|
1165 |
protected ZipFormatException(String message) { |
|
1166 |
super(message); |
|
1167 |
} |
|
1168 |
||
1169 |
protected ZipFormatException(String message, Throwable cause) { |
|
1170 |
super(message, cause); |
|
1171 |
} |
|
1172 |
} |
|
10 | 1173 |
} |