harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r823206 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony: pack200/NewAttributeBands.java pack200/PackingOptions.java unpack200/NewAttributeBands.java unpack200/SegmentHeader.java
Date Thu, 08 Oct 2009 15:30:10 GMT
Author: odeakin
Date: Thu Oct  8 15:30:09 2009
New Revision: 823206

URL: http://svn.apache.org/viewvc?rev=823206&view=rev
Log:
Commit a few small fixes for bugs found by findbugs:
1) Capture stream read return values in an int, as a char cannot be negative and thus cannot
handle a -1 error return value.
2) When calling String.replaceAll(), capture the output as it does not alter the original
String.
3) Cast int value to a long before shifting left by 32 bits.

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java?rev=823206&r1=823205&r2=823206&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
Thu Oct  8 15:30:09 2009
@@ -194,20 +194,21 @@
 
     private LayoutElement readNextLayoutElement(StringReader stream)
             throws IOException {
-        char nextChar = (char)stream.read();
+        int nextChar = stream.read();
         if (nextChar == -1) {
             return null;
         }
+
         switch (nextChar) {
         // Integrals
         case 'B':
         case 'H':
         case 'I':
         case 'V':
-            return new Integral(new String(new char[] { nextChar }));
+            return new Integral(new String(new char[] { (char)nextChar }));
         case 'S':
         case 'F':
-            return new Integral(new String(new char[] { nextChar,
+            return new Integral(new String(new char[] { (char)nextChar,
                     (char) stream.read() }));
         case 'P':
             stream.mark(1);
@@ -266,7 +267,7 @@
             // Reference
         case 'K':
         case 'R':
-            String string = "" + nextChar + (char) stream.read();
+            String string = "" + (char)nextChar + (char) stream.read();
             char nxt = (char) stream.read();
             string += nxt;
             if (nxt == 'N') {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java?rev=823206&r1=823205&r2=823206&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
Thu Oct  8 15:30:09 2009
@@ -183,7 +183,7 @@
             // Need to escape backslashes for replaceAll(), which uses regex
             fileSeparator += "\\";
         }
-        passFileName.replaceAll(fileSeparator, "/");
+        passFileName = passFileName.replaceAll(fileSeparator, "/");
         passFiles.add(passFileName);
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java?rev=823206&r1=823205&r2=823206&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
Thu Oct  8 15:30:09 2009
@@ -214,7 +214,7 @@
 
     private LayoutElement readNextLayoutElement(StringReader stream)
             throws IOException {
-        char nextChar = (char)stream.read();
+        int nextChar = stream.read();
         if (nextChar == -1) {
             return null;
         }
@@ -224,10 +224,10 @@
         case 'H':
         case 'I':
         case 'V':
-            return new Integral(new String(new char[] { nextChar }));
+            return new Integral(new String(new char[] { (char)nextChar }));
         case 'S':
         case 'F':
-            return new Integral(new String(new char[] { nextChar,
+            return new Integral(new String(new char[] { (char)nextChar,
                     (char) stream.read() }));
         case 'P':
             stream.mark(1);
@@ -284,7 +284,7 @@
             // Reference
         case 'K':
         case 'R':
-            String string = "" + nextChar + (char) stream.read();
+            String string = "" + (char)nextChar + (char) stream.read();
             char nxt = (char) stream.read();
             string += nxt;
             if (nxt == 'N') {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java?rev=823206&r1=823205&r2=823206&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/SegmentHeader.java
Thu Oct  8 15:30:09 2009
@@ -283,7 +283,7 @@
     private void parseArchiveFileCounts(InputStream in) throws IOException,
             Pack200Exception {
         if (options.hasArchiveFileCounts()) {
-            setArchiveSize(decodeScalar("archive_size_hi", in, Codec.UNSIGNED5) <<
32
+            setArchiveSize((long)decodeScalar("archive_size_hi", in, Codec.UNSIGNED5) <<
32
                     | decodeScalar("archive_size_lo", in, Codec.UNSIGNED5));
             archiveSizeOffset = in.available();
             setSegmentsRemaining(decodeScalar("archive_next_count", in,



Mime
View raw message