You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/09/26 05:02:54 UTC
svn commit: r449886 [1/2] - in
/incubator/harmony/enhanced/classlib/trunk/modules/archive/src:
main/java/java/util/jar/ main/java/java/util/zip/
main/java/org/apache/harmony/archive/internal/pack200/
test/java/org/apache/harmony/archive/tests/internal/...
Author: ndbeyer
Date: Mon Sep 25 20:02:49 2006
New Revision: 449886
URL: http://svn.apache.org/viewvc?view=rev&rev=449886
Log:
Code cleanup
* eliminate compiler warnings
* add if/else braces
* generifications
* add Override and SuppressWarnings annotations
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/InitManifest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarOutputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/BHSDCodec.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Pack200Exception.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecEncodingTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CRC32Test.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedOutputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java Mon Sep 25 20:02:49 2006
@@ -30,7 +30,7 @@
protected Map<Object, Object> map;
public static class Name {
- private String name;
+ private final String name;
private int hashCode;
@@ -100,10 +100,12 @@
name = s;
}
+ @Override
public String toString() {
return name;
}
+ @Override
public boolean equals(Object an) {
if (an == null) {
return false;
@@ -112,6 +114,7 @@
&& name.equalsIgnoreCase(((Name) an).name);
}
+ @Override
public int hashCode() {
if (hashCode == 0) {
hashCode = name.toLowerCase().hashCode();
@@ -134,8 +137,9 @@
* @param attrib
* The Attributes to obtain entries from.
*/
+ @SuppressWarnings("unchecked")
public Attributes(Attributes attrib) {
- map = (Map<Object, Object>) ((HashMap) attrib.map).clone();
+ map = (Map<Object, Object>)((HashMap) attrib.map).clone();
}
/**
@@ -232,7 +236,13 @@
* String
*/
public Object put(Object key, Object value) {
- return map.put((Name)key, (String)value);
+ if (!(key instanceof Name)) {
+ throw new ClassCastException();
+ }
+ if (!(value instanceof String)) {
+ throw new ClassCastException();
+ }
+ return map.put(key, value);
}
/**
@@ -242,10 +252,10 @@
* the associations to store (must be of type Attributes).
*/
public void putAll(Map<?, ?> attrib) {
- if (attrib == null) {
+ if (attrib == null || !(attrib instanceof Attributes)) {
throw new ClassCastException();
}
- this.map.putAll((Attributes)attrib);
+ this.map.putAll(attrib);
}
/**
@@ -277,6 +287,8 @@
return map.values();
}
+ @SuppressWarnings("unchecked")
+ @Override
public Object clone() {
Attributes clone;
try {
@@ -284,7 +296,7 @@
} catch (CloneNotSupportedException e) {
return null;
}
- clone.map = (Map<Object, Object>) ((HashMap) this.map).clone();
+ clone.map = (Map<Object, Object>) ((HashMap) map).clone();
return clone;
}
@@ -293,6 +305,7 @@
*
* @return the hashCode of this Object.
*/
+ @Override
public int hashCode() {
return map.hashCode();
}
@@ -303,6 +316,7 @@
*
* @return true if the Attributes are equals, false otherwise
*/
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/InitManifest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/InitManifest.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/InitManifest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/InitManifest.java Mon Sep 25 20:02:49 2006
@@ -31,7 +31,7 @@
import org.apache.harmony.luni.util.Util;
class InitManifest {
- private byte[] inbuf = new byte[1024];
+ private final byte[] inbuf = new byte[1024];
private int inbufCount = 0, inbufPos = 0;
@@ -39,15 +39,15 @@
private char[] charbuf = new char[0];
- private ByteArrayOutputStream out = new ByteArrayOutputStream(256);
+ private final ByteArrayOutputStream out = new ByteArrayOutputStream(256);
private String encoding;
private boolean usingUTF8 = true;
- private Map<String, Attributes.Name> attributeNames = new HashMap<String, Attributes.Name>();
+ private final Map<String, Attributes.Name> attributeNames = new HashMap<String, Attributes.Name>();
- private byte[] mainAttributesChunk;
+ private final byte[] mainAttributesChunk;
InitManifest(InputStream is, Attributes main, Map<String, Attributes> entries, Map<String, byte[]> chunks,
String verString) throws IOException {
@@ -152,11 +152,10 @@
addLine(pos, lines);
}
return out.toByteArray();
- } else {
- if (inbufCount == inbuf.length && in.available() == 0) {
- /* KA000 = "line too long" */
- throw new IOException(Msg.getString("KA000"));
- }
+ }
+ if (inbufCount == inbuf.length && in.available() == 0) {
+ /* KA000 = "line too long" */
+ throw new IOException(Msg.getString("KA000"));
}
inbufPos = 0;
}
@@ -222,11 +221,10 @@
addLine(pos, lines);
}
return lines.size() != 0;
- } else {
- if (inbufCount == inbuf.length && in.available() == 0) {
- /* KA000 = "line too long" */
- throw new IOException(Msg.getString("KA000"));
- }
+ }
+ if (inbufCount == inbuf.length && in.available() == 0) {
+ /* KA000 = "line too long" */
+ throw new IOException(Msg.getString("KA000"));
}
inbufPos = 0;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java Mon Sep 25 20:02:49 2006
@@ -67,6 +67,7 @@
}
}
+ @Override
public int read() throws IOException {
int r = super.read();
if (entry != null) {
@@ -83,6 +84,7 @@
return r;
}
+ @Override
public int read(byte[] buf, int off, int nbytes) throws IOException {
int r = super.read(buf, off, nbytes);
if (entry != null) {
@@ -103,6 +105,7 @@
return r;
}
+ @Override
public long skip(long nbytes) throws IOException {
long cnt = 0, rem = 0;
byte[] buf = new byte[4096];
@@ -207,6 +210,7 @@
* @exception java.lang.IllegalStateException
* If this JarFile has been closed.
*/
+ @Override
public Enumeration<JarEntry> entries() {
class JarFileEnumerator implements Enumeration<JarEntry> {
Enumeration<? extends ZipEntry> ze;
@@ -278,7 +282,7 @@
}
private void readMetaEntries() throws IOException {
- ZipEntry[] metaEntries = this.getMetaEntriesImpl(null);
+ ZipEntry[] metaEntries = getMetaEntriesImpl(null);
int dirLength = META_DIR.length();
boolean signed = false;
@@ -329,6 +333,7 @@
* @exception java.io.IOException
* If an error occured while creating the InputStream.
*/
+ @Override
public InputStream getInputStream(ZipEntry ze) throws IOException {
if (manifestEntry != null) {
getManifest();
@@ -364,6 +369,7 @@
* the name of the entry in the jar file
* @return java.util.jar.JarEntry
*/
+ @Override
public ZipEntry getEntry(String name) {
ZipEntry ze = super.getEntry(name);
if (ze == null) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarInputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarInputStream.java Mon Sep 25 20:02:49 2006
@@ -107,6 +107,7 @@
return (JarEntry) getNextEntry();
}
+ @Override
public int read(byte[] buffer, int offset, int length) throws IOException {
if (mEntry != null) {
return -1;
@@ -128,7 +129,7 @@
}
} else {
verifier.verifySignatures(
- (JarVerifier.VerifierEntry) this.verStream,
+ (JarVerifier.VerifierEntry) verStream,
jarEntry);
}
}
@@ -147,6 +148,7 @@
* @exception java.io.IOException
* If an error occurs while reading the entry
*/
+ @Override
public ZipEntry getNextEntry() throws IOException {
if (mEntry != null) {
jarEntry = mEntry;
@@ -171,6 +173,7 @@
return jarEntry;
}
+ @Override
protected ZipEntry createZipEntry(String name) {
JarEntry entry = new JarEntry(name);
if (manifest != null) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarOutputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarOutputStream.java Mon Sep 25 20:02:49 2006
@@ -73,6 +73,7 @@
* @exception IOException
* If an error occurs writing the entry
*/
+ @Override
public void putNextEntry(ZipEntry ze) throws IOException {
super.putNextEntry(ze);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java Mon Sep 25 20:02:49 2006
@@ -53,19 +53,19 @@
*/
class JarVerifier {
- private String jarName;
+ private final String jarName;
private Manifest man;
private HashMap<String, byte[]> metaEntries = new HashMap<String, byte[]>(5);
- private Hashtable<String, HashMap<String, Attributes>> signatures =
+ private final Hashtable<String, HashMap<String, Attributes>> signatures =
new Hashtable<String, HashMap<String, Attributes>>(5);
- private Hashtable<String, Certificate[]> certificates =
+ private final Hashtable<String, Certificate[]> certificates =
new Hashtable<String, Certificate[]>(5);
- private Hashtable<String, Certificate[]> verifiedEntries =
+ private final Hashtable<String, Certificate[]> verifiedEntries =
new Hashtable<String, Certificate[]>();
byte[] mainAttributesChunk;
@@ -93,6 +93,7 @@
*
* @see java.io.OutputStream#write(int)
*/
+ @Override
public void write(int value) {
digest.update((byte) value);
}
@@ -102,6 +103,7 @@
*
* @see java.io.OutputStream#write(byte[], int, int)
*/
+ @Override
public void write(byte[] buf, int off, int nbytes) {
digest.update(buf, off, nbytes);
}
@@ -268,7 +270,7 @@
new ByteArrayInputStream(sfBytes),
new ByteArrayInputStream(sBlockBytes));
if (signerCertChain != null) {
- this.certificates.put(signatureFile, signerCertChain);
+ certificates.put(signatureFile, signerCertChain);
}
} catch (IOException e) {
return;
@@ -299,9 +301,9 @@
// file, such as those created before java 1.5, then we ignore
// such verification.
// FIXME: The meaning of createdBySigntool
- if (this.mainAttributesChunk != null && !createdBySigntool) {
+ if (mainAttributesChunk != null && !createdBySigntool) {
String digestAttribute = "-Digest-Manifest-Main-Attributes";
- if (!verify(attributes, digestAttribute, this.mainAttributesChunk,
+ if (!verify(attributes, digestAttribute, mainAttributesChunk,
false, true)) {
/* [MSG "K00eb", "{0} failed verification of {1}"] */
throw new SecurityException(
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java Mon Sep 25 20:02:49 2006
@@ -116,7 +116,8 @@
* @param man
* Manifest instance to obtain attributes from
*/
- public Manifest(Manifest man) {
+ @SuppressWarnings("unchecked")
+ public Manifest(Manifest man) {
mainAttributes = (Attributes) man.mainAttributes.clone();
entryAttributes = (HashMap<String, Attributes>) man.entryAttributes.clone();
}
@@ -127,16 +128,17 @@
*
* @return A copy of the receiver.
*/
- public Object clone() {
+ @Override
+ public Object clone() {
return new Manifest(this);
}
static class WriteManifest {
private static final int LIMIT = 70;
- private static byte[] sepBuf = new byte[] { '\r', '\n' };
+ private static final byte[] sepBuf = new byte[] { '\r', '\n' };
- private static Attributes.Name nameAttribute = new Attributes.Name(
+ private static final Attributes.Name nameAttribute = new Attributes.Name(
"Name", false);
byte[] oneByte = new byte[1];
@@ -145,7 +147,7 @@
private Charset charset;
- private byte[] outBuf = new byte[LIMIT];
+ private final byte[] outBuf = new byte[LIMIT];
OutputStream os;
@@ -291,7 +293,8 @@
*
* @return This Manifest's hashCode
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
return mainAttributes.hashCode() ^ entryAttributes.hashCode();
}
@@ -305,7 +308,8 @@
* @return <code>true</code> if the manifests are equal,
* <code>false</code> otherwise
*/
- public boolean equals(Object o) {
+ @Override
+ public boolean equals(Object o) {
if (o == null) {
return false;
}
@@ -328,6 +332,6 @@
byte[] getMainAttributesChunk()
{
- return this.mainAttributesChunk;
+ return mainAttributesChunk;
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Pack200.java Mon Sep 25 20:02:49 2006
@@ -58,8 +58,9 @@
return null;
}
});
- if (null != packer)
- return packer;
+ if (null != packer) {
+ return packer;
+ }
return PackFactory.newPacker();
}
@@ -87,8 +88,9 @@
return null;
}
});
- if (null != unpacker)
- return unpacker;
+ if (null != unpacker) {
+ return unpacker;
+ }
return PackFactory.newUnpacker();
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Adler32.java Mon Sep 25 20:02:49 2006
@@ -73,10 +73,11 @@
public void update(byte[] buf, int off, int nbytes) {
// avoid int overflow, check null buf
if (off <= buf.length && nbytes >= 0 && off >= 0
- && buf.length - off >= nbytes)
- adler = updateImpl(buf, off, nbytes, adler);
- else
- throw new ArrayIndexOutOfBoundsException();
+ && buf.length - off >= nbytes) {
+ adler = updateImpl(buf, off, nbytes, adler);
+ } else {
+ throw new ArrayIndexOutOfBoundsException();
+ }
}
private native long updateImpl(byte[] buf, int off, int nbytes, long adler1);
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CRC32.java Mon Sep 25 20:02:49 2006
@@ -76,8 +76,9 @@
&& buf.length - off >= nbytes) {
tbytes += nbytes;
crc = updateImpl(buf, off, nbytes, crc);
- } else
- throw new ArrayIndexOutOfBoundsException();
+ } else {
+ throw new ArrayIndexOutOfBoundsException();
+ }
}
private native long updateImpl(byte[] buf, int off, int nbytes, long crc1);
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedInputStream.java Mon Sep 25 20:02:49 2006
@@ -25,7 +25,7 @@
*/
public class CheckedInputStream extends java.io.FilterInputStream {
- private Checksum check;
+ private final Checksum check;
/**
* Constructs a new CheckedInputStream on InputStream is. The Checksum will
@@ -47,7 +47,8 @@
*
* @return -1 if end of stream, a single byte value otherwise
*/
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
int x = in.read();
if (x != -1) {
check.update(x);
@@ -61,10 +62,12 @@
*
* @return Number of bytes read, -1 if end of stream
*/
- public int read(byte[] buf, int off, int nbytes) throws IOException {
+ @Override
+ public int read(byte[] buf, int off, int nbytes) throws IOException {
int x = in.read(buf, off, nbytes);
- if (x != -1)
- check.update(buf, off, x);
+ if (x != -1) {
+ check.update(buf, off, x);
+ }
return x;
}
@@ -85,7 +88,8 @@
* long Number of bytes to skip
* @return Number of bytes skipped
*/
- public long skip(long nbytes) throws IOException {
+ @Override
+ public long skip(long nbytes) throws IOException {
if (nbytes < 1) {
return 0;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/CheckedOutputStream.java Mon Sep 25 20:02:49 2006
@@ -25,7 +25,7 @@
*/
public class CheckedOutputStream extends java.io.FilterOutputStream {
- private Checksum check;
+ private final Checksum check;
/**
* Constructs a new CheckedOutputStream on OutputStream os. The Checksum
@@ -60,7 +60,8 @@
* @throws IOException
* if an IO error has occured
*/
- public void write(int val) throws IOException {
+ @Override
+ public void write(int val) throws IOException {
out.write(val);
check.update(val);
}
@@ -79,7 +80,8 @@
* @throws IOException
* if an IO error has occured
*/
- public void write(byte[] buf, int off, int nbytes) throws IOException {
+ @Override
+ public void write(byte[] buf, int off, int nbytes) throws IOException {
out.write(buf, off, nbytes);
check.update(buf, off, nbytes);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java Mon Sep 25 20:02:49 2006
@@ -124,7 +124,8 @@
}
}
- protected void finalize() {
+ @Override
+ protected void finalize() {
end();
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java Mon Sep 25 20:02:49 2006
@@ -74,10 +74,12 @@
*/
public DeflaterOutputStream(OutputStream os, Deflater def, int bsize) {
super(os);
- if (os == null || def == null)
- throw new NullPointerException();
- if (bsize <= 0)
- throw new IllegalArgumentException();
+ if (os == null || def == null) {
+ throw new NullPointerException();
+ }
+ if (bsize <= 0) {
+ throw new IllegalArgumentException();
+ }
this.def = def;
buf = new byte[bsize];
}
@@ -105,9 +107,11 @@
* @exception java.io.IOException
* If an error occurs during close.
*/
- public void close() throws IOException {
- if (!def.finished())
- finish();
+ @Override
+ public void close() throws IOException {
+ if (!def.finished()) {
+ finish();
+ }
def.end();
out.close();
}
@@ -121,20 +125,23 @@
* If an error occurs.
*/
public void finish() throws IOException {
- if (done)
- return;
+ if (done) {
+ return;
+ }
def.finish();
int x = 0;
while (!def.finished()) {
- if (def.needsInput())
- def.setInput(buf, 0, 0);
+ if (def.needsInput()) {
+ def.setInput(buf, 0, 0);
+ }
x = def.deflate(buf);
out.write(buf, 0, x);
}
done = true;
}
- public void write(int i) throws IOException {
+ @Override
+ public void write(int i) throws IOException {
byte[] b = new byte[1];
b[0] = (byte) i;
write(b, 0, 1);
@@ -154,17 +161,21 @@
* @exception java.io.IOException
* If an error occurs during writing.
*/
- public void write(byte[] buffer, int off, int nbytes) throws IOException {
- if (done)
- throw new IOException(Msg.getString("K0007"));
+ @Override
+ public void write(byte[] buffer, int off, int nbytes) throws IOException {
+ if (done) {
+ throw new IOException(Msg.getString("K0007"));
+ }
// avoid int overflow, check null buf
if (off <= buffer.length && nbytes >= 0 && off >= 0
&& buffer.length - off >= nbytes) {
- if (!def.needsInput())
- throw new IOException();
+ if (!def.needsInput()) {
+ throw new IOException();
+ }
def.setInput(buffer, off, nbytes);
deflate();
- } else
- throw new ArrayIndexOutOfBoundsException();
+ } else {
+ throw new ArrayIndexOutOfBoundsException();
+ }
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java Mon Sep 25 20:02:49 2006
@@ -64,36 +64,44 @@
super(is, new Inflater(true), size);
byte[] header = new byte[10];
readFully(header, 0, header.length);
- if (getShort(header, 0) != GZIP_MAGIC)
- throw new IOException(Msg.getString("K0020"));
+ if (getShort(header, 0) != GZIP_MAGIC) {
+ throw new IOException(Msg.getString("K0020"));
+ }
int flags = header[3];
boolean hcrc = (flags & FHCRC) != 0;
- if (hcrc)
- crc.update(header, 0, header.length);
+ if (hcrc) {
+ crc.update(header, 0, header.length);
+ }
if ((flags & FEXTRA) != 0) {
readFully(header, 0, 2);
- if (hcrc)
- crc.update(header, 0, 2);
+ if (hcrc) {
+ crc.update(header, 0, 2);
+ }
int length = getShort(header, 0);
while (length > 0) {
int max = length > buf.length ? buf.length : length;
int result = in.read(buf, 0, max);
- if (result == -1)
- throw new EOFException();
- if (hcrc)
- crc.update(buf, 0, result);
+ if (result == -1) {
+ throw new EOFException();
+ }
+ if (hcrc) {
+ crc.update(buf, 0, result);
+ }
length -= result;
}
}
- if ((flags & FNAME) != 0)
- readZeroTerminated(hcrc);
- if ((flags & FCOMMENT) != 0)
- readZeroTerminated(hcrc);
+ if ((flags & FNAME) != 0) {
+ readZeroTerminated(hcrc);
+ }
+ if ((flags & FCOMMENT) != 0) {
+ readZeroTerminated(hcrc);
+ }
if (hcrc) {
readFully(header, 0, 2);
int crc16 = getShort(header, 0);
- if ((crc.getValue() & 0xffff) != crc16)
- throw new IOException(Msg.getString("K0077"));
+ if ((crc.getValue() & 0xffff) != crc16) {
+ throw new IOException(Msg.getString("K0077"));
+ }
crc.reset();
}
}
@@ -121,14 +129,15 @@
* @param nbytes
* Number of bytes to read
*/
- public int read(byte[] buffer, int off, int nbytes) throws IOException {
+ @Override
+ public int read(byte[] buffer, int off, int nbytes) throws IOException {
// avoid int overflow, check null buffer
if (off <= buffer.length && nbytes >= 0 && off >= 0
&& buffer.length - off >= nbytes) {
int val = super.read(buffer, off, nbytes);
- if (val != -1)
- crc.update(buffer, off, val);
- else if (!eos) {
+ if (val != -1) {
+ crc.update(buffer, off, val);
+ } else if (!eos) {
eos = true;
// Get non-compressed bytes read by fill
int size = 0;
@@ -138,16 +147,19 @@
int diff = inB % buf.length;
if (diff != 0 || len != buf.length) {
size = len - diff;
- if (size > b.length)
- size = b.length;
+ if (size > b.length) {
+ size = b.length;
+ }
System.arraycopy(buf, diff, b, 0, size);
}
}
readFully(b, size, b.length - size);
- if (getLong(b, 0) != crc.getValue())
- throw new IOException(Msg.getString("K0077"));
- if ((int) getLong(b, 4) != inf.getTotalOut())
- throw new IOException(Msg.getString("K00ae"));
+ if (getLong(b, 0) != crc.getValue()) {
+ throw new IOException(Msg.getString("K0077"));
+ }
+ if ((int) getLong(b, 4) != inf.getTotalOut()) {
+ throw new IOException(Msg.getString("K00ae"));
+ }
}
return val;
}
@@ -157,7 +169,8 @@
/**
* Closes this stream and any underlying streams.
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
eos = true;
super.close();
}
@@ -167,8 +180,9 @@
int result;
while (length > 0) {
result = in.read(buffer, offset, length);
- if (result == -1)
- throw new EOFException();
+ if (result == -1) {
+ throw new EOFException();
+ }
offset += result;
length -= result;
}
@@ -177,13 +191,16 @@
private void readZeroTerminated(boolean hcrc) throws IOException {
int result;
while ((result = in.read()) > 0) {
- if (hcrc)
- crc.update(result);
+ if (hcrc) {
+ crc.update(result);
+ }
}
- if (result == -1)
- throw new EOFException();
+ if (result == -1) {
+ throw new EOFException();
+ }
// Add the zero
- if (hcrc)
- crc.update(result);
+ if (hcrc) {
+ crc.update(result);
+ }
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java Mon Sep 25 20:02:49 2006
@@ -61,7 +61,8 @@
* Indicates to the stream that all data has been written out, and any GZIP
* terminal data can now be output.
*/
- public void finish() throws IOException {
+ @Override
+ public void finish() throws IOException {
super.finish();
writeLong(crc.getValue());
writeLong(crc.tbytes);
@@ -71,7 +72,8 @@
* Write up to nbytes of data from buf, starting at offset off, to the
* underlying stream in GZIP format.
*/
- public void write(byte[] buffer, int off, int nbytes) throws IOException {
+ @Override
+ public void write(byte[] buffer, int off, int nbytes) throws IOException {
super.write(buffer, off, nbytes);
crc.update(buffer, off, nbytes);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java Mon Sep 25 20:02:49 2006
@@ -59,7 +59,8 @@
private native synchronized void endImpl(long handle);
- protected void finalize() {
+ @Override
+ protected void finalize() {
end();
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java Mon Sep 25 20:02:49 2006
@@ -96,7 +96,8 @@
* @throws IOException
* If an error occurs reading
*/
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
byte[] b = new byte[1];
if (read(b, 0, 1) == -1) {
return -1;
@@ -118,7 +119,8 @@
* @throws IOException
* If an error occurs reading
*/
- public int read(byte[] buffer, int off, int nbytes) throws IOException {
+ @Override
+ public int read(byte[] buffer, int off, int nbytes) throws IOException {
/* [MSG "K0059", "Stream is closed"] */
if (closed) {
throw new IOException(Msg.getString("K0059"));
@@ -191,7 +193,8 @@
* @throws IOException
* If an error occurs skipping
*/
- public long skip(long nbytes) throws IOException {
+ @Override
+ public long skip(long nbytes) throws IOException {
if (nbytes >= 0) {
long count = 0, rem = 0;
while (count < nbytes) {
@@ -215,7 +218,8 @@
* @throws IOException
* If an error occurs
*/
- public int available() throws IOException {
+ @Override
+ public int available() throws IOException {
if (closed) {
throw new IOException(Msg.getString("K0059"));
}
@@ -231,7 +235,8 @@
* @throws IOException
* If an error occurs closing the stream
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
if (!closed) {
inf.end();
closed = true;
@@ -249,7 +254,8 @@
* @param readlimit
* of no use
*/
- public void mark(int readlimit) {
+ @Override
+ public void mark(int readlimit) {
// do nothing
}
@@ -262,6 +268,7 @@
* @throws IOException
* if the method is called
*/
+ @Override
public void reset() throws IOException{
throw new IOException();
}
@@ -271,7 +278,8 @@
* does not support mark, so always responds <code>false</code>.
* @return false
*/
- public boolean markSupported() {
+ @Override
+ public boolean markSupported() {
return false;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipEntry.java Mon Sep 25 20:02:49 2006
@@ -52,10 +52,12 @@
* the name of the zip entry
*/
public ZipEntry(String name) {
- if (name == null)
- throw new NullPointerException();
- if (name.length() > 0xFFFF)
- throw new IllegalArgumentException();
+ if (name == null) {
+ throw new NullPointerException();
+ }
+ if (name.length() > 0xFFFF) {
+ throw new IllegalArgumentException();
+ }
this.name = name;
}
@@ -164,10 +166,11 @@
* the comment
*/
public void setComment(String string) {
- if (string == null || string.length() <= 0xFFFF)
- this.comment = string;
- else
- throw new IllegalArgumentException();
+ if (string == null || string.length() <= 0xFFFF) {
+ comment = string;
+ } else {
+ throw new IllegalArgumentException();
+ }
}
/**
@@ -190,10 +193,11 @@
* if value is < 0 or > 0xFFFFFFFFL
*/
public void setCrc(long value) {
- if (value >= 0 && value <= 0xFFFFFFFFL)
- crc = value;
- else
- throw new IllegalArgumentException();
+ if (value >= 0 && value <= 0xFFFFFFFFL) {
+ crc = value;
+ } else {
+ throw new IllegalArgumentException();
+ }
}
/**
@@ -206,10 +210,11 @@
* when the length of data is > 0xFFFF bytes
*/
public void setExtra(byte[] data) {
- if (data == null || data.length <= 0xFFFF)
- extra = data;
- else
- throw new IllegalArgumentException();
+ if (data == null || data.length <= 0xFFFF) {
+ extra = data;
+ } else {
+ throw new IllegalArgumentException();
+ }
}
/**
@@ -222,8 +227,9 @@
* when value is not DEFLATED or STORED
*/
public void setMethod(int value) {
- if (value != STORED && value != DEFLATED)
- throw new IllegalArgumentException();
+ if (value != STORED && value != DEFLATED) {
+ throw new IllegalArgumentException();
+ }
compressionMethod = value;
}
@@ -245,10 +251,11 @@
* if value is < 0 or > 0xFFFFFFFFL
*/
public void setSize(long value) {
- if (value >= 0 && value <= 0xFFFFFFFFL)
- size = value;
- else
- throw new IllegalArgumentException();
+ if (value >= 0 && value <= 0xFFFFFFFFL) {
+ size = value;
+ } else {
+ throw new IllegalArgumentException();
+ }
}
/**
@@ -280,7 +287,8 @@
*
* @return the string representation of this ZipEntry
*/
- public String toString() {
+ @Override
+ public String toString() {
return name;
}
@@ -290,13 +298,13 @@
this.name = name;
this.comment = comment;
this.extra = extra;
- this.time = (int) modTime;
+ time = (int) modTime;
this.size = size;
this.compressedSize = compressedSize;
this.crc = crc;
this.compressionMethod = compressionMethod;
this.modDate = (int) modDate;
- this.dataOffset = offset;
+ dataOffset = offset;
}
/**
@@ -306,16 +314,16 @@
* ZipEntry from which to obtain values.
*/
public ZipEntry(ZipEntry ze) {
- this.name = ze.name;
- this.comment = ze.comment;
- this.time = ze.time;
- this.size = ze.size;
- this.compressedSize = ze.compressedSize;
- this.crc = ze.crc;
- this.compressionMethod = ze.compressionMethod;
- this.modDate = ze.modDate;
- this.extra = ze.extra;
- this.dataOffset = ze.dataOffset;
+ name = ze.name;
+ comment = ze.comment;
+ time = ze.time;
+ size = ze.size;
+ compressedSize = ze.compressedSize;
+ crc = ze.crc;
+ compressionMethod = ze.compressionMethod;
+ modDate = ze.modDate;
+ extra = ze.extra;
+ dataOffset = ze.dataOffset;
}
/**
@@ -323,7 +331,8 @@
*
* @return a copy of this entry
*/
- public Object clone() {
+ @Override
+ public Object clone() {
return new ZipEntry(this);
}
@@ -332,7 +341,8 @@
*
* @return the hashCode of the entry
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
return name.hashCode();
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java Mon Sep 25 20:02:49 2006
@@ -89,8 +89,9 @@
}
this.mode = mode;
openZip(fileName);
- } else
- throw new IllegalArgumentException();
+ } else {
+ throw new IllegalArgumentException();
+ }
}
/**
@@ -122,7 +123,8 @@
}
}
- protected void finalize() throws IOException {
+ @Override
+ protected void finalize() throws IOException {
close();
}
@@ -182,7 +184,9 @@
throw new IllegalStateException();
}
byte[] buf = inflateEntryImpl2(descriptor, entry.getName());
- if (buf == null) return null;
+ if (buf == null) {
+ return null;
+ }
return new ByteArrayInputStream(buf);
}
@@ -210,8 +214,9 @@
* @return Number of entries in this file
*/
public int size() {
- if (size != -1)
- return size;
+ if (size != -1) {
+ return size;
+ }
size = 0;
Enumeration<?> e = entries();
@@ -226,7 +231,7 @@
private static native void ntvinit();
class ZFEnum<T extends ZipEntry> implements Enumeration<T> {
- private long nextEntryPointer;
+ private final long nextEntryPointer;
private T current;
@@ -248,8 +253,9 @@
}
public T nextElement() {
- if (current == null)
- throw new NoSuchElementException();
+ if (current == null) {
+ throw new NoSuchElementException();
+ }
T ze = current;
current = getNextEntry(descriptor, nextEntryPointer);
return ze;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipInputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipInputStream.java Mon Sep 25 20:02:49 2006
@@ -53,9 +53,9 @@
ZipEntry currentEntry;
- private byte[] hdrBuf = new byte[LOCHDR - LOCVER];
+ private final byte[] hdrBuf = new byte[LOCHDR - LOCVER];
- private CRC32 crc = new CRC32();
+ private final CRC32 crc = new CRC32();
private byte[] nameBuf = new byte[256];
@@ -69,13 +69,15 @@
*/
public ZipInputStream(InputStream stream) {
super(new PushbackInputStream(stream, BUF_SIZE), new Inflater(true));
- if (stream == null)
- throw new NullPointerException();
+ if (stream == null) {
+ throw new NullPointerException();
+ }
}
/**
* Closes this ZipInputStream.
*/
+ @Override
public void close() throws IOException {
if (zipClosed != true) {
closeEntry(); // Close the current entry
@@ -88,14 +90,17 @@
* Closes the current zip entry and positions to read the next entry.
*/
public void closeEntry() throws IOException {
- if (zipClosed)
- throw new IOException(Msg.getString("K0059"));
- if (currentEntry == null)
- return;
+ if (zipClosed) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+ if (currentEntry == null) {
+ return;
+ }
if (currentEntry instanceof java.util.jar.JarEntry) {
Attributes temp = ((JarEntry) currentEntry).getAttributes();
- if (temp != null && temp.containsKey("hidden"))
- return;
+ if (temp != null && temp.containsKey("hidden")) {
+ return;
+ }
}
// Ensure all entry bytes are read
skip(Long.MAX_VALUE);
@@ -109,21 +114,25 @@
}
int diff = 0;
// Pushback any required bytes
- if ((diff = entryIn - inB) != 0)
- ((PushbackInputStream) in).unread(buf, len - diff, diff);
+ if ((diff = entryIn - inB) != 0) {
+ ((PushbackInputStream) in).unread(buf, len - diff, diff);
+ }
if (hasDD) {
in.read(hdrBuf, 0, EXTHDR);
- if (getLong(hdrBuf, 0) != EXTSIG)
- throw new ZipException(Msg.getString("K0020"));
+ if (getLong(hdrBuf, 0) != EXTSIG) {
+ throw new ZipException(Msg.getString("K0020"));
+ }
currentEntry.crc = getLong(hdrBuf, EXTCRC);
currentEntry.compressedSize = getLong(hdrBuf, EXTSIZ);
currentEntry.size = getLong(hdrBuf, EXTLEN);
}
- if (currentEntry.crc != crc.getValue())
- throw new ZipException(Msg.getString("K0077"));
- if (currentEntry.compressedSize != inB || currentEntry.size != out)
- throw new ZipException(Msg.getString("K00ae"));
+ if (currentEntry.crc != crc.getValue()) {
+ throw new ZipException(Msg.getString("K0077"));
+ }
+ if (currentEntry.compressedSize != inB || currentEntry.size != out) {
+ throw new ZipException(Msg.getString("K00ae"));
+ }
inf.reset();
lastRead = inRead = entryIn = len = 0;
@@ -135,35 +144,41 @@
* Reads the next zip entry from this ZipInputStream.
*/
public ZipEntry getNextEntry() throws IOException {
- if (currentEntry != null)
- closeEntry();
- if (entriesEnd)
- return null;
+ if (currentEntry != null) {
+ closeEntry();
+ }
+ if (entriesEnd) {
+ return null;
+ }
int x = 0, count = 0;
while (count != 4) {
count += x = in.read(hdrBuf, count, 4 - count);
- if (x == -1)
- return null;
+ if (x == -1) {
+ return null;
+ }
}
long hdr = getLong(hdrBuf, 0);
if (hdr == CENSIG) {
entriesEnd = true;
return null;
}
- if (hdr != LOCSIG)
- return null;
+ if (hdr != LOCSIG) {
+ return null;
+ }
// Read the local header
count = 0;
while (count != (LOCHDR - LOCVER)) {
count += x = in.read(hdrBuf, count, (LOCHDR - LOCVER) - count);
- if (x == -1)
- throw new EOFException();
+ if (x == -1) {
+ throw new EOFException();
+ }
}
int version = getShort(hdrBuf, 0) & 0xff;
- if (version > ZIPLocalHeaderVersionNeeded)
- throw new ZipException(Msg.getString("K0008"));
+ if (version > ZIPLocalHeaderVersionNeeded) {
+ throw new ZipException(Msg.getString("K0008"));
+ }
int flags = getShort(hdrBuf, LOCFLG - LOCVER);
hasDD = ((flags & ZIPDataDescriptorFlag) == ZIPDataDescriptorFlag);
int cetime = getShort(hdrBuf, LOCTIM - LOCVER);
@@ -176,8 +191,9 @@
cesize = getLong(hdrBuf, LOCLEN - LOCVER);
}
int flen = getShort(hdrBuf, LOCNAM - LOCVER);
- if (flen == 0)
- throw new ZipException(Msg.getString("K000a"));
+ if (flen == 0) {
+ throw new ZipException(Msg.getString("K000a"));
+ }
int elen = getShort(hdrBuf, LOCEXT - LOCVER);
count = 0;
@@ -187,8 +203,9 @@
}
while (count != flen) {
count += x = in.read(nameBuf, count, flen - count);
- if (x == -1)
- throw new EOFException();
+ if (x == -1) {
+ throw new EOFException();
+ }
}
currentEntry = createZipEntry(Util.convertUTF8WithBuf(nameBuf, charBuf,
0, flen));
@@ -205,8 +222,9 @@
byte[] e = new byte[elen];
while (count != elen) {
count += x = in.read(e, count, elen - count);
- if (x == -1)
- throw new EOFException();
+ if (x == -1) {
+ throw new EOFException();
+ }
}
currentEntry.setExtra(e);
}
@@ -227,27 +245,33 @@
* the number of bytes to read
* @return the number of bytes read
*/
- public int read(byte[] buffer, int start, int length) throws IOException {
- if (zipClosed)
- throw new IOException(Msg.getString("K0059"));
- if (inf.finished() || currentEntry == null)
- return -1;
+ @Override
+ public int read(byte[] buffer, int start, int length) throws IOException {
+ if (zipClosed) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+ if (inf.finished() || currentEntry == null) {
+ return -1;
+ }
// avoid int overflow, check null buffer
if (start <= buffer.length && length >= 0 && start >= 0
&& buffer.length - start >= length) {
if (currentEntry.compressionMethod == STORED) {
int csize = (int) currentEntry.size;
- if (inRead >= csize)
- return -1;
+ if (inRead >= csize) {
+ return -1;
+ }
if (lastRead >= len) {
lastRead = 0;
- if ((len = in.read(buf)) == -1)
- return -1;
+ if ((len = in.read(buf)) == -1) {
+ return -1;
+ }
entryIn += len;
}
int toRead = length > len ? len - lastRead : length;
- if ((csize - inRead) < toRead)
- toRead = csize - inRead;
+ if ((csize - inRead) < toRead) {
+ toRead = csize - inRead;
+ }
System.arraycopy(buf, lastRead, buffer, start, toRead);
lastRead += toRead;
inRead += toRead;
@@ -256,8 +280,9 @@
}
if (inf.needsInput()) {
fill();
- if (len > 0)
- entryIn += len;
+ if (len > 0) {
+ entryIn += len;
+ }
}
int read = 0;
try {
@@ -265,8 +290,9 @@
} catch (DataFormatException e) {
throw new ZipException(e.getMessage());
}
- if (read == 0 && inf.finished())
- return -1;
+ if (read == 0 && inf.finished()) {
+ return -1;
+ }
crc.update(buffer, start, read);
return read;
}
@@ -280,20 +306,22 @@
* the number of bytes to skip
* @return the number of bytes skipped
*/
- public long skip(long value) throws IOException {
+ @Override
+ public long skip(long value) throws IOException {
if (value >= 0) {
long skipped = 0;
byte[] b = new byte[1024];
while (skipped != value) {
long rem = value - skipped;
int x = read(b, 0, (int) (b.length > rem ? rem : b.length));
- if (x == -1)
- return skipped;
+ if (x == -1) {
+ return skipped;
+ }
skipped += x;
}
return skipped;
- } else
- throw new IllegalArgumentException();
+ }
+ throw new IllegalArgumentException();
}
/**
@@ -301,17 +329,22 @@
*
* @return 0 after EOF of current entry, 1 otherwise
*/
- public int available() throws IOException {
- if (zipClosed)
- throw new IOException(Msg.getString("K0059"));
- if (currentEntry == null)
- return 1;
+ @Override
+ public int available() throws IOException {
+ if (zipClosed) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+ if (currentEntry == null) {
+ return 1;
+ }
if (currentEntry.compressionMethod == STORED) {
- if (inRead >= currentEntry.size)
- return 0;
+ if (inRead >= currentEntry.size) {
+ return 0;
+ }
} else {
- if (inf.finished())
- return 0;
+ if (inf.finished()) {
+ return 0;
+ }
}
return 1;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipOutputStream.java Mon Sep 25 20:02:49 2006
@@ -43,7 +43,7 @@
private String comment;
- private Vector<String> entries = new Vector<String>();
+ private final Vector<String> entries = new Vector<String>();
private int compressMethod = DEFLATED;
@@ -53,7 +53,7 @@
private ZipEntry currentEntry;
- private CRC32 crc = new CRC32();
+ private final CRC32 crc = new CRC32();
private int offset = 0, curOffset = 0, nameLength;
@@ -76,7 +76,8 @@
* @exception IOException
* If an error occurs closing the stream
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
if (out != null) {
finish();
out.close();
@@ -92,20 +93,24 @@
* If an error occurs closing the entry
*/
public void closeEntry() throws IOException {
- if (cDir == null)
- throw new IOException(Msg.getString("K0059"));
- if (currentEntry == null)
- return;
+ if (cDir == null) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+ if (currentEntry == null) {
+ return;
+ }
if (currentEntry.getMethod() == DEFLATED) {
super.finish();
}
// Verify values for STORED types
if (currentEntry.getMethod() == STORED) {
- if (crc.getValue() != currentEntry.crc)
- throw new ZipException(Msg.getString("K0077"));
- if (currentEntry.size != crc.tbytes)
- throw new ZipException(Msg.getString("K00ae"));
+ if (crc.getValue() != currentEntry.crc) {
+ throw new ZipException(Msg.getString("K0077"));
+ }
+ if (currentEntry.size != crc.tbytes) {
+ throw new ZipException(Msg.getString("K00ae"));
+ }
}
curOffset = LOCHDR;
@@ -135,26 +140,30 @@
writeLong(cDir, crc.tbytes);
}
curOffset += writeShort(cDir, nameLength);
- if (currentEntry.extra != null)
- curOffset += writeShort(cDir, currentEntry.extra.length);
- else
- writeShort(cDir, 0);
+ if (currentEntry.extra != null) {
+ curOffset += writeShort(cDir, currentEntry.extra.length);
+ } else {
+ writeShort(cDir, 0);
+ }
String c;
- if ((c = currentEntry.getComment()) != null)
- writeShort(cDir, c.length());
- else
- writeShort(cDir, 0);
+ if ((c = currentEntry.getComment()) != null) {
+ writeShort(cDir, c.length());
+ } else {
+ writeShort(cDir, 0);
+ }
writeShort(cDir, 0); // Disk Start
writeShort(cDir, 0); // Internal File Attributes
writeLong(cDir, 0); // External File Attributes
writeLong(cDir, offset);
cDir.write(nameBytes);
nameBytes = null;
- if (currentEntry.extra != null)
- cDir.write(currentEntry.extra);
+ if (currentEntry.extra != null) {
+ cDir.write(currentEntry.extra);
+ }
offset += curOffset;
- if (c != null)
- cDir.write(c.getBytes());
+ if (c != null) {
+ cDir.write(c.getBytes());
+ }
currentEntry = null;
crc.reset();
def.reset();
@@ -168,15 +177,20 @@
* @exception IOException
* If an error occurs while finishing
*/
- public void finish() throws IOException {
- if (out == null)
- throw new IOException(Msg.getString("K0059"));
- if (cDir == null)
- return;
- if (entries.size() == 0)
- throw new ZipException(Msg.getString("K00b6"));
- if (currentEntry != null)
- closeEntry();
+ @Override
+ public void finish() throws IOException {
+ if (out == null) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+ if (cDir == null) {
+ return;
+ }
+ if (entries.size() == 0) {
+ throw new ZipException(Msg.getString("K00b6"));
+ }
+ if (currentEntry != null) {
+ closeEntry();
+ }
int cdirSize = cDir.size();
// Write Central Dir End
writeLong(cDir, ENDSIG);
@@ -189,8 +203,9 @@
if (comment != null) {
writeShort(cDir, comment.length());
cDir.write(comment.getBytes());
- } else
- writeShort(cDir, 0);
+ } else {
+ writeShort(cDir, 0);
+ }
// Write the central dir
out.write(cDir.toByteArray());
cDir = null;
@@ -210,52 +225,62 @@
* @see #write
*/
public void putNextEntry(ZipEntry ze) throws java.io.IOException {
- if (currentEntry != null)
+ if (currentEntry != null) {
closeEntry();
+ }
if (ze.getMethod() == STORED
|| (compressMethod == STORED && ze.getMethod() == -1)) {
- if (ze.crc == -1)
- /* [MSG "K0077", "Crc mismatch"] */
+ if (ze.crc == -1) {
+ /* [MSG "K0077", "Crc mismatch"] */
throw new ZipException(Msg.getString("K0077"));
- if (ze.size == -1 && ze.compressedSize == -1)
- /* [MSG "K00ae", "Size mismatch"] */
+ }
+ if (ze.size == -1 && ze.compressedSize == -1) {
+ /* [MSG "K00ae", "Size mismatch"] */
throw new ZipException(Msg.getString("K00ae"));
+ }
if (ze.size != ze.compressedSize && ze.compressedSize != -1
- && ze.size != -1)
- /* [MSG "K00ae", "Size mismatch"] */
+ && ze.size != -1) {
+ /* [MSG "K00ae", "Size mismatch"] */
throw new ZipException(Msg.getString("K00ae"));
+ }
}
/* [MSG "K0059", "Stream is closed"] */
- if (cDir == null)
- throw new IOException(Msg.getString("K0059"));
- if (entries.contains(ze.name))
- /* [MSG "K0066", "Entry already exists: {0}"] */
+ if (cDir == null) {
+ throw new IOException(Msg.getString("K0059"));
+ }
+ if (entries.contains(ze.name)) {
+ /* [MSG "K0066", "Entry already exists: {0}"] */
throw new ZipException(Msg.getString("K0066", ze.name));
+ }
nameLength = utf8Count(ze.name);
- if (nameLength > 0xffff)
- /* [MSG "K01a7", "Name too long: {0}"] */
+ if (nameLength > 0xffff) {
+ /* [MSG "K01a7", "Name too long: {0}"] */
throw new IllegalArgumentException(Msg.getString("K01a7", ze.name));
+ }
def.setLevel(compressLevel);
currentEntry = ze;
entries.add(currentEntry.name);
- if (currentEntry.getMethod() == -1)
- currentEntry.setMethod(compressMethod);
+ if (currentEntry.getMethod() == -1) {
+ currentEntry.setMethod(compressMethod);
+ }
writeLong(out, LOCSIG); // Entry header
writeShort(out, ZIPLocalHeaderVersionNeeded); // Extraction version
writeShort(out, currentEntry.getMethod() == STORED ? 0
: ZIPDataDescriptorFlag);
writeShort(out, currentEntry.getMethod());
- if (currentEntry.getTime() == -1)
- currentEntry.setTime(System.currentTimeMillis());
+ if (currentEntry.getTime() == -1) {
+ currentEntry.setTime(System.currentTimeMillis());
+ }
writeShort(out, currentEntry.time);
writeShort(out, currentEntry.modDate);
if (currentEntry.getMethod() == STORED) {
- if (currentEntry.size == -1)
- currentEntry.size = currentEntry.compressedSize;
- else if (currentEntry.compressedSize == -1)
- currentEntry.compressedSize = currentEntry.size;
+ if (currentEntry.size == -1) {
+ currentEntry.size = currentEntry.compressedSize;
+ } else if (currentEntry.compressedSize == -1) {
+ currentEntry.compressedSize = currentEntry.size;
+ }
writeLong(out, currentEntry.crc);
writeLong(out, currentEntry.size);
writeLong(out, currentEntry.size);
@@ -265,14 +290,16 @@
writeLong(out, 0);
}
writeShort(out, nameLength);
- if (currentEntry.extra != null)
- writeShort(out, currentEntry.extra.length);
- else
- writeShort(out, 0);
+ if (currentEntry.extra != null) {
+ writeShort(out, currentEntry.extra.length);
+ } else {
+ writeShort(out, 0);
+ }
nameBytes = toUTF8Bytes(currentEntry.name, nameLength);
out.write(nameBytes);
- if (currentEntry.extra != null)
- out.write(currentEntry.extra);
+ if (currentEntry.extra != null) {
+ out.write(currentEntry.extra);
+ }
}
/**
@@ -280,8 +307,9 @@
*
*/
public void setComment(String comment) {
- if (comment.length() > 0xFFFF)
- throw new IllegalArgumentException(Msg.getString("K0068"));
+ if (comment.length() > 0xFFFF) {
+ throw new IllegalArgumentException(Msg.getString("K0068"));
+ }
this.comment = comment;
}
@@ -293,8 +321,9 @@
*/
public void setLevel(int level) {
if (level < Deflater.DEFAULT_COMPRESSION
- || level > Deflater.BEST_COMPRESSION)
- throw new IllegalArgumentException();
+ || level > Deflater.BEST_COMPRESSION) {
+ throw new IllegalArgumentException();
+ }
compressLevel = level;
}
@@ -306,8 +335,9 @@
* Compression method to use
*/
public void setMethod(int method) {
- if (method != STORED && method != DEFLATED)
- throw new IllegalArgumentException();
+ if (method != STORED && method != DEFLATED) {
+ throw new IllegalArgumentException();
+ }
compressMethod = method;
}
@@ -334,7 +364,8 @@
* @exception IOException
* If an error occurs writing to the stream
*/
- public void write(byte[] buffer, int off, int nbytes)
+ @Override
+ public void write(byte[] buffer, int off, int nbytes)
throws java.io.IOException {
// avoid int overflow, check null buf
if ((off > buffer.length) || (nbytes < 0) || (off < 0)
@@ -347,10 +378,11 @@
throw new ZipException(Msg.getString("K00ab"));
}
- if (currentEntry.getMethod() == STORED)
- out.write(buffer, off, nbytes);
- else
- super.write(buffer, off, nbytes);
+ if (currentEntry.getMethod() == STORED) {
+ out.write(buffer, off, nbytes);
+ } else {
+ super.write(buffer, off, nbytes);
+ }
crc.update(buffer, off, nbytes);
}
@@ -358,12 +390,13 @@
int total = 0;
for (int i = value.length(); --i >= 0;) {
char ch = value.charAt(i);
- if (ch < 0x80)
- total++;
- else if (ch < 0x800)
- total += 2;
- else
- total += 3;
+ if (ch < 0x80) {
+ total++;
+ } else if (ch < 0x800) {
+ total += 2;
+ } else {
+ total += 3;
+ }
}
return total;
}
@@ -373,9 +406,9 @@
int pos = result.length;
for (int i = value.length(); --i >= 0;) {
char ch = value.charAt(i);
- if (ch < 0x80)
- result[--pos] = (byte) ch;
- else if (ch < 0x800) {
+ if (ch < 0x80) {
+ result[--pos] = (byte) ch;
+ } else if (ch < 0x800) {
result[--pos] = (byte) (0x80 | (ch & 0x3f));
result[--pos] = (byte) (0xc0 | (ch >> 6));
} else {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/BHSDCodec.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/BHSDCodec.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/BHSDCodec.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/BHSDCodec.java Mon Sep 25 20:02:49 2006
@@ -127,9 +127,8 @@
public long cardinality() {
if (h > 1) {
return (long) (l * Math.pow(1 - h, b) / (1 - h) + Math.pow(h, b));
- } else {
- return (b * 255) + 1;
}
+ return (b * 255) + 1;
}
@Override
@@ -242,7 +241,8 @@
* Returns the codec in the form (1,256) or (1,64,1,1). Note that trailing
* zero fields are not shown.
*/
- public String toString() {
+ @Override
+ public String toString() {
StringBuffer buffer = new StringBuffer(11);
buffer.append('(');
buffer.append(b);
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java Mon Sep 25 20:02:49 2006
@@ -163,12 +163,11 @@
// number of items read from the fCodec. So we don't know in advance what
// the codec will be.
return new PopulationCodec(fCodec,l,uCodec);
- } else {
- Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
- Codec uCodec = (udef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
- Codec tCodec = getCodec(in.read(),in,defaultCodec);
- return new PopulationCodec(fCodec,uCodec,tCodec);
}
+ Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
+ Codec uCodec = (udef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
+ Codec tCodec = getCodec(in.read(),in,defaultCodec);
+ return new PopulationCodec(fCodec,uCodec,tCodec);
} else {
throw new Pack200Exception("Invalid codec encoding byte (" + value + ") found" );
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Pack200Exception.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Pack200Exception.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Pack200Exception.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Pack200Exception.java Mon Sep 25 20:02:49 2006
@@ -24,7 +24,9 @@
*/
public class Pack200Exception extends Exception {
- /**
+ private static final long serialVersionUID = 5168177401552611803L;
+
+ /**
* Create a new Pack200 exception with the given message and cause
*
* @param message
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java Mon Sep 25 20:02:49 2006
@@ -43,21 +43,25 @@
this.aCodec = aCodec;
this.bCodec = bCodec;
}
- public long decode(InputStream in) throws IOException, Pack200Exception {
+
+ @Override
+ public long decode(InputStream in) throws IOException, Pack200Exception {
return decode(in,this.last);
}
- public long decode(InputStream in, long last) throws IOException, Pack200Exception {
+ @Override
+ public long decode(InputStream in, long last) throws IOException, Pack200Exception {
if(--k>=0) {
long value = aCodec.decode(in,last);
this.last = (k == 0 ? 0 : value);
return value;
- } else {
- this.last = bCodec.decode(in,last);
- return this.last;
}
+ this.last = bCodec.decode(in,last);
+ return this.last;
}
- public String toString() {
+
+ @Override
+ public String toString() {
return "RunCodec[k="+k+";aCodec="+aCodec+"bCodec="+bCodec+"]";
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java Mon Sep 25 20:02:49 2006
@@ -255,7 +255,8 @@
* @param message
* @deprecated this should be removed from production code
*/
- private void debug(String message) {
+ @Deprecated
+ private void debug(String message) {
if (System.getProperty("debug.pack200") != null) {
System.err.println(message);
}
@@ -777,7 +778,7 @@
String form = cpSignatureForm[i];
int len = form.length();
StringBuffer signature = new StringBuffer(64);
- ArrayList list = new ArrayList();
+ ArrayList<String> list = new ArrayList<String>();
for (int j = 0; j < len; j++) {
char c = form.charAt(j);
signature.append(c);
@@ -817,7 +818,7 @@
private void parseCpUtf8(InputStream in) throws IOException,
Pack200Exception {
// TODO Update codec.decode -> decodeScalar
- cpUTF8 = new String[(int) cpUTF8Count];
+ cpUTF8 = new String[cpUTF8Count];
cpUTF8[0] = "";
int[] prefix = new int[cpUTF8Count];
int[] suffix = new int[cpUTF8Count];
@@ -1128,7 +1129,7 @@
debug("-------");
parseSegmentHeader(in);
if (bandHeadersSize > 0) {
- byte[] bandHeaders = new byte[(int) bandHeadersSize];
+ byte[] bandHeaders = new byte[bandHeadersSize];
readFully(in, bandHeaders);
setBandHeadersData(bandHeaders);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecEncodingTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecEncodingTest.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecEncodingTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecEncodingTest.java Mon Sep 25 20:02:49 2006
@@ -36,7 +36,7 @@
public void testCanonicalEncodings() throws IOException, Pack200Exception {
Codec defaultCodec = new BHSDCodec(2,16,0,0);
assertEquals(defaultCodec,CodecEncoding.getCodec(0,null, defaultCodec));
- Map map = new HashMap();
+ Map<Integer, String> map = new HashMap<Integer, String>();
// These are the canonical encodings specified by the Pack200 spec
map.put(new Integer(1), "(1,256)");
map.put(new Integer(2), "(1,256,1)");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecTest.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/CodecTest.java Mon Sep 25 20:02:49 2006
@@ -107,7 +107,7 @@
decode(BYTE1S2,new byte[] { 11 }, -3, 0);
}
public void testCardinality() throws Exception {
- BHSDCodec byte1 = (BHSDCodec) Codec.BYTE1;
+ BHSDCodec byte1 = Codec.BYTE1;
assertEquals(256,byte1.cardinality());
assertEquals(0,byte1.smallest());
assertEquals(255,byte1.largest());
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java Mon Sep 25 20:02:49 2006
@@ -90,16 +90,16 @@
*/
public void test_entrySet() {
// Test for method java.util.Set java.util.jar.Attributes.entrySet()
- Set entrySet = a.entrySet();
- Set keySet = new HashSet();
- Set valueSet = new HashSet();
- Iterator i;
+ Set<Map.Entry<Object, Object>> entrySet = a.entrySet();
+ Set<Object> keySet = new HashSet<Object>();
+ Set<Object> valueSet = new HashSet<Object>();
+ Iterator<?> i;
assertTrue("Wrong size--Wanted: 4, got: " + entrySet.size(), entrySet
.size() == 4);
i = entrySet.iterator();
while (i.hasNext()) {
- java.util.Map.Entry e;
- e = (Map.Entry) i.next();
+ java.util.Map.Entry<?, ?> e;
+ e = (Map.Entry<?, ?>) i.next();
keySet.add(e.getKey());
valueSet.add(e.getValue());
}
@@ -146,7 +146,7 @@
*/
public void test_keySet() {
// Test for method java.util.Set java.util.jar.Attributes.keySet()
- Set s = a.keySet();
+ Set<?> s = a.keySet();
assertTrue("Wrong size--Wanted: 4, got: " + s.size(), s.size() == 4);
assertTrue("a) Should contain entry", s.contains(new Attributes.Name(
"1")));
@@ -210,10 +210,11 @@
//verify that special care for null is done in the Attributes.putAll() method
try {
new Attributes() {
- public void putAll(Map attrib) {
- map.putAll((Attributes) attrib);
+ @Override
+ public void putAll(Map<?, ?> attrib) {
+ map.putAll(attrib);
}
- }.putAll((Map) null);
+ }.putAll((Map<?, ?>) null);
fail("NullPointerException expected");
} catch (NullPointerException e) {
}
@@ -249,7 +250,7 @@
public void test_values() {
// Test for method java.util.Collection
// java.util.jar.Attributes.values()
- Collection valueCollection = a.values();
+ Collection<?> valueCollection = a.values();
assertTrue("a) Should contain entry", valueCollection.contains("one"));
assertTrue("b) Should contain entry", valueCollection.contains("two"));
assertTrue("c) Should contain entry", valueCollection.contains("three"));
@@ -287,19 +288,13 @@
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.
*/
- protected void setUp() {
+ @Override
+ protected void setUp() {
a = new Attributes();
a.putValue("1", "one");
a.putValue("2", "two");
a.putValue("3", "three");
a.putValue("4", "four");
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
}
/*
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java Mon Sep 25 20:02:49 2006
@@ -127,11 +127,11 @@
}
CodeSigner[] codeSigners = jarEntry.getCodeSigners();
assertEquals(2, codeSigners.length);
- List certs_bob = codeSigners[0].getSignerCertPath().getCertificates();
- List certs_alice = codeSigners[1].getSignerCertPath().getCertificates();
+ List<?> certs_bob = codeSigners[0].getSignerCertPath().getCertificates();
+ List<?> certs_alice = codeSigners[1].getSignerCertPath().getCertificates();
if(1 == certs_bob.size())
{
- List temp = certs_bob;
+ List<?> temp = certs_bob;
certs_bob = certs_alice;
certs_alice = temp;
}
@@ -147,7 +147,8 @@
* is called before a test is executed.
*/
- protected void setUp() {
+ @Override
+ protected void setUp() {
try {
resources = Support_Resources.createTempFolder();
Support_Resources.copyFile(resources, null, jarName);
@@ -163,10 +164,12 @@
* method is called after a test is executed.
*/
- protected void tearDown() {
+ @Override
+ protected void tearDown() {
try {
- if (jarFile != null)
- jarFile.close();
+ if (jarFile != null) {
+ jarFile.close();
+ }
} catch (java.io.IOException e) {
System.out.println("Exception during tearDown");
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java?view=diff&rev=449886&r1=449885&r2=449886
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java Mon Sep 25 20:02:49 2006
@@ -40,14 +40,16 @@
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.
*/
- protected void setUp() {
+ @Override
+ protected void setUp() {
}
/**
* Tears down the fixture, for example, close a network connection. This
* method is called after a test is executed.
*/
- protected void tearDown() {
+ @Override
+ protected void tearDown() {
}
}