Property changes on: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200
___________________________________________________________________
Name: svn:ignore
+ bin
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/pack200-java5.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/pack200-java5.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/META-INF/MANIFEST.MF
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/META-INF/MANIFEST.MF (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/META-INF/MANIFEST.MF (working copy)
@@ -11,21 +11,12 @@
Bundle-Version: 1.0.0
Bundle-ClassPath: .
Eclipse-JREBundle: true
-Import-Package: java.beans,
- java.io,
- java.lang,
- java.lang.ref,
- java.lang.reflect,
- java.net,
- java.nio,
- java.nio.charset,
- java.security,
- java.security.cert,
- java.util,
- javax.security.auth.x500,
- org.apache.harmony.luni.util,
- org.apache.harmony.security.utils,
- org.apache.harmony.kernel.vm
+Import-Package: java.io;resolution:=optional,
+ java.lang;resolution:=optional,
+ java.util;resolution:=optional,
+ java.util.jar;resolution:=optional
Export-Package: org.apache.harmony.pack200,
org.apache.harmony.pack200.bytecode
+Bundle-RequiredExecutionEnvironment: J2SE-1.4,
+ J2SE-1.5
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/.classpath
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/.classpath (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/.classpath (working copy)
@@ -1,9 +1,11 @@
-
-
-
+
+
+
-
+
+
+
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java (working copy)
@@ -35,7 +35,7 @@
// Will be uncommented later
// public void testHelloWorld() throws Exception {
// assertNotNull(Segment.parse(Segment.class
-// .getResourceAsStream("/org/apache/harmony/archive/tests/internal/pack200/HelloWorld.pack")));
+// .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack")));
// }
/**
* @param args
@@ -43,7 +43,7 @@
*/
public void testJustResources() throws Exception {
assertNotNull(Segment.parse(Segment.class
- .getResourceAsStream("/org/apache/harmony/archive/tests/internal/pack200/JustResources.pack")));
+ .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack")));
}
}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ClassVersionTest.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ClassVersionTest.java (revision 0)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ClassVersionTest.java (revision 0)
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.pack200.tests;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.pack200.Segment;
+
+public class ClassVersionTest extends TestCase {
+ public void testCorrectVersionOfSegment() throws IOException {
+ InputStream in = Segment.class.getResourceAsStream("/org/apache/harmony/pack200/Segment.class");
+ DataInputStream din = new DataInputStream(in);
+ assertEquals(0xCAFEBABE,din.readInt());
+ din.readShort(); // MINOR -- don't care
+ assertTrue("Class file has been compiled with Java 1.5 compatibility instead of 1.4 or lower",din.readShort() < 49); // 49 = Java 1.5
+ }
+ public void testCorrectVersionOfTest() throws IOException {
+ InputStream in = Segment.class.getResourceAsStream("/org/apache/harmony/pack200/tests/ClassVersionTest.class");
+ DataInputStream din = new DataInputStream(in);
+ assertEquals(0xCAFEBABE,din.readInt());
+ din.readShort(); // MINOR -- don't care
+ assertTrue("Class file has been compiled with Java 1.5 compatibility instead of 1.4 or lower",din.readShort() < 49); // 49 = Java 1.5
+ }
+ public void testCorrectVersionOfAdapter() throws IOException {
+ // tests that both the file is on the classpath and that it's been compiled correctly, but without actually loading the class
+ InputStream in = Segment.class.getResourceAsStream("/org/apache/harmony/pack200/Pack200Adapter.class");
+ DataInputStream din = new DataInputStream(in);
+ assertEquals(0xCAFEBABE,din.readInt());
+ din.readShort(); // MINOR -- don't care
+ assertTrue("Class file needs 1.5 compatibility",din.readShort() >= 49); // 49 = Java 1.5
+ }
+}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java (working copy)
@@ -40,7 +40,7 @@
private String name;
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
@@ -49,7 +49,7 @@
return result;
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -238,7 +238,7 @@
return (value & mask) != 0;
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java (working copy)
@@ -392,7 +392,6 @@
* @param message
* @deprecated this should be removed from production code
*/
- @Deprecated
private void debug(String message) {
if (System.getProperty("debug.pack200") != null) {
System.err.println(message);
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java (working copy)
@@ -41,18 +41,18 @@
this.unvafouredCodec = unvafouredCodec;
}
- @Override
+
public long decode(InputStream in) throws IOException, Pack200Exception {
throw new Pack200Exception("Population encoding does not work unless the number of elements are known");
}
- @Override
+
public long decode(InputStream in, long last) throws IOException,
Pack200Exception {
throw new Pack200Exception("Population encoding does not work unless the number of elements are known");
}
- @Override
+
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
long result[];
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFieldRef.java (working copy)
@@ -35,7 +35,7 @@
}
- @Override
+
protected ClassFileEntry[] getNestedClassFileEntries() {
ClassFileEntry[] entries = new ClassFileEntry[2];
entries[0] = className;
@@ -44,7 +44,7 @@
}
- @Override
+
protected void resolve(ClassConstantPool pool) {
super.resolve(pool);
nameAndTypeIndex = pool.indexOf(nameAndType);
@@ -56,13 +56,13 @@
dos.writeShort(nameAndTypeIndex);
}
- @Override
+
public String toString() {
return "FieldRef: " + className + "#" + nameAndType;
}
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
@@ -72,7 +72,7 @@
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/Attribute.java (working copy)
@@ -29,7 +29,6 @@
this.attributeName = new CPUTF8(attributeName);
}
- @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -52,7 +51,7 @@
protected abstract int getLength();
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ExceptionsAttribute.java (working copy)
@@ -22,6 +22,19 @@
public class ExceptionsAttribute extends Attribute {
+ private static int hashCode(Object[] array) {
+ final int prime = 31;
+ if (array == null)
+ return 0;
+ int result = 1;
+ for (int index = 0; index < array.length; index++) {
+ result = prime * result
+ + (array[index] == null ? 0 : array[index].hashCode());
+ }
+ return result;
+ }
+
+
private transient int[] exceptionIndexes;
private CPClass[] exceptions;
@@ -31,7 +44,7 @@
this.exceptions = exceptions;
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -45,7 +58,7 @@
return true;
}
- @Override
+
protected int getLength() {
return 2 + 2 * exceptions.length;
}
@@ -59,11 +72,11 @@
return result;
}
- @Override
+
public int hashCode() {
- final int PRIME = 31;
+ final int prime = 31;
int result = super.hashCode();
- result = PRIME * result + Arrays.hashCode(exceptions);
+ result = prime * result + ExceptionsAttribute.hashCode(exceptions);
return result;
}
@@ -80,7 +93,7 @@
return "Exceptions:" + exceptions;
}
- @Override
+
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeShort(exceptionIndexes.length);
for (int i = 0; i < exceptionIndexes.length; i++) {
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java (working copy)
@@ -28,7 +28,7 @@
this.utf8 = utf8;
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -45,7 +45,7 @@
return true;
}
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantValueAttribute.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantValueAttribute.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ConstantValueAttribute.java (working copy)
@@ -41,7 +41,7 @@
}
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -58,7 +58,7 @@
return true;
}
- @Override
+
protected int getLength() {
return 2;
}
@@ -67,7 +67,7 @@
return new ClassFileEntry[] { getAttributeName(), entry };
}
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = super.hashCode();
@@ -85,7 +85,7 @@
return "Constant:" + entry;
}
- @Override
+
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeShort(constantIndex);
}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPConstant.java (working copy)
@@ -26,7 +26,7 @@
this.value = value;
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -43,7 +43,7 @@
return true;
}
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPInteger.java (working copy)
@@ -25,12 +25,12 @@
super(ConstantPoolEntry.CP_Integer,value);
}
- @Override
+
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeInt(getNumber().intValue());
}
- @Override
+
public String toString() {
return "Integer: " + getValue();
}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPLong.java (working copy)
@@ -25,12 +25,12 @@
super(ConstantPoolEntry.CP_Long,value);
}
- @Override
+
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeLong(getNumber().longValue());
}
- @Override
+
public String toString() {
return "Long: " + getValue();
}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/SourceFileAttribute.java (working copy)
@@ -30,7 +30,6 @@
this.name = new CPUTF8(name);
}
- @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -47,7 +46,6 @@
return true;
}
- @Override
protected int getLength() {
return 2;
}
@@ -56,7 +54,6 @@
return new ClassFileEntry[] { getAttributeName(), name };
}
- @Override
public int hashCode() {
final int PRIME = 31;
int result = super.hashCode();
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java (working copy)
@@ -37,7 +37,7 @@
this.descriptor = new CPUTF8(descriptor.substring(colon+1));
}
- @Override
+
protected void resolve(ClassConstantPool pool) {
super.resolve(pool);
descriptorIndex = pool.indexOf(descriptor);
@@ -48,18 +48,18 @@
* field_info { u2 access_flags; u2 name_index; u2 descriptor_index; u2
* attributes_count; attribute_info attributes[attributes_count]; }
*/
- @Override
+
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeShort(nameIndex);
dos.writeShort(descriptorIndex);
}
- @Override
+
public String toString() {
return "NameAndType: " + name + "(" + descriptor + ")";
}
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
@@ -68,7 +68,7 @@
return result;
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPFloat.java (working copy)
@@ -24,12 +24,12 @@
super(ConstantPoolEntry.CP_Float,value);
}
- @Override
+
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeFloat(getNumber().floatValue());
}
- @Override
+
public String toString() {
return "Float: " + getValue();
}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPClass.java (working copy)
@@ -33,7 +33,7 @@
this.utf8 = new CPUTF8(name);
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -59,7 +59,7 @@
return new ClassFileEntry[] { utf8, };
}
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPString.java (working copy)
@@ -29,12 +29,12 @@
}
- @Override
+
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeShort(nameIndex);
}
- @Override
+
public String toString() {
return "String: " + getValue();
}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMember.java (working copy)
@@ -45,7 +45,7 @@
}
- @Override
+
protected ClassFileEntry[] getNestedClassFileEntries() {
int attributeCount = attributes.size();
ClassFileEntry[] entries = new ClassFileEntry[attributeCount+2];
@@ -58,7 +58,7 @@
}
- @Override
+
protected void resolve(ClassConstantPool pool) {
super.resolve(pool);
nameIndex = pool.indexOf(name);
@@ -69,12 +69,12 @@
}
}
- @Override
+
public String toString() {
return "Field: " + name + "(" + descriptor + ")";
}
- @Override
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
@@ -86,7 +86,7 @@
}
- @Override
+
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -116,7 +116,7 @@
}
- @Override
+
protected void doWrite(DataOutputStream dos) throws IOException {
dos.writeShort(flags);
dos.writeShort(nameIndex);
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPDouble.java (working copy)
@@ -24,12 +24,12 @@
super(ConstantPoolEntry.CP_Double,value);
}
- @Override
+
protected void writeBody(DataOutputStream dos) throws IOException {
dos.writeDouble(getNumber().doubleValue());
}
- @Override
+
public String toString() {
return "Double: " + getValue();
}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java (working copy)
@@ -134,7 +134,7 @@
}
}
- @Override
+
public long decode(InputStream in) throws IOException, Pack200Exception {
if (d != 0)
throw new Pack200Exception(
@@ -142,7 +142,7 @@
return decode(in, 0);
}
- @Override
+
public long decode(InputStream in, long last) throws IOException,
Pack200Exception {
int n = 0;
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java (revision 0)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java (revision 0)
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.pack200;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * Provides generic JavaBeans support for the Pack/UnpackAdapters
+ */
+public abstract class Pack200Adapter {
+
+ protected static final int DEFAULT_BUFFER_SIZE = 8192;
+
+ private PropertyChangeSupport support = new PropertyChangeSupport(this);
+
+ private SortedMap properties = new TreeMap();
+
+ public SortedMap properties() {
+ return properties;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue,
+ Object newValue) {
+ support.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ support.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * Completion between 0..1
+ * @param value
+ */
+ protected void completed(double value) {
+ firePropertyChange("pack.progress", null, String.valueOf((int)(100*value))); //$NON-NLS-1$
+ }
+}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java (revision 0)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java (revision 0)
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.pack200;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.Pack200.Packer;
+
+
+/**
+ * This class provides the binding between the standard Pack200 interface and the
+ * internal interface for (un)packing. As this uses generics for the SortedMap,
+ * this class must be compiled and run on a Java 1.5 system. However, Java 1.5
+ * is not necessary to use the internal libraries for unpacking.
+ */
+public class Pack200PackerAdapter extends Pack200Adapter implements Packer {
+
+ public void pack(JarFile arg0, OutputStream arg1) throws IOException {
+ throw new Error("Not yet implemented");
+ }
+
+ public void pack(JarInputStream arg0, OutputStream arg1) throws IOException {
+ throw new Error("Not yet implemented");
+ }
+
+}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java (revision 0)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200UnpackerAdapter.java (revision 0)
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.pack200;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Pack200.Unpacker;
+
+import org.apache.harmony.pack200.Pack200Exception;
+import org.apache.harmony.pack200.Segment;
+
+/**
+ * This class provides the binding between the standard Pack200 interface and
+ * the internal interface for (un)packing. As this uses generics for the
+ * SortedMap, this class must be compiled and run on a Java 1.5 system. However,
+ * Java 1.5 is not necessary to use the internal libraries for unpacking.
+ */
+public class Pack200UnpackerAdapter extends Pack200Adapter implements Unpacker {
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.jar.Pack200.Unpacker#unpack(java.io.InputStream,
+ * java.util.jar.JarOutputStream)
+ */
+ public void unpack(InputStream in, JarOutputStream out) throws IOException {
+ if (in == null || out == null)
+ throw new IllegalArgumentException(
+ "Must specify both input and output streams");
+ completed(0);
+ try {
+ while (in.available() > 0) {
+ Segment s = Segment.parse(in);
+ s.writeJar(out, in);
+ out.flush();
+ }
+ } catch (Pack200Exception e) {
+ throw new IOException("Failed to unpack Jar:" + String.valueOf(e));
+ }
+ completed(1);
+ in.close();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.jar.Pack200.Unpacker#unpack(java.io.File,
+ * java.util.jar.JarOutputStream)
+ */
+ public void unpack(File file, JarOutputStream out) throws IOException {
+ if (file == null || out == null)
+ throw new IllegalArgumentException(
+ "Must specify both input and output streams");
+ int size = (int) file.length();
+ int bufferSize = (size > 0 && size < DEFAULT_BUFFER_SIZE ? size
+ : DEFAULT_BUFFER_SIZE);
+ InputStream in = new BufferedInputStream(new FileInputStream(file),
+ bufferSize);
+ unpack(in, out);
+ }
+}
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/build.xml
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/build.xml (revision 493685)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/build.xml (working copy)
@@ -71,7 +71,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -112,6 +148,7 @@
+
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/.settings/org.eclipse.jdt.core.prefs (revision 0)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/.settings/org.eclipse.jdt.core.prefs (revision 0)
@@ -0,0 +1,12 @@
+#Tue Jan 09 09:46:02 GMT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
Index: /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/pack200-java5.README.txt
===================================================================
--- /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/pack200-java5.README.txt (revision 0)
+++ /Users/alex/Documents/Harmony/Workspace/Harmony/trunk/modules/pack200/pack200-java5.README.txt (revision 0)
@@ -0,0 +1,11 @@
+The pack200-java5 is a compiled set of libraries under Java 5. The
+reason why it's checked in as a Jar is to support development of the main
+libraries, which are compiled under 1.4. At build time, the contents of
+the src/main/java5 project should be added to the build (with a 1.5 target)
+and the src/main/java should be compiled with a 1.4 target.
+
+The other approach would be to create two projects; one pack200 project
+and one pack200-java5 project, each with different settings. But given
+the amount of difficulty it's taken to even get the pack200 split out
+from the archive project, I really wouldn't hold my breath about that
+getting anywhere any time soon.