You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2008/01/21 12:55:41 UTC
svn commit: r613858 [4/5] - in /harmony/enhanced/classlib/branches/java6:
depends/build/ depends/libs/freebsd.x86/ depends/libs/linux.ia64/
depends/libs/linux.ppc32/ depends/libs/linux.ppc64/
depends/libs/linux.x86.libstdc++6/ depends/libs/linux.x86/ d...
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java Mon Jan 21 03:55:17 2008
@@ -25,7 +25,9 @@
import org.apache.harmony.pack200.bytecode.Attribute;
import org.apache.harmony.pack200.bytecode.BCIRenumberedAttribute;
import org.apache.harmony.pack200.bytecode.ByteCode;
+import org.apache.harmony.pack200.bytecode.CPClass;
import org.apache.harmony.pack200.bytecode.CodeAttribute;
+import org.apache.harmony.pack200.bytecode.ExceptionTableEntry;
import org.apache.harmony.pack200.bytecode.OperandManager;
/**
@@ -365,23 +367,46 @@
int i = 0;
ArrayList orderedCodeAttributes = segment.getClassBands().getOrderedCodeAttributes();
+
+ // Exception table fields
+ int[] handlerCount = segment.getClassBands().getCodeHandlerCount();
+ int[][] handlerStartPCs = segment.getClassBands().getCodeHandlerStartP();
+ int[][] handlerEndPCs = segment.getClassBands().getCodeHandlerEndPO();
+ int[][] handlerCatchPCs = segment.getClassBands().getCodeHandlerCatchPO();
+ String[][] handlerClassTypes = segment.getClassBands().getCodeHandlerClassRCN();
+
for (int c = 0; c < classCount; c++) {
- int numberOfMethods = methodFlags[c].length;
- for (int m = 0; m < numberOfMethods; m++) {
- long methodFlag = methodFlags[c][m];
- if (!abstractModifier.matches(methodFlag)
- && !nativeModifier.matches(methodFlag)) {
- int maxStack = codeMaxStack[i];
- int maxLocal = codeMaxNALocals[i];
- if (!staticModifier.matches(methodFlag))
- maxLocal++; // one for 'this' parameter
- maxLocal += SegmentUtils.countArgs(methodDescr[c][m]);
- operandManager.setCurrentClass(segment.getClassBands().getClassThis()[c]);
- operandManager.setSuperClass(segment.getClassBands().getClassSuper()[c]);
- CodeAttribute codeAttr = new CodeAttribute(maxStack, maxLocal,
- methodByteCodePacked[c][m], segment, operandManager);
- methodAttributes[c][m].add(codeAttr);
- // Should I add all the attributes in here?
+ int numberOfMethods = methodFlags[c].length;
+ for (int m = 0; m < numberOfMethods; m++) {
+ long methodFlag = methodFlags[c][m];
+ if (!abstractModifier.matches(methodFlag)
+ && !nativeModifier.matches(methodFlag)) {
+ int maxStack = codeMaxStack[i];
+ int maxLocal = codeMaxNALocals[i];
+ if (!staticModifier.matches(methodFlag))
+ maxLocal++; // one for 'this' parameter
+ maxLocal += SegmentUtils.countArgs(methodDescr[c][m]);
+ operandManager.setCurrentClass(segment.getClassBands()
+ .getClassThis()[c]);
+ operandManager.setSuperClass(segment.getClassBands()
+ .getClassSuper()[c]);
+ List exceptionTable = new ArrayList();
+ if(handlerCount != null) {
+ for (int j = 0; j < handlerCount[i]; j++) {
+ String handlerClass = handlerClassTypes[i][j];
+ CPClass cpHandlerClass = new CPClass(handlerClass);
+ ExceptionTableEntry entry = new ExceptionTableEntry(
+ handlerStartPCs[i][j], handlerEndPCs[i][j],
+ handlerCatchPCs[i][j], cpHandlerClass);
+ exceptionTable.add(entry);
+ }
+ }
+ CodeAttribute codeAttr = new CodeAttribute(maxStack,
+ maxLocal, methodByteCodePacked[c][m], segment,
+ operandManager, exceptionTable);
+ methodAttributes[c][m].add(codeAttr);
+ codeAttr.renumber(codeAttr.byteCodeOffsets);
+ // Should I add all the attributes in here?
ArrayList currentAttributes = (ArrayList)orderedCodeAttributes.get(i);
for(int index=0;index < currentAttributes.size(); index++) {
Attribute currentAttribute = (Attribute)currentAttributes.get(index);
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=613858&r1=613857&r2=613858&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 Mon Jan 21 03:55:17 2008
@@ -92,6 +92,14 @@
private int[] methodAttrCalls;
+ private int[][] codeHandlerStartP;
+
+ private int[][] codeHandlerEndPO;
+
+ private int[][] codeHandlerCatchPO;
+
+ private String[][] codeHandlerClassRCN;
+
/**
* @param segment
*/
@@ -667,18 +675,29 @@
throw new IllegalStateException("Shouldn't get here either");
}
}
- int sumCodeHandlerCount = 0;
- for (int i = 0; i < codeHandlerCount.length; i++) {
- sumCodeHandlerCount += codeHandlerCount[i];
- }
- int[] codeHandlerStartP = decodeBandInt("code_handler_start_P", in,
- Codec.BCI5, sumCodeHandlerCount);
- int[] codeHandlerEndPO = decodeBandInt("code_handler_end_PO", in,
- Codec.BRANCH5, sumCodeHandlerCount);
- int[] codeHandlerCatchPO = decodeBandInt("code_handler_catch_PO", in,
- Codec.BRANCH5, sumCodeHandlerCount);
- int[] codeHandlerClassRCN = decodeBandInt("code_handler_class_RCN", in,
- Codec.UNSIGNED5, sumCodeHandlerCount);
+ codeHandlerStartP = decodeBandInt("code_handler_start_P", in,
+ Codec.BCI5, codeHandlerCount);
+ codeHandlerEndPO = decodeBandInt("code_handler_end_PO", in,
+ Codec.BRANCH5, codeHandlerCount);
+ codeHandlerCatchPO = decodeBandInt("code_handler_catch_PO", in,
+ Codec.BRANCH5, codeHandlerCount);
+ int[][] codeHandlerClassRCNints = decodeBandInt("code_handler_class_RCN", in,
+ Codec.UNSIGNED5, codeHandlerCount);
+ // The codeHandlerClassRCN band contains incremented references to
+ // cp_Class so we can't use parseReferences(..) here.
+ String[] cpClass = cpBands.getCpClass();
+ codeHandlerClassRCN = new String[codeHandlerClassRCNints.length][];
+ for (int i = 0; i < codeHandlerClassRCNints.length; i++) {
+ codeHandlerClassRCN[i] = new String[codeHandlerClassRCNints[i].length];
+ for (int j = 0; j < codeHandlerClassRCNints[i].length; j++) {
+ int handlerClassReference = codeHandlerClassRCNints[i][j];
+ if(handlerClassReference == 0) {
+ codeHandlerClassRCN[i][j] = null;
+ } else {
+ codeHandlerClassRCN[i][j] = cpClass[handlerClassReference - 1];
+ }
+ }
+ }
int codeFlagsCount = segment.getSegmentHeader().getOptions()
.hasAllCodeFlags() ? codeCount : codeSpecialHeader;
@@ -1227,6 +1246,26 @@
*/
public int[] getClassVersionMinor() {
return classVersionMinor;
+ }
+
+ public int[] getCodeHandlerCount() {
+ return codeHandlerCount;
+ }
+
+ public int[][] getCodeHandlerCatchPO() {
+ return codeHandlerCatchPO;
+ }
+
+ public String[][] getCodeHandlerClassRCN() {
+ return codeHandlerClassRCN;
+ }
+
+ public int[][] getCodeHandlerEndPO() {
+ return codeHandlerEndPO;
+ }
+
+ public int[][] getCodeHandlerStartP() {
+ return codeHandlerStartP;
}
}
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=613858&r1=613857&r2=613858&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 Mon Jan 21 03:55:17 2008
@@ -123,7 +123,7 @@
int h = code + 1;
// This handles the special cases for invalid combinations of data.
return new BHSDCodec(b,h,s,d);
- } else if (value >= 117 && value <= 140) {
+ } else if (value >= 117 && value <= 140) { // Run codec
int offset = value - 117;
int kx = offset & 3;
boolean kbflag = (offset >> 2 & 1) == 1;
@@ -146,7 +146,7 @@
bCodec = getCodec(in.read(),in,defaultCodec);
}
return new RunCodec(k,aCodec,bCodec);
- } else if (value >= 141 && value <= 188) {
+ } else if (value >= 141 && value <= 188) { // Population Codec
int offset = value - 141;
boolean fdef = (offset & 1) == 1;
boolean udef = (offset >> 1 & 1) == 1;
@@ -166,9 +166,9 @@
return new PopulationCodec(fCodec,l,uCodec);
} else {
Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
+ Codec tCodec = getCodec(in.read(),in,defaultCodec);
Codec uCodec = (udef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
- Codec tCodec = getCodec(in.read(),in,defaultCodec);
- return new PopulationCodec(fCodec,uCodec,tCodec);
+ return new PopulationCodec(fCodec,tCodec,uCodec);
}
} else {
throw new Pack200Exception("Invalid codec encoding byte (" + value + ") found" );
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=613858&r1=613857&r2=613858&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 Mon Jan 21 03:55:17 2008
@@ -40,6 +40,8 @@
private long[] fileSize;
private String[] cpUTF8;
+
+ private InputStream in;
/**
* @param header
@@ -73,10 +75,11 @@
} else {
fileOptions = new long[numberOfFiles];
}
+ this.in = in; // store for use by processFileBits(), which is called later
}
-
- public void processFileBits(InputStream in) throws IOException,
+ // TODO: stream the file bits directly somehow
+ public void processFileBits() throws IOException,
Pack200Exception {
// now read in the bytes
int numberOfFiles = header.getNumberOfFiles();
@@ -86,8 +89,9 @@
// TODO This breaks if file_size > 2^32. Probably an array is
// not the right choice, and we should just serialize it here?
fileBits[i] = new byte[size];
- for (int j = 0; j < size; j++) {
- fileBits[i][j] = (byte) Codec.BYTE1.decode(in);
+ int read = in.read(fileBits[i]);
+ if(read < size) {
+ throw new Pack200Exception("Expected to read " + size +" bytes but read " + read);
}
}
}
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=613858&r1=613857&r2=613858&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 Mon Jan 21 03:55:17 2008
@@ -391,11 +391,11 @@
} else if (tag.startsWith("PO")) {
char uint_type = tag.substring(2).toCharArray()[0];
int length = getLength(uint_type);
- attribute.addBCOffset(length, value);
+ attribute.addBCOffset(length, (int) value);
} else if (tag.startsWith("P")) {
char uint_type = tag.substring(1).toCharArray()[0];
int length = getLength(uint_type);
- attribute.addBCIndex(length, value);
+ attribute.addBCIndex(length, (int) value);
} else if (tag.startsWith("OS")) {
char uint_type = tag.substring(1).toCharArray()[0];
int length = getLength(uint_type);
@@ -406,11 +406,11 @@
} else if(length == 4) {
value = (int)value;
}
- attribute.addBCLength(length, value);
+ attribute.addBCLength(length, (int) value);
} else if (tag.startsWith("O")) {
char uint_type = tag.substring(1).toCharArray()[0];
int length = getLength(uint_type);
- attribute.addBCLength(length, value);
+ attribute.addBCLength(length, (int) value);
}
}
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=613858&r1=613857&r2=613858&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 Mon Jan 21 03:55:17 2008
@@ -24,6 +24,7 @@
private Codec tokenCodec;
private Codec unvafouredCodec;
private int l;
+ private long[] favoured;
public PopulationCodec(Codec favouredCodec, Codec tableCodec, Codec unvafouredCodec) {
this.favouredCodec = favouredCodec;
@@ -52,7 +53,7 @@
public long[] decode(int n, InputStream in) throws IOException, Pack200Exception {
- long favoured[] = new long[n]; // there must be <= n values, but probably a lot less
+ favoured = new long[n]; // there must be <= n values, but probably a lot less
long result[];
// read table of favorites first
long smallest = Long.MAX_VALUE;
@@ -71,7 +72,7 @@
// ensure that -X and +X -> +X
smallest = Math.abs(smallest);
}
- }
+ }
// if tokenCodec needs to be derived from the T, L and K values
if (tokenCodec == null) {
if (k < 256) {
@@ -101,5 +102,17 @@
}
}
return result;
+ }
+
+ public long[] getFavoured() {
+ return favoured;
+ }
+
+ public Codec getFavouredCodec() {
+ return favouredCodec;
+ }
+
+ public Codec getUnvafouredCodec() {
+ return unvafouredCodec;
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java Mon Jan 21 03:55:17 2008
@@ -97,7 +97,7 @@
} else {
in.reset();
}
- segment.parseSegment(in);
+ segment.parseSegment(in);
return segment;
}
@@ -268,9 +268,9 @@
* @throws Pack200Exception
* if an error occurs whilst unpacking data
*/
- public void writeJar(JarOutputStream out, InputStream in)
+ public void writeJar(JarOutputStream out)
throws IOException, Pack200Exception {
- fileBands.processFileBits(in);
+ fileBands.processFileBits();
DataOutputStream dos = new DataOutputStream(out);
String[] fileName = fileBands.getFileName();
long[] fileModtime = fileBands.getFileModtime();
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java Mon Jan 21 03:55:17 2008
@@ -329,7 +329,7 @@
private long[] decodeScalar(String name, InputStream in, BHSDCodec codec,
int n) throws IOException, Pack200Exception {
// TODO Remove debugging code
-// debug("Parsed #" + name + " (" + n + ")");
+ debug("Parsed #" + name + " (" + n + ")");
return codec.decode(n, in);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java Mon Jan 21 03:55:17 2008
@@ -20,7 +20,7 @@
import java.io.IOException;
public abstract class Attribute extends ClassFileEntry {
- private final CPUTF8 attributeName;
+ protected final CPUTF8 attributeName;
private int attributeNameIndex;
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java Mon Jan 21 03:55:17 2008
@@ -54,10 +54,9 @@
}
this.domain = ClassConstantPool.DOMAIN_NAMEANDTYPE;
this.name = new CPUTF8(nameString, ClassConstantPool.DOMAIN_NORMALASCIIZ);
- if((nameString.equals("<init>")) || (nameString.equals("<clinit>")) || nativeDescriptor ) {
- // Signatures for init methods are stored with the init methods.
- // Not sure why. Similarly, native signatures are stored
- // there as well.
+ if( nativeDescriptor ) {
+ // Native signatures are stored in DOMAIN_NORMALASCIIZ, not
+ // DOMAIN_SIGNATUREASCIIZ for some reason.
descriptorDomain = ClassConstantPool.DOMAIN_NORMALASCIIZ;
} else {
descriptorDomain = ClassConstantPool.DOMAIN_SIGNATUREASCIIZ;
@@ -132,4 +131,43 @@
public int invokeInterfaceCount() {
return 1 + SegmentUtils.countInvokeInterfaceArgs(descriptor.underlyingString());
}
+
+
+ /* (non-Javadoc)
+ * @see org.apache.harmony.pack200.bytecode.ConstantPoolEntry#comparisonString()
+ */
+ public String comparisonString() {
+ // First come those things which don't have an
+ // associated signature. Then come the native signatures,
+ // then finally the class signatures.
+ // TODO: I think Character.MAX_VALUE is no longer the
+ // biggest character, what with the weird codepage thing
+ // going on. How to sort these things so that even if
+ // they're in some oddball codepage they'll still end
+ // up sorted correctly?
+ String descriptorString = descriptor.underlyingString();
+ StringBuffer comparisonBuffer = new StringBuffer();
+ if((descriptorString.indexOf("(")) == -1) {
+ // it's a variable reference
+ comparisonBuffer.append(descriptor.underlyingString());
+ } else {
+ // it's a signature. Append something that will
+ // make the comparison buffer bigger than all
+ // non-signature references.
+ comparisonBuffer.append(Character.MAX_VALUE);
+ // do the natives first
+ if(descriptorString.length() <= 4) {
+ // it's a native signature
+ comparisonBuffer.append(descriptor.underlyingString());
+ } else {
+ // it's a non-native signature. Append something
+ // that will make the comparison buffer bigger
+ // than all native signature references.
+ comparisonBuffer.append(Character.MAX_VALUE);
+ comparisonBuffer.append(descriptor.underlyingString());
+ }
+ }
+ comparisonBuffer.append(name.underlyingString());
+ return comparisonBuffer.toString();
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPRef.java Mon Jan 21 03:55:17 2008
@@ -77,6 +77,37 @@
classNameIndex = pool.indexOf(className);
}
+ public String comparisonString() {
+ // This one is tricky. The sorting appears to be
+ // done based on the indices of the method descriptor
+ // and class name in the classpool *after* sorting them.
+
+ // If we haven't yet been resolved, just do a normal
+ // compare (so things like .contains() work).
+ if(!isResolved()) {
+ return super.comparisonString();
+ }
+
+ // If we get here, the receiver has been resolved; there
+ // is a different sort order.
+ StringBuffer result = new StringBuffer();
+ // Pad all numbers to 6 digits so they sort correctly.
+ int padLength = 6;
+ int classIndexLength = ("" + classNameIndex).length();
+ int nameAndTypeIndexLength = ("" + nameAndTypeIndex).length();
+
+ for(int index=0; index < (padLength - classIndexLength); index++) {
+ result.append('0');
+ }
+ result.append("" + classNameIndex);
+ result.append(":");
+ for(int index=0; index < (padLength - nameAndTypeIndexLength); index++) {
+ result.append('0');
+ }
+ result.append("" + nameAndTypeIndex);
+ return result.toString();
+ }
+
public String toString() {
String type;
if (getTag() == ConstantPoolEntry.CP_Fieldref) {
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java Mon Jan 21 03:55:17 2008
@@ -29,7 +29,6 @@
this.domain = domain;
}
-
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -45,7 +44,6 @@
return false;
return true;
}
-
public int hashCode() {
final int PRIME = 31;
@@ -80,20 +78,36 @@
}
public String comparisonString() {
- String returnValue = utf8;
- if(utf8.endsWith(";")) {
- StringBuffer alphaChars = new StringBuffer();
- StringBuffer extraChars = new StringBuffer();
- extraChars.append((char)0xFFFF);
- for(int index=0; index < utf8.length(); index++) {
- if( (utf8.charAt(index) == '(') || (utf8.charAt(index) == ')') || (utf8.charAt(index) == '[') || (utf8.charAt(index) == ']') ) {
- extraChars.append(utf8.charAt(index));
- } else {
- alphaChars.append(utf8.charAt(index));
- }
- }
- returnValue = alphaChars.toString() + extraChars.toString();
- }
- return returnValue;
+ // Should use either normalComparisonString or signatureComparisonString.
+ // If we get here, that might indicate an error.
+ throw new Error("Should use specific kinds of comparisonString() on CPUTF8s");
}
+
+ public String normalComparisonString() {
+ return utf8;
+ }
+
+ public String signatureComparisonString() {
+ StringBuffer alphaChars = new StringBuffer();
+ StringBuffer extraChars = new StringBuffer();
+ if(utf8.length() > 0){
+ if(utf8.charAt(0) == '(') {
+ // Things with return values (which apparently
+ // always begin with '(') sort after things
+ // without return values.
+ // TODO: need a better way for this - possibly in the comparator?
+ alphaChars.append(Character.MAX_VALUE);
+ }
+ }
+ // TODO: need a better way for this - possibly in the comparator?
+ extraChars.append(Character.MAX_VALUE);
+ for(int index=0; index < utf8.length(); index++) {
+ if( (utf8.charAt(index) == '(') || (utf8.charAt(index) == ')') || (utf8.charAt(index) == '[') || (utf8.charAt(index) == ']') ) {
+ extraChars.append(utf8.charAt(index));
+ } else {
+ alphaChars.append(utf8.charAt(index));
+ }
+ }
+ return(alphaChars.toString() + extraChars.toString());
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java Mon Jan 21 03:55:17 2008
@@ -17,16 +17,10 @@
package org.apache.harmony.pack200.bytecode;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.harmony.pack200.bytecode.ConstantPoolEntry;
-import org.apache.harmony.pack200.Pack200Exception;
import org.apache.harmony.pack200.Segment;
import org.apache.harmony.pack200.SegmentUtils;
@@ -81,9 +75,10 @@
public static int DOMAIN_FIELD = 10;
public static int DOMAIN_METHOD = 11;
public static int DOMAIN_ATTRIBUTEASCIIZ = 12;
+ public static int NUM_DOMAINS = DOMAIN_ATTRIBUTEASCIIZ + 1;
- protected SortedSet sortedEntries = new TreeSet(new PoolComparator());
-
+// protected SortedSet sortedEntries = new TreeSet(new PoolComparator());
+ protected ClassPoolSet classPoolSet = new ClassPoolSet();
public String toString() {
return entries.toString();
}
@@ -100,44 +95,17 @@
// This is a handy way to see what's adding a ClassFileEntry - set a breakpoint on the print
// if(entry instanceof CPUTF8) {
// System.out.println("AAH:" + ((CPUTF8)entry).comparisonString());
-// if (((CPUTF8)entry).comparisonString().matches("Ljava.*")) {
+// if (((CPUTF8)entry).underlyingString().matches("Code")) {
// System.out.println("Adding");
// }
// }
if (entry instanceof ConstantPoolEntry) {
+ classPoolSet.add(entry);
if (!entries.contains(entry)) {
entries.add(entry);
- sortedEntries.add(entry);
// TODO This will be a bugger when they're sorted.
if (entry instanceof CPLong ||entry instanceof CPDouble)
entries.add(entry); //these get 2 slots because of their size
- } else {
- // TODO: This is awful. If I'm presented with
- // an entry that has a lower domain than the
- // current entry but is otherwise the same,
- // change its domain and rebalance the tree.
- // And by "rebalance" I mean destroy and recreate
- // the tree.
- Iterator iterator = sortedEntries.iterator();
- boolean replaceTree = false;
- SortedSet newSortedSet = new TreeSet(new PoolComparator());
- while(iterator.hasNext()) {
- ConstantPoolEntry storedEntry = (ConstantPoolEntry)iterator.next();
- if(storedEntry.equals(entry)) {
- if(storedEntry.getDomain() > ((ConstantPoolEntry)entry).getDomain()) {
- // need to blow away the tree.
- replaceTree = true;
- newSortedSet.add(entry);
- } else {
- newSortedSet.add(storedEntry);
- }
- } else {
- newSortedSet.add(storedEntry);
- }
- if(replaceTree) {
- sortedEntries = newSortedSet;
- }
- }
}
} else {
if (!others.contains(entry))
@@ -177,42 +145,15 @@
// In an ideal world, you wouldn't actually add to it unless you're
// sure.
entries = new ArrayList();
-// entries.addAll(sortedEntries);
- Iterator sortedIterator = sortedEntries.iterator();
+ Iterator sortedIterator = classPoolSet.iterator();
while(sortedIterator.hasNext()) {
ConstantPoolEntry entry = (ConstantPoolEntry)sortedIterator.next();
entries.add(entry);
+ // need to do this both here and in the sort below
+ // so the indices are correct.
if (entry instanceof CPLong ||entry instanceof CPDouble)
entries.add(entry); //these get 2 slots because of their size
}
-// HashMap sortMap = new HashMap();
-// List cpAll = null;
-// // TODO: HACK - this is a 1.5 api.
-// // Need to do the right thing and do it with 1.4 API.
-// try {
-// cpAll = Arrays.asList(segment.getConstantPool().getCpAll());
-// } catch (Pack200Exception ex) {
-// ex.printStackTrace();
-// }
-// Iterator it = entries.iterator();
-// while(it.hasNext()) {
-// ClassFileEntry entry = (ClassFileEntry) it.next();
-// int indexInCpAll = cpAll.indexOf(entry);
-// if(indexInCpAll > 0) {
-// sortMap.put(new Integer(indexInCpAll), entry);
-// } else {
-// sortMap.put(new Integer(99999), entry);
-// }
-// }
-// ArrayList sortedList = new ArrayList();
-// for(int index=0; index < 99999; index++) {
-// if(sortMap.containsKey(new Integer(index))) {
-// sortedList.add((ClassFileEntry)sortMap.get(new Integer(index)));
-// }
-// }
-// for(int xindex=0; xindex < sortedList.size(); xindex++) {
-// SegmentUtils.debug(sortedList.get(xindex).toString());
-// }
resolve();
}
@@ -227,7 +168,25 @@
while (it.hasNext()) {
ClassFileEntry entry = (ClassFileEntry) it.next();
entry.resolve(this);
- }
+ }
+
+ // Now that everything has been resolved, do one
+ // final sort of the class pool. This fixes up
+ // references, which are sorted by index in the
+ // class pool.
+ it = entries.iterator();
+ ClassPoolSet finalSort = new ClassPoolSet();
+ while(it.hasNext()) {
+ finalSort.add(it.next());
+ }
+ it = finalSort.iterator();
+ entries = new ArrayList();
+ while(it.hasNext()) {
+ ClassFileEntry entry = (ClassFileEntry) it.next();
+ entries.add(entry);
+ if (entry instanceof CPLong ||entry instanceof CPDouble)
+ entries.add(entry); //these get 2 slots because of their size
+ }
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassFileEntry.java Mon Jan 21 03:55:17 2008
@@ -42,6 +42,10 @@
resolved = true;
}
+ protected boolean isResolved() {
+ return resolved;
+ }
+
public abstract String toString();
public final void write(DataOutputStream dos) throws IOException {
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CodeAttribute.java Mon Jan 21 03:55:17 2008
@@ -24,28 +24,31 @@
import org.apache.harmony.pack200.Segment;
-public class CodeAttribute extends Attribute {
+public class CodeAttribute extends BCIRenumberedAttribute {
public List attributes = new ArrayList();
// instances
public List byteCodeOffsets = new ArrayList();
public List byteCodes = new ArrayList();
public int codeLength;
- public List exceptionTable = new ArrayList(); // of ExceptionTableEntry
+ public List exceptionTable; // of ExceptionTableEntry
public int maxLocals;
public int maxStack;
public CodeAttribute(int maxStack, int maxLocals, byte codePacked[],
- Segment segment, OperandManager operandManager) {
+ Segment segment, OperandManager operandManager, List exceptionTable) {
super("Code"); //$NON-NLS-1$
this.maxLocals = maxLocals;
this.maxStack = maxStack;
this.codeLength = 0;
+ this.exceptionTable = exceptionTable;
byteCodeOffsets.add(new Integer(0));
+ int byteCodeIndex = 0;
for (int i = 0; i < codePacked.length; i++) {
ByteCode byteCode = ByteCode.getByteCode(codePacked[i] & 0xff);
// Setting the offset must happen before extracting operands
// because label bytecodes need to know their offsets.
- byteCode.setByteCodeIndex(i);
+ byteCode.setByteCodeIndex(byteCodeIndex);
+ byteCodeIndex++;
byteCode.extractOperands(operandManager, segment, codeLength);
byteCodes.add(byteCode);
codeLength += byteCode.getLength();
@@ -56,6 +59,7 @@
// another bytecode.
if (byteCode.hasMultipleByteCodes()) {
byteCodeOffsets.add(new Integer(lastBytecodePosition + 1));
+ byteCodeIndex++;
}
// I've already added the first element (at 0) before
// entering this loop, so make sure I don't add one
@@ -119,6 +123,10 @@
ByteCode byteCode = (ByteCode) it.next();
byteCode.resolve(pool);
}
+ for (Iterator iter = exceptionTable.iterator(); iter.hasNext();) {
+ ExceptionTableEntry entry = (ExceptionTableEntry) iter.next();
+ entry.resolve(pool);
+ }
}
public String toString() {
@@ -155,5 +163,17 @@
public List attributes() {
return attributes;
+ }
+
+ protected int[] getStartPCs() {
+ // Do nothing here as we've overriden renumber
+ return null;
+ }
+
+ public void renumber(List byteCodeOffsets) {
+ for (Iterator iter = exceptionTable.iterator(); iter.hasNext();) {
+ ExceptionTableEntry entry = (ExceptionTableEntry) iter.next();
+ entry.renumber(byteCodeOffsets);
+ }
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantPoolEntry.java Mon Jan 21 03:55:17 2008
@@ -59,7 +59,7 @@
protected int domain = ClassConstantPool.DOMAIN_UNDEFINED;
public static int creationOrderCount = 100;
public String comparisonString() {
- return "" + creationOrder;
+ return toString();
}
public int creationOrder = -1;
ConstantPoolEntry(byte tag) {
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionTableEntry.java Mon Jan 21 03:55:17 2008
@@ -18,18 +18,44 @@
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.List;
public class ExceptionTableEntry {
- public int catchType;
- public int endPC;
- public int handlerPC;
- public int startPC;
+ private int startPC;
+ private int endPC;
+ private int handlerPC;
+ private CPClass catchType;
+
+ private int startPcRenumbered;
+ private int endPcRenumbered;
+ private int handlerPcRenumbered;
+ private int catchTypeIndex;
+
+ public ExceptionTableEntry(int startPC, int endPC, int handlerPC, CPClass catchType) {
+ this.startPC = startPC;
+ this.endPC = endPC;
+ this.handlerPC = handlerPC;
+ this.catchType = catchType;
+ }
public void write(DataOutputStream dos) throws IOException {
- dos.writeShort(startPC);
- dos.writeShort(endPC);
- dos.writeShort(handlerPC);
- dos.writeShort(catchType);
+ dos.writeShort(startPcRenumbered);
+ dos.writeShort(endPcRenumbered);
+ dos.writeShort(handlerPcRenumbered);
+ dos.writeShort(catchTypeIndex);
}
+
+ public void renumber(List byteCodeOffsets) {
+ startPcRenumbered = ((Integer)byteCodeOffsets.get(startPC)).intValue();
+ int endPcIndex = startPC + endPC;
+ endPcRenumbered = ((Integer)byteCodeOffsets.get(endPcIndex)).intValue();
+ int handlerPcIndex = endPcIndex + handlerPC;
+ handlerPcRenumbered = ((Integer)byteCodeOffsets.get(handlerPcIndex)).intValue();
+ }
+
+ public void resolve(ClassConstantPool pool) {
+ catchType.resolve(pool);
+ catchTypeIndex = pool.indexOf(catchType);
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/LineNumberTableAttribute.java Mon Jan 21 03:55:17 2008
@@ -18,7 +18,6 @@
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.List;
public class LineNumberTableAttribute extends BCIRenumberedAttribute {
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/NewAttribute.java Mon Jan 21 03:55:17 2008
@@ -18,96 +18,218 @@
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
/**
* A New (i.e. non-predefined) Class File attribute
*/
-public class NewAttribute extends Attribute {
+public class NewAttribute extends BCIRenumberedAttribute {
+
+ private List lengths = new ArrayList(); // List of Integers
+ private List body = new ArrayList();
+ private ClassConstantPool pool;
public NewAttribute(String attributeName) {
super(attributeName);
- // TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see org.apache.harmony.pack200.bytecode.Attribute#getLength()
*/
protected int getLength() {
- // TODO Auto-generated method stub
- return 0;
+ int length = 0;
+ for (Iterator iter = lengths.iterator(); iter.hasNext();) {
+ length += ((Integer) iter.next()).intValue();
+ }
+ return length;
}
/* (non-Javadoc)
* @see org.apache.harmony.pack200.bytecode.Attribute#writeBody(java.io.DataOutputStream)
*/
protected void writeBody(DataOutputStream dos) throws IOException {
- // TODO Auto-generated method stub
-
+ for (int i = 0; i < lengths.size(); i++) {
+ int length = ((Integer) lengths.get(i)).intValue();
+ Object obj = body.get(i);
+ long value = 0;
+ if(obj instanceof Long) {
+ value = ((Long)obj).longValue();
+ } else if (obj instanceof ClassFileEntry) {
+ value = pool.indexOf(((ClassFileEntry)obj));
+ } else if (obj instanceof BCValue) {
+ value = ((BCValue)obj).actualValue;
+ }
+ // Write
+ if(length == 1) {
+ dos.writeByte((int)value);
+ } else if (length == 2) {
+ dos.writeShort((int)value);
+ } else if (length == 4) {
+ dos.writeInt((int)value);
+ } else if (length == 8) {
+ dos.writeLong(value);
+ }
+ }
}
/* (non-Javadoc)
* @see org.apache.harmony.pack200.bytecode.ClassFileEntry#toString()
*/
public String toString() {
- // TODO Auto-generated method stub
- return null;
+ return attributeName.underlyingString();
}
public void addInteger(int length, long value) {
-
+ lengths.add(new Integer(length));
+ body.add(new Long(value));
}
- public void addBCOffset(int length, long value) {
- // TODO Auto-generated method stub
-
+ public void addBCOffset(int length, int value) {
+ lengths.add(new Integer(length));
+ body.add(new BCOffset(value));
}
- public void addBCIndex(int length, long value) {
- // TODO Auto-generated method stub
-
+ public void addBCIndex(int length, int value) {
+ lengths.add(new Integer(length));
+ body.add(new BCIndex(value));
}
- public void addBCLength(int length, long value) {
- // TODO Auto-generated method stub
-
+ public void addBCLength(int length, int value) {
+ lengths.add(new Integer(length));
+ body.add(new BCLength(value));
}
public void addCPConstant(int length, CPConstant constant) {
- // TODO Auto-generated method stub
-
+ lengths.add(new Integer(length));
+ body.add(constant);
}
public void addCPClass(int length, CPClass class1) {
- // TODO Auto-generated method stub
-
+ lengths.add(new Integer(length));
+ body.add(class1);
}
public void addCPUTF8(int length, CPUTF8 cputf8) {
- // TODO Auto-generated method stub
-
+ lengths.add(new Integer(length));
+ body.add(cputf8);
}
public void addCPNameAndType(int length, CPNameAndType type) {
- // TODO Auto-generated method stub
-
+ lengths.add(new Integer(length));
+ body.add(type);
}
public void addCPFieldRef(int length, CPFieldRef ref) {
- // TODO Auto-generated method stub
-
+ lengths.add(new Integer(length));
+ body.add(ref);
}
public void addCPMethodRef(int length, CPMethodRef ref) {
- // TODO Auto-generated method stub
-
+ lengths.add(new Integer(length));
+ body.add(ref);
}
public void addCPIMethodRef(int length, CPInterfaceMethodRef ref) {
- // TODO Auto-generated method stub
+ lengths.add(new Integer(length));
+ body.add(ref);
+ }
+
+ protected void resolve(ClassConstantPool pool) {
+ super.resolve(pool);
+ for (Iterator iter = body.iterator(); iter.hasNext();) {
+ Object element = (Object) iter.next();
+ if(element instanceof ClassFileEntry) {
+ ((ClassFileEntry)element).resolve(pool);
+ }
+ }
+ this.pool = pool;
+ }
+
+ private static class BCOffset extends BCValue {
+ private int offset;
+ private int index;
+
+ public BCOffset(int offset) {
+ this.offset = offset;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
}
+ private static class BCIndex extends BCValue {
+
+ private int index;
+
+ public BCIndex(int index) {
+ this.index = index;
+ }
+ }
+
+ private static class BCLength extends BCValue {
+
+ private int length;
+
+ public BCLength(int length) {
+ this.length = length;
+ }
+ }
+ // Bytecode-related value (either a bytecode index or a length)
+ private static abstract class BCValue {
+
+ int actualValue;
+
+ public void setActualValue(int value) {
+ this.actualValue = value;
+ }
+
+ }
+
+ protected int[] getStartPCs() {
+ // Don't need to return anything here as we've overridden renumber
+ return null;
+ }
+ public void renumber(List byteCodeOffsets) {
+ if(!renumbered) {
+ Object previous = null;
+ for (Iterator iter = body.iterator(); iter.hasNext();) {
+ Object obj = (Object) iter.next();
+ if(obj instanceof BCIndex) {
+ BCIndex bcIndex = (BCIndex) obj;
+ bcIndex.setActualValue(((Integer)byteCodeOffsets.get(bcIndex.index)).intValue());
+ } else if (obj instanceof BCOffset) {
+ BCOffset bcOffset = (BCOffset)obj;
+ if(previous instanceof BCIndex) {
+ int index = ((BCIndex)previous).index + bcOffset.offset;
+ bcOffset.setIndex(index);
+ bcOffset.setActualValue(((Integer)byteCodeOffsets.get(index)).intValue());
+ } else if(previous instanceof BCOffset) {
+ int index = ((BCOffset)previous).index + bcOffset.offset;
+ bcOffset.setIndex(index);
+ bcOffset.setActualValue(((Integer)byteCodeOffsets.get(index)).intValue());
+ } else {
+ // Not sure if this should be able to happen
+ bcOffset.setActualValue(((Integer)byteCodeOffsets.get(bcOffset.offset)).intValue());
+ }
+ } else if (obj instanceof BCLength) {
+ // previous must be a BCIndex
+ BCLength bcLength = (BCLength) obj;
+ BCIndex prevIndex = (BCIndex) previous;
+ int index = prevIndex.index + bcLength.length;
+ int actualLength = ((Integer)byteCodeOffsets.get(index)).intValue() - prevIndex.actualValue;
+ bcLength.setActualValue(actualLength);
+ }
+ previous = obj;
+ }
+ renumbered = true;
+ }
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ByteCodeForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ByteCodeForm.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ByteCodeForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ByteCodeForm.java Mon Jan 21 03:55:17 2008
@@ -291,16 +291,16 @@
byteCodeArray[224] = new SuperFieldRefForm(224, "aload_0_putstatic_super", new int[] {42, 179, -1, -1});
byteCodeArray[225] = new SuperFieldRefForm(225, "aload_0_getfield_super", new int[] {42, 180, -1, -1});
byteCodeArray[226] = new SuperFieldRefForm(226, "aload_0_putfield_super", new int[] {42, 181, -1, -1});
- byteCodeArray[227] = new SuperFieldRefForm(227, "aload_0_invokevirtual_super", new int[] {42, 182, -1, -1});
- byteCodeArray[228] = new SuperFieldRefForm(228, "aload_0_invokespecial_super", new int[] {42, 183, -1, -1});
- byteCodeArray[229] = new SuperFieldRefForm(229, "aload_0_invokestatic_super", new int[] {42, 184, -1, -1});
+ byteCodeArray[227] = new SuperMethodRefForm(227, "aload_0_invokevirtual_super", new int[] {42, 182, -1, -1});
+ byteCodeArray[228] = new SuperMethodRefForm(228, "aload_0_invokespecial_super", new int[] {42, 183, -1, -1});
+ byteCodeArray[229] = new SuperMethodRefForm(229, "aload_0_invokestatic_super", new int[] {42, 184, -1, -1});
byteCodeArray[230] = new ThisInitMethodRefForm(230, "invokespecial_this_init", new int[] {183, -1, -1});
byteCodeArray[231] = new SuperInitMethodRefForm(231, "invokespecial_super_init", new int[] {183, -1, -1});
byteCodeArray[232] = new NewInitMethodRefForm(232, "invokespecial_new_init", new int[] {183, -1, -1});
- byteCodeArray[233] = new ClassRefForm(233, "cldc", new int[] {18, -1});
+ byteCodeArray[233] = new NarrowClassRefForm(233, "cldc", new int[] {18, -1});
byteCodeArray[234] = new IntRefForm(234, "ildc", new int[] {18, -1});
byteCodeArray[235] = new FloatRefForm(235, "fldc", new int[] {18, -1});
- byteCodeArray[236] = new ClassRefForm(236, "cldc_w", new int[] {19, -1, -1}, WIDENED);
+ byteCodeArray[236] = new NarrowClassRefForm(236, "cldc_w", new int[] {19, -1, -1}, WIDENED);
byteCodeArray[237] = new IntRefForm(237, "ildc_w", new int[] {19, -1, -1}, WIDENED);
byteCodeArray[238] = new FloatRefForm(238, "fldc_w", new int[] {19, -1, -1}, WIDENED);
byteCodeArray[239] = new DoubleForm(239, "dldc2_w", new int[] {20, -1, -1});
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/ClassRefForm.java Mon Jan 21 03:55:17 2008
@@ -53,5 +53,4 @@
protected int getPoolID() {
return SegmentConstantPool.CP_CLASS;
}
-
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/LabelForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/LabelForm.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/LabelForm.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/forms/LabelForm.java Mon Jan 21 03:55:17 2008
@@ -59,7 +59,6 @@
int sourceValue = ((Integer)codeAttribute.byteCodeOffsets.get(sourceIndex)).intValue();
// The operand is the difference between the source instruction
// and the destination instruction.
- // TODO: Probably have to do something other than setOperandInt if this is widened.
byteCode.setOperandSigned2Bytes(targetValue - sourceValue, 0);
if(widened) {
byteCode.setNestedPositions(new int[][] {{0,4}});
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java Mon Jan 21 03:55:17 2008
@@ -48,7 +48,7 @@
try {
while (in.available() > 0) {
Segment s = Segment.parse(in);
- s.writeJar(out, in);
+ s.writeJar(out);
out.flush();
}
} catch (Pack200Exception e) {
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/Unpack.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/Unpack.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/Unpack.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/Unpack.java Mon Jan 21 03:55:17 2008
@@ -33,6 +33,6 @@
JarOutputStream out = new JarOutputStream(
args.length > 1 ? (OutputStream) new FileOutputStream(args[1])
: (OutputStream) new BufferedOutputStream(System.out));
- Segment.parse(in).writeJar(out, in);
+ Segment.parse(in).writeJar(out);
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodeAttributeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodeAttributeTest.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodeAttributeTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodeAttributeTest.java Mon Jan 21 03:55:17 2008
@@ -16,6 +16,9 @@
*/
package org.apache.harmony.pack200.tests;
+import java.util.ArrayList;
+import java.util.List;
+
import junit.framework.TestCase;
import org.apache.harmony.pack200.CpBands;
@@ -35,9 +38,8 @@
public MockCodeAttribute(int maxStack, int maxLocals,
byte[] codePacked, Segment segment,
- OperandManager operandManager) {
- super(maxStack, maxLocals, codePacked, segment, operandManager);
- // TODO Auto-generated constructor stub
+ OperandManager operandManager, List exceptionTable) {
+ super(maxStack, maxLocals, codePacked, segment, operandManager, exceptionTable);
}
public int getLength() {
@@ -146,7 +148,8 @@
2, // maxLocals
mixedByteArray, // codePacked
segment, // segment
- operandManager // operandManager
+ operandManager, // operandManager
+ new ArrayList()
);
assertEquals(29, attribute.getLength());
@@ -164,7 +167,8 @@
2, // maxLocals
mixedByteArray, // codePacked
segment, // segment
- operandManager // operandManager
+ operandManager, // operandManager
+ new ArrayList()
);
assertEquals(2, attribute.maxLocals);
assertEquals(3, attribute.maxStack);
@@ -187,7 +191,8 @@
3, // maxLocals
singleByteArray, // codePacked
segment, // segment
- operandManager // operandManager
+ operandManager, // operandManager
+ new ArrayList()
);
assertEquals(3, attribute.maxLocals);
assertEquals(4, attribute.maxStack);
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java Mon Jan 21 03:55:17 2008
@@ -29,90 +29,123 @@
* Tests for org.apache.harmony.pack200.Segment, which is the main class for pack200.
*/
public class SegmentTest extends TestCase {
+
+ InputStream in;
+ JarOutputStream out;
boolean handlingInnerClasses = false;
public void testHelloWorld() throws Exception {
- InputStream in = Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack");
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack");
Segment segment = Segment.parse(in);
assertNotNull(segment);
- segment.writeJar(new JarOutputStream(new FileOutputStream(File.createTempFile("Hello", "World.jar"))), in);
- }
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("hello", "world.jar")));
+ segment.writeJar(out);
+ }
public void testJustResources() throws Exception {
- InputStream in = Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack");
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack");
Segment segment = Segment.parse(in);
- assertNotNull(segment);
- segment.writeJar(new JarOutputStream(new FileOutputStream(File.createTempFile("just", "Resources.jar"))), in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("just", "resources.jar")));
+ segment.writeJar(out);
}
public void testJustResourcesGZip() throws Exception {
- assertNotNull(Segment
- .parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack.gz")));
- }
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack.gz");
+ Segment segment = Segment.parse(in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("Just", "ResourcesGz.jar")));
+ segment.writeJar(out);
+ }
// Test with an archive containing Harmony's SQL module, packed with -E1
public void testWithSqlE1() throws Exception {
- // This test will not pass until we handle inner classes
- // correctly.
- if(!handlingInnerClasses) return;
- assertNotNull(Segment
- .parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/sql-e1.pack.gz")));
-
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/sql-e1.pack.gz");
+ Segment segment = Segment.parse(in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("sql", "-e1.jar")));
+ segment.writeJar(out);
}
// Test with an archive containing Harmony's SQL module
public void testWithSql() throws Exception {
- // This test will not pass until we handle inner classes
- // correctly.
if(!handlingInnerClasses) return;
- assertNotNull(Segment
- .parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz")));
-
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
+ Segment segment = Segment.parse(in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("sql", ".jar")));
+ segment.writeJar(out);
}
// Test with an archive containing Harmony's Pack200 module, packed with -E1
public void testWithPack200E1() throws Exception {
- assertNotNull(Segment
- .parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/pack200-e1.pack.gz")));
-
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/pack200-e1.pack.gz");
+ Segment segment = Segment.parse(in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("pack", "200-e1.jar")));
+ segment.writeJar(out);
}
// Test with an archive containing Harmony's Pack200 module
public void testWithPack200() throws Exception {
- assertNotNull(Segment
- .parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/pack200.pack.gz")));
-
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/pack200.pack.gz");
+ Segment segment = Segment.parse(in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("pack", "200.jar")));
+ segment.writeJar(out);
}
// Test with an archive containing Harmony's JNDI module
public void testWithJNDIE1() throws Exception {
if(!handlingInnerClasses) return;
- assertNotNull(Segment
- .parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/jndi-e1.pack.gz")));
-
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/jndi-e1.pack.gz");
+ Segment segment = Segment.parse(in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("jndi", "-e1.jar")));
+ segment.writeJar(out);
}
// Test with an archive containing Annotations
public void testWithAnnotations() throws Exception {
- assertNotNull(Segment
- .parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/annotations.pack.gz")));
+
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/annotations.pack.gz");
+ Segment segment = Segment.parse(in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("ann", "otations.jar")));
+ segment.writeJar(out);
}
public void testInterfaceOnly() throws Exception {
- assertNotNull(Segment
- .parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/pack200/tests/InterfaceOnly.pack")));
+ in = Segment.class
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/InterfaceOnly.pack");
+ Segment segment = Segment.parse(in);
+ assertNotNull(segment);
+ out = new JarOutputStream(new FileOutputStream(File.createTempFile("Interface", "Only.jar")));
+ segment.writeJar(out);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/bytecode/ConstantPoolTest.java Mon Jan 21 03:55:17 2008
@@ -29,8 +29,8 @@
pool = new ClassConstantPool();
}
public void testDuplicateUTF8() {
- CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_UNDEFINED);
- CPUTF8 u2 = new CPUTF8("thing", ClassConstantPool.DOMAIN_UNDEFINED);
+ CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
+ CPUTF8 u2 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
pool.add(u1);
pool.add(u2);
assertEquals(1,pool.size());
@@ -44,8 +44,8 @@
assertEquals(2,pool.size());
}
public void testIndex() {
- pool.add(new CPUTF8("OtherThing", ClassConstantPool.DOMAIN_UNDEFINED));
- CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_UNDEFINED);
+ pool.add(new CPUTF8("OtherThing", ClassConstantPool.DOMAIN_NORMALASCIIZ));
+ CPUTF8 u1 = new CPUTF8("thing", ClassConstantPool.DOMAIN_NORMALASCIIZ);
pool.add(u1);
pool.resolve();
assertTrue(pool.indexOf(u1) > 0);
Modified: harmony/enhanced/classlib/branches/java6/modules/print/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/print/META-INF/MANIFEST.MF?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/print/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/print/META-INF/MANIFEST.MF Mon Jan 21 03:55:17 2008
@@ -29,11 +29,15 @@
java.text,
java.util,
javax.accessibility,
+ javax.imageio,
javax.swing,
javax.swing.border,
javax.swing.event,
- javax.swing.text
+ javax.swing.text,
+ org.apache.harmony.awt.gl,
+ org.apache.harmony.awt.gl.windows
Export-Package: javax.print,
javax.print.attribute,
javax.print.attribute.standard,
- javax.print.event
+ javax.print.event,
+ org.apache.harmony.x.print
Propchange: harmony/enhanced/classlib/branches/java6/modules/security/src/main/native/security/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jan 21 03:55:17 2008
@@ -2,3 +2,4 @@
hysecurity.map
hysecurity.pdb
*.manifest
+libhysecurity.so
Propchange: harmony/enhanced/classlib/branches/java6/modules/security/src/main/native/security/shared/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 21 03:55:17 2008
@@ -0,0 +1,2 @@
+*.obj
+
Propchange: harmony/enhanced/classlib/branches/java6/modules/security/src/main/native/security/unix/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 21 03:55:17 2008
@@ -0,0 +1 @@
+libhysecurity.exp
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java Mon Jan 21 03:55:17 2008
@@ -712,16 +712,16 @@
crsetCopy.updateRow();
crsetCopy.acceptChanges();
- assertEquals(crsetCopy.getString(2), "copyTest3");
+ assertEquals("copyTest3", crsetCopy.getString(2));
- assertEquals(crset.getString(2), "test3");
+ assertEquals("test3", crset.getString(2));
rs = st.executeQuery("select * from USER_INFO");
rs.next();
rs.next();
rs.next();
// TODO: Uncomment it when Writer is implemented fully.
- // assertEquals(rs.getString(2), "copyTest3");
+ // assertEquals("copyTest3", rs.getString(2));
reloadCachedRowSet();
crset.absolute(2);
@@ -831,13 +831,13 @@
copy.updateRow();
copy.acceptChanges();
- assertEquals(copy.getString(2), "updated");
- assertEquals(crset.getString(2), "test3");
+ assertEquals("updated", copy.getString(2));
+ assertEquals("test3", crset.getString(2));
crset.updateString(2, "again");
- assertEquals(copy.getString(2), "updated");
- assertEquals(crset.getString(2), "again");
+ assertEquals("updated", copy.getString(2));
+ assertEquals("again", crset.getString(2));
crset.updateRow();
try {
@@ -854,7 +854,7 @@
// expected
}
- assertEquals(copy.getString(2), "updated");
+ assertEquals("updated", copy.getString(2));
crset.absolute(3);
// data doesn't change
Modified: harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/html/StyleSheet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/html/StyleSheet.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/html/StyleSheet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/text/html/StyleSheet.java Mon Jan 21 03:55:17 2008
@@ -817,12 +817,12 @@
public AttributeSet removeAttributes(final AttributeSet old,
final AttributeSet rem) {
- return removeAttributes(old, new NameConverterEnumeration(old, rem));
+ return localRemoveAttributes(old, new NameConverterEnumeration(old, rem));
}
public AttributeSet removeAttributes(final AttributeSet old,
final Enumeration<?> names) {
- return removeAttributes(old, new NameConverterEnumeration(names));
+ return localRemoveAttributes(old, new NameConverterEnumeration(names));
}
public void addCSSAttribute(final MutableAttributeSet attr,
@@ -1251,7 +1251,7 @@
return result;
}
- private AttributeSet removeAttributes(final AttributeSet toModify,
+ private AttributeSet localRemoveAttributes(final AttributeSet toModify,
final NameConverterEnumeration keys) {
if (!keys.isUnderline() && !keys.isLineThrough()) {
return super.removeAttributes(toModify, keys);
Modified: harmony/enhanced/classlib/branches/java6/modules/text/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/make/exclude.common?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/make/exclude.common (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/make/exclude.common Mon Jan 21 03:55:17 2008
@@ -1,2 +1,5 @@
org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
org/apache/harmony/text/tests/java/text/MessageFormatTest.java
+org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
+org/apache/harmony/text/tests/java/text/NumberFormatTest.java
+org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java
Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormat.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormat.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormat.java Mon Jan 21 03:55:17 2008
@@ -22,7 +22,6 @@
import java.util.Date;
import java.util.Hashtable;
import java.util.Locale;
-import java.util.ResourceBundle;
import java.util.TimeZone;
import org.apache.harmony.text.internal.nls.Messages;
@@ -321,9 +320,8 @@
*/
public final static DateFormat getDateInstance(int style, Locale locale) {
checkDateStyle(style);
- ResourceBundle bundle = getBundle(locale);
- String pattern = bundle.getString("Date_" + getStyleName(style)); //$NON-NLS-1$
- return new SimpleDateFormat(pattern, locale);
+ com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getDateInstance(style, locale);
+ return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
}
/**
@@ -370,10 +368,8 @@
int timeStyle, Locale locale) {
checkTimeStyle(timeStyle);
checkDateStyle(dateStyle);
- ResourceBundle bundle = getBundle(locale);
- String pattern = bundle.getString("Date_" + getStyleName(dateStyle)) //$NON-NLS-1$
- + " " + bundle.getString("Time_" + getStyleName(timeStyle)); //$NON-NLS-1$ //$NON-NLS-2$
- return new SimpleDateFormat(pattern, locale);
+ com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
+ return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
}
/**
@@ -451,9 +447,8 @@
*/
public final static DateFormat getTimeInstance(int style, Locale locale) {
checkTimeStyle(style);
- ResourceBundle bundle = getBundle(locale);
- String pattern = bundle.getString("Time_" + getStyleName(style)); //$NON-NLS-1$
- return new SimpleDateFormat(pattern, locale);
+ com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getTimeInstance(style, locale);
+ return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormatSymbols.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormatSymbols.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormatSymbols.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DateFormatSymbols.java Mon Jan 21 03:55:17 2008
@@ -20,7 +20,6 @@
import java.io.Serializable;
import java.util.Arrays;
import java.util.Locale;
-import java.util.ResourceBundle;
/**
* DateFormatSymbols holds the Strings used in the formating and parsing of
@@ -52,15 +51,16 @@
* the Locale
*/
public DateFormatSymbols(Locale locale) {
- ResourceBundle bundle = Format.getBundle(locale);
- localPatternChars = bundle.getString("LocalPatternChars"); //$NON-NLS-1$
- ampms = bundle.getStringArray("ampm"); //$NON-NLS-1$
- eras = bundle.getStringArray("eras"); //$NON-NLS-1$
- months = bundle.getStringArray("months"); //$NON-NLS-1$
- shortMonths = bundle.getStringArray("shortMonths"); //$NON-NLS-1$
- shortWeekdays = bundle.getStringArray("shortWeekdays"); //$NON-NLS-1$
- weekdays = bundle.getStringArray("weekdays"); //$NON-NLS-1$
- zoneStrings = (String[][]) bundle.getObject("timezones"); //$NON-NLS-1$
+ com.ibm.icu.text.DateFormatSymbols icuSymbols = new com.ibm.icu.text.DateFormatSymbols(locale);
+
+ localPatternChars = icuSymbols.getLocalPatternChars();
+ ampms = icuSymbols.getAmPmStrings();
+ eras = icuSymbols.getEras();
+ months = icuSymbols.getMonths();
+ shortMonths = icuSymbols.getShortMonths();
+ shortWeekdays = icuSymbols.getShortWeekdays();
+ weekdays = icuSymbols.getWeekdays();
+ zoneStrings = icuSymbols.getZoneStrings();
}
/**
@@ -273,7 +273,9 @@
}
for (String[] element : zoneStrings) {
for (int j = 0; j < element.length; j++) {
- hashCode += element[j].hashCode();
+ if (element[j] != null) {
+ hashCode += element[j].hashCode();
+ }
}
}
return hashCode;
Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormat.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormat.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormat.java Mon Jan 21 03:55:17 2008
@@ -54,7 +54,15 @@
* default Locale.
*/
public DecimalFormat() {
- this(getPattern(Locale.getDefault(), "Number")); //$NON-NLS-1$
+ Locale locale = Locale.getDefault();
+ icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
+ symbols = new DecimalFormatSymbols(locale);
+ dform = new com.ibm.icu.text.DecimalFormat();
+
+ super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+ super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+ super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+ super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
}
/**
@@ -68,7 +76,15 @@
* when the pattern cannot be parsed
*/
public DecimalFormat(String pattern) {
- this(pattern, new DecimalFormatSymbols());
+ Locale locale = Locale.getDefault();
+ icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
+ symbols = new DecimalFormatSymbols(locale);
+ dform = new com.ibm.icu.text.DecimalFormat(pattern, icuSymbols);
+
+ super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+ super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+ super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+ super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
}
/**
@@ -85,7 +101,7 @@
*/
public DecimalFormat(String pattern, DecimalFormatSymbols value) {
symbols = (DecimalFormatSymbols) value.clone();
- Locale locale = (Locale) this.getInternalField("locale", symbols); //$NON-NLS-1$
+ Locale locale = symbols.getLocale(); //$NON-NLS-1$
icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
copySymbols(icuSymbols, symbols);
@@ -711,16 +727,16 @@
fields.put("positiveSuffix", dform.getPositiveSuffix());
fields.put("negativePrefix", dform.getNegativePrefix());
fields.put("negativeSuffix", dform.getNegativeSuffix());
- String posPrefixPattern = (String) this.getInternalField(
+ String posPrefixPattern = (String) Format.getInternalField(
"posPrefixPattern", dform);
fields.put("posPrefixPattern", posPrefixPattern);
- String posSuffixPattern = (String) this.getInternalField(
+ String posSuffixPattern = (String) Format.getInternalField(
"posSuffixPattern", dform);
fields.put("posSuffixPattern", posSuffixPattern);
- String negPrefixPattern = (String) this.getInternalField(
+ String negPrefixPattern = (String) Format.getInternalField(
"negPrefixPattern", dform);
fields.put("negPrefixPattern", negPrefixPattern);
- String negSuffixPattern = (String) this.getInternalField(
+ String negSuffixPattern = (String) Format.getInternalField(
"negSuffixPattern", dform);
fields.put("negSuffixPattern", negSuffixPattern);
fields.put("multiplier", dform.getMultiplier());
@@ -729,10 +745,10 @@
.isDecimalSeparatorAlwaysShown());
fields.put("parseBigDecimal", parseBigDecimal);
fields.put("symbols", symbols);
- boolean useExponentialNotation = ((Boolean) this.getInternalField(
+ boolean useExponentialNotation = ((Boolean) Format.getInternalField(
"useExponentialNotation", dform)).booleanValue();
fields.put("useExponentialNotation", useExponentialNotation);
- byte minExponentDigits = ((Byte) this.getInternalField(
+ byte minExponentDigits = ((Byte) Format.getInternalField(
"minExponentDigits", dform)).byteValue();
fields.put("minExponentDigits", minExponentDigits);
fields.put("maximumIntegerDigits", dform.getMaximumIntegerDigits());
@@ -786,7 +802,7 @@
int minimumFractionDigits = fields.get("minimumFractionDigits", 340);
this.serialVersionOnStream = fields.get("serialVersionOnStream", 0);
- Locale locale = (Locale) getInternalField("locale", symbols);
+ Locale locale = (Locale) Format.getInternalField("locale", symbols);
dform = new com.ibm.icu.text.DecimalFormat("",
new com.ibm.icu.text.DecimalFormatSymbols(locale));
setInternalField("useExponentialNotation", dform, Boolean
@@ -831,8 +847,14 @@
*/
private void copySymbols(final com.ibm.icu.text.DecimalFormatSymbols icu,
final DecimalFormatSymbols dfs) {
- icu.setCurrency(com.ibm.icu.util.Currency.getInstance(dfs.getCurrency()
- .getCurrencyCode()));
+ Currency currency = dfs.getCurrency();
+ if (currency == null) {
+ icu.setCurrency(com.ibm.icu.util.Currency.getInstance("XXX"));
+ } else {
+ icu.setCurrency(com.ibm.icu.util.Currency.getInstance(dfs
+ .getCurrency().getCurrencyCode()));
+ }
+
icu.setCurrencySymbol(dfs.getCurrencySymbol());
icu.setDecimalSeparator(dfs.getDecimalSeparator());
icu.setDigit(dfs.getDigit());
@@ -874,31 +896,4 @@
}
});
}
-
- /*
- * Gets private field value by reflection.
- *
- * @param fieldName the field name to be set @param target the object which
- * field to be gotten
- */
- private Object getInternalField(final String fieldName, final Object target) {
- Object value = AccessController
- .doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- Object result = null;
- java.lang.reflect.Field field = null;
- try {
- field = target.getClass().getDeclaredField(
- fieldName);
- field.setAccessible(true);
- result = field.get(target);
- } catch (Exception e1) {
- return null;
- }
- return result;
- }
- });
- return value;
- }
-
}