You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2009/07/04 10:38:24 UTC
svn commit: r791082 [5/8] - in /harmony/enhanced/classlib/branches/java6: ./
depends/build/ depends/build/platform/ depends/manifests/asm-3.1/ make/
modules/accessibility/ modules/accessibility/make/
modules/accessibility/src/main/java/javax/accessibil...
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java Sat Jul 4 08:38:13 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",
- listToArray(codeHandlerStartP), Codec.BCI5));
- out.write(encodeBandInt("codeHandlerEndPO",
- listToArray(codeHandlerEndPO), Codec.BRANCH5));
- out.write(encodeBandInt("codeHandlerCatchPO",
- listToArray(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",
- listToArray(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",
- listToArray(codeLocalVariableTableBciP), Codec.BCI5));
- out.write(encodeBandInt("code_LocalVariableTable_span_O",
- listToArray(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",
- listToArray(codeLocalVariableTypeTableBciP), Codec.BCI5));
- out.write(encodeBandInt("code_LocalVariableTypeTable_span_O",
- listToArray(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/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java Sat Jul 4 08:38:13 2009
@@ -125,9 +125,10 @@
throws IOException, Pack200Exception {
// Sanity check to make sure that no-one has changed
// the canonical codecs, which would really cause havoc
- if (canonicalCodec.length != 116)
+ if (canonicalCodec.length != 116) {
throw new Error(
"Canonical encodings have been incorrectly modified");
+ }
if (value < 0) {
throw new IllegalArgumentException(
"Encoding cannot be less than zero");
@@ -137,18 +138,20 @@
return canonicalCodec[value];
} else if (value == 116) {
int code = in.read();
- if (code == -1)
+ if (code == -1) {
throw new EOFException(
"End of buffer read whilst trying to decode codec");
+ }
int d = (code & 0x01);
int s = (code >> 1 & 0x03);
int b = (code >> 3 & 0x07) + 1; // this might result in an invalid
// number, but it's checked in the
// Codec constructor
code = in.read();
- if (code == -1)
+ if (code == -1) {
throw new EOFException(
"End of buffer read whilst trying to decode codec");
+ }
int h = code + 1;
// This handles the special cases for invalid combinations of data.
return new BHSDCodec(b, h, s, d);
@@ -160,9 +163,10 @@
boolean bdef = (offset >> 4 & 1) == 1;
// If both A and B use the default encoding, what's the point of
// having a run of default values followed by default values
- if (adef && bdef)
+ if (adef && bdef) {
throw new Pack200Exception(
"ADef and BDef should never both be true");
+ }
int kb = (kbflag ? in.read() : 3);
int k = (kb + 1) * (int) Math.pow(16, kx);
Codec aCodec, bCodec;
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java Sat Jul 4 08:38:13 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/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java Sat Jul 4 08:38:13 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,27 +42,28 @@
private final byte[][] file_bits;
public FileBands(CpBands cpBands, SegmentHeader segmentHeader,
- 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")) {
+ if(name.endsWith(".class") && !options.isPassFile(name)) {
file_options[i] |= (1 << 1);
if(classNames.contains(name.substring(0, name.length() - 6))) {
fileName[i] = emptyString;
@@ -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/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java Sat Jul 4 08:38:13 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/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java Sat Jul 4 08:38:13 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/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttribute.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttribute.java Sat Jul 4 08:38:13 2009
@@ -69,6 +69,7 @@
break;
case AttributeDefinitionBands.CONTEXT_CODE:
contextCode = true;
+ break;
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java Sat Jul 4 08:38:13 2009
@@ -425,7 +425,12 @@
}
public void pack(OutputStream out) throws IOException, Pack200Exception {
- out.write(encodeBandInt(tag, listToArray(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) {
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java Sat Jul 4 08:38:13 2009
@@ -34,6 +34,7 @@
/**
* @param b
+ * the contents of class file in the format of bytes
*/
public Pack200ClassReader(byte[] b) {
super(b);
@@ -41,6 +42,7 @@
/**
* @param is
+ * the input stream of class file
* @throws IOException
*/
public Pack200ClassReader(InputStream is) throws IOException {
@@ -55,6 +57,15 @@
super(name);
}
+ /**
+ * @param b
+ * @param off
+ * @param len
+ */
+ public Pack200ClassReader(byte[] b, int off, int len) {
+ super(b, off, len);
+ }
+
public int readUnsignedShort(int index) {
// Doing this to check whether last load-constant instruction was ldc (18) or ldc_w (19)
// TODO: Assess whether this impacts on performance
@@ -74,21 +85,12 @@
public String readUTF8(int arg0, char[] arg1) {
String utf8 = super.readUTF8(arg0, arg1);
- if(!anySyntheticAttributes && utf8.equals("Synthetic")) {
+ if(!anySyntheticAttributes && "Synthetic".equals(utf8)) {
anySyntheticAttributes = true;
}
return utf8;
}
- /**
- * @param b
- * @param off
- * @param len
- */
- public Pack200ClassReader(byte[] b, int off, int len) {
- super(b, off, len);
- }
-
public boolean lastConstantHadWideIndex() {
return lastConstantHadWideIndex;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Pack200Exception.java Sat Jul 4 08:38:13 2009
@@ -24,7 +24,7 @@
private static final long serialVersionUID = 5168177401552611803L;
/**
- * Create a new Pack200 exception with the given message and cause
+ * Create a new Pack200 exception with the given message
*
* @param message
* the text message to display
@@ -46,7 +46,7 @@
}
/**
- * Create a new Pack200 exception with the given message and cause
+ * Create a new Pack200 exception with the given cause
*
* @param cause
* the {@link Throwable} that caused this problem
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java Sat Jul 4 08:38:13 2009
@@ -135,8 +135,25 @@
this.modificationTime = modificationTime;
}
- public List getPassFiles() {
- return passFiles;
+ public boolean isPassFile(String passFileName) {
+ if (passFiles != null) {
+ for (Iterator iterator = passFiles.iterator(); iterator.hasNext();) {
+ String pass = (String) iterator.next();
+ if (passFileName.equals(pass)) {
+ return true;
+ } else if (!pass.endsWith(".class")) { // a whole directory is
+ // passed
+ if (!pass.endsWith("/")) {
+ // Make sure we don't get any false positives (e.g.
+ // exclude "org/apache/harmony/pack" should not match
+ // files under "org/apache/harmony/pack200/")
+ pass = pass + "/";
+ }
+ return passFileName.startsWith(pass);
+ }
+ }
+ }
+ return false;
}
/**
@@ -150,6 +167,12 @@
if(passFiles == null) {
passFiles = new ArrayList();
}
+ String fileSeparator = System.getProperty("file.separator");
+ if(fileSeparator.equals("\\")) {
+ // Need to escape backslashes for replaceAll(), which uses regex
+ fileSeparator += "\\";
+ }
+ passFileName.replaceAll(fileSeparator, "/");
passFiles.add(passFileName);
}
@@ -167,9 +190,9 @@
*/
public void setUnknownAttributeAction(String unknownAttributeAction) {
this.unknownAttributeAction = unknownAttributeAction;
- if (!unknownAttributeAction.equals(PASS)
- && !unknownAttributeAction.equals(ERROR)
- && !unknownAttributeAction.equals(STRIP)) {
+ if (!PASS.equals(unknownAttributeAction)
+ && !ERROR.equals(unknownAttributeAction)
+ && !STRIP.equals(unknownAttributeAction)) {
throw new RuntimeException("Incorrect option for -U, "
+ unknownAttributeAction);
}
@@ -243,101 +266,59 @@
this.logFile = logFile;
}
- public Attribute[] getUnknownAttributePrototypes() {
- if(unknownAttributeTypes == null) {
- List prototypes = new ArrayList();
- if(classAttributeActions != null) {
- for (Iterator iterator = classAttributeActions.keySet().iterator(); iterator
- .hasNext();) {
- String name = (String) iterator.next();
- String action = (String) classAttributeActions.get(name);
- if(!(action.equals(ERROR)
- || action.equals(STRIP)
- || action.equals(PASS))) {
- NewAttribute prototype = new NewAttribute(name, action, AttributeDefinitionBands.CONTEXT_CLASS);
- prototypes.add(prototype);
- }
- }
- }
- if(methodAttributeActions != null) {
- for (Iterator iterator = methodAttributeActions.keySet().iterator(); iterator
+ private void addOrUpdateAttributeActions(List prototypes, Map attributeActions,
+ int tag) {
+ if (attributeActions != null) {
+ if (attributeActions.size() > 0) {
+ String name, action;
+ boolean prototypeExists;
+ NewAttribute newAttribute;
+ for (Iterator iteratorI = attributeActions.keySet().iterator(); iteratorI
.hasNext();) {
- String name = (String) iterator.next();
- String action = (String) methodAttributeActions.get(name);
- if(!(action.equals(ERROR)
- || action.equals(STRIP)
- || action.equals(PASS))) {
- boolean prototypeExists = false;
- for (Iterator iterator2 = prototypes.iterator(); iterator2
+ name = (String) iteratorI.next();
+ action = (String) attributeActions.get(name);
+ if (!ERROR.equals(action) && !STRIP.equals(action)
+ && !PASS.equals(action)) {
+ prototypeExists = false;
+ for (Iterator iteratorJ = prototypes.iterator(); iteratorJ
.hasNext();) {
- NewAttribute newAttr = (NewAttribute) iterator2.next();
- if(newAttr.type.equals(name)) {
- newAttr.addContext(AttributeDefinitionBands.CONTEXT_METHOD);
+ newAttribute = (NewAttribute) iteratorJ.next();
+ if (newAttribute.type.equals(name)) {
+ // if the attribute exists, update its context
+ newAttribute.addContext(tag);
prototypeExists = true;
break;
}
- }
- if(!prototypeExists) {
- NewAttribute prototype = new NewAttribute(name, action, AttributeDefinitionBands.CONTEXT_METHOD);
- prototypes.add(prototype);
- }
- }
- }
- }
- if(fieldAttributeActions != null) {
- for (Iterator iterator = fieldAttributeActions.keySet().iterator(); iterator
- .hasNext();) {
- String name = (String) iterator.next();
- String action = (String) fieldAttributeActions.get(name);
- if(!(action.equals(ERROR)
- || action.equals(STRIP)
- || action.equals(PASS))) {
- boolean prototypeExists = false;
- for (Iterator iterator2 = prototypes.iterator(); iterator2
- .hasNext();) {
- NewAttribute newAttr = (NewAttribute) iterator2.next();
- if(newAttr.type.equals(name)) {
- newAttr.addContext(AttributeDefinitionBands.CONTEXT_FIELD);
- prototypeExists = true;
- break;
+ // if no attribute is found, add a new attribute
+ if (!prototypeExists) {
+ newAttribute = new NewAttribute(name, action,
+ tag);
+ prototypes.add(newAttribute);
}
}
- if(!prototypeExists) {
- NewAttribute prototype = new NewAttribute(name, action, AttributeDefinitionBands.CONTEXT_FIELD);
- prototypes.add(prototype);
- }
}
}
}
- if(codeAttributeActions != null) {
- for (Iterator iterator = codeAttributeActions.keySet().iterator(); iterator
- .hasNext();) {
- String name = (String) iterator.next();
- String action = (String) codeAttributeActions.get(name);
- if(!(action.equals(ERROR)
- || action.equals(STRIP)
- || action.equals(PASS))) {
- boolean prototypeExists = false;
- for (Iterator iterator2 = prototypes.iterator(); iterator2
- .hasNext();) {
- NewAttribute newAttr = (NewAttribute) iterator2.next();
- if(newAttr.type.equals(name)) {
- newAttr.addContext(AttributeDefinitionBands.CONTEXT_CODE);
- prototypeExists = true;
- break;
- }
- }
- if(!prototypeExists) {
- NewAttribute prototype = new NewAttribute(name, action, AttributeDefinitionBands.CONTEXT_CODE);
- prototypes.add(prototype);
- }
- }
- }
- }
- unknownAttributeTypes = new Attribute[prototypes.size()];
- for (int i = 0; i < unknownAttributeTypes.length; i++) {
- unknownAttributeTypes[i] = (Attribute) prototypes.get(i);
- }
+ }
+ }
+
+ public Attribute[] getUnknownAttributePrototypes() {
+ if (unknownAttributeTypes == null) {
+ List prototypes = new ArrayList();
+ addOrUpdateAttributeActions(prototypes, classAttributeActions,
+ AttributeDefinitionBands.CONTEXT_CLASS);
+
+ addOrUpdateAttributeActions(prototypes, methodAttributeActions,
+ AttributeDefinitionBands.CONTEXT_METHOD);
+
+ addOrUpdateAttributeActions(prototypes, fieldAttributeActions,
+ AttributeDefinitionBands.CONTEXT_FIELD);
+
+ addOrUpdateAttributeActions(prototypes, codeAttributeActions,
+ AttributeDefinitionBands.CONTEXT_CODE);
+
+ unknownAttributeTypes = (Attribute[]) prototypes
+ .toArray(new Attribute[0]);
}
return unknownAttributeTypes;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java Sat Jul 4 08:38:13 2009
@@ -30,7 +30,7 @@
private final Codec favouredCodec;
private Codec tokenCodec;
- private final Codec unvafouredCodec;
+ private final Codec unfavouredCodec;
private int l;
private int[] favoured;
@@ -38,15 +38,16 @@
Codec unvafouredCodec) {
this.favouredCodec = favouredCodec;
this.tokenCodec = tokenCodec;
- this.unvafouredCodec = unvafouredCodec;
+ this.unfavouredCodec = unvafouredCodec;
}
- public PopulationCodec(Codec favouredCodec, int l, Codec unvafouredCodec) {
- if (l >= 256 || l <= 0)
+ public PopulationCodec(Codec favouredCodec, int l, Codec unfavouredCodec) {
+ if (l >= 256 || l <= 0) {
throw new IllegalArgumentException("L must be between 1..255");
+ }
this.favouredCodec = favouredCodec;
this.l = l;
- this.unvafouredCodec = unvafouredCodec;
+ this.unfavouredCodec = unfavouredCodec;
}
public int decode(InputStream in) throws IOException, Pack200Exception {
@@ -67,20 +68,23 @@
// less
int result[];
// read table of favorites first
- int smallest = Integer.MAX_VALUE;
+ int smallest = Integer.MAX_VALUE, absoluteSmallest;
int last = 0;
- int value = 0;
+ int value = 0, absoluteValue;
int k = -1;
while (true) {
value = favouredCodec.decode(in, last);
- if (k > -1 && (value == smallest || value == last))
+ if (k > -1 && (value == smallest || value == last)) {
break;
+ }
favoured[++k] = value;
- if (Math.abs(smallest) > Math.abs(value)) {
+ absoluteSmallest = Math.abs(smallest);
+ absoluteValue = Math.abs(value);
+ if (absoluteSmallest > absoluteValue) {
smallest = value;
- } else if (Math.abs(smallest) == Math.abs(value)) {
+ } else if (absoluteSmallest == absoluteValue) {
// ensure that -X and +X -> +X
- smallest = Math.abs(smallest);
+ smallest = absoluteSmallest;
}
last = value;
}
@@ -92,15 +96,19 @@
} else {
// if k >= 256, b >= 2
int b = 1;
- while (++b < 5 && tokenCodec == null) {
- BHSDCodec codec = new BHSDCodec(b, 256 - l, 0);
- if (codec.encodes(k))
+ BHSDCodec codec = null;
+ while (++b < 5) {
+ codec = new BHSDCodec(b, 256 - l, 0);
+ if (codec.encodes(k)) {
tokenCodec = codec;
+ break;
+ }
}
- if (tokenCodec == null)
+ if (tokenCodec == null) {
throw new Pack200Exception(
"Cannot calculate token codec from " + k + " and "
+ l);
+ }
}
}
// read favorites
@@ -112,7 +120,7 @@
int index = result[i];
if (index == 0) {
lastBandLength++;
- result[i] = last = unvafouredCodec.decode(in, last);
+ result[i] = last = unfavouredCodec.decode(in, last);
} else {
result[i] = favoured[index - 1];
}
@@ -129,7 +137,7 @@
}
public Codec getUnfavouredCodec() {
- return unvafouredCodec;
+ return unfavouredCodec;
}
public byte[] encode(int value, int last) throws Pack200Exception {
@@ -145,7 +153,7 @@
public byte[] encode(int[] favoured, int[] tokens, int[] unfavoured) throws Pack200Exception {
byte[] favouredEncoded = favouredCodec.encode(favoured);
byte[] tokensEncoded = tokenCodec.encode(tokens);
- byte[] unfavouredEncoded = unvafouredCodec.encode(unfavoured);
+ byte[] unfavouredEncoded = unfavouredCodec.encode(unfavoured);
byte[] band = new byte[favouredEncoded.length + tokensEncoded.length + unfavouredEncoded.length];
return band;
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java Sat Jul 4 08:38:13 2009
@@ -34,11 +34,13 @@
private int last;
public RunCodec(int k, Codec aCodec, Codec bCodec) throws Pack200Exception {
- if (k <= 0)
+ if (k <= 0) {
throw new Pack200Exception(
"Cannot have a RunCodec for a negative number of numbers");
- if (aCodec == null || bCodec == null)
+ }
+ if (aCodec == null || bCodec == null) {
throw new Pack200Exception("Must supply both codecs for a RunCodec");
+ }
this.k = k;
this.aCodec = aCodec;
this.bCodec = bCodec;
@@ -53,22 +55,24 @@
if (--k >= 0) {
int value = aCodec.decode(in, this.last);
this.last = (k == 0 ? 0 : value);
- return normalise(aCodec, value);
+ return normalise(value, aCodec);
} else {
this.last = bCodec.decode(in, this.last);
- return normalise(bCodec, this.last);
+ return normalise(this.last, bCodec);
}
}
- private int normalise(Codec codecUsed, int value) {
- if (codecUsed instanceof BHSDCodec && ((BHSDCodec) codecUsed).isDelta()) {
+ private int normalise(int value, Codec codecUsed) {
+ if (codecUsed instanceof BHSDCodec) {
BHSDCodec bhsd = (BHSDCodec) codecUsed;
- long cardinality = bhsd.cardinality();
- while (value > bhsd.largest()) {
- value -= cardinality;
- }
- while (value < bhsd.smallest()) {
- value += cardinality;
+ if (bhsd.isDelta()) {
+ long cardinality = bhsd.cardinality();
+ while (value > bhsd.largest()) {
+ value -= cardinality;
+ }
+ while (value < bhsd.smallest()) {
+ value += cardinality;
+ }
}
}
return value;
@@ -88,15 +92,17 @@
}
private void normalise(int[] band, Codec codecUsed) {
- if (codecUsed instanceof BHSDCodec && ((BHSDCodec) codecUsed).isDelta()) {
+ if (codecUsed instanceof BHSDCodec) {
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;
+ if (bhsd.isDelta()) {
+ 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) {
@@ -107,21 +113,22 @@
boolean favouredValue = Arrays.binarySearch(favoured, band[i]) > -1;
Codec theCodec = favouredValue ? popCodec.getFavouredCodec()
: popCodec.getUnfavouredCodec();
- if (theCodec instanceof BHSDCodec
- && ((BHSDCodec) theCodec).isDelta()) {
+ if (theCodec instanceof BHSDCodec) {
BHSDCodec bhsd = (BHSDCodec) theCodec;
- long cardinality = bhsd.cardinality();
- while (band[i] > bhsd.largest()) {
- band[i] -= cardinality;
- }
- while (band[i] < bhsd.smallest()) {
- band[i] += cardinality;
+ if (bhsd.isDelta()) {
+ long cardinality = bhsd.cardinality();
+ while (band[i] > bhsd.largest()) {
+ band[i] -= cardinality;
+ }
+ while (band[i] < bhsd.smallest()) {
+ band[i] += cardinality;
+ }
}
}
}
}
}
-
+
public String toString() {
return "RunCodec[k=" + k + ";aCodec=" + aCodec + "bCodec=" + bCodec
+ "]";