You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sj...@apache.org on 2009/05/05 13:58:42 UTC
svn commit: r771681 - in
/harmony/enhanced/classlib/trunk/modules/pack200/src:
main/java/org/apache/harmony/unpack200/
test/java/org/apache/harmony/unpack200/tests/
Author: sjanuary
Date: Tue May 5 11:58:32 2009
New Revision: 771681
URL: http://svn.apache.org/viewvc?rev=771681&view=rev
Log:
Unpack200 - remove unnecessary method
Modified:
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/FileBands.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/Segment.java
harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/BandSetTest.java
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java?rev=771681&r1=771680&r2=771681&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java Tue May 5 11:58:32 2009
@@ -184,89 +184,6 @@
return result;
}
- /**
- * Decode a band and return an array of <code>long</code> values
- *
- * @param name
- * the name of the band (primarily for logging/debugging
- * purposes)
- * @param in
- * the InputStream to decode from
- * @param codec
- * the default codec for this band
- * @param count
- * the number of elements to read
- * @return an array of decoded <code>long</code> values
- * @throws IOException
- * if there is a problem reading from the underlying input
- * stream
- * @throws Pack200Exception
- * if there is a problem decoding the value or that the value is
- * invalid
- */
- public long[] decodeBandLong(String name, InputStream in, BHSDCodec codec,
- int count) throws IOException, Pack200Exception {
- if (codec.getB() == 1 || count == 0) {
- return codec.decode(count, in);
- }
- Codec codecUsed = codec;
- long[] band;
- long[] getFirst = codec.decode(1, in);
- if (getFirst.length == 0) {
- return getFirst;
- }
- long first = getFirst[0];
- if (codec.isSigned() && first >= -256 && first <= -1) {
- // Non-default codec should be used
- codecUsed = CodecEncoding.getCodec((int) (-1 - first), header
- .getBandHeadersInputStream(), codec);
- band = codecUsed.decode(count, in);
- } else if (!codec.isSigned() && first >= codec.getL()
- && first <= codec.getL() + 255) {
- // Non-default codec should be used
- codecUsed = CodecEncoding.getCodec((int) first - codec.getL(),
- header.getBandHeadersInputStream(), codec);
- band = codecUsed.decode(count, in);
- } else {
- // First element should not be discarded
- band = codec.decode(count - 1, in, first);
- }
-
- if (codecUsed instanceof BHSDCodec && ((BHSDCodec) codecUsed).isDelta()) {
- BHSDCodec bhsd = (BHSDCodec) codecUsed;
- long cardinality = bhsd.cardinality();
- for (int i = 0; i < band.length; i++) {
- while (band[i] > bhsd.largest()) {
- band[i] -= cardinality;
- }
- while (band[i] < bhsd.smallest()) {
- band[i] += cardinality;
- }
- }
- } else if (codecUsed instanceof PopulationCodec) {
- PopulationCodec popCodec = (PopulationCodec) codecUsed;
- long[] favoured = (long[]) popCodec.getFavoured().clone();
- Arrays.sort(favoured);
- for (int i = 0; i < band.length; i++) {
- boolean favouredValue = Arrays.binarySearch(favoured, band[i]) > -1;
- Codec theCodec = favouredValue ? popCodec.getFavouredCodec()
- : popCodec.getUnfavouredCodec();
- if (theCodec instanceof BHSDCodec
- && ((BHSDCodec) theCodec).isDelta()) {
- BHSDCodec bhsd = (BHSDCodec) theCodec;
- long cardinality = bhsd.cardinality();
- while (band[i] > bhsd.largest()) {
- band[i] -= cardinality;
- }
- while (band[i] < bhsd.smallest()) {
- band[i] += cardinality;
- }
- }
- }
- }
- return band;
- }
-
public long[] parseFlags(String name, InputStream in, int count,
BHSDCodec codec, boolean hasHi) throws IOException,
Pack200Exception {
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java?rev=771681&r1=771680&r2=771681&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java Tue May 5 11:58:32 2009
@@ -348,7 +348,7 @@
AttributeLayout.CONTEXT_METHOD);
int count1 = SegmentUtils.countMatches(methodFlags,
methodSignatureLayout);
- long[] methodSignatureRS = decodeBandLong("method_signature_RS", in,
+ int[] methodSignatureRS = decodeBandInt("method_signature_RS", in,
Codec.UNSIGNED5, count1);
AttributeLayout deprecatedLayout = attrMap.getAttributeLayout(
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/FileBands.java?rev=771681&r1=771680&r2=771681&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/FileBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/FileBands.java Tue May 5 11:58:32 2009
@@ -33,11 +33,11 @@
private byte[][] fileBits;
- private long[] fileModtime;
+ private int[] fileModtime;
private String[] fileName;
- private long[] fileOptions;
+ private int[] fileOptions;
private long[] fileSize;
@@ -67,16 +67,16 @@
fileSize = parseFlags("file_size", in, numberOfFiles, Codec.UNSIGNED5,
options.hasFileSizeHi());
if (options.hasFileModtime()) {
- fileModtime = decodeBandLong("file_modtime", in, Codec.DELTA5,
+ fileModtime = decodeBandInt("file_modtime", in, Codec.DELTA5,
numberOfFiles);
} else {
- fileModtime = new long[numberOfFiles];
+ fileModtime = new int[numberOfFiles];
}
if (options.hasFileOptions()) {
- fileOptions = decodeBandLong("file_options", in, Codec.UNSIGNED5,
+ fileOptions = decodeBandInt("file_options", in, Codec.UNSIGNED5,
numberOfFiles);
} else {
- fileOptions = new long[numberOfFiles];
+ fileOptions = new int[numberOfFiles];
}
this.in = in; // store for use by processFileBits(), which is called
// later
@@ -108,7 +108,7 @@
return fileBits;
}
- public long[] getFileModtime() {
+ public int[] getFileModtime() {
return fileModtime;
}
@@ -116,7 +116,7 @@
return fileName;
}
- public long[] getFileOptions() {
+ public int[] getFileOptions() {
return fileOptions;
}
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=771681&r1=771680&r2=771681&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 Tue May 5 11:58:32 2009
@@ -390,7 +390,7 @@
private class Integral extends LayoutElement {
private final String tag;
- private long[] band;
+ private int[] band;
public Integral(String tag) {
this.tag = tag;
@@ -398,7 +398,7 @@
public void readBands(InputStream in, int count) throws IOException,
Pack200Exception {
- band = decodeBandLong(attributeLayout.getName() + "_" + tag, in,
+ band = decodeBandInt(attributeLayout.getName() + "_" + tag, in,
getCodec(tag), count);
}
@@ -522,7 +522,7 @@
public void readBands(InputStream in, int count) throws IOException,
Pack200Exception {
unionTag.readBands(in, count);
- long[] values = unionTag.band;
+ int[] values = unionTag.band;
// Count the band size for each union case then read the bands
caseCounts = new int[unionCases.size()];
for (int i = 0; i < caseCounts.length; i++) {
@@ -558,7 +558,7 @@
public void addToAttribute(int n, NewAttribute attribute) {
unionTag.addToAttribute(n, attribute);
int offset = 0;
- long[] tagBand = unionTag.band;
+ int[] tagBand = unionTag.band;
long tag = unionTag.getValue(n);
boolean defaultCase = true;
for(int i = 0; i < unionCases.size(); i++) {
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java?rev=771681&r1=771680&r2=771681&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java Tue May 5 11:58:32 2009
@@ -419,7 +419,7 @@
int classNum = 0;
int numberOfFiles = header.getNumberOfFiles();
String[] fileName = fileBands.getFileName();
- long[] fileOptions = fileBands.getFileOptions();
+ int[] fileOptions = fileBands.getFileOptions();
SegmentOptions options = header.getOptions();
classFilesContents = new byte[numberOfFiles][];
@@ -525,7 +525,7 @@
public void writeJar(JarOutputStream out) throws IOException,
Pack200Exception {
String[] fileName = fileBands.getFileName();
- long[] fileModtime = fileBands.getFileModtime();
+ int[] fileModtime = fileBands.getFileModtime();
long[] fileSize = fileBands.getFileSize();
byte[][] fileBits = fileBands.getFileBits();
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/BandSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/BandSetTest.java?rev=771681&r1=771680&r2=771681&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/BandSetTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/BandSetTest.java Tue May 5 11:58:32 2009
@@ -59,33 +59,6 @@
}
}
- public void testDecodeBandLong() throws IOException, Pack200Exception {
- BHSDCodec codec = Codec.BYTE1;
- byte[] bytes = new byte[] { (byte) 3, (byte) 56, (byte) 122, (byte) 78,
- (byte) 0, (byte) 255 };
- InputStream in = new ByteArrayInputStream(bytes);
- long[] longs = bandSet.decodeBandLong("Test Band", in, codec, 6);
- for (int i = 0; i < longs.length; i++) {
- assertEquals("Wrong value in position " + i, (byte) longs[i],
- bytes[i]);
- }
- // TODO: Should test this with other Codecs.
- }
-
- public void testDecodeBandLong2() throws IOException, Pack200Exception {
-
- BHSDCodec codec = Codec.DELTA5;
- byte[] bytes = new byte[] { 3, 1, 2, 3, 4, 5 }; // 3 is decoded to -2 by
- // DELTA5, which
- // signifies a switch to
- // BYTE1
- InputStream in = new ByteArrayInputStream(bytes);
- long[] longs = bandSet.decodeBandLong("Test Band", in, codec, 5);
- for (int i = 0; i < longs.length; i++) {
- assertEquals("Wrong value in position " + i, longs[i], bytes[i + 1]);
- }
- }
-
public void testParseFlags1() {
}