You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2010/09/14 12:28:22 UTC
svn commit: r996816 [1/2] - in /harmony/enhanced/java/branches/java6: ./
classlib/ classlib/depends/libs/
classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/
classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/
classlib/m...
Author: hindessm
Date: Tue Sep 14 10:28:21 2010
New Revision: 996816
URL: http://svn.apache.org/viewvc?rev=996816&view=rev
Log:
Merge change from /harmony/enhanced/java/trunk@996801:
r996801 | sjanuary | 2010-09-14 10:06:42 +0100 (Tue, 14 Sep 2010) | 1 line
Pack200 - added some tests and fixed resulting bugs
Added:
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PackingOptionsTest.java
- copied unchanged from r996801, harmony/enhanced/java/trunk/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/PackingOptionsTest.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/NewAttributeBandsTest.java
- copied unchanged from r996801, harmony/enhanced/java/trunk/classlib/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/NewAttributeBandsTest.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/annotationsRI.jar
- copied unchanged from r996801, harmony/enhanced/java/trunk/classlib/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/annotationsRI.jar
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/jndiWithUnknownAttributes.jar
- copied unchanged from r996801, harmony/enhanced/java/trunk/classlib/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/jndiWithUnknownAttributes.jar
Modified:
harmony/enhanced/java/branches/java6/ (props changed)
harmony/enhanced/java/branches/java6/classlib/ (props changed)
harmony/enhanced/java/branches/java6/classlib/depends/libs/ (props changed)
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/NewAttributeBandsTest.java
harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
harmony/enhanced/java/branches/java6/drlvm/ (props changed)
harmony/enhanced/java/branches/java6/jdktools/ (props changed)
Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 10:28:21 2010
@@ -1,4 +1,4 @@
/harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-996210,996457,996567,996687,996798
+/harmony/enhanced/java/trunk:929253-996210,996457,996567,996687,996798,996801
/harmony/enhanced/trunk:476395-929252
/incubator/harmony/enhanced/trunk:292550-476394
Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 10:28:21 2010
@@ -1,7 +1,7 @@
/harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
/harmony/enhanced/classlib/trunk/working_classlib:884014-884286
/harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-996210,996457,996567,996687,996798
+/harmony/enhanced/java/trunk/classlib:929253-996210,996457,996567,996687,996798,996801
/harmony/enhanced/trunk/classlib:476395-929252
/harmony/enhanced/trunk/working_classlib:476396-920147
/incubator/harmony/enhanced/trunk/classlib:292550-476394
Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 10:28:21 2010
@@ -1,4 +1,4 @@
/harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-996210,996457,996567,996687,996798
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-996210,996457,996567,996687,996798,996801
/harmony/enhanced/trunk/classlib/depends/libs:476395-929252
/incubator/harmony/enhanced/trunk/classlib/depends/libs:292550-476394
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java Tue Sep 14 10:28:21 2010
@@ -331,26 +331,6 @@ public abstract class BandSet {
}
}
- /**
- * Returns true if the name of the source file can be predicted from the
- * class name
- *
- * @param className
- * the class name
- * @param sourceFileName
- * the source file name
- */
- public boolean isPredictableSourceFileName(String className, String sourceFileName) {
- if (className.indexOf('.') != -1) {
- className = className.substring(className.lastIndexOf('.') + 1);
- }
- if (className.indexOf('$') != -1) {
- className = className.substring(0, className.indexOf('$'));
- }
- className += ".java";
- return className.equals(sourceFileName);
- }
-
// This could be useful if further enhancements are done but is not currently used
//
// private void encodeWithRunCodec(String name, int[] band, int index,
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java Tue Sep 14 10:28:21 2010
@@ -119,6 +119,8 @@ public class ClassBands extends BandSet
private final List tempFieldDesc = new ArrayList();
private final List tempMethodFlags = new ArrayList();
private final List tempMethodDesc = new ArrayList();
+ private TempParamAnnotation tempMethodRVPA;
+ private TempParamAnnotation tempMethodRIPA;
private boolean anySyntheticClasses = false;
private boolean anySyntheticFields = false;
@@ -153,6 +155,10 @@ public class ClassBands extends BandSet
field_flags = new long[numClasses][];
method_descr = new CPNameAndType[numClasses][];
method_flags = new long[numClasses][];
+ for (int i = 0; i < numClasses; i++) {
+ field_flags[i] = new long[0];
+ method_flags[i] = new long[0];
+ }
// minor_versions = new int[numClasses];
major_versions = new int[numClasses];
class_flags = new long[numClasses];
@@ -520,7 +526,7 @@ public class ClassBands extends BandSet
int totalFields = sum(class_field_count);
int[] fieldDescr = new int[totalFields];
k = 0;
- for (int i = 0; i < field_descr.length; i++) {
+ for (int i = 0; i < index; i++) {
for (int j = 0; j < field_descr[i].length; j++) {
CPNameAndType descr = field_descr[i][j];
fieldDescr[k] = descr.getIndex();
@@ -538,7 +544,7 @@ public class ClassBands extends BandSet
int totalMethods = sum(class_method_count);
int[] methodDescr = new int[totalMethods];
k = 0;
- for (int i = 0; i < method_descr.length; i++) {
+ for (int i = 0; i < index; i++) {
for (int j = 0; j < method_descr[i].length; j++) {
CPNameAndType descr = method_descr[i][j];
methodDescr[k] = descr.getIndex();
@@ -774,7 +780,9 @@ public class ClassBands extends BandSet
private int[] getInts(CPClass[] cpClasses) {
int[] ints = new int[cpClasses.length];
for (int i = 0; i < ints.length; i++) {
- ints[i] = cpClasses[i].getIndex();
+ if(cpClasses[i] != null) {
+ ints[i] = cpClasses[i].getIndex();
+ }
}
return ints;
}
@@ -999,6 +1007,24 @@ public class ClassBands extends BandSet
}
public void endOfMethod() {
+ if (tempMethodRVPA != null) {
+ method_RVPA_bands.addParameterAnnotation(tempMethodRVPA.numParams,
+ tempMethodRVPA.annoN, tempMethodRVPA.pairN,
+ tempMethodRVPA.typeRS, tempMethodRVPA.nameRU,
+ tempMethodRVPA.t, tempMethodRVPA.values,
+ tempMethodRVPA.caseArrayN, tempMethodRVPA.nestTypeRS,
+ tempMethodRVPA.nestNameRU, tempMethodRVPA.nestPairN);
+ tempMethodRVPA = null;
+ }
+ if (tempMethodRIPA != null) {
+ method_RIPA_bands.addParameterAnnotation(tempMethodRIPA.numParams,
+ tempMethodRIPA.annoN, tempMethodRIPA.pairN,
+ tempMethodRIPA.typeRS, tempMethodRIPA.nameRU,
+ tempMethodRIPA.t, tempMethodRIPA.values,
+ tempMethodRIPA.caseArrayN, tempMethodRIPA.nestTypeRS,
+ tempMethodRIPA.nestNameRU, tempMethodRIPA.nestPairN);
+ tempMethodRIPA = null;
+ }
if(codeFlags.size() > 0) {
long latestCodeFlag = ((Long)codeFlags.get(codeFlags.size() - 1)).longValue();
int latestLocalVariableTableN = codeLocalVariableTableN.get(codeLocalVariableTableN.size() - 1);
@@ -1327,26 +1353,57 @@ public class ClassBands extends BandSet
public void addParameterAnnotation(int parameter, String desc,
boolean visible, List nameRU, List t, List values, List caseArrayN, List nestTypeRS, List nestNameRU, List nestPairN) {
if(visible) {
- method_RVPA_bands.addParameterAnnotation(parameter, desc, nameRU, t, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
- Long flag = (Long) tempMethodFlags.remove(tempMethodFlags.size() - 1);
- if((flag.intValue() & (1<<23)) != 0) {
- method_RVPA_bands.incrementAnnoN();
- } else {
- method_RVPA_bands.newEntryInAnnoN();
+ if(tempMethodRVPA == null) {
+ tempMethodRVPA = new TempParamAnnotation(numMethodArgs);
+ tempMethodRVPA.addParameterAnnotation(parameter, desc, nameRU, t, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
}
+ Long flag = (Long) tempMethodFlags.remove(tempMethodFlags.size() - 1);
tempMethodFlags.add(new Long(flag.longValue() | (1<<23)));
} else {
- method_RIPA_bands.addParameterAnnotation(parameter, desc, nameRU, t, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
- Long flag = (Long) tempMethodFlags.remove(tempMethodFlags.size() - 1);
- if((flag.longValue() & (1<<24)) != 0) {
- method_RIPA_bands.incrementAnnoN();
- } else {
- method_RIPA_bands.newEntryInAnnoN();
+ if(tempMethodRIPA == null) {
+ tempMethodRIPA = new TempParamAnnotation(numMethodArgs);
+ tempMethodRIPA.addParameterAnnotation(parameter, desc, nameRU, t, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
}
+ Long flag = (Long) tempMethodFlags.remove(tempMethodFlags.size() - 1);
tempMethodFlags.add(new Long(flag.longValue() | (1<<24)));
}
}
+ private static class TempParamAnnotation {
+
+ int numParams;
+ int[] annoN;
+ IntList pairN = new IntList();
+ List typeRS = new ArrayList();
+ List nameRU = new ArrayList();
+ List t = new ArrayList();
+ List values = new ArrayList();
+ List caseArrayN = new ArrayList();
+ List nestTypeRS = new ArrayList();
+ List nestNameRU = new ArrayList();
+ List nestPairN = new ArrayList();
+
+ public TempParamAnnotation (int numParams) {
+ this.numParams = numParams;
+ annoN = new int[numParams];
+ }
+
+ public void addParameterAnnotation(int parameter, String desc,
+ List nameRU, List t, List values, List caseArrayN,
+ List nestTypeRS, List nestNameRU, List nestPairN) {
+ annoN[parameter]++;
+ typeRS.add(desc);
+ pairN.add(nameRU.size());
+ this.nameRU.addAll(nameRU);
+ this.t.addAll(t);
+ this.values.addAll(values);
+ this.caseArrayN.addAll(caseArrayN);
+ this.nestTypeRS.addAll(nestTypeRS);
+ this.nestNameRU.addAll(nestNameRU);
+ this.nestPairN.addAll(nestPairN);
+ }
+ }
+
public void addAnnotation(int context, String desc, boolean visible, List nameRU, List t, List values, List caseArrayN, List nestTypeRS, List nestNameRU, List nestPairN) {
switch (context) {
case MetadataBandGroup.CONTEXT_CLASS:
@@ -1548,6 +1605,12 @@ public class ClassBands extends BandSet
tempFieldFlags.clear();
tempMethodDesc.clear();
tempMethodFlags.clear();
- index--;
+ if(index > 0) {
+ index--;
+ }
+ }
+
+ public int numClassesProcessed() {
+ return index;
}
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java Tue Sep 14 10:28:21 2010
@@ -22,7 +22,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.TimeZone;
import org.apache.harmony.pack200.Archive.PackingFile;
import org.apache.harmony.pack200.Archive.SegmentUnit;
@@ -41,11 +40,16 @@ public class FileBands extends BandSet {
private final long[] file_size;
private final int[] file_options;
private final byte[][] file_bits;
+ private final List fileList;
+ private final PackingOptions options;
+ private final CpBands cpBands;
public FileBands(CpBands cpBands, SegmentHeader segmentHeader,
PackingOptions options, SegmentUnit segmentUnit, int effort) {
super(effort, segmentHeader);
- List fileList = segmentUnit.getFileList();
+ fileList = segmentUnit.getFileList();
+ this.options = options;
+ this.cpBands = cpBands;
int size = fileList.size();
fileName = new CPUTF8[size];
file_modtime = new int[size];
@@ -88,7 +92,7 @@ public class FileBands extends BandSet {
totalSize += file_size[i];
// update modification time
- modtime = (packingFile.getModtime() + TimeZone.getDefault().getRawOffset()) / 1000L;
+ modtime = (packingFile.getModtime()) / 1000L;
file_modtime[i] = (int) (modtime - archiveModtime);
if (isLatest && latestModtime < file_modtime[i]) {
latestModtime = file_modtime[i];
@@ -112,6 +116,14 @@ public class FileBands extends BandSet {
public void finaliseBands() {
file_name = new int[fileName.length];
for (int i = 0; i < file_name.length; i++) {
+ if (fileName[i].equals(cpBands.getCPUtf8(""))) {
+ PackingFile packingFile = (PackingFile) fileList.get(i);
+ String name = packingFile.getName();
+ if (options.isPassFile(name)) {
+ fileName[i] = cpBands.getCPUtf8(name);
+ file_options[i] &= (1 << 1) ^ 0xFFFFFFFF;
+ }
+ }
file_name[i] = fileName[i].getIndex();
}
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/IntList.java Tue Sep 14 10:28:21 2010
@@ -250,4 +250,11 @@ public class IntList {
return result;
}
+ public void addAll(IntList list) {
+ growAtEnd(list.size());
+ for (int i = 0; i < list.size(); i++) {
+ add(list.get(i));
+ }
+ }
+
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java Tue Sep 14 10:28:21 2010
@@ -252,9 +252,69 @@ public class MetadataBandGroup extends B
* @param nestNameRU
* @param nestPairN
*/
- public void addParameterAnnotation(int parameter, String desc, List nameRU, List t, List values, List caseArrayN, List nestTypeRS, List nestNameRU, List nestPairN) {
- param_NB.add(parameter);
- addAnnotation(desc, nameRU, t, values, caseArrayN, nestTypeRS, nestNameRU, nestPairN);
+ public void addParameterAnnotation(int numParams, int[] annoN, IntList pairN, List typeRS, List nameRU, List t, List values, List caseArrayN, List nestTypeRS, List nestNameRU, List nestPairN) {
+ param_NB.add(numParams);
+ for (int i = 0; i < annoN.length; i++) {
+ anno_N.add(annoN[i]);
+ }
+ pair_N.addAll(pairN);
+ for (Iterator iterator = typeRS.iterator(); iterator.hasNext();) {
+ String desc = (String) iterator.next();
+ type_RS.add(cpBands.getCPSignature(desc));
+ }
+ for (Iterator iterator = nameRU.iterator(); iterator.hasNext();) {
+ String name = (String) iterator.next();
+ name_RU.add(cpBands.getCPUtf8(name));
+ }
+ Iterator valuesIterator = values.iterator();
+ for (Iterator iterator = t.iterator(); iterator.hasNext();) {
+ String tag = (String) iterator.next();
+ T.add(tag);
+ if (tag.equals("B") || tag.equals("C") || tag.equals("I")
+ || tag.equals("S") || tag.equals("Z")) {
+ Integer value = (Integer)valuesIterator.next();
+ caseI_KI.add(cpBands.getConstant(value));
+ } else if (tag.equals("D")) {
+ Double value = (Double)valuesIterator.next();
+ caseD_KD.add(cpBands.getConstant(value));
+ } else if (tag.equals("F")) {
+ Float value = (Float)valuesIterator.next();
+ caseF_KF.add(cpBands.getConstant(value));
+ } else if (tag.equals("J")) {
+ Long value = (Long)valuesIterator.next();
+ caseJ_KJ.add(cpBands.getConstant(value));
+ } else if (tag.equals("c")) {
+ String value = (String)valuesIterator.next();
+ casec_RS.add(cpBands.getCPSignature(value));
+ } else if (tag.equals("e")) {
+ String value = (String)valuesIterator.next();
+ String value2 = (String)valuesIterator.next();
+ caseet_RS.add(cpBands.getCPSignature(value));
+ caseec_RU.add(cpBands.getCPUtf8(value2));
+ } else if (tag.equals("s")) {
+ String value = (String)valuesIterator.next();
+ cases_RU.add(cpBands.getCPUtf8(value));
+ }
+ // do nothing here for [ or @ (handled below)
+ }
+ for (Iterator iterator = caseArrayN.iterator(); iterator.hasNext();) {
+ int arraySize = ((Integer)iterator.next()).intValue();
+ casearray_N.add(arraySize);
+ numBackwardsCalls += arraySize;
+ }
+ for (Iterator iterator = nestTypeRS.iterator(); iterator.hasNext();) {
+ String type = (String) iterator.next();
+ nesttype_RS.add(cpBands.getCPSignature(type));
+ }
+ for (Iterator iterator = nestNameRU.iterator(); iterator.hasNext();) {
+ String name = (String) iterator.next();
+ nestname_RU.add(cpBands.getCPUtf8(name));
+ }
+ for (Iterator iterator = nestPairN.iterator(); iterator.hasNext();) {
+ Integer numPairs = (Integer) iterator.next();
+ nestpair_N.add(numPairs.intValue());
+ numBackwardsCalls += numPairs.intValue();
+ }
}
/**
@@ -314,17 +374,17 @@ public class MetadataBandGroup extends B
casearray_N.add(arraySize);
numBackwardsCalls += arraySize;
}
- for (Iterator iterator = nesttype_RS.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = nestTypeRS.iterator(); iterator.hasNext();) {
String type = (String) iterator.next();
nesttype_RS.add(cpBands.getCPSignature(type));
}
- for (Iterator iterator = nestname_RU.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = nestNameRU.iterator(); iterator.hasNext();) {
String name = (String) iterator.next();
nestname_RU.add(cpBands.getCPUtf8(name));
}
for (Iterator iterator = nestPairN.iterator(); iterator.hasNext();) {
Integer numPairs = (Integer) iterator.next();
- nestPairN.add(numPairs);
+ nestpair_N.add(numPairs.intValue());
numBackwardsCalls += numPairs.intValue();
}
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/NewAttributeBands.java Tue Sep 14 10:28:21 2010
@@ -155,7 +155,7 @@ public class NewAttributeBands extends B
}
}
} else { // Backwards call
- for (int k = i; k >= 0; k--) {
+ for (int k = i - 1; k >= 0; k--) {
AttributeLayoutElement el = (AttributeLayoutElement) attributeLayoutElements
.get(k);
if (el instanceof Callable) {
@@ -657,13 +657,10 @@ public class NewAttributeBands extends B
private List band;
- private final int length;
-
private boolean nullsAllowed = false;
public Reference(String tag) {
this.tag = tag;
- length = getLength(tag.charAt(tag.length() - 1));
nullsAllowed = tag.indexOf('N') != -1;
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java Tue Sep 14 10:28:21 2010
@@ -35,7 +35,6 @@ public class PackingOptions {
public static final String KEEP = "keep";
// All options are initially set to their defaults
- private boolean repack = false;
private boolean gzip = true;
private boolean stripDebug = false;
private boolean keepFileOrder = true;
@@ -50,19 +49,10 @@ public class PackingOptions {
private Map methodAttributeActions;
private Map codeAttributeActions;
private boolean verbose = false;
- private boolean quiet = true;
private String logFile;
private Attribute[] unknownAttributeTypes;
- public boolean isRepack() {
- return repack;
- }
-
- public void setRepack(boolean repack) {
- this.repack = repack;
- }
-
public boolean isGzip() {
return gzip;
}
@@ -128,6 +118,14 @@ public class PackingOptions {
}
public void setDeflateHint(String deflateHint) {
+ if (!KEEP.equals(deflateHint)
+ && !"true".equals(deflateHint)
+ && !"false".equals(deflateHint)) {
+ throw new IllegalArgumentException(
+ "Bad argument: -H "
+ + deflateHint
+ + " ? deflate hint should be either true, false or keep (default)");
+ }
this.deflateHint = deflateHint;
}
@@ -245,12 +243,8 @@ public class PackingOptions {
this.verbose = verbose;
}
- public boolean isQuiet() {
- return quiet;
- }
-
public void setQuiet(boolean quiet) {
- this.quiet = quiet;
+ this.verbose = !quiet;
}
public String getLogFile() {
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java Tue Sep 14 10:28:21 2010
@@ -108,7 +108,7 @@ public class Segment implements ClassVis
PackingUtils.log("Setup file bands for the segment");
fileBands = new FileBands(cpBands, segmentHeader, options, segmentUnit, effort);
- processClasses(segmentUnit);
+ processClasses(segmentUnit, nonStandardAttributePrototypes);
cpBands.finaliseBands();
attributeDefinitionBands.finaliseBands();
@@ -124,11 +124,15 @@ public class Segment implements ClassVis
ByteArrayOutputStream bandsOutputStream = new ByteArrayOutputStream();
PackingUtils.log("Packing...");
+ int finalNumberOfClasses = classBands.numClassesProcessed();
+ segmentHeader.setClass_count(finalNumberOfClasses);
cpBands.pack(bandsOutputStream);
- attributeDefinitionBands.pack(bandsOutputStream);
- icBands.pack(bandsOutputStream);
- classBands.pack(bandsOutputStream);
- bcBands.pack(bandsOutputStream);
+ if(finalNumberOfClasses > 0) {
+ attributeDefinitionBands.pack(bandsOutputStream);
+ icBands.pack(bandsOutputStream);
+ classBands.pack(bandsOutputStream);
+ bcBands.pack(bandsOutputStream);
+ }
fileBands.pack(bandsOutputStream);
ByteArrayOutputStream headerOutputStream = new ByteArrayOutputStream();
@@ -147,7 +151,7 @@ public class Segment implements ClassVis
+ segmentUnit.getPackedByteAmount() + " bytes");
}
- private void processClasses(SegmentUnit segmentUnit) throws Pack200Exception {
+ private void processClasses(SegmentUnit segmentUnit, Attribute[] attributes) throws Pack200Exception {
segmentHeader.setClass_count(segmentUnit.classListSize());
for (Iterator iterator = segmentUnit.getClassList().iterator(); iterator.hasNext();) {
Pack200ClassReader classReader = (Pack200ClassReader) iterator
@@ -158,12 +162,14 @@ public class Segment implements ClassVis
flags |= ClassReader.SKIP_DEBUG;
}
try {
- classReader.accept(this, flags);
+ classReader.accept(this, attributes, flags);
} catch (PassException pe) {
// Pass this class through as-is rather than packing it
// TODO: probably need to deal with any inner classes
classBands.removeCurrentClass();
String name = classReader.getFileName();
+ options.addPassFile(name);
+ cpBands.addCPUtf8(name);
boolean found = false;
for (Iterator iterator2 = segmentUnit.getFileList().iterator(); iterator2
.hasNext();) {
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java Tue Sep 14 10:28:21 2010
@@ -234,7 +234,7 @@ public class Archive {
public void setLogFile(String logFileName, boolean append)
throws FileNotFoundException {
- logFile = new FileOutputStream(logFileName, true);
+ logFile = new FileOutputStream(logFileName, append);
}
public void setDeflateHint(boolean deflateHint) {
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java Tue Sep 14 10:28:21 2010
@@ -1085,7 +1085,7 @@ public class ClassBands extends BandSet
+ "_caseF_KF", in, Codec.UNSIGNED5, FCount);
mbg[i].caseJ_KJ = parseCPLongReferences(contextName + "_" + rxa
+ "_caseJ_KJ", in, Codec.UNSIGNED5, JCount);
- mbg[i].casec_RS = parseCPUTF8References(contextName + "_" + rxa
+ mbg[i].casec_RS = parseCPSignatureReferences(contextName + "_" + rxa
+ "_casec_RS", in, Codec.UNSIGNED5, cCount);
mbg[i].caseet_RS = parseReferences(contextName + "_" + rxa
+ "_caseet_RS", in, Codec.UNSIGNED5, eCount, cpBands
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java Tue Sep 14 10:28:21 2010
@@ -88,7 +88,7 @@ public class CpBands extends BandSet {
private Map mapUTF8;
// TODO: Not used
-// private Map mapSignature;
+ private Map mapSignature;
private int intOffset;
private int floatOffset;
@@ -341,6 +341,7 @@ public class CpBands extends BandSet {
Codec.DELTA5, cpSignatureCount);
String[] cpSignatureForm = getReferences(cpSignatureInts, cpUTF8);
cpSignature = new String[cpSignatureCount];
+ mapSignature = new HashMap();
int lCount = 0;
for (int i = 0; i < cpSignatureCount; i++) {
String form = cpSignatureForm[i];
@@ -371,6 +372,7 @@ public class CpBands extends BandSet {
}
}
cpSignature[i] = signature.toString();
+ mapSignature.put(signature.toString(), new Integer(i));
}
// for (int i = 0; i < cpSignatureInts.length; i++) {
// if(cpSignatureInts[i] == -1) {
@@ -547,19 +549,18 @@ public class CpBands extends BandSet {
CPUTF8 cputf8 = (CPUTF8) stringsToCPUTF8.get(string);
if (cputf8 == null) {
Integer index = null;
- if(searchForIndex) {
+ if(searchForIndex) {
index = (Integer)mapUTF8.get(string);
}
if(index != null) {
return cpUTF8Value(index.intValue());
}
- /* TODO: mapSignature is not filled anywhere
if(searchForIndex) {
index = (Integer)mapSignature.get(string);
}
if(index != null) {
return cpSignatureValue(index.intValue());
- }*/
+ }
cputf8 = new CPUTF8(string, -1);
stringsToCPUTF8.put(string, cputf8);
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java Tue Sep 14 10:28:21 2010
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -49,7 +50,7 @@ public class NewAttributeBands extends B
private int backwardsCallCount;
- private List attributeLayoutElements;
+ protected List attributeLayoutElements;
public NewAttributeBands(Segment segment, AttributeLayout attributeLayout)
throws IOException {
@@ -76,14 +77,15 @@ public class NewAttributeBands extends B
*/
public List parseAttributes(InputStream in, int occurrenceCount)
throws IOException, Pack200Exception {
- for(int i = 0; i < attributeLayoutElements.size(); i++) {
- AttributeLayoutElement element = (AttributeLayoutElement) attributeLayoutElements.get(i);
+ for (int i = 0; i < attributeLayoutElements.size(); i++) {
+ AttributeLayoutElement element = (AttributeLayoutElement) attributeLayoutElements
+ .get(i);
element.readBands(in, occurrenceCount);
}
List attributes = new ArrayList(occurrenceCount);
for (int i = 0; i < occurrenceCount; i++) {
- attributes.add(getOneAttribute(i, attributeLayoutElements));
+ attributes.add(getOneAttribute(i, attributeLayoutElements));
}
return attributes;
}
@@ -100,8 +102,9 @@ public class NewAttributeBands extends B
NewAttribute attribute = new NewAttribute(segment.getCpBands()
.cpUTF8Value(attributeLayout.getName()),
attributeLayout.getIndex());
- for(int i = 0; i < elements.size(); i++) {
- AttributeLayoutElement element = (AttributeLayoutElement) elements.get(i);
+ for (int i = 0; i < elements.size(); i++) {
+ AttributeLayoutElement element = (AttributeLayoutElement) elements
+ .get(i);
element.addToAttribute(index, attribute);
}
return attribute;
@@ -135,66 +138,67 @@ public class NewAttributeBands extends B
.get(i);
if (element instanceof Callable) {
Callable callable = (Callable) element;
- if(i == 0) {
- callable.setFirstCallable(true);
+ if (i == 0) {
+ callable.setFirstCallable(true);
}
List body = callable.body; // Look for calls in the body
- for(int iIndex = 0; iIndex < body.size(); iIndex++) {
+ for (int iIndex = 0; iIndex < body.size(); iIndex++) {
LayoutElement layoutElement = (LayoutElement) body
- .get(iIndex);
- // Set the callable for each call
- backwardsCalls += resolveCallsForElement(i, callable,
- layoutElement);
+ .get(iIndex);
+ // Set the callable for each call
+ backwardsCalls += resolveCallsForElement(i, callable,
+ layoutElement);
}
}
}
backwardsCallCount = backwardsCalls;
}
- private int resolveCallsForElement(int i,
- Callable currentCallable, LayoutElement layoutElement) {
- int backwardsCalls = 0;
- if (layoutElement instanceof Call) {
+ private int resolveCallsForElement(int i, Callable currentCallable,
+ LayoutElement layoutElement) {
+ int backwardsCalls = 0;
+ if (layoutElement instanceof Call) {
Call call = (Call) layoutElement;
- int index = call.callableIndex;
- if (index == 0) { // Calls the parent callable
- backwardsCalls++;
- call.setCallable(currentCallable);
- } else if (index > 0) { // Forwards call
- for (int k = i + 1; k < attributeLayoutElements.size(); k++) {
- AttributeLayoutElement el = (AttributeLayoutElement) attributeLayoutElements
- .get(k);
- if (el instanceof Callable) {
- index--;
- if (index == 0) {
- call.setCallable((Callable) el);
- break;
- }
- }
- }
- } else { // Backwards call
- backwardsCalls++;
- for (int k = i; k >= 0; k--) {
- AttributeLayoutElement el = (AttributeLayoutElement) attributeLayoutElements
- .get(k);
- if (el instanceof Callable) {
- index++;
- if (index == 0) {
- call.setCallable((Callable) el);
- break;
- }
- }
- }
- }
- } else if (layoutElement instanceof Replication) {
- List children = ((Replication)layoutElement).layoutElements;
- for (Iterator iterator = children.iterator(); iterator.hasNext();) {
- LayoutElement object = (LayoutElement) iterator.next();
- backwardsCalls += resolveCallsForElement(i, currentCallable, object);
- }
- }
- return backwardsCalls;
- }
+ int index = call.callableIndex;
+ if (index == 0) { // Calls the parent callable
+ backwardsCalls++;
+ call.setCallable(currentCallable);
+ } else if (index > 0) { // Forwards call
+ for (int k = i + 1; k < attributeLayoutElements.size(); k++) {
+ AttributeLayoutElement el = (AttributeLayoutElement) attributeLayoutElements
+ .get(k);
+ if (el instanceof Callable) {
+ index--;
+ if (index == 0) {
+ call.setCallable((Callable) el);
+ break;
+ }
+ }
+ }
+ } else { // Backwards call
+ backwardsCalls++;
+ for (int k = i - 1; k >= 0; k--) {
+ AttributeLayoutElement el = (AttributeLayoutElement) attributeLayoutElements
+ .get(k);
+ if (el instanceof Callable) {
+ index++;
+ if (index == 0) {
+ call.setCallable((Callable) el);
+ break;
+ }
+ }
+ }
+ }
+ } else if (layoutElement instanceof Replication) {
+ List children = ((Replication) layoutElement).layoutElements;
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ LayoutElement object = (LayoutElement) iterator.next();
+ backwardsCalls += resolveCallsForElement(i, currentCallable,
+ object);
+ }
+ }
+ return backwardsCalls;
+ }
private AttributeLayoutElement readNextAttributeElement(StringReader stream)
throws IOException {
@@ -224,10 +228,10 @@ public class NewAttributeBands extends B
case 'H':
case 'I':
case 'V':
- return new Integral(new String(new char[] { (char)nextChar }));
+ return new Integral(new String(new char[] { (char) nextChar }));
case 'S':
case 'F':
- return new Integral(new String(new char[] { (char)nextChar,
+ return new Integral(new String(new char[] { (char) nextChar,
(char) stream.read() }));
case 'P':
stream.mark(1);
@@ -284,7 +288,7 @@ public class NewAttributeBands extends B
// Reference
case 'K':
case 'R':
- String string = "" + (char)nextChar + (char) stream.read();
+ String string = "" + (char) nextChar + (char) stream.read();
char nxt = (char) stream.read();
string += nxt;
if (nxt == 'N') {
@@ -316,9 +320,9 @@ public class NewAttributeBands extends B
List tags = new ArrayList();
Integer nextTag;
do {
- nextTag = readNumber(stream);
- if(nextTag != null) {
- tags.add(nextTag);
+ nextTag = readNumber(stream);
+ if (nextTag != null) {
+ tags.add(nextTag);
stream.read(); // ',' or ')'
}
} while (nextTag != null);
@@ -385,9 +389,10 @@ public class NewAttributeBands extends B
}
}
- private class Integral extends LayoutElement {
+ public class Integral extends LayoutElement {
private final String tag;
+
private int[] band;
public Integral(String tag) {
@@ -447,12 +452,16 @@ public class NewAttributeBands extends B
return band[index];
}
+ public String getTag() {
+ return tag;
+ }
+
}
/**
* A replication is an array of layout elements, with an associated count
*/
- private class Replication extends LayoutElement {
+ public class Replication extends LayoutElement {
private final Integral countElement;
@@ -474,7 +483,7 @@ public class NewAttributeBands extends B
for (int i = 0; i < count; i++) {
arrayCount += countElement.getValue(i);
}
- for(int i = 0; i < layoutElements.size(); i++) {
+ for (int i = 0; i < layoutElements.size(); i++) {
LayoutElement element = (LayoutElement) layoutElements.get(i);
element.readBands(in, arrayCount);
}
@@ -492,18 +501,27 @@ public class NewAttributeBands extends B
long numElements = countElement.getValue(index);
for (int i = offset; i < offset + numElements; i++) {
for (int it = 0; it < layoutElements.size(); it++) {
- LayoutElement element = (LayoutElement) layoutElements.get(it);
+ LayoutElement element = (LayoutElement) layoutElements
+ .get(it);
element.addToAttribute(i, attribute);
}
}
}
+
+ public Integral getCountElement() {
+ return countElement;
+ }
+
+ public List getLayoutElements() {
+ return layoutElements;
+ }
}
/**
* A Union is a type of layout element where the tag value acts as a
* selector for one of the union cases
*/
- private class Union extends LayoutElement {
+ public class Union extends LayoutElement {
private final Integral unionTag;
private final List unionCases;
@@ -535,7 +553,7 @@ public class NewAttributeBands extends B
// Count number of default cases then read the default bands
for (int i = 0; i < values.length; i++) {
boolean found = false;
- for(int it = 0; it < unionCases.size(); it++) {
+ for (int it = 0; it < unionCases.size(); it++) {
UnionCase unionCase = (UnionCase) unionCases.get(it);
if (unionCase.hasTag(values[i])) {
found = true;
@@ -546,8 +564,9 @@ public class NewAttributeBands extends B
}
}
if (defaultCaseBody != null) {
- for(int i = 0; i < defaultCaseBody.size(); i++) {
- LayoutElement element = (LayoutElement) defaultCaseBody.get(i);
+ for (int i = 0; i < defaultCaseBody.size(); i++) {
+ LayoutElement element = (LayoutElement) defaultCaseBody
+ .get(i);
element.readBands(in, defaultCount);
}
}
@@ -559,7 +578,7 @@ public class NewAttributeBands extends B
int[] tagBand = unionTag.band;
long tag = unionTag.getValue(n);
boolean defaultCase = true;
- for(int i = 0; i < unionCases.size(); i++) {
+ for (int i = 0; i < unionCases.size(); i++) {
UnionCase element = (UnionCase) unionCases.get(i);
if (element.hasTag(tag)) {
defaultCase = false;
@@ -576,7 +595,7 @@ public class NewAttributeBands extends B
int defaultOffset = 0;
for (int j = 0; j < n; j++) {
boolean found = false;
- for(int i = 0; i < unionCases.size(); i++) {
+ for (int i = 0; i < unionCases.size(); i++) {
UnionCase element = (UnionCase) unionCases.get(i);
if (element.hasTag(tagBand[j])) {
found = true;
@@ -587,17 +606,30 @@ public class NewAttributeBands extends B
}
}
if (defaultCaseBody != null) {
- for(int i = 0; i < defaultCaseBody.size(); i++) {
- LayoutElement element = (LayoutElement) defaultCaseBody.get(i);
+ for (int i = 0; i < defaultCaseBody.size(); i++) {
+ LayoutElement element = (LayoutElement) defaultCaseBody
+ .get(i);
element.addToAttribute(defaultOffset, attribute);
}
}
}
}
+ public Integral getUnionTag() {
+ return unionTag;
+ }
+
+ public List getUnionCases() {
+ return unionCases;
+ }
+
+ public List getDefaultCaseBody() {
+ return defaultCaseBody;
+ }
+
}
- private class Call extends LayoutElement {
+ public class Call extends LayoutElement {
private final int callableIndex;
private Callable callable;
@@ -628,12 +660,20 @@ public class NewAttributeBands extends B
public void addToAttribute(int n, NewAttribute attribute) {
callable.addNextToAttribute(attribute);
}
+
+ public int getCallableIndex() {
+ return callableIndex;
+ }
+
+ public Callable getCallable() {
+ return callable;
+ }
}
/**
* Constant Pool Reference
*/
- private class Reference extends LayoutElement {
+ public class Reference extends LayoutElement {
private final String tag;
@@ -679,8 +719,8 @@ public class NewAttributeBands extends B
band = parseCPMethodRefReferences(attributeLayout.getName(),
in, Codec.UNSIGNED5, count);
} else if (tag.startsWith("RI")) { // Interface Method Reference
- band = parseCPInterfaceMethodRefReferences(attributeLayout
- .getName(), in, Codec.UNSIGNED5, count);
+ band = parseCPInterfaceMethodRefReferences(
+ attributeLayout.getName(), in, Codec.UNSIGNED5, count);
} else if (tag.startsWith("RU")) { // UTF8 String
band = parseCPUTF8References(attributeLayout.getName(), in,
Codec.UNSIGNED5, count);
@@ -716,15 +756,19 @@ public class NewAttributeBands extends B
}
}
+ public String getTag() {
+ return tag;
+ }
+
}
- private static class Callable implements AttributeLayoutElement {
+ public static class Callable implements AttributeLayoutElement {
private final List body;
private boolean isBackwardsCallable;
- private boolean isFirstCallable;
+ private boolean isFirstCallable;
public Callable(List body) throws IOException {
this.body = body;
@@ -740,7 +784,7 @@ public class NewAttributeBands extends B
* @param attribute
*/
public void addNextToAttribute(NewAttribute attribute) {
- for(int i = 0; i < body.size(); i++) {
+ for (int i = 0; i < body.size(); i++) {
LayoutElement element = (LayoutElement) body.get(i);
element.addToAttribute(index, attribute);
}
@@ -758,26 +802,26 @@ public class NewAttributeBands extends B
public void readBands(InputStream in, int count) throws IOException,
Pack200Exception {
- if(isFirstCallable) {
- count += this.count;
- } else {
- count = this.count;
- }
- for(int i = 0; i < body.size(); i++) {
+ if (isFirstCallable) {
+ count += this.count;
+ } else {
+ count = this.count;
+ }
+ for (int i = 0; i < body.size(); i++) {
LayoutElement element = (LayoutElement) body.get(i);
element.readBands(in, count);
}
}
public void addToAttribute(int n, NewAttribute attribute) {
- if(isFirstCallable) {
- // Ignore n because bands also contain element parts from calls
- for(int i = 0; i < body.size(); i++) {
- LayoutElement element = (LayoutElement) body.get(i);
- element.addToAttribute(index, attribute);
- }
- index++;
- }
+ if (isFirstCallable) {
+ // Ignore n because bands also contain element parts from calls
+ for (int i = 0; i < body.size(); i++) {
+ LayoutElement element = (LayoutElement) body.get(i);
+ element.addToAttribute(index, attribute);
+ }
+ index++;
+ }
}
public boolean isBackwardsCallable() {
@@ -791,15 +835,19 @@ public class NewAttributeBands extends B
this.isBackwardsCallable = true;
}
- public void setFirstCallable(boolean isFirstCallable) {
- this.isFirstCallable = isFirstCallable;
- }
+ public void setFirstCallable(boolean isFirstCallable) {
+ this.isFirstCallable = isFirstCallable;
+ }
+
+ public List getBody() {
+ return body;
+ }
}
/**
* A Union case
*/
- private class UnionCase extends LayoutElement {
+ public class UnionCase extends LayoutElement {
private List body;
@@ -821,7 +869,7 @@ public class NewAttributeBands extends B
public void readBands(InputStream in, int count) throws IOException,
Pack200Exception {
if (body != null) {
- for(int i = 0; i < body.size(); i++) {
+ for (int i = 0; i < body.size(); i++) {
LayoutElement element = (LayoutElement) body.get(i);
element.readBands(in, count);
}
@@ -830,12 +878,16 @@ public class NewAttributeBands extends B
public void addToAttribute(int index, NewAttribute attribute) {
if (body != null) {
- for(int i = 0; i < body.size(); i++) {
+ for (int i = 0; i < body.size(); i++) {
LayoutElement element = (LayoutElement) body.get(i);
element.addToAttribute(index, attribute);
}
}
}
+
+ public List getBody() {
+ return body == null ? Collections.EMPTY_LIST : body;
+ }
}
/**
@@ -876,7 +928,8 @@ public class NewAttributeBands extends B
return Codec.BRANCH5;
} else if (layoutElement.indexOf('P') >= 0) {
return Codec.BCI5;
- } else if (layoutElement.indexOf('S') >= 0 && layoutElement.indexOf("KS") < 0 //$NON-NLS-1$
+ } else if (layoutElement.indexOf('S') >= 0
+ && layoutElement.indexOf("KS") < 0 //$NON-NLS-1$
&& layoutElement.indexOf("RS") < 0) { //$NON-NLS-1$
return Codec.SIGNED5;
} else if (layoutElement.indexOf('B') >= 0) {
@@ -934,15 +987,16 @@ public class NewAttributeBands extends B
length++;
}
stream.reset();
- if(length == 0) {
- return null;
+ if (length == 0) {
+ return null;
}
char[] digits = new char[length];
int read = stream.read(digits);
if (read != digits.length) {
throw new IOException("Error reading from the input stream");
}
- return new Integer(Integer.parseInt((negative ? "-" : "") + new String(digits)));
+ return new Integer(Integer.parseInt((negative ? "-" : "")
+ + new String(digits)));
}
/**
@@ -978,8 +1032,9 @@ public class NewAttributeBands extends B
public void setBackwardsCalls(int[] backwardsCalls) throws IOException {
int index = 0;
parseLayout();
- for(int i = 0; i < attributeLayoutElements.size(); i++) {
- AttributeLayoutElement element = (AttributeLayoutElement) attributeLayoutElements.get(i);
+ for (int i = 0; i < attributeLayoutElements.size(); i++) {
+ AttributeLayoutElement element = (AttributeLayoutElement) attributeLayoutElements
+ .get(i);
if (element instanceof Callable
&& ((Callable) element).isBackwardsCallable()) {
((Callable) element).addCount(backwardsCalls[index]);
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java Tue Sep 14 10:28:21 2010
@@ -506,6 +506,9 @@ public class Segment {
void unpackWrite(JarOutputStream out) throws IOException, Pack200Exception {
writeJar(out);
+ if(logStream != null) {
+ logStream.close();
+ }
}
/**
@@ -592,10 +595,6 @@ public class Segment {
return attrDefinitionBands;
}
- protected BcBands getBcBands() {
- return bcBands;
- }
-
protected ClassBands getClassBands() {
return classBands;
}
@@ -604,10 +603,6 @@ public class Segment {
return cpBands;
}
- protected FileBands getFileBands() {
- return fileBands;
- }
-
protected IcBands getIcBands() {
return icBands;
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/AnnotationsAttribute.java Tue Sep 14 10:28:21 2010
@@ -127,6 +127,9 @@ public abstract class AnnotationsAttribu
} else if (value instanceof CPClass) {
((CPClass) value).resolve(pool);
constant_value_index = pool.indexOf((CPClass) value);
+ } else if (value instanceof CPUTF8) {
+ ((CPUTF8) value).resolve(pool);
+ constant_value_index = pool.indexOf((CPUTF8) value);
} else if (value instanceof CPNameAndType) {
((CPNameAndType) value).resolve(pool);
} else if (value instanceof Annotation) {
@@ -149,9 +152,12 @@ public abstract class AnnotationsAttribu
((Annotation) value).writeBody(dos);
} else if (value instanceof ElementValue[]) {
ElementValue[] nestedValues = (ElementValue[]) value;
+ dos.writeShort(nestedValues.length);
for (int i = 0; i < nestedValues.length; i++) {
nestedValues[i].writeBody(dos);
}
+ } else {
+ throw new Error("");
}
}
@@ -166,6 +172,7 @@ public abstract class AnnotationsAttribu
case 'S':
case 'Z':
case 'c':
+ case 's':
return 3;
case 'e':
return 5;
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java Tue Sep 14 10:28:21 2010
@@ -54,10 +54,14 @@ public class RuntimeVisibleorInvisibleAn
}
protected void writeBody(DataOutputStream dos) throws IOException {
+ int size = dos.size();
dos.writeShort(num_annotations);
for (int i = 0; i < num_annotations; i++) {
annotations[i].writeBody(dos);
}
+ if (dos.size() - size != getLength()) {
+ throw new Error();
+ }
}
public String toString() {
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java Tue Sep 14 10:28:21 2010
@@ -47,6 +47,7 @@ public class ArchiveTest extends TestCas
in = new JarFile(new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/hw.jar").toURI()));
file = File.createTempFile("helloworld", ".pack.gz");
+ file.deleteOnExit();
out = new FileOutputStream(file);
new Archive(in, out, null).pack();
in.close();
@@ -55,6 +56,7 @@ public class ArchiveTest extends TestCas
// now unpack
InputStream in2 = new FileInputStream(file);
File file2 = File.createTempFile("helloworld", ".jar");
+ file2.deleteOnExit();
JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
org.apache.harmony.unpack200.Archive archive = new org.apache.harmony.unpack200.Archive(
in2, out2);
@@ -63,7 +65,6 @@ public class ArchiveTest extends TestCas
in2.close();
JarFile jarFile = new JarFile(file2);
- file2.deleteOnExit();
JarEntry entry = jarFile
.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
assertNotNull(entry);
@@ -97,6 +98,7 @@ public class ArchiveTest extends TestCas
in = new JarFile(new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
file = File.createTempFile("sql", ".pack");
+ file.deleteOnExit();
out = new FileOutputStream(file);
PackingOptions options = new PackingOptions();
options.setGzip(false);
@@ -108,11 +110,11 @@ public class ArchiveTest extends TestCas
// now unpack
InputStream in2 = new FileInputStream(file);
File file2 = File.createTempFile("sqlout", ".jar");
+ file2.deleteOnExit();
JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
org.apache.harmony.unpack200.Archive archive = new org.apache.harmony.unpack200.Archive(in2, out2);
archive.unpack();
JarFile jarFile = new JarFile(file2);
- file2.deleteOnExit();
File compareFile = new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI());
@@ -128,6 +130,7 @@ public class ArchiveTest extends TestCas
"/org/apache/harmony/pack200/tests/largeClassUnpacked.jar")
.toURI()));
file = File.createTempFile("largeClass", ".pack");
+ file.deleteOnExit();
out = new FileOutputStream(file);
PackingOptions options = new PackingOptions();
options.setGzip(false);
@@ -138,11 +141,11 @@ public class ArchiveTest extends TestCas
// now unpack
InputStream in2 = new FileInputStream(file);
File file2 = File.createTempFile("largeClassOut", ".jar");
+ file2.deleteOnExit();
JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
org.apache.harmony.unpack200.Archive archive = new org.apache.harmony.unpack200.Archive(in2, out2);
archive.unpack();
JarFile jarFile = new JarFile(file2);
- file2.deleteOnExit();
File compareFile = new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/largeClassUnpacked.jar").toURI());
@@ -157,6 +160,7 @@ public class ArchiveTest extends TestCas
in = new JarFile(new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/jndi.jar").toURI()));
file = File.createTempFile("jndi", ".pack");
+ file.deleteOnExit();
out = new FileOutputStream(file);
PackingOptions options = new PackingOptions();
options.setGzip(false);
@@ -167,162 +171,24 @@ public class ArchiveTest extends TestCas
// now unpack
InputStream in2 = new FileInputStream(file);
File file2 = File.createTempFile("jndiout", ".jar");
+ file2.deleteOnExit();
JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
org.apache.harmony.unpack200.Archive archive = new org.apache.harmony.unpack200.Archive(in2, out2);
archive.unpack();
JarFile jarFile = new JarFile(file2);
- file2.deleteOnExit();
JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/jndiUnpacked.jar").toURI()));
compareFiles(jarFile, jarFile2);
}
- public void testSegmentLimits() throws IOException, Pack200Exception,
- URISyntaxException {
- in = new JarFile(new File(Archive.class.getResource(
- "/org/apache/harmony/pack200/tests/hw.jar").toURI()));
- file = File.createTempFile("helloworld", ".pack.gz");
- out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
- options.setSegmentLimit(0);
- Archive archive = new Archive(in, out, options);
- archive.pack();
- in.close();
- out.close();
-
- in = new JarFile(new File(Archive.class.getResource(
- "/org/apache/harmony/pack200/tests/hw.jar").toURI()));
- file = File.createTempFile("helloworld", ".pack.gz");
- out = new FileOutputStream(file);
- options = new PackingOptions();
- options.setSegmentLimit(-1);
- archive = new Archive(in, out, options);
- archive.pack();
- in.close();
- out.close();
-
- in = new JarFile(new File(Archive.class.getResource(
- "/org/apache/harmony/pack200/tests/hw.jar").toURI()));
- file = File.createTempFile("helloworld", ".pack.gz");
- out = new FileOutputStream(file);
- options = new PackingOptions();
- options.setSegmentLimit(5000);
- archive = new Archive(in, out, options);
- archive.pack();
- in.close();
- out.close();
- }
-
- public void testStripDebug() throws IOException, Pack200Exception, URISyntaxException {
- in = new JarFile(new File(Archive.class
- .getResource("/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
- file = File.createTempFile("sql", ".pack");
- out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
- options.setGzip(false);
- options.setStripDebug(true);
- Archive archive = new Archive(in, out, options);
- archive.pack();
- in.close();
- out.close();
-
- // now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("sqloutNoDebug", ".jar");
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.harmony.unpack200.Archive u2archive = new org.apache.harmony.unpack200.Archive(in2, out2);
- u2archive.unpack();
-
- File compareFile = new File(Archive.class.getResource(
- "/org/apache/harmony/pack200/tests/sqlUnpackedNoDebug.jar").toURI());
- JarFile jarFile = new JarFile(file2);
- assertTrue(file2.length() < 250000);
- file2.deleteOnExit();
-
- JarFile jarFile2 = new JarFile(compareFile);
-
- compareFiles(jarFile, jarFile2);
- }
-
- public void testPassFiles() throws IOException, URISyntaxException, Pack200Exception {
- // Don't pass any
- in = new JarFile(new File(Archive.class
- .getResource("/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
- File file0 = File.createTempFile("sql", ".pack");
- out = new FileOutputStream(file0);
- PackingOptions options = new PackingOptions();
- options.setGzip(false);
- Archive archive = new Archive(in, out, options);
- archive.pack();
- in.close();
- out.close();
-
- // Pass one file
- in = new JarFile(new File(Archive.class
- .getResource("/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
- file = File.createTempFile("sql", ".pack");
- out = new FileOutputStream(file);
- options = new PackingOptions();
- options.setGzip(false);
- options.addPassFile("bin/test/org/apache/harmony/sql/tests/java/sql/DatabaseMetaDataTest.class");
- assertTrue(options.isPassFile("bin/test/org/apache/harmony/sql/tests/java/sql/DatabaseMetaDataTest.class"));
- archive = new Archive(in, out, options);
- archive.pack();
- in.close();
- out.close();
-
- // Pass a whole directory
- in = new JarFile(new File(Archive.class
- .getResource("/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI()));
- File file2 = File.createTempFile("sql", ".pack");
- out = new FileOutputStream(file2);
- options = new PackingOptions();
- options.setGzip(false);
- options.addPassFile("bin/test/org/apache/harmony/sql/tests/java/sql");
- assertTrue(options.isPassFile("bin/test/org/apache/harmony/sql/tests/java/sql/DatabaseMetaDataTest.class"));
- assertFalse(options.isPassFile("bin/test/org/apache/harmony/sql/tests/java/sqldata/SqlData.class"));
- archive = new Archive(in, out, options);
- archive.pack();
- in.close();
- out.close();
-
- assertTrue("If files are passed then the pack file should be larger", file.length() > file0.length());
- assertTrue("If more files are passed then the pack file should be larger", file2.length() > file.length());
-
- // now unpack
- InputStream in2 = new FileInputStream(file);
- File file3 = File.createTempFile("sql", ".jar");
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file3));
- org.apache.harmony.unpack200.Archive u2archive = new org.apache.harmony.unpack200.Archive(in2, out2);
- u2archive.unpack();
-
- File compareFile = new File(Archive.class.getResource(
- "/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI());
- JarFile jarFile = new JarFile(file3);
- file2.deleteOnExit();
-
- JarFile jarFile2 = new JarFile(compareFile);
- // Check that both jars have the same entries
- compareJarEntries(jarFile, jarFile2);
-
- // now unpack the file with lots of passed files
- InputStream in3 = new FileInputStream(file2);
- File file4 = File.createTempFile("sql", ".jar");
- JarOutputStream out3 = new JarOutputStream(new FileOutputStream(file4));
- u2archive = new org.apache.harmony.unpack200.Archive(in3, out3);
- u2archive.unpack();
- jarFile = new JarFile(file4);
- jarFile2 = new JarFile(compareFile);
- compareJarEntries(jarFile, jarFile2);
- }
-
public void testAnnotations() throws IOException, Pack200Exception,
URISyntaxException {
in = new JarFile(new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/annotationsUnpacked.jar")
.toURI()));
file = File.createTempFile("annotations", ".pack");
+ file.deleteOnExit();
out = new FileOutputStream(file);
PackingOptions options = new PackingOptions();
options.setGzip(false);
@@ -333,12 +199,12 @@ public class ArchiveTest extends TestCas
// now unpack
InputStream in2 = new FileInputStream(file);
File file2 = File.createTempFile("annotationsout", ".jar");
+ file2.deleteOnExit();
JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
org.apache.harmony.unpack200.Archive archive = new org.apache.harmony.unpack200.Archive(
in2, out2);
archive.unpack();
JarFile jarFile = new JarFile(file2);
- file2.deleteOnExit();
JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/annotationsUnpacked.jar").toURI()));
@@ -347,10 +213,11 @@ public class ArchiveTest extends TestCas
public void testAnnotations2() throws IOException, Pack200Exception,
URISyntaxException {
+
in = new JarFile(new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/annotations.jar").toURI()));
file = File.createTempFile("annotations", ".pack");
- file.deleteOnExit();
+// file.deleteOnExit();
out = new FileOutputStream(file);
PackingOptions options = new PackingOptions();
options.setGzip(false);
@@ -361,51 +228,38 @@ public class ArchiveTest extends TestCas
// now unpack
InputStream in2 = new FileInputStream(file);
File file2 = File.createTempFile("annotationsout", ".jar");
- // file2.deleteOnExit();
+// file2.deleteOnExit();
JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
org.apache.harmony.unpack200.Archive archive = new org.apache.harmony.unpack200.Archive(
in2, out2);
archive.unpack();
// TODO: This isn't quite right - to fix
-// JarFile jarFile = new JarFile(file2);
-// JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
-// "/org/apache/harmony/pack200/tests/annotations2unpacked.jar")
-// .toURI()));
-// compareFiles(jarFile, jarFile2);
+ JarFile jarFile = new JarFile(file2);
+ JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
+ "/org/apache/harmony/pack200/tests/annotationsRI.jar")
+ .toURI()));
+ compareFiles(jarFile, jarFile2);
}
- public void testE0() throws Pack200Exception, IOException, URISyntaxException {
- File f1 = new File(Archive.class.getResource(
- "/org/apache/harmony/pack200/tests/jndi.jar").toURI());
- in = new JarFile(f1);
- file = File.createTempFile("jndiE0", ".pack");
- out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
- options.setGzip(false);
- options.setEffort(0);
- Archive archive = new Archive(in, out, options);
- archive.pack();
- in.close();
- out.close();
- compareFiles(new JarFile(f1), new JarFile(file));
+// Test with an archive containing Annotations
+ public void testWithAnnotations2() throws Exception {
+ InputStream i = Archive.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/annotationsRI.pack.gz");
+ file = File.createTempFile("annotations", ".jar");
+ file.deleteOnExit();
+ JarOutputStream jout = new JarOutputStream(new FileOutputStream(file));
+ org.apache.harmony.unpack200.Archive archive = new org.apache.harmony.unpack200.Archive(
+ i, jout);
+ archive.unpack();
+ JarFile jarFile = new JarFile(file);
+ JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
+ "/org/apache/harmony/pack200/tests/annotationsRI.jar")
+ .toURI()));
+ compareFiles(jarFile, jarFile2);
}
-// public void testE0again() throws IOException, Pack200Exception, URISyntaxException {
-// JarInputStream inputStream = new JarInputStream(Archive.class.getResourceAsStream("/org/apache/harmony/pack200/tests/jndi.jar"));
-// file = File.createTempFile("jndiE0", ".pack");
-// out = new FileOutputStream(file);
-// Archive archive = new Archive(inputStream, out, false);
-// archive.setEffort(0);
-// archive.pack();
-// inputStream.close();
-// out.close();
-// in = new JarFile(new File(Archive.class.getResource(
-// "/org/apache/harmony/pack200/tests/jndi.jar").toURI()));
-// compareFiles(in, new JarFile(file));
-// }
-
public void testMultipleJars() throws URISyntaxException, IOException, Pack200Exception {
File folder = new File(Archive.class
.getResource("/org/apache/harmony/pack200/tests/jars").toURI());
@@ -415,6 +269,7 @@ public class ArchiveTest extends TestCas
File inputFile = new File(folder, children[i]);
in = new JarFile(inputFile);
file = File.createTempFile("temp", ".pack.gz");
+ file.deleteOnExit();
out = new FileOutputStream(file);
// System.out.println("packing " + children[i]);
new Archive(in, out, null).pack();