author | vasya |
Mon, 14 Dec 2015 20:18:19 +0100 | |
changeset 34752 | 9c262a013456 |
parent 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
14964
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
14964
diff
changeset
|
2 |
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. |
14964
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
4 |
* |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
8 |
* |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
13 |
* accompanied this code). |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
14 |
* |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
18 |
* |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
21 |
* questions. |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
22 |
*/ |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
23 |
|
34752
9c262a013456
8145342: Some copyright notices are inconsistently and ill formatted
vasya
parents:
30730
diff
changeset
|
24 |
|
14964
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
25 |
/* |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
26 |
* @test |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
27 |
* @bug 8003512 |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
28 |
* @summary javac doesn't work with jar files with >64k entries |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
14964
diff
changeset
|
29 |
* @modules jdk.compiler |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
14964
diff
changeset
|
30 |
* jdk.jartool/sun.tools.jar |
14964
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
31 |
* @compile -target 6 -source 6 -XDignore.symbol.file LoadClassFromJava6CreatedJarTest.java ../Utils.java |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
32 |
* @run main/timeout=360 LoadClassFromJava6CreatedJarTest |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
33 |
*/ |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
34 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
35 |
/* |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
36 |
* The test creates a jar file with more than 64K entries. The jar file is |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
37 |
* created executing the LoadClassFromJava6CreatedJarTest$MakeJar |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
38 |
* class with a JVM version 6. The test must include Java 6 features only. |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
39 |
* |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
40 |
* The aim is to verify classes included in jar files with more than 64K entries |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
41 |
* created with Java 6 can be loaded by more recent versions of Java. |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
42 |
* |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
43 |
* A path to JDK or JRE version 6 is needed. This can be provided |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
44 |
* by passing this option to jtreg: |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
45 |
* -javaoption:-Djava6.home="/path/to/jdk_or_jre6" |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
46 |
*/ |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
47 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
48 |
import java.io.BufferedInputStream; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
49 |
import java.io.BufferedReader; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
50 |
import java.io.File; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
51 |
import java.io.FileInputStream; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
52 |
import java.io.FileOutputStream; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
53 |
import java.io.IOException; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
54 |
import java.io.InputStreamReader; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
55 |
import java.util.Arrays; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
56 |
import java.util.List; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
57 |
import java.util.zip.CRC32; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
58 |
import java.util.zip.ZipEntry; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
59 |
import java.util.zip.ZipOutputStream; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
60 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
61 |
public class LoadClassFromJava6CreatedJarTest { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
62 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
63 |
static final String javaHome6 = System.getProperty("java6.home"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
64 |
static final String testClasses = System.getProperty("test.classes"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
65 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
66 |
public static void main(String... args) |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
67 |
throws IOException, InterruptedException { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
68 |
if (javaHome6 != null) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
69 |
new LoadClassFromJava6CreatedJarTest().run(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
70 |
} else { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
71 |
System.out.println( |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
72 |
"The test LoadClassFromJava6CreatedJarTest cannot be executed. " + |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
73 |
"In order to run it you should pass an option with " + |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
74 |
"this form -javaoption:-Djava6.home=\"/path/to/jdk_or_jre6\" " + |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
75 |
"to jtreg."); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
76 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
77 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
78 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
79 |
void run() throws IOException, InterruptedException { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
80 |
File classA = new File("A.java"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
81 |
Utils.createJavaFile(classA, null); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
82 |
if (!Utils.compile("-target", "6", "-source", "6", |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
83 |
classA.getAbsolutePath())) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
84 |
throw new AssertionError("Test failed while compiling class A"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
85 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
86 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
87 |
executeCommand(Arrays.asList(javaHome6 + "/bin/java", "-classpath", |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
88 |
testClasses, "LoadClassFromJava6CreatedJarTest$MakeJar")); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
89 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
90 |
File classB = new File("B.java"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
91 |
Utils.createJavaFile(classB, classA); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
92 |
if (!Utils.compile("-cp", "a.jar", classB.getAbsolutePath())) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
93 |
throw new AssertionError("Test failed while compiling class Main"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
94 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
95 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
96 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
97 |
void executeCommand(List<String> command) |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
98 |
throws IOException, InterruptedException { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
99 |
ProcessBuilder pb = new ProcessBuilder(command). |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
100 |
redirectErrorStream(true); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
101 |
Process p = pb.start(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
102 |
BufferedReader r = |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
103 |
new BufferedReader(new InputStreamReader(p.getInputStream())); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
104 |
String line; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
105 |
while ((line = r.readLine()) != null) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
106 |
System.err.println(line); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
107 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
108 |
int rc = p.waitFor(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
109 |
if (rc != 0) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
110 |
throw new AssertionError("Unexpected exit code: " + rc); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
111 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
112 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
113 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
114 |
static class MakeJar { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
115 |
public static void main(String[] args) throws Throwable { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
116 |
File classFile = new File("A.class"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
117 |
ZipOutputStream zos = null; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
118 |
FileInputStream fis = null; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
119 |
final int MAX = Short.MAX_VALUE * 2 + 10; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
120 |
ZipEntry ze = null; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
121 |
try { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
122 |
zos = new ZipOutputStream(new FileOutputStream("a.jar")); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
123 |
zos.setLevel(ZipOutputStream.STORED); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
124 |
zos.setMethod(ZipOutputStream.STORED); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
125 |
for (int i = 0; i < MAX ; i++) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
126 |
ze = new ZipEntry("X" + i + ".txt"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
127 |
ze.setSize(0); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
128 |
ze.setCompressedSize(0); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
129 |
ze.setCrc(0); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
130 |
zos.putNextEntry(ze); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
131 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
132 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
133 |
// add a class file |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
134 |
ze = new ZipEntry("A.class"); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
135 |
ze.setCompressedSize(classFile.length()); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
136 |
ze.setSize(classFile.length()); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
137 |
ze.setCrc(computeCRC(classFile)); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
138 |
zos.putNextEntry(ze); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
139 |
fis = new FileInputStream(classFile); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
140 |
for (int c; (c = fis.read()) >= 0;) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
141 |
zos.write(c); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
142 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
143 |
} finally { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
144 |
zos.close(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
145 |
fis.close(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
146 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
147 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
148 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
149 |
private static final int BUFFER_LEN = Short.MAX_VALUE * 2; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
150 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
151 |
static long getCount(long minlength) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
152 |
return (minlength / BUFFER_LEN) + 1; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
153 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
154 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
155 |
static long computeCRC(long minlength) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
156 |
CRC32 crc = new CRC32(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
157 |
byte[] buffer = new byte[BUFFER_LEN]; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
158 |
long count = getCount(minlength); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
159 |
for (long i = 0; i < count; i++) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
160 |
crc.update(buffer); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
161 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
162 |
return crc.getValue(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
163 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
164 |
|
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
165 |
static long computeCRC(File inFile) throws IOException { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
166 |
byte[] buffer = new byte[8192]; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
167 |
CRC32 crc = new CRC32(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
168 |
FileInputStream fis = null; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
169 |
BufferedInputStream bis = null; |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
170 |
try { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
171 |
fis = new FileInputStream(inFile); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
172 |
bis = new BufferedInputStream(fis); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
173 |
int n = bis.read(buffer); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
174 |
while (n > 0) { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
175 |
crc.update(buffer, 0, n); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
176 |
n = bis.read(buffer); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
177 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
178 |
} finally { |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
179 |
bis.close(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
180 |
fis.close(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
181 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
182 |
return crc.getValue(); |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
183 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
184 |
} |
391288e42c67
8003512: javac doesn't work with jar files with >64k entries
vromero
parents:
diff
changeset
|
185 |
} |