You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by zh...@apache.org on 2009/07/01 12:13:30 UTC
svn commit: r790097 [1/2] - in /harmony/enhanced:
classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/
jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/
Author: zhoukevin
Date: Wed Jul 1 10:13:29 2009
New Revision: 790097
URL: http://svn.apache.org/viewvc?rev=790097&view=rev
Log:
Implement -v, -q, -l cmd line options for pack200
Added:
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java (with props)
Modified:
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
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/Segment.java
harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java?rev=790097&r1=790096&r2=790097&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java Wed Jul 1 10:13:29 2009
@@ -24,6 +24,7 @@
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.Iterator;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -65,6 +66,7 @@
outputStream = new GZIPOutputStream(outputStream);
}
this.outputStream = new BufferedOutputStream(outputStream);
+ PackingUtils.config(options);
}
/**
@@ -87,6 +89,7 @@
this.outputStream = new BufferedOutputStream(outputStream);
this.jarFile = jarFile;
inputStream = null;
+ PackingUtils.config(options);
}
/**
@@ -95,30 +98,27 @@
* @throws IOException
*/
public void pack() throws Pack200Exception, IOException {
- List classes = new ArrayList();
- List files = new ArrayList();
-
int effort = options.getEffort();
- long segmentLimit = options.getSegmentLimit();
-
if(effort == 0) {
doZeroEffortPack();
} else {
+ List classes = new ArrayList();
+ List files = new ArrayList();
+ long segmentLimit = options.getSegmentLimit();
+ List segmentUnitList = new ArrayList();
if (inputStream != null) {
Manifest manifest = jarFile != null ? jarFile.getManifest()
: inputStream.getManifest();
if (manifest != null) {
- System.out.println("manifest exists");
- System.out.println(manifest.toString());
+ PackingUtils.log("Pack META-INF/MANIFEST.MF");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
manifest.write(baos);
- files.add(new File("META-INF", new byte[0], 0));
files.add(new File("META-INF/MANIFEST.MF", baos.toByteArray(), 0));
}
JarEntry jarEntry = inputStream.getNextJarEntry();
while (jarEntry != null) {
if(jarEntry.getName().startsWith("META-INF")) {
- System.out.println(jarEntry.getName());
+ PackingUtils.log("Pack " + jarEntry.getName());
}
boolean added = addJarEntry(jarEntry,
new BufferedInputStream(inputStream), classes,
@@ -126,7 +126,7 @@
if (!added) { // not added because segment has reached
// maximum size
if(classes.size() > 0 || files.size() > 0) {
- new Segment().pack(classes, files, outputStream, options);
+ segmentUnitList.add(new SegmentUnit(classes, files));
classes = new ArrayList();
files = new ArrayList();
currentSegmentSize = 0;
@@ -135,7 +135,7 @@
}
} else if (segmentLimit == 0 && estimateSize(jarEntry) > 0) {
// create a new segment for each class unless size = 0
- new Segment().pack(classes, files, outputStream, options);
+ segmentUnitList.add(new SegmentUnit(classes, files));
classes = new ArrayList();
files = new ArrayList();
}
@@ -149,7 +149,7 @@
jarFile.getInputStream(jarEntry)), classes, files);
if (!added) { // not added because segment has reached maximum
// size
- new Segment().pack(classes, files, outputStream, options);
+ segmentUnitList.add(new SegmentUnit(classes, files));
classes = new ArrayList();
files = new ArrayList();
currentSegmentSize = 0;
@@ -158,41 +158,58 @@
currentSegmentSize = 0; // ignore the size of the first entry for compatibility with the RI
} else if (segmentLimit == 0 && estimateSize(jarEntry) > 0) {
// create a new segment for each class unless size = 0
- new Segment().pack(classes, files, outputStream, options);
+ segmentUnitList.add(new SegmentUnit(classes, files));
classes = new ArrayList();
files = new ArrayList();
}
}
}
if(classes.size() > 0 || files.size() > 0) {
- new Segment().pack(classes, files, outputStream, options);
+ segmentUnitList.add(new SegmentUnit(classes, files));
+ }
+
+ int size = segmentUnitList.size();
+ int classFileAmount = 0;
+ int fileAmount = 0;
+ int totalByteAmount = 0;
+ int totalPackedByteAmount = 0;
+ SegmentUnit segmentUnit = null;
+ for (int index = 0; index < size; index++) {
+ segmentUnit = (SegmentUnit) segmentUnitList.get(index);
+ classFileAmount += segmentUnit.classList.size();
+ fileAmount += segmentUnit.fileList.size();
+ new Segment().pack(segmentUnit, outputStream, options);
+ totalByteAmount += segmentUnit.getByteAmount();
+ totalPackedByteAmount += segmentUnit.getPackedByteAmount();
}
+ PackingUtils.log("Total: Packed " + fileAmount + " files including "
+ + classFileAmount + " classes of " + totalByteAmount
+ + " input bytes into " + totalPackedByteAmount + " bytes");
+
outputStream.close();
}
}
private void doZeroEffortPack() throws IOException, Pack200Exception {
+ PackingUtils.log("Start to perform a zero-effort packing");
JarOutputStream jarOutputStream = new JarOutputStream(outputStream);
if(inputStream != null) {
- JarInputStream jarInputStream;
- if(!(inputStream instanceof JarInputStream)) {
- jarInputStream = new JarInputStream(inputStream);
- } else {
- jarInputStream = inputStream;
- }
- Manifest manifest = jarInputStream.getManifest();
+ Manifest manifest = inputStream.getManifest();
if (manifest != null) {
jarOutputStream.putNextEntry(new JarEntry("META-INF/"));
jarOutputStream.closeEntry();
+ PackingUtils.log("Packed \"META-INF\" folder");
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
manifest.write(baos);
jarOutputStream.putNextEntry(new JarEntry("META-INF/MANIFEST.MF"));
jarOutputStream.write(baos.toByteArray());
jarOutputStream.closeEntry();
+ PackingUtils.log("Packed META-INF/MANIFEST.MF");
}
- BufferedInputStream buff = new BufferedInputStream(jarInputStream);
+ BufferedInputStream buff = new BufferedInputStream(inputStream);
JarEntry jarEntry;
- while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
+ while ((jarEntry = inputStream.getNextJarEntry()) != null) {
jarOutputStream.putNextEntry(jarEntry);
byte[] bytes = new byte[(int) jarEntry.getSize()];
int bytesRead = buff.read(bytes);
@@ -201,6 +218,7 @@
}
jarOutputStream.write(bytes, 0, bytesRead);
jarOutputStream.closeEntry();
+ PackingUtils.log("Packed " + jarEntry.getName());
}
jarOutputStream.close();
} else {
@@ -217,6 +235,7 @@
bytesRead = inStream.read(bytes);
}
jarOutputStream.closeEntry();
+ PackingUtils.log("Packed " + jarEntry.getName());
}
jarOutputStream.close();
}
@@ -273,6 +292,63 @@
}
}
+ static class SegmentUnit {
+
+ private List classList;
+
+ private List fileList;
+
+ private int byteAmount = 0;
+
+ private int packedByteAmount = 0;
+
+ public SegmentUnit(List classes, List files) {
+ classList = classes;
+ fileList = files;
+
+ // Calculate the amount of bytes in classes and files before packing
+ Pack200ClassReader classReader;
+ for (Iterator iterator = classList.iterator(); iterator.hasNext();) {
+ classReader = (Pack200ClassReader) iterator.next();
+ byteAmount += classReader.b.length;
+ }
+
+ File file;
+ for (Iterator iterator = fileList.iterator(); iterator.hasNext();) {
+ file = (File) iterator.next();
+ byteAmount += file.contents.length;
+ }
+ }
+
+ public List getClassList() {
+ return classList;
+ }
+
+ public int classListSize() {
+ return classList.size();
+ }
+
+ public int fileListSize() {
+ return fileList.size();
+ }
+
+ public List getFileList() {
+ return fileList;
+ }
+
+ public int getByteAmount() {
+ return byteAmount;
+ }
+
+ public int getPackedByteAmount() {
+ return packedByteAmount;
+ }
+
+ public void addPackedByteAmount(int amount) {
+ packedByteAmount += amount;
+ }
+ }
+
static class File {
private final String name;
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java?rev=790097&r1=790096&r2=790097&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java Wed Jul 1 10:13:29 2009
@@ -122,6 +122,7 @@
}
public void pack(OutputStream out) throws IOException, Pack200Exception {
+ PackingUtils.log("Writing attribute definition bands...");
int[] attributeDefinitionHeader = new int[attributeDefinitions.size()];
int[] attributeDefinitionName = new int[attributeDefinitions.size()];
int[] attributeDefinitionLayout = new int[attributeDefinitions.size()];
@@ -134,12 +135,26 @@
attributeDefinitionLayout[i] = def.layout.getIndex();
}
- out.write(encodeBandInt("attributeDefinitionHeader",
- attributeDefinitionHeader, Codec.BYTE1));
- out.write(encodeBandInt("attributeDefinitionName",
- attributeDefinitionName, Codec.UNSIGNED5));
- out.write(encodeBandInt("attributeDefinitionLayout",
- attributeDefinitionLayout, Codec.UNSIGNED5));
+ byte[] encodedBand = encodeBandInt("attributeDefinitionHeader",
+ attributeDefinitionHeader, Codec.BYTE1);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from attributeDefinitionHeader["
+ + attributeDefinitionHeader.length + "]");
+
+ encodedBand = encodeBandInt("attributeDefinitionName",
+ attributeDefinitionName, Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from attributeDefinitionName["
+ + attributeDefinitionName.length + "]");
+
+ encodedBand = encodeBandInt("attributeDefinitionLayout",
+ attributeDefinitionLayout, Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from attributeDefinitionLayout["
+ + attributeDefinitionLayout.length + "]");
}
private void addSyntheticDefinitions() {
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java?rev=790097&r1=790096&r2=790097&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java Wed Jul 1 10:13:29 2009
@@ -99,51 +99,138 @@
}
public void pack(OutputStream out) throws IOException, Pack200Exception {
- out.write(encodeBandInt("bcCodes", bcCodes.toArray(), Codec.BYTE1));
- out.write(encodeBandInt("bcCaseCount", bcCaseCount.toArray(),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("bcCaseValue", bcCaseValue.toArray(),
- Codec.DELTA5));
- out.write(encodeBandInt("bcByte", bcByte.toArray(), Codec.BYTE1));
- out.write(encodeBandInt("bcShort", bcShort.toArray(), Codec.DELTA5));
- out.write(encodeBandInt("bcLocal", bcLocal.toArray(),
- Codec.UNSIGNED5));
- out
- .write(encodeBandInt("bcLabel", integerListToArray(bcLabel),
- Codec.BRANCH5));
- out.write(encodeBandInt("bcIntref", cpEntryListToArray(bcIntref),
- Codec.DELTA5));
- out.write(encodeBandInt("bcFloatRef", cpEntryListToArray(bcFloatRef),
- Codec.DELTA5));
- out.write(encodeBandInt("bcLongRef", cpEntryListToArray(bcLongRef),
- Codec.DELTA5));
- out.write(encodeBandInt("bcDoubleRef", cpEntryListToArray(bcDoubleRef),
- Codec.DELTA5));
- out.write(encodeBandInt("bcStringRef", cpEntryListToArray(bcStringRef),
- Codec.DELTA5));
- out.write(encodeBandInt("bcClassRef",
- cpEntryOrNullListToArray(bcClassRef), Codec.UNSIGNED5));
- out.write(encodeBandInt("bcFieldRef", cpEntryListToArray(bcFieldRef),
- Codec.DELTA5));
- out.write(encodeBandInt("bcMethodRef", cpEntryListToArray(bcMethodRef),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("bcIMethodRef",
- cpEntryListToArray(bcIMethodRef), Codec.DELTA5));
- out.write(encodeBandInt("bcThisField", integerListToArray(bcThisField),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("bcSuperField", integerListToArray(bcSuperField),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("bcThisMethod", integerListToArray(bcThisMethod),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("bcSuperMethod",
- integerListToArray(bcSuperMethod), Codec.UNSIGNED5));
- out.write(encodeBandInt("bcInitRef", integerListToArray(bcInitRef),
- Codec.UNSIGNED5));
- // out.write(encodeBandInt(cpEntryListToArray(bcEscRef),
+ PackingUtils.log("Writing byte code bands...");
+ byte[] encodedBand = encodeBandInt("bcCodes", bcCodes.toArray(),
+ Codec.BYTE1);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from bcCodes["
+ + bcCodes.size() + "]");
+
+ encodedBand = encodeBandInt("bcCaseCount", bcCaseCount.toArray(),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcCaseCount[" + bcCaseCount.size() + "]");
+
+ encodedBand = encodeBandInt("bcCaseValue", bcCaseValue.toArray(),
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcCaseValue[" + bcCaseValue.size() + "]");
+
+ encodedBand = encodeBandInt("bcByte", bcByte.toArray(), Codec.BYTE1);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from bcByte["
+ + bcByte.size() + "]");
+
+ encodedBand = encodeBandInt("bcShort", bcShort.toArray(), Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from bcShort["
+ + bcShort.size() + "]");
+
+ encodedBand = encodeBandInt("bcLocal", bcLocal.toArray(),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from bcLocal["
+ + bcLocal.size() + "]");
+
+ encodedBand = encodeBandInt("bcLabel", integerListToArray(bcLabel),
+ Codec.BRANCH5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from bcLabel["
+ + bcLabel.size() + "]");
+
+ encodedBand = encodeBandInt("bcIntref", cpEntryListToArray(bcIntref),
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcIntref[" + bcIntref.size() + "]");
+
+ encodedBand = encodeBandInt("bcFloatRef",
+ cpEntryListToArray(bcFloatRef), Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcFloatRef[" + bcFloatRef.size() + "]");
+
+ encodedBand = encodeBandInt("bcLongRef", cpEntryListToArray(bcLongRef),
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcLongRef[" + bcLongRef.size() + "]");
+
+ encodedBand = encodeBandInt("bcDoubleRef",
+ cpEntryListToArray(bcDoubleRef), Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcDoubleRef[" + bcDoubleRef.size() + "]");
+
+ encodedBand = encodeBandInt("bcStringRef",
+ cpEntryListToArray(bcStringRef), Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcStringRef[" + bcStringRef.size() + "]");
+
+ encodedBand = encodeBandInt("bcClassRef",
+ cpEntryOrNullListToArray(bcClassRef), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcClassRef[" + bcClassRef.size() + "]");
+
+ encodedBand = encodeBandInt("bcFieldRef",
+ cpEntryListToArray(bcFieldRef), Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcFieldRef[" + bcFieldRef.size() + "]");
+
+ encodedBand = encodeBandInt("bcMethodRef",
+ cpEntryListToArray(bcMethodRef), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcMethodRef[" + bcMethodRef.size() + "]");
+
+ encodedBand = encodeBandInt("bcIMethodRef",
+ cpEntryListToArray(bcIMethodRef), Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcIMethodRef[" + bcIMethodRef.size() + "]");
+
+ encodedBand = encodeBandInt("bcThisField",
+ integerListToArray(bcThisField), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcThisField[" + bcThisField.size() + "]");
+
+ encodedBand = encodeBandInt("bcSuperField",
+ integerListToArray(bcSuperField), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcSuperField[" + bcSuperField.size() + "]");
+
+ encodedBand = encodeBandInt("bcThisMethod",
+ integerListToArray(bcThisMethod), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcThisMethod[" + bcThisMethod.size() + "]");
+
+ encodedBand = encodeBandInt("bcSuperMethod",
+ integerListToArray(bcSuperMethod), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcSuperMethod[" + bcSuperMethod.size() + "]");
+
+ encodedBand = encodeBandInt("bcInitRef", integerListToArray(bcInitRef),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from bcInitRef[" + bcInitRef.size() + "]");
+
+ // out.write(encodeBandInt(cpEntryintegerListToArray(bcEscRef),
+ // Codec.UNSIGNED5));
+ // out.write(encodeBandInt(integerListToArray(bcEscRefSize),
+ // Codec.UNSIGNED5));
+ // out.write(encodeBandInt(integerListToArray(bcEscSize),
// Codec.UNSIGNED5));
- // out.write(encodeBandInt(listToArray(bcEscRefSize), Codec.UNSIGNED5));
- // out.write(encodeBandInt(listToArray(bcEscSize), Codec.UNSIGNED5));
- // out.write(encodeBandInt(listToArray(bcEscByte), Codec.BYTE1));
+ // out.write(encodeBandInt(integerListToArray(bcEscByte), Codec.BYTE1));
}
private List getIndexInClass(List cPMethodOrFieldList) {
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java?rev=790097&r1=790096&r2=790097&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java Wed Jul 1 10:13:29 2009
@@ -463,10 +463,26 @@
}
public void pack(OutputStream out) throws IOException, Pack200Exception {
- out.write(encodeBandInt("class_this", getInts(class_this), Codec.DELTA5));
- out.write(encodeBandInt("class_super", getInts(class_super), Codec.DELTA5));
- out.write(encodeBandInt("class_interface_count", class_interface_count,
- Codec.DELTA5));
+ PackingUtils.log("Writing class bands...");
+
+ byte[] encodedBand = encodeBandInt("class_this", getInts(class_this),
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_this[" + class_this.length + "]");
+
+ encodedBand = encodeBandInt("class_super", getInts(class_super),
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_super[" + class_super.length + "]");
+
+ encodedBand = encodeBandInt("class_interface_count",
+ class_interface_count, Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_interface_count["
+ + class_interface_count.length + "]");
int totalInterfaces = sum(class_interface_count);
int[] classInterface = new int[totalInterfaces];
@@ -480,12 +496,26 @@
}
}
}
- out.write(encodeBandInt("class_interface", classInterface,
- Codec.DELTA5));
- out.write(encodeBandInt("class_field_count", class_field_count,
- Codec.DELTA5));
- out.write(encodeBandInt("class_method_count", class_method_count,
- Codec.DELTA5));
+
+ encodedBand = encodeBandInt("class_interface", classInterface,
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_interface[" + classInterface.length + "]");
+
+ encodedBand = encodeBandInt("class_field_count", class_field_count,
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_field_count[" + class_field_count.length
+ + "]");
+
+ encodedBand = encodeBandInt("class_method_count", class_method_count,
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_method_count[" + class_method_count.length
+ + "]");
int totalFields = sum(class_field_count);
int[] fieldDescr = new int[totalFields];
@@ -497,7 +527,12 @@
k++;
}
}
- out.write(encodeBandInt("field_descr", fieldDescr, Codec.DELTA5));
+
+ encodedBand = encodeBandInt("field_descr", fieldDescr, Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from field_descr[" + fieldDescr.length + "]");
+
writeFieldAttributeBands(out);
int totalMethods = sum(class_method_count);
@@ -510,7 +545,11 @@
k++;
}
}
- out.write(encodeBandInt("method_descr", methodDescr, Codec.MDELTA5));
+
+ encodedBand = encodeBandInt("method_descr", methodDescr, Codec.MDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from method_descr[" + methodDescr.length + "]");
writeMethodAttributeBands(out);
writeClassAttributeBands(out);
@@ -527,18 +566,39 @@
private void writeFieldAttributeBands(OutputStream out) throws IOException,
Pack200Exception {
- out.write(encodeFlags("field_flags", field_flags, Codec.UNSIGNED5,
- Codec.UNSIGNED5, segmentHeader.have_field_flags_hi()));
-// *field_attr_count :UNSIGNED5 [COUNT(1<<16,...)]
-// *field_attr_indexes :UNSIGNED5 [SUM(*field_attr_count)]
- out.write(encodeBandInt("field_attr_calls", field_attr_calls, Codec.UNSIGNED5));
- out.write(encodeBandInt("fieldConstantValueKQ",
- cpEntryListToArray(fieldConstantValueKQ), Codec.UNSIGNED5));
- out.write(encodeBandInt("fieldSignature",
- cpEntryListToArray(fieldSignature), Codec.UNSIGNED5));
+ byte[] encodedBand = encodeFlags("field_flags", field_flags,
+ Codec.UNSIGNED5, Codec.UNSIGNED5, segmentHeader
+ .have_field_flags_hi());
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from field_flags[" + field_flags.length + "]");
+
+ // *field_attr_count :UNSIGNED5 [COUNT(1<<16,...)]
+ // *field_attr_indexes :UNSIGNED5 [SUM(*field_attr_count)]
+ encodedBand = encodeBandInt("field_attr_calls", field_attr_calls,
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from field_attr_calls[" + field_attr_calls.length
+ + "]");
+
+ encodedBand = encodeBandInt("fieldConstantValueKQ",
+ cpEntryListToArray(fieldConstantValueKQ), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from fieldConstantValueKQ["
+ + fieldConstantValueKQ.size() + "]");
+
+ encodedBand = encodeBandInt("fieldSignature",
+ cpEntryListToArray(fieldSignature), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from fieldSignature[" + fieldSignature.size() + "]");
+
field_RVA_bands.pack(out);
field_RIA_bands.pack(out);
- for (Iterator iterator = fieldAttributeBands.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = fieldAttributeBands.iterator(); iterator
+ .hasNext();) {
NewAttributeBands bands = (NewAttributeBands) iterator.next();
bands.pack(out);
}
@@ -546,23 +606,51 @@
private void writeMethodAttributeBands(OutputStream out)
throws IOException, Pack200Exception {
- out.write(encodeFlags("method_flags", method_flags, Codec.UNSIGNED5,
- Codec.UNSIGNED5, segmentHeader.have_method_flags_hi()));
-// *method_attr_count :UNSIGNED5 [COUNT(1<<16,...)]
-// *method_attr_indexes :UNSIGNED5 [SUM(*method_attr_count)]
- out.write(encodeBandInt("method_attr_calls", method_attr_calls, Codec.UNSIGNED5));
- out.write(encodeBandInt("methodExceptionNumber",
- methodExceptionNumber.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt("methodExceptionClasses",
- cpEntryListToArray(methodExceptionClasses), Codec.UNSIGNED5));
- out.write(encodeBandInt("methodSignature",
- cpEntryListToArray(methodSignature), Codec.UNSIGNED5));
+ byte[] encodedBand = encodeFlags("method_flags", method_flags,
+ Codec.UNSIGNED5, Codec.UNSIGNED5, segmentHeader
+ .have_method_flags_hi());
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from method_flags[" + method_flags.length + "]");
+
+ // *method_attr_count :UNSIGNED5 [COUNT(1<<16,...)]
+ // *method_attr_indexes :UNSIGNED5 [SUM(*method_attr_count)]
+ encodedBand = encodeBandInt("method_attr_calls", method_attr_calls,
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from method_attr_calls[" + method_attr_calls.length
+ + "]");
+
+ encodedBand = encodeBandInt("methodExceptionNumber",
+ methodExceptionNumber.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from methodExceptionNumber["
+ + methodExceptionNumber.size() + "]");
+
+ encodedBand = encodeBandInt("methodExceptionClasses",
+ cpEntryListToArray(methodExceptionClasses), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from methodExceptionClasses["
+ + methodExceptionClasses.size() + "]");
+
+ encodedBand = encodeBandInt("methodSignature",
+ cpEntryListToArray(methodSignature), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils
+ .log("Wrote " + encodedBand.length
+ + " bytes from methodSignature["
+ + methodSignature.size() + "]");
+
method_RVA_bands.pack(out);
method_RIA_bands.pack(out);
method_RVPA_bands.pack(out);
method_RIPA_bands.pack(out);
method_AD_bands.pack(out);
- for (Iterator iterator = methodAttributeBands.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = methodAttributeBands.iterator(); iterator
+ .hasNext();) {
NewAttributeBands bands = (NewAttributeBands) iterator.next();
bands.pack(out);
}
@@ -570,40 +658,114 @@
private void writeClassAttributeBands(OutputStream out) throws IOException,
Pack200Exception {
- out.write(encodeFlags("class_flags", class_flags, Codec.UNSIGNED5,
- Codec.UNSIGNED5, segmentHeader.have_class_flags_hi()));
+ byte[] encodedBand = encodeFlags("class_flags", class_flags,
+ Codec.UNSIGNED5, Codec.UNSIGNED5, segmentHeader
+ .have_class_flags_hi());
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_flags[" + class_flags.length + "]");
// These bands are not needed, but could be used to reduce the size of
// the archive if there are enough different non-standard attributes
// defined that segmentHeader.have_class_flags_hi() is true. The same
// applies to method_attr_count, field_attr_count, code_attr_count etc.
-// *class_attr_count :UNSIGNED5 [COUNT(1<<16,...)]
-// *class_attr_indexes :UNSIGNED5 [SUM(*class_attr_count)]
+ // *class_attr_count :UNSIGNED5 [COUNT(1<<16,...)]
+ // *class_attr_indexes :UNSIGNED5 [SUM(*class_attr_count)]
+
+ encodedBand = encodeBandInt("class_attr_calls", class_attr_calls,
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_attr_calls[" + class_attr_calls.length
+ + "]");
+
+ encodedBand = encodeBandInt("classSourceFile",
+ cpEntryOrNullListToArray(classSourceFile), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils
+ .log("Wrote " + encodedBand.length
+ + " bytes from classSourceFile["
+ + classSourceFile.size() + "]");
+
+ encodedBand = encodeBandInt("class_enclosing_method_RC",
+ cpEntryListToArray(classEnclosingMethodClass), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_enclosing_method_RC["
+ + classEnclosingMethodClass.size() + "]");
- out.write(encodeBandInt("class_attr_calls", class_attr_calls, Codec.UNSIGNED5));
- out.write(encodeBandInt("classSourceFile",
- cpEntryOrNullListToArray(classSourceFile), Codec.UNSIGNED5));
- out.write(encodeBandInt("class_enclosing_method_RC",
- cpEntryListToArray(classEnclosingMethodClass),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("class_EnclosingMethod_RDN",
+ encodedBand = encodeBandInt("class_EnclosingMethod_RDN",
cpEntryOrNullListToArray(classEnclosingMethodDesc),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("class_Signature_RS",
- cpEntryListToArray(classSignature), Codec.UNSIGNED5));
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_EnclosingMethod_RDN["
+ + classEnclosingMethodDesc.size() + "]");
+
+ encodedBand = encodeBandInt("class_Signature_RS",
+ cpEntryListToArray(classSignature), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_Signature_RS[" + classSignature.size()
+ + "]");
+
class_RVA_bands.pack(out);
class_RIA_bands.pack(out);
- out.write(encodeBandInt("class_InnerClasses_N", class_InnerClasses_N, Codec.UNSIGNED5));
- out.write(encodeBandInt("class_InnerClasses_RC", getInts(class_InnerClasses_RC), Codec.UNSIGNED5));
- out.write(encodeBandInt("class_InnerClasses_F", class_InnerClasses_F, Codec.UNSIGNED5));
- out.write(encodeBandInt("class_InnerClasses_outer_RCN", cpEntryOrNullListToArray(classInnerClassesOuterRCN), Codec.UNSIGNED5));
- out.write(encodeBandInt("class_InnerClasses_name_RUN", cpEntryOrNullListToArray(classInnerClassesNameRUN), Codec.UNSIGNED5));
- out.write(encodeBandInt("classFileVersionMinor",
- classFileVersionMinor.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt("classFileVersionMajor",
- classFileVersionMajor.toArray(), Codec.UNSIGNED5));
- for (Iterator iterator = classAttributeBands.iterator(); iterator.hasNext();) {
+
+ encodedBand = encodeBandInt("class_InnerClasses_N",
+ class_InnerClasses_N, Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_InnerClasses_N["
+ + class_InnerClasses_N.length + "]");
+
+ encodedBand = encodeBandInt("class_InnerClasses_RC",
+ getInts(class_InnerClasses_RC), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_InnerClasses_RC["
+ + class_InnerClasses_RC.length + "]");
+
+ encodedBand = encodeBandInt("class_InnerClasses_F",
+ class_InnerClasses_F, Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_InnerClasses_F["
+ + class_InnerClasses_F.length + "]");
+
+ encodedBand = encodeBandInt("class_InnerClasses_outer_RCN",
+ cpEntryOrNullListToArray(classInnerClassesOuterRCN),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_InnerClasses_outer_RCN["
+ + classInnerClassesOuterRCN.size() + "]");
+
+ encodedBand = encodeBandInt("class_InnerClasses_name_RUN",
+ cpEntryOrNullListToArray(classInnerClassesNameRUN),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from class_InnerClasses_name_RUN["
+ + classInnerClassesNameRUN.size() + "]");
+
+ encodedBand = encodeBandInt("classFileVersionMinor",
+ classFileVersionMinor.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from classFileVersionMinor["
+ + classFileVersionMinor.size() + "]");
+
+ encodedBand = encodeBandInt("classFileVersionMajor",
+ classFileVersionMajor.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from classFileVersionMajor["
+ + classFileVersionMajor.size() + "]");
+
+ for (Iterator iterator = classAttributeBands.iterator(); iterator
+ .hasNext();) {
NewAttributeBands bands = (NewAttributeBands) iterator.next();
bands.pack(out);
}
@@ -619,67 +781,190 @@
private void writeCodeBands(OutputStream out) throws IOException,
Pack200Exception {
- out.write(encodeBandInt("codeHeaders", codeHeaders, Codec.BYTE1));
- out.write(encodeBandInt("codeMaxStack", codeMaxStack.toArray(),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("codeMaxLocals", codeMaxLocals.toArray(),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("codeHandlerCount",
- codeHandlerCount.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt("codeHandlerStartP",
- integerListToArray(codeHandlerStartP), Codec.BCI5));
- out.write(encodeBandInt("codeHandlerEndPO",
- integerListToArray(codeHandlerEndPO), Codec.BRANCH5));
- out.write(encodeBandInt("codeHandlerCatchPO",
- integerListToArray(codeHandlerCatchPO), Codec.BRANCH5));
- out.write(encodeBandInt("codeHandlerClass",
- cpEntryOrNullListToArray(codeHandlerClass), Codec.UNSIGNED5));
+ byte[] encodedBand = encodeBandInt("codeHeaders", codeHeaders,
+ Codec.BYTE1);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeHeaders[" + codeHeaders.length + "]");
+
+ encodedBand = encodeBandInt("codeMaxStack", codeMaxStack.toArray(),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeMaxStack[" + codeMaxStack.size() + "]");
+
+ encodedBand = encodeBandInt("codeMaxLocals", codeMaxLocals.toArray(),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeMaxLocals[" + codeMaxLocals.size() + "]");
+
+ encodedBand = encodeBandInt("codeHandlerCount", codeHandlerCount
+ .toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeHandlerCount[" + codeHandlerCount.size()
+ + "]");
+
+ encodedBand = encodeBandInt("codeHandlerStartP",
+ integerListToArray(codeHandlerStartP), Codec.BCI5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeHandlerStartP[" + codeHandlerStartP.size()
+ + "]");
+
+ encodedBand = encodeBandInt("codeHandlerEndPO",
+ integerListToArray(codeHandlerEndPO), Codec.BRANCH5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeHandlerEndPO[" + codeHandlerEndPO.size()
+ + "]");
+
+ encodedBand = encodeBandInt("codeHandlerCatchPO",
+ integerListToArray(codeHandlerCatchPO), Codec.BRANCH5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeHandlerCatchPO[" + codeHandlerCatchPO.size()
+ + "]");
+
+ encodedBand = encodeBandInt("codeHandlerClass",
+ cpEntryOrNullListToArray(codeHandlerClass), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeHandlerClass[" + codeHandlerClass.size()
+ + "]");
+
writeCodeAttributeBands(out);
}
private void writeCodeAttributeBands(OutputStream out) throws IOException,
Pack200Exception {
- out.write(encodeFlags("codeFlags", longListToArray(codeFlags),
- Codec.UNSIGNED5, Codec.UNSIGNED5, segmentHeader.have_code_flags_hi()));
+ byte[] encodedBand = encodeFlags("codeFlags",
+ longListToArray(codeFlags), Codec.UNSIGNED5, Codec.UNSIGNED5,
+ segmentHeader.have_code_flags_hi());
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from codeFlags[" + codeFlags.size() + "]");
// *code_attr_count :UNSIGNED5 [COUNT(1<<16,...)]
// *code_attr_indexes :UNSIGNED5 [SUM(*code_attr_count)]
- out.write(encodeBandInt("code_attr_calls", code_attr_calls,
- Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LineNumberTable_N",
- codeLineNumberTableN.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LineNumberTable_bci_P",
- integerListToArray(codeLineNumberTableBciP), Codec.BCI5));
- out.write(encodeBandInt("code_LineNumberTable_line",
- codeLineNumberTableLine.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LocalVariableTable_N",
- codeLocalVariableTableN.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LocalVariableTable_bci_P",
- integerListToArray(codeLocalVariableTableBciP), Codec.BCI5));
- out.write(encodeBandInt("code_LocalVariableTable_span_O",
- integerListToArray(codeLocalVariableTableSpanO), Codec.BRANCH5));
- out.write(encodeBandInt("code_LocalVariableTable_name_RU",
+ encodedBand = encodeBandInt("code_attr_calls", code_attr_calls,
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils
+ .log("Wrote " + encodedBand.length
+ + " bytes from code_attr_calls["
+ + code_attr_calls.length + "]");
+
+ encodedBand = encodeBandInt("code_LineNumberTable_N",
+ codeLineNumberTableN.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LineNumberTable_N["
+ + codeLineNumberTableN.size() + "]");
+
+ encodedBand = encodeBandInt("code_LineNumberTable_bci_P",
+ integerListToArray(codeLineNumberTableBciP), Codec.BCI5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LineNumberTable_bci_P["
+ + codeLineNumberTableBciP.size() + "]");
+
+ encodedBand = encodeBandInt("code_LineNumberTable_line",
+ codeLineNumberTableLine.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LineNumberTable_line["
+ + codeLineNumberTableLine.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTable_N",
+ codeLocalVariableTableN.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTable_N["
+ + codeLocalVariableTableN.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTable_bci_P",
+ integerListToArray(codeLocalVariableTableBciP), Codec.BCI5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTable_bci_P["
+ + codeLocalVariableTableBciP.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTable_span_O",
+ integerListToArray(codeLocalVariableTableSpanO), Codec.BRANCH5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTable_span_O["
+ + codeLocalVariableTableSpanO.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTable_name_RU",
cpEntryListToArray(codeLocalVariableTableNameRU),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LocalVariableTable_type_RS",
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTable_name_RU["
+ + codeLocalVariableTableNameRU.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTable_type_RS",
cpEntryListToArray(codeLocalVariableTableTypeRS),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LocalVariableTable_slot",
- codeLocalVariableTableSlot.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LocalVariableTypeTable_N",
- codeLocalVariableTypeTableN.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LocalVariableTypeTable_bci_P",
- integerListToArray(codeLocalVariableTypeTableBciP), Codec.BCI5));
- out.write(encodeBandInt("code_LocalVariableTypeTable_span_O",
- integerListToArray(codeLocalVariableTypeTableSpanO), Codec.BRANCH5));
- out.write(encodeBandInt("code_LocalVariableTypeTable_name_RU",
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTable_type_RS["
+ + codeLocalVariableTableTypeRS.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTable_slot",
+ codeLocalVariableTableSlot.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTable_slot["
+ + codeLocalVariableTableSlot.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTypeTable_N",
+ codeLocalVariableTypeTableN.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTypeTable_N["
+ + codeLocalVariableTypeTableN.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTypeTable_bci_P",
+ integerListToArray(codeLocalVariableTypeTableBciP), Codec.BCI5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTypeTable_bci_P["
+ + codeLocalVariableTypeTableBciP.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTypeTable_span_O",
+ integerListToArray(codeLocalVariableTypeTableSpanO), Codec.BRANCH5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTypeTable_span_O["
+ + codeLocalVariableTypeTableSpanO.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTypeTable_name_RU",
cpEntryListToArray(codeLocalVariableTypeTableNameRU),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LocalVariableTypeTable_type_RS",
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTypeTable_name_RU["
+ + codeLocalVariableTypeTableNameRU.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTypeTable_type_RS",
cpEntryListToArray(codeLocalVariableTypeTableTypeRS),
- Codec.UNSIGNED5));
- out.write(encodeBandInt("code_LocalVariableTypeTable_slot",
- codeLocalVariableTypeTableSlot.toArray(), Codec.UNSIGNED5));
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTypeTable_type_RS["
+ + codeLocalVariableTypeTableTypeRS.size() + "]");
+
+ encodedBand = encodeBandInt("code_LocalVariableTypeTable_slot",
+ codeLocalVariableTypeTableSlot.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from code_LocalVariableTypeTable_slot["
+ + codeLocalVariableTypeTableSlot.size() + "]");
+
for (Iterator iterator = codeAttributeBands.iterator(); iterator.hasNext();) {
NewAttributeBands bands = (NewAttributeBands) iterator.next();
bands.pack(out);
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java?rev=790097&r1=790096&r2=790097&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java Wed Jul 1 10:13:29 2009
@@ -84,6 +84,7 @@
}
public void pack(OutputStream out) throws IOException, Pack200Exception {
+ PackingUtils.log("Writing constant pool bands...");
writeCpUtf8(out);
writeCpInt(out);
writeCpFloat(out);
@@ -100,6 +101,7 @@
private void writeCpUtf8(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_Utf8.size() + " UTF8 entries...");
int[] cpUtf8Prefix = new int[cp_Utf8.size() - 2];
int[] cpUtf8Suffix = new int[cp_Utf8.size() - 1];
List chars = new ArrayList();
@@ -149,14 +151,35 @@
cpUtf8BigChars[i][j] = ((Character) bigChars.remove(0)).charValue();
}
}
- out.write(encodeBandInt("cpUtf8Prefix", cpUtf8Prefix, Codec.DELTA5));
- out.write(encodeBandInt("cpUtf8Suffix", cpUtf8Suffix, Codec.UNSIGNED5));
- out.write(encodeBandInt("cpUtf8Chars", cpUtf8Chars, Codec.CHAR3));
- out.write(encodeBandInt("cpUtf8BigSuffix", cpUtf8BigSuffix,
- Codec.DELTA5));
+
+ byte[] encodedBand = encodeBandInt("cpUtf8Prefix", cpUtf8Prefix, Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpUtf8Prefix[" + cpUtf8Prefix.length + "]");
+
+ encodedBand = encodeBandInt("cpUtf8Suffix", cpUtf8Suffix, Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpUtf8Suffix[" + cpUtf8Suffix.length + "]");
+
+ encodedBand = encodeBandInt("cpUtf8Chars", cpUtf8Chars, Codec.CHAR3);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpUtf8Chars[" + cpUtf8Chars.length + "]");
+
+ encodedBand = encodeBandInt("cpUtf8BigSuffix", cpUtf8BigSuffix,
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpUtf8BigSuffix[" + cpUtf8BigSuffix.length + "]");
+
for (int i = 0; i < cpUtf8BigChars.length; i++) {
- out.write(encodeBandInt("cpUtf8BigChars " + i, cpUtf8BigChars[i],
- Codec.DELTA5));
+ encodedBand = encodeBandInt("cpUtf8BigChars " + i,
+ cpUtf8BigChars[i], Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpUtf8BigChars" + i + "["
+ + cpUtf8BigChars[i].length + "]");
}
}
@@ -168,6 +191,7 @@
private void writeCpInt(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_Int.size() + " Integer entries...");
int[] cpInt = new int[cp_Int.size()];
int i = 0;
for (Iterator iterator = cp_Int.iterator(); iterator.hasNext();) {
@@ -175,11 +199,15 @@
cpInt[i] = integer.getInt();
i++;
}
- out.write(encodeBandInt("cp_Int", cpInt, Codec.UDELTA5));
+ byte[] encodedBand = encodeBandInt("cp_Int", cpInt, Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cp_Int[" + cpInt.length + "]");
}
private void writeCpFloat(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_Float.size() + " Float entries...");
int[] cpFloat = new int[cp_Float.size()];
int i = 0;
for (Iterator iterator = cp_Float.iterator(); iterator.hasNext();) {
@@ -187,11 +215,15 @@
cpFloat[i] = Float.floatToIntBits(fl.getFloat());
i++;
}
- out.write(encodeBandInt("cp_Float", cpFloat, Codec.UDELTA5));
+ byte[] encodedBand = encodeBandInt("cp_Float", cpFloat, Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cp_Float[" + cpFloat.length + "]");
}
private void writeCpLong(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_Long.size() + " Long entries...");
int[] highBits = new int[cp_Long.size()];
int[] loBits = new int[cp_Long.size()];
int i = 0;
@@ -202,12 +234,20 @@
loBits[i] = (int) l;
i++;
}
- out.write(encodeBandInt("cp_Long_hi", highBits, Codec.UDELTA5));
- out.write(encodeBandInt("cp_Long_lo", loBits, Codec.DELTA5));
+ byte[] encodedBand = encodeBandInt("cp_Long_hi", highBits, Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cp_Long_hi[" + highBits.length + "]");
+
+ encodedBand = encodeBandInt("cp_Long_lo", loBits, Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cp_Long_lo[" + loBits.length + "]");
}
private void writeCpDouble(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_Double.size() + " Double entries...");
int[] highBits = new int[cp_Double.size()];
int[] loBits = new int[cp_Double.size()];
int i = 0;
@@ -218,12 +258,20 @@
loBits[i] = (int) l;
i++;
}
- out.write(encodeBandInt("cp_Double_hi", highBits, Codec.UDELTA5));
- out.write(encodeBandInt("cp_Double_lo", loBits, Codec.DELTA5));
+ byte[] encodedBand = encodeBandInt("cp_Double_hi", highBits, Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cp_Double_hi[" + highBits.length + "]");
+
+ encodedBand = encodeBandInt("cp_Double_lo", loBits, Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cp_Double_lo[" + loBits.length + "]");
}
private void writeCpString(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_String.size() + " String entries...");
int[] cpString = new int[cp_String.size()];
int i = 0;
for (Iterator iterator = cp_String.iterator(); iterator.hasNext();) {
@@ -231,11 +279,15 @@
cpString[i] = cpStr.getIndexInCpUtf8();
i++;
}
- out.write(encodeBandInt("cpString", cpString, Codec.UDELTA5));
+ byte[] encodedBand = encodeBandInt("cpString", cpString, Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpString[" + cpString.length + "]");
}
private void writeCpClass(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_Class.size() + " Class entries...");
int[] cpClass = new int[cp_Class.size()];
int i = 0;
for (Iterator iterator = cp_Class.iterator(); iterator.hasNext();) {
@@ -243,11 +295,15 @@
cpClass[i] = cpCl.getIndexInCpUtf8();
i++;
}
- out.write(encodeBandInt("cpClass", cpClass, Codec.UDELTA5));
+ byte[] encodedBand = encodeBandInt("cpClass", cpClass, Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpClass[" + cpClass.length + "]");
}
private void writeCpSignature(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_Signature.size() + " Signature entries...");
int[] cpSignatureForm = new int[cp_Signature.size()];
List classes = new ArrayList();
int i = 0;
@@ -261,14 +317,24 @@
for (int j = 0; j < cpSignatureClasses.length; j++) {
cpSignatureClasses[j] = ((CPClass) classes.get(j)).getIndex();
}
- out.write(encodeBandInt("cpSignatureForm", cpSignatureForm,
- Codec.DELTA5));
- out.write(encodeBandInt("cpSignatureClasses", cpSignatureClasses,
- Codec.UDELTA5));
+
+ byte[] encodedBand = encodeBandInt("cpSignatureForm", cpSignatureForm,
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpSignatureForm[" + cpSignatureForm.length + "]");
+
+ encodedBand = encodeBandInt("cpSignatureClasses", cpSignatureClasses,
+ Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cpSignatureClasses[" + cpSignatureClasses.length + "]");
}
private void writeCpDescr(OutputStream out) throws IOException,
Pack200Exception {
+ PackingUtils.log("Writing " + cp_Descr.size()
+ + " Descriptor entries...");
int[] cpDescrName = new int[cp_Descr.size()];
int[] cpDescrType = new int[cp_Descr.size()];
int i = 0;
@@ -278,12 +344,23 @@
cpDescrType[i] = nameAndType.getTypeIndex();
i++;
}
- out.write(encodeBandInt("cp_Descr_Name", cpDescrName, Codec.DELTA5));
- out.write(encodeBandInt("cp_Descr_Type", cpDescrType, Codec.UDELTA5));
+
+ byte[] encodedBand = encodeBandInt("cp_Descr_Name", cpDescrName,
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cp_Descr_Name[" + cpDescrName.length + "]");
+
+ encodedBand = encodeBandInt("cp_Descr_Type", cpDescrType, Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from cp_Descr_Type[" + cpDescrType.length + "]");
}
private void writeCpMethodOrField(Set cp, OutputStream out, String name)
throws IOException, Pack200Exception {
+ PackingUtils.log("Writing " + cp.size()
+ + " Method and Field entries...");
int[] cp_methodOrField_class = new int[cp.size()];
int[] cp_methodOrField_desc = new int[cp.size()];
int i = 0;
@@ -293,10 +370,17 @@
cp_methodOrField_desc[i] = mOrF.getDescIndex();
i++;
}
- out.write(encodeBandInt(name + "_class",
- cp_methodOrField_class, Codec.DELTA5));
- out.write(encodeBandInt(name + "_desc", cp_methodOrField_desc,
- Codec.UDELTA5));
+ byte[] encodedBand = encodeBandInt(name + "_class",
+ cp_methodOrField_class, Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + name + "_class[" + cp_methodOrField_class.length + "]");
+
+ encodedBand = encodeBandInt(name + "_desc", cp_methodOrField_desc,
+ Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + name + "_desc[" + cp_methodOrField_desc.length + "]");
}
/**
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java?rev=790097&r1=790096&r2=790097&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java Wed Jul 1 10:13:29 2009
@@ -24,6 +24,7 @@
import java.util.Set;
import org.apache.harmony.pack200.Archive.File;
+import org.apache.harmony.pack200.Archive.SegmentUnit;
import org.objectweb.asm.ClassReader;
/**
@@ -41,25 +42,26 @@
private final byte[][] file_bits;
public FileBands(CpBands cpBands, SegmentHeader segmentHeader,
- PackingOptions options, List files, List classes, int effort) {
+ PackingOptions options, SegmentUnit segmentUnit, int effort) {
super(effort, segmentHeader);
- int size = files.size();
+ List fileList = segmentUnit.getFileList();
+ int size = fileList.size();
fileName = new CPUTF8[size];
file_modtime = new int[size];
file_size = new long[size];
file_options = new int[size];
int totalSize = 0;
- file_bits = new byte[files.size()][];
+ file_bits = new byte[size][];
int archiveModtime = segmentHeader.getArchive_modtime();
Set classNames = new HashSet();
- for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = segmentUnit.getClassList().iterator(); iterator.hasNext();) {
ClassReader reader = (ClassReader) iterator.next();
classNames.add(reader.getClassName());
}
CPUTF8 emptyString = cpBands.getCPUtf8("");
- for (int i = 0; i < files.size(); i++) {
- File file = (File)files.get(i);
+ for (int i = 0; i < size; i++) {
+ File file = (File)fileList.get(i);
String name = file.getName();
if(name.endsWith(".class") && !options.isPassFile(name)) {
file_options[i] |= (1 << 1);
@@ -92,17 +94,39 @@
}
public void pack(OutputStream out) throws IOException, Pack200Exception {
- out.write(encodeBandInt("file_name", file_name, Codec.UNSIGNED5));
- out.write(encodeFlags("file_size", file_size, Codec.UNSIGNED5,
- Codec.UNSIGNED5, segmentHeader.have_file_size_hi()));
+ PackingUtils.log("Writing file bands...");
+ byte[] encodedBand = encodeBandInt("file_name", file_name,
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from file_name[" + file_name.length + "]");
+
+ encodedBand = encodeFlags("file_size", file_size, Codec.UNSIGNED5,
+ Codec.UNSIGNED5, segmentHeader.have_file_size_hi());
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from file_size[" + file_size.length + "]");
+
if (segmentHeader.have_file_modtime()) {
- out.write(encodeBandInt("file_modtime", file_modtime, Codec.DELTA5));
+ encodedBand = encodeBandInt("file_modtime", file_modtime,
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from file_modtime[" + file_modtime.length + "]");
}
if (segmentHeader.have_file_options()) {
- out.write(encodeBandInt("file_options", file_options,
- Codec.UNSIGNED5));
+ encodedBand = encodeBandInt("file_options", file_options,
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from file_options[" + file_options.length + "]");
}
- out.write(encodeBandInt("file_bits", flatten(file_bits), Codec.BYTE1));
+
+ encodedBand = encodeBandInt("file_bits", flatten(file_bits),
+ Codec.BYTE1);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from file_bits[" + file_bits.length + "]");
}
private int[] flatten(byte[][] bytes) {
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java?rev=790097&r1=790096&r2=790097&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java Wed Jul 1 10:13:29 2009
@@ -53,6 +53,7 @@
}
public void pack(OutputStream out) throws IOException, Pack200Exception {
+ PackingUtils.log("Writing internal class bands...");
int[] ic_this_class = new int[innerClasses.size()];
int[] ic_flags = new int[innerClasses.size()];
int[] ic_outer_class = new int[bit16Count];
@@ -70,10 +71,27 @@
index2++;
}
}
- out.write(encodeBandInt("ic_this_class", ic_this_class, Codec.UDELTA5));
- out.write(encodeBandInt("ic_flags", ic_flags, Codec.UNSIGNED5));
- out.write(encodeBandInt("ic_outer_class", ic_outer_class, Codec.DELTA5));
- out.write(encodeBandInt("ic_name", ic_name, Codec.DELTA5));
+ byte[] encodedBand = encodeBandInt("ic_this_class", ic_this_class,
+ Codec.UDELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from ic_this_class[" + ic_this_class.length + "]");
+
+ encodedBand = encodeBandInt("ic_flags", ic_flags, Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from ic_flags[" + ic_flags.length + "]");
+
+ encodedBand = encodeBandInt("ic_outer_class", ic_outer_class,
+ Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from ic_outer_class[" + ic_outer_class.length + "]");
+
+ encodedBand = encodeBandInt("ic_name", ic_name, Codec.DELTA5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from ic_name[" + ic_name.length + "]");
}
public void addInnerClass(String name, String outerName, String innerName,
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java?rev=790097&r1=790096&r2=790097&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java Wed Jul 1 10:13:29 2009
@@ -83,6 +83,7 @@
* @see org.apache.harmony.pack200.BandSet#pack(java.io.OutputStream)
*/
public void pack(OutputStream out) throws IOException, Pack200Exception {
+ PackingUtils.log("Writing metadata band group...");
if(hasContent()) {
String contextStr;
if(context == CONTEXT_CLASS) {
@@ -92,25 +93,132 @@
} else {
contextStr = "Method";
}
+ byte[] encodedBand = null;
if(!type.equals("AD")) {
- out.write(encodeBandInt(contextStr + "_" + type + " anno_N", anno_N.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " type_RS", cpEntryListToArray(type_RS), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " pair_N", pair_N.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " name_RU", cpEntryListToArray(name_RU), Codec.UNSIGNED5));
- }
- out.write(encodeBandInt(contextStr + "_" + type + " T", tagListToArray(T), Codec.BYTE1));
- out.write(encodeBandInt(contextStr + "_" + type + " caseI_KI", cpEntryListToArray(caseI_KI), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " caseD_KD", cpEntryListToArray(caseD_KD), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " caseF_KF", cpEntryListToArray(caseF_KF), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " caseJ_KJ", cpEntryListToArray(caseJ_KJ), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " casec_RS", cpEntryListToArray(casec_RS), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " caseet_RS", cpEntryListToArray(caseet_RS), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " caseec_RU", cpEntryListToArray(caseec_RU), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " cases_RU", cpEntryListToArray(cases_RU), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " casearray_N", casearray_N.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " nesttype_RS", cpEntryListToArray(nesttype_RS), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " nestpair_N", nestpair_N.toArray(), Codec.UNSIGNED5));
- out.write(encodeBandInt(contextStr + "_" + type + " nestname_RU", cpEntryListToArray(nestname_RU), Codec.UNSIGNED5));
+ encodedBand = encodeBandInt(
+ contextStr + "_" + type + " anno_N", anno_N.toArray(),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from " + contextStr + "_" + type + " anno_N["
+ + anno_N.size() + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type
+ + " type_RS", cpEntryListToArray(type_RS),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from " + contextStr + "_" + type
+ + " type_RS[" + type_RS.size() + "]");
+
+ encodedBand = encodeBandInt(
+ contextStr + "_" + type + " pair_N", pair_N.toArray(),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from " + contextStr + "_" + type + " pair_N["
+ + pair_N.size() + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type
+ + " name_RU", cpEntryListToArray(name_RU),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length
+ + " bytes from " + contextStr + "_" + type
+ + " name_RU[" + name_RU.size() + "]");
+ }
+ encodedBand = encodeBandInt(contextStr + "_" + type + " T",
+ tagListToArray(T), Codec.BYTE1);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " T[" + T.size() + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type + " caseI_KI",
+ cpEntryListToArray(caseI_KI), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " caseI_KI[" + caseI_KI.size()
+ + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type + " caseD_KD",
+ cpEntryListToArray(caseD_KD), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " caseD_KD[" + caseD_KD.size()
+ + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type + " caseF_KF",
+ cpEntryListToArray(caseF_KF), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " caseF_KF[" + caseF_KF.size()
+ + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type + " caseJ_KJ",
+ cpEntryListToArray(caseJ_KJ), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " caseJ_KJ[" + caseJ_KJ.size()
+ + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type + " casec_RS",
+ cpEntryListToArray(casec_RS), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " casec_RS[" + casec_RS.size()
+ + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type + " caseet_RS",
+ cpEntryListToArray(caseet_RS), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " caseet_RS["
+ + caseet_RS.size() + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type + " caseec_RU",
+ cpEntryListToArray(caseec_RU), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " caseec_RU["
+ + caseec_RU.size() + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type + " cases_RU",
+ cpEntryListToArray(cases_RU), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " cases_RU[" + cases_RU.size()
+ + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type
+ + " casearray_N", casearray_N.toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " casearray_N["
+ + casearray_N.size() + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type
+ + " nesttype_RS", cpEntryListToArray(nesttype_RS),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " nesttype_RS["
+ + nesttype_RS.size() + "]");
+
+ encodedBand = encodeBandInt(
+ contextStr + "_" + type + " nestpair_N", nestpair_N
+ .toArray(), Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " nestpair_N["
+ + nestpair_N.size() + "]");
+
+ encodedBand = encodeBandInt(contextStr + "_" + type
+ + " nestname_RU", cpEntryListToArray(nestname_RU),
+ Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + contextStr + "_" + type + " nestname_RU["
+ + nestname_RU.size() + "]");
}
}
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=790097&r1=790096&r2=790097&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 Wed Jul 1 10:13:29 2009
@@ -425,7 +425,12 @@
}
public void pack(OutputStream out) throws IOException, Pack200Exception {
- out.write(encodeBandInt(tag, integerListToArray(band), defaultCodec));
+ PackingUtils.log("Writing new attribute bands...");
+ byte[] encodedBand = encodeBandInt(tag, integerListToArray(band),
+ defaultCodec);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + tag + "[" + band.size() + "]");
}
public int latestValue() {
@@ -687,7 +692,10 @@
} else {
ints = cpEntryListToArray(band);
}
- out.write(encodeBandInt(tag, ints, Codec.UNSIGNED5));
+ byte[] encodedBand = encodeBandInt(tag, ints, Codec.UNSIGNED5);
+ out.write(encodedBand);
+ PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
+ + tag + "[" + ints.length + "]");
}
public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java?rev=790097&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java Wed Jul 1 10:13:29 2009
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.pack200;
+
+import java.io.IOException;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import java.util.logging.SimpleFormatter;
+
+public class PackingUtils {
+
+ private static PackingLogger packingLogger;
+
+ static {
+ packingLogger = new PackingLogger("org.harmony.apache.pack200", null);
+ LogManager.getLogManager().addLogger(packingLogger);
+ }
+
+ private static class PackingLogger extends Logger {
+
+ private boolean verbose = false;
+
+ protected PackingLogger(String name, String resourceBundleName) {
+ super(name, resourceBundleName);
+ }
+
+ public void log(LogRecord logRecord) {
+ if (verbose) {
+ super.log(logRecord);
+ }
+ }
+
+ public void setVerbose(boolean isVerbose) {
+ verbose = isVerbose;
+ }
+ }
+
+ public static void config(PackingOptions options) throws IOException {
+ String logFileName = options.getLogFile();
+ if (logFileName != null) {
+ FileHandler fileHandler = new FileHandler(logFileName, false);
+ fileHandler.setFormatter(new SimpleFormatter());
+ packingLogger.addHandler(fileHandler);
+ packingLogger.setUseParentHandlers(false);
+ }
+
+ packingLogger.setVerbose(options.isVerbose());
+ }
+
+ public static void log(String message) {
+ packingLogger.log(Level.INFO, message);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java
------------------------------------------------------------------------------
svn:eol-style = native