harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r572686 [1/3] - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/pack200/ test/java/org/apache/harmony/pack200/tests/
Date Tue, 04 Sep 2007 13:54:47 GMT
Author: odeakin
Date: Tue Sep  4 06:54:46 2007
New Revision: 572686

URL: http://svn.apache.org/viewvc?rev=572686&view=rev
Log:
Apply patch HARMONY-4734 ([classlib] [pack200] Pack200 - Some refactoring)

Added:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentConstantPool.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java   (with props)
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java?rev=572686&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java Tue Sep  4 06:54:46 2007
@@ -0,0 +1,72 @@
+/*
+ *  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.InputStream;
+import java.io.OutputStream;
+
+/**
+ *
+ */
+public class AttrDefinitionBands extends BandSet {
+    
+    private int[] attributeDefinitionHeader;
+
+    private String[] attributeDefinitionLayout;    
+
+    private String[] attributeDefinitionName;
+
+    private AttributeLayoutMap attributeDefinitionMap;
+
+    private String[] cpUTF8;
+    
+    public AttrDefinitionBands(Segment segment) {
+        super(segment);
+        this.cpUTF8 = segment.getCpBands().getCpUTF8();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.BandSet#pack(java.io.OutputStream)
+     */
+    public void pack(OutputStream outputStream) {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.BandSet#unpack(java.io.InputStream)
+     */
+    public void unpack(InputStream in) throws IOException,
+            Pack200Exception {
+        int attributeDefinitionCount = header.getAttributeDefinitionCount();
+        attributeDefinitionHeader = decodeBandInt("attr_definition_headers",
+                in, Codec.BYTE1, attributeDefinitionCount);
+        attributeDefinitionName = parseReferences("attr_definition_name", in,
+                Codec.UNSIGNED5, attributeDefinitionCount, cpUTF8);
+        attributeDefinitionLayout = parseReferences("attr_definition_layout",
+                in, Codec.UNSIGNED5, attributeDefinitionCount, cpUTF8);
+        if (attributeDefinitionCount > 0)
+            throw new Error("No idea what the adc is for yet");
+        attributeDefinitionMap = new AttributeLayoutMap();
+    }
+
+    public AttributeLayoutMap getAttributeDefinitionMap() {
+        return attributeDefinitionMap;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttrDefinitionBands.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java?rev=572686&r1=572685&r2=572686&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeLayout.java Tue Sep  4 06:54:46 2007
@@ -20,7 +20,6 @@
 // NOTE: Do not extract strings as messages; this code is still a
 // work-in-progress
 // NOTE: Also, don't get rid of 'else' statements for the hell of it ...
-import org.apache.harmony.pack200.Segment.SegmentConstantPool;
 
 public class AttributeLayout implements IMatcher {
 	static class Key {
@@ -111,9 +110,8 @@
 	private static final String[] contextNames = { "Class", "Field", "Method", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 			"Code", }; //$NON-NLS-1$
 
-	private static Object getValue(String layout, long value, Segment segment)
+	private static Object getValue(String layout, long value, SegmentConstantPool pool)
 			throws Pack200Exception {
-		SegmentConstantPool pool = segment.getConstantPool();
 		if (layout.startsWith("R")) { //$NON-NLS-1$
 			// references
 			if (layout.indexOf('N') != -1)
@@ -210,25 +208,25 @@
 		return layout;
 	}
 
-	public Object getValue(long value, Segment segment) throws Pack200Exception {
-		return getValue(layout, value, segment);
+	public Object getValue(long value, SegmentConstantPool pool) throws Pack200Exception {
+		return getValue(layout, value, pool);
 	}
 
-	public Object getValue(long value, String type, Segment segment)
+	public Object getValue(long value, String type, SegmentConstantPool pool)
 			throws Pack200Exception {
 		// TODO This really needs to be better tested, esp. the different types
 		// TODO This should have the ability to deal with RUN stuff too, and
 		// unions
 		if (layout.startsWith("KQ")) { //$NON-NLS-1$
 			if (type.equals("Ljava/lang/String;")) { //$NON-NLS-1$
-				Object value2 = getValue("KS", value, segment); //$NON-NLS-1$
+				Object value2 = getValue("KS", value, pool); //$NON-NLS-1$
 				return value2;
 			} else {
 				return getValue("K" + type + layout.substring(2), value, //$NON-NLS-1$
-						segment);
+						pool);
 			}
 		} else {
-			return getValue(layout, value, segment);
+			return getValue(layout, value, pool);
 		}
 	}
 

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java?rev=572686&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java Tue Sep  4 06:54:46 2007
@@ -0,0 +1,272 @@
+/*
+ *  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.InputStream;
+import java.io.OutputStream;
+
+public abstract class BandSet {
+    
+    public abstract void unpack(InputStream inputStream) throws IOException, Pack200Exception;
+    
+    public abstract void pack(OutputStream outputStream);
+    
+    protected Segment segment;
+    
+    protected SegmentHeader header;
+
+    public BandSet(Segment segment) {
+        this.segment = segment;
+        this.header = segment.getSegmentHeader();
+    }
+
+    /**
+     * Decode a band and return an array of <code>int[]</code> values
+     * 
+     * @param name
+     *            the name of the band (primarily for logging/debugging
+     *            purposes)
+     * @param in
+     *            the InputStream to decode from
+     * @param defaultCodec
+     *            the default codec for this band
+     * @param count
+     *            the number of elements to read
+     * @return an array of decoded <code>int[]</code> values
+     * @throws IOException
+     *             if there is a problem reading from the underlying input
+     *             stream
+     * @throws Pack200Exception
+     *             if there is a problem decoding the value or that the value is
+     *             invalid
+     */
+    public int[] decodeBandInt(String name, InputStream in,
+            BHSDCodec defaultCodec, int count) throws IOException,
+            Pack200Exception {
+        // TODO Might be able to improve this directly.
+        int[] result = new int[count];
+
+        // TODO We need to muck around in the scenario where the first value
+        // read indicates
+        // an uber-codec
+        long[] longResult = decodeBandLong(name, in, defaultCodec, count);
+        for (int i = 0; i < count; i++) {
+            result[i] = (int) longResult[i];
+        }
+        return result;
+    }
+    
+    /**
+     * Decode a band and return an array of <code>long[]</code> values
+     * 
+     * @param name
+     *            the name of the band (primarily for logging/debugging
+     *            purposes)
+     * @param in
+     *            the InputStream to decode from
+     * @param codec
+     *            the default codec for this band
+     * @param count
+     *            the number of elements to read
+     * @return an array of decoded <code>long[]</code> values
+     * @throws IOException
+     *             if there is a problem reading from the underlying input
+     *             stream
+     * @throws Pack200Exception
+     *             if there is a problem decoding the value or that the value is
+     *             invalid
+     */
+    public long[] decodeBandLong(String name, InputStream in, BHSDCodec codec,
+            int count) throws IOException, Pack200Exception {
+        if (codec.getB() == 1 || count == 0) {
+            return codec.decode(count, in);
+        }
+        long[] getFirst = codec.decode(1, in);
+        if (getFirst.length == 0) {
+            return getFirst;
+        }
+        long first = getFirst[0];
+        if (codec.isSigned() && first >= -256 && first <= -1) {
+            // Non-default codec should be used
+            Codec nonDefaultCodec = CodecEncoding.getCodec((int) (-1 - first),
+                    header.getBandHeadersInputStream(), codec);
+            return nonDefaultCodec.decode(count, in);
+        } else if (!codec.isSigned() && first >= codec.getL()
+                && first <= codec.getL() + 255) {
+            // Non-default codec should be used
+            Codec nonDefaultCodec = CodecEncoding.getCodec((int) first
+                    - codec.getL(), header.getBandHeadersInputStream(), codec);
+            return nonDefaultCodec.decode(count, in);
+        } else {
+            // First element should not be discarded
+            return codec.decode(count - 1, in, first);
+        }
+    }
+    
+    public long[] parseFlags(String name, InputStream in, int count,
+            Codec codec, boolean hasHi) throws IOException, Pack200Exception {
+        return parseFlags(name, in, 1, new int[] { count }, (hasHi ? codec
+                : null), codec)[0];
+    }
+
+    public long[][] parseFlags(String name, InputStream in, int count,
+            int counts[], Codec codec, boolean hasHi) throws IOException,
+            Pack200Exception {
+        return parseFlags(name, in, count, counts, (hasHi ? codec : null),
+                codec);
+    }
+
+    public long[][] parseFlags(String name, InputStream in, int count,
+            int counts[], Codec hiCodec, Codec loCodec) throws IOException,
+            Pack200Exception {
+        // TODO Move away from decoding into a parseBand type structure
+        if (count == 0) {
+            return new long[][] { {} };
+        }
+        long[][] result = new long[count][];
+        // TODO What happens when the decode here indicates a different
+        // encoding?
+        // TODO Move this to a decodeBandInt
+        long last = 0;
+        for (int j = 0; j < count; j++) {
+            result[j] = new long[counts[j]];
+            for (int i = 0; i < counts[j] && hiCodec != null; i++) {
+                last = hiCodec.decode(in, last);
+                result[j][i] = last << 32;
+            }
+        }
+        last = 0;
+        for (int j = 0; j < count; j++)
+            for (int i = 0; i < counts[j]; i++) {
+                last = loCodec.decode(in, last);
+                result[j][i] = result[j][i] | last;
+            }
+        // TODO Remove debugging code
+        debug("Parsed *" + name + " (" + result.length + ")");
+        return result;
+    }
+    
+    /**
+     * Helper method to parse <i>count</i> references from <code>in</code>,
+     * using <code>codec</code> to decode the values as indexes into
+     * <code>reference</code> (which is populated prior to this call). An
+     * exception is thrown if a decoded index falls outside the range
+     * [0..reference.length-1].
+     * 
+     * @param name
+     *            TODO
+     * @param in
+     *            the input stream to read from
+     * @param codec
+     *            the codec to use for decoding
+     * @param count
+     *            the number of references to decode
+     * @param reference
+     *            the array of values to use for the indexes; often
+     *            {@link #cpUTF8}
+     * 
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    public String[] parseReferences(String name, InputStream in,
+            BHSDCodec codec, int count, String[] reference) throws IOException,
+            Pack200Exception {
+        return parseReferences(name, in, codec, 1, new int[] { count },
+                reference)[0];
+    }
+    
+    /**
+     * Helper method to parse <i>count</i> references from <code>in</code>,
+     * using <code>codec</code> to decode the values as indexes into
+     * <code>reference</code> (which is populated prior to this call). An
+     * exception is thrown if a decoded index falls outside the range
+     * [0..reference.length-1]. Unlike the other parseReferences, this
+     * post-processes the result into an array of results.
+     * 
+     * @param name
+     *            TODO
+     * @param in
+     *            the input stream to read from
+     * @param codec
+     *            the codec to use for decoding
+     * @param count
+     *            the number of references to decode
+     * @param reference
+     *            the array of values to use for the indexes; often
+     *            {@link #cpUTF8}
+     * 
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    protected String[][] parseReferences(String name, InputStream in,
+            BHSDCodec codec, int count, int counts[], String[] reference)
+            throws IOException, Pack200Exception {
+        if (count == 0) {
+            return new String[][] { {} };
+        }
+        String[][] result = new String[count][];
+        int sum = 0;
+        for (int i = 0; i < count; i++) {
+            result[i] = new String[counts[i]];
+            sum += counts[i];
+        }
+        // TODO Merge the decode and parsing of a multiple structure into one
+        String[] result1 = new String[sum];
+        int[] decode = decodeBandInt(name, in, codec, sum);
+        for (int i1 = 0; i1 < sum; i1++) {
+            int index = decode[i1];
+            if (index < 0 || index >= reference.length)
+                throw new Pack200Exception(
+                        "Something has gone wrong during parsing references");
+            result1[i1] = reference[index];
+        }
+        String[] refs = result1;
+        // TODO Merge the decode and parsing of a multiple structure into one
+        int pos = 0;
+        for (int i = 0; i < count; i++) {
+            int num = counts[i];
+            result[i] = new String[num];
+            System.arraycopy(refs, pos, result[i], 0, num);
+            pos += num;
+        }
+        return result;
+    }
+
+    /**
+     * This is a local debugging message to aid the developer in writing this
+     * class. It will be removed before going into production. If the property
+     * 'debug.pack200' is set, this will generate messages to stderr; otherwise,
+     * it will be silent.
+     * 
+     * @param message
+     * @deprecated this should be removed from production code
+     */
+    protected void debug(String message) {
+        if (System.getProperty("debug.pack200") != null) {
+            System.err.println(message);
+        }
+    }
+
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java?rev=572686&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java Tue Sep  4 06:54:46 2007
@@ -0,0 +1,198 @@
+/*
+ *  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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+import org.apache.harmony.pack200.bytecode.ByteCode;
+import org.apache.harmony.pack200.bytecode.CodeAttribute;
+
+/**
+ *
+ */
+public class BcBands extends BandSet {
+    
+    private byte[][][] methodByteCodePacked;
+
+    /**
+     * @param header
+     */
+    public BcBands(Segment segment) {
+        super(segment);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.BandSet#pack(java.io.OutputStream)
+     */
+    public void pack(OutputStream outputStream) {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.BandSet#unpack(java.io.InputStream)
+     */
+    public void unpack(InputStream in) throws IOException,
+            Pack200Exception {
+        
+       AttributeLayoutMap attributeDefinitionMap = segment.getAttrDefinitionBands().getAttributeDefinitionMap();
+       int classCount = header.getClassCount();
+       long[][] methodFlags = segment.getClassBands().getMethodFlags();
+       int[] codeMaxNALocals = segment.getClassBands().getCodeMaxNALocals();
+       int[] codeMaxStack = segment.getClassBands().getCodeMaxStack();
+       ArrayList[][] methodAttributes = segment.getClassBands().getMethodAttributes();
+       String[][] methodDescr = segment.getClassBands().getMethodDescr();
+       
+       int bcStringRefCount = 0;
+       int bcInitRefCount = 0;
+       int bcFieldRefCount = 0;
+       int bcThisFieldCount = 0;
+       int bcMethodRefCount = 0;
+       int bcIMethodRefCount = 0;
+
+       AttributeLayout abstractModifier = attributeDefinitionMap
+               .getAttributeLayout(AttributeLayout.ACC_ABSTRACT,
+                       AttributeLayout.CONTEXT_METHOD);
+       AttributeLayout nativeModifier = attributeDefinitionMap
+               .getAttributeLayout(AttributeLayout.ACC_NATIVE,
+                       AttributeLayout.CONTEXT_METHOD);
+       AttributeLayout staticModifier = attributeDefinitionMap
+               .getAttributeLayout(AttributeLayout.ACC_STATIC,
+                       AttributeLayout.CONTEXT_METHOD);
+       methodByteCodePacked = new byte[classCount][][];
+       int bcParsed = 0;
+       for (int c = 0; c < classCount; c++) {
+           int numberOfMethods = methodFlags[c].length;
+           methodByteCodePacked[c] = new byte[numberOfMethods][];
+           for (int m = 0; m < numberOfMethods; m++) {
+               long methodFlag = methodFlags[c][m];
+               if (!abstractModifier.matches(methodFlag)
+                       && !nativeModifier.matches(methodFlag)) {
+                   ByteArrayOutputStream codeBytes = new ByteArrayOutputStream();
+                   byte code;
+                   while ((code = (byte) (0xff & in.read())) != -1)
+                       codeBytes.write(code);
+                   methodByteCodePacked[c][m] = codeBytes.toByteArray();
+                   bcParsed += methodByteCodePacked[c][m].length;
+                   for (int i = 0; i < methodByteCodePacked[c][m].length; i++) {
+                       int codePacked = 0xff & methodByteCodePacked[c][m][i];
+                       // TODO a lot of this needs to be encapsulated in the
+                       // place that
+                       // calculates what the arguments are, since (a) it will
+                       // need
+                       // to know where to get them, and (b) what to do with
+                       // them
+                       // once they've been gotten. But that's for another
+                       // time.
+                       switch (codePacked) {
+                       case 18: // (a)ldc
+                           bcStringRefCount++;
+                           break;
+                       case 178: // getstatic
+                       case 179: // putstatic
+                       case 180: // getfield
+                       case 181: // putfield
+                           bcFieldRefCount++;
+                           break;
+                       case 182: // invokevirtual
+                       case 183: // invokespecial
+                       case 184: // invokestatic
+                           bcMethodRefCount++;
+                           break;
+                       case 185: // invokeinterface
+                           bcIMethodRefCount++;
+                           break;
+                       case 202: // getstatic_this
+                       case 203: // putstatic_this
+                       case 204: // getfield_this
+                       case 205: // putfield_this
+                           bcThisFieldCount++;
+                           break;
+                       case 231: // invoke_special_init
+                           bcInitRefCount++;
+                           break;
+
+                       default: // unhandled specifically at this stage
+                           debug("Found unhandled "
+                            + ByteCode.getByteCode(codePacked));
+                       }
+                   }
+               }
+            }
+        }
+       // other bytecode bands
+       debug("Parsed *bc_codes (" + bcParsed + ")");
+       debug("unimplemented bc_case_count");
+       debug("unimplemented bc_case_value");
+       debug("unimplemented bc_byte");
+       debug("unimplemented bc_short");
+       debug("unimplemented bc_local");
+       debug("unimplemented bc_label");
+       debug("unimplemented bc_intref");
+       debug("unimplemented bc_floatref");
+       debug("unimplemented bc_longref");
+       debug("unimplemented bc_doubleref");
+       int[] bcStringRef = decodeBandInt("bc_stringref", in, Codec.DELTA5,
+               bcStringRefCount);
+       debug("unimplemented bc_classref");
+       int[] bcFieldRef = decodeBandInt("bc_fieldref", in, Codec.DELTA5,
+               bcFieldRefCount);
+       int[] bcMethodRef = decodeBandInt("bc_methodref", in, Codec.UNSIGNED5,
+               bcMethodRefCount);
+       int[] bcIMethodRef = decodeBandInt("bc_imethodref", in, Codec.DELTA5,
+               bcIMethodRefCount);
+       int[] bcThisField = decodeBandInt("bc_thisfield", in, Codec.UNSIGNED5,
+               bcThisFieldCount);
+       debug("unimplemented bc_superfield");
+       debug("unimplemented bc_thismethod");
+       debug("unimplemented bc_supermethod");
+       debug("unimplemented bc_initref");
+       int[] bcInitRef = decodeBandInt("bc_initref", in, Codec.UNSIGNED5,
+               bcInitRefCount);
+       debug("unimplemented bc_escref");
+       debug("unimplemented bc_escrefsize");
+       debug("unimplemented bc_escsize");
+       debug("unimplemented bc_escbyte");
+       int i = 0;
+       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]);
+                   // TODO Move creation of code attribute until after constant
+                   // pool resolved
+                   CodeAttribute attr = new CodeAttribute(maxStack, maxLocal,
+                           methodByteCodePacked[c][m]);
+                   methodAttributes[c][m].add(attr);
+                   i++;
+               }
+           }
+       }
+
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java?rev=572686&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java Tue Sep  4 06:54:46 2007
@@ -0,0 +1,523 @@
+/*
+ *  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.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+import org.apache.harmony.pack200.bytecode.CPClass;
+import org.apache.harmony.pack200.bytecode.ConstantValueAttribute;
+import org.apache.harmony.pack200.bytecode.ExceptionsAttribute;
+
+/**
+ *
+ */
+public class ClassBands extends BandSet {
+
+    private int classAttrCount;
+
+    private int[] classFieldCount;
+
+    private long[] classFlags;
+
+    private String[][] classInterfaces;
+
+    private int[] classMethodCount;
+
+    private String[] classSuper;
+    
+    private String[] classThis;
+
+    private int[] codeHandlerCount;
+
+    private int[] codeMaxNALocals;
+
+    private int[] codeMaxStack;
+
+    private int fieldAttrCount;
+
+    private ArrayList[][] fieldAttributes;
+
+    private String[][] fieldDescr;
+
+    private long[][] fieldFlags;
+    
+    private int methodAttrCount;
+
+    private ArrayList[][] methodAttributes;
+    
+    private String[][] methodDescr;
+
+    private ExceptionsAttribute[][] methodExceptions;
+
+    private long[][] methodFlags;
+
+    private AttributeLayoutMap attrMap;
+
+    private CpBands cpBands;
+    
+    /**
+     * @param header
+     */
+    public ClassBands(Segment segment){
+        super(segment);
+        this.attrMap = segment.getAttrDefinitionBands().getAttributeDefinitionMap();
+        this.cpBands = segment.getCpBands();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.harmony.pack200.BandSet#pack(java.io.OutputStream)
+     */
+    public void pack(OutputStream outputStream) {
+        // TODO Auto-generated method stub
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.harmony.pack200.BandSet#unpack(java.io.InputStream)
+     */
+    public void unpack(InputStream in) throws IOException,
+            Pack200Exception {
+        int classCount = header.getClassCount();
+        classThis = parseReferences("class_this", in, Codec.DELTA5, classCount,
+                cpBands.getCpClass());
+        classSuper = parseReferences("class_super", in, Codec.DELTA5,
+                classCount, cpBands.getCpClass());
+        classInterfaces = new String[classCount][];
+        int[] classInterfaceLengths = decodeBandInt("class_interface_count",
+                in, Codec.DELTA5, classCount);
+        // for (int i = 0; i < classCount; i++) {
+        classInterfaces = parseReferences("class_interface", in, Codec.DELTA5,
+                classCount, classInterfaceLengths, cpBands.getCpClass());
+        // }
+        classFieldCount = decodeBandInt("class_field_count", in, Codec.DELTA5,
+                classCount);
+        classMethodCount = decodeBandInt("class_method_count", in,
+                Codec.DELTA5, classCount);
+        parseFieldBands(in);
+        parseMethodBands(in);
+        parseClassAttrBands(in);
+        parseCodeBands(in);
+
+    }
+
+    private void parseFieldBands(InputStream in) throws IOException,
+            Pack200Exception {
+        int classCount = header.getClassCount();
+        SegmentOptions options = header.getOptions();
+        fieldDescr = parseReferences("field_descr", in, Codec.DELTA5,
+                classCount, classFieldCount, cpBands.getCpDescriptor());
+        fieldFlags = parseFlags("field_flags", in, classCount, classFieldCount,
+                Codec.UNSIGNED5, options.hasFieldFlagsHi());
+        for (int i = 0; i < classCount; i++) {
+            for (int j = 0; j < fieldFlags[i].length; j++) {
+                long flag = fieldFlags[i][j];
+                if ((flag & (1 << 16)) != 0)
+                    fieldAttrCount++;
+            }
+        }
+        if (fieldAttrCount > 0)
+            throw new Error(
+                    "There are attribute flags, and I don't know what to do with them");
+        debug("unimplemented field_attr_indexes");
+        debug("unimplemented field_attr_calls");
+        AttributeLayout layout = attrMap.getAttributeLayout(
+                        "ConstantValue", AttributeLayout.CONTEXT_FIELD);
+        Codec codec = layout.getCodec();
+        fieldAttributes = new ArrayList[classCount][];
+        for (int i = 0; i < classCount; i++) {
+            fieldAttributes[i] = new ArrayList[fieldFlags[i].length];
+            for (int j = 0; j < fieldFlags[i].length; j++) {
+                fieldAttributes[i][j] = new ArrayList();
+                long flag = fieldFlags[i][j];
+                if (layout.matches(flag)) {
+                    // we've got a value to read
+                    long result = codec.decode(in);
+                    String desc = fieldDescr[i][j];
+                    int colon = desc.indexOf(':');
+                    // String name = desc.substring(0, colon);
+                    String type = desc.substring(colon + 1);
+                    // TODO Got to get better at this ... in any case, it should
+                    // be e.g. KIB or KIH
+                    if (type.equals("B") || type.equals("H"))
+                        type = "I";
+                    Object value = layout.getValue(result, type, cpBands.getConstantPool());
+                    fieldAttributes[i][j]
+                            .add(new ConstantValueAttribute(value));
+                    debug("Processed value " + value + " for ConstantValue");
+                }
+            }
+        }
+        debug("unimplemented field_Signature_RS");
+        parseMetadataBands(AttributeLayout.CONTEXT_FIELD);
+    }
+
+    private void parseMethodBands(InputStream in) throws IOException,
+            Pack200Exception {
+        int classCount = header.getClassCount();
+        SegmentOptions options = header.getOptions();
+        methodDescr = parseReferences("method_descr", in, Codec.MDELTA5,
+                classCount, classMethodCount, cpBands.getCpDescriptor());
+        methodFlags = parseFlags("method_flags", in, classCount,
+                classMethodCount, Codec.UNSIGNED5, options.hasMethodFlagsHi());
+        for (int i = 0; i < classCount; i++) {
+            for (int j = 0; j < methodFlags[i].length; j++) {
+                long flag = methodFlags[i][j];
+                if ((flag & (1 << 16)) != 0)
+                    methodAttrCount++;
+            }
+        }
+        if (methodAttrCount > 0)
+            throw new Error(
+                    "There are method attribute flags, and I don't know what to do with them");
+        debug("unimplemented method_attr_count");
+        debug("unimplemented method_attr_indexes");
+        debug("unimplemented method_attr_calls");
+        // assign empty method attributes
+        methodAttributes = new ArrayList[classCount][];
+        for (int i = 0; i < classCount; i++) {
+            methodAttributes[i] = new ArrayList[methodFlags[i].length];
+            for (int j = 0; j < methodFlags[i].length; j++) {
+                methodAttributes[i][j] = new ArrayList();
+            }
+        }
+        parseAttributeMethodExceptions(in);
+        parseAttributeMethodSignature(in);
+        parseMetadataBands(AttributeLayout.CONTEXT_METHOD);
+    }
+    
+    /**
+     * @param in
+     * @throws Pack200Exception
+     * @throws IOException
+     */
+    private void parseAttributeMethodExceptions(InputStream in)
+            throws Pack200Exception, IOException {
+        // TODO Should refactor this stuff into the layout somehow
+        int classCount = header.getClassCount();
+        AttributeLayout layout = attrMap.getAttributeLayout(
+                "Exceptions", AttributeLayout.CONTEXT_METHOD);
+        Codec codec = layout.getCodec();
+        methodExceptions = new ExceptionsAttribute[classCount][];
+        int[][] numExceptions = new int[classCount][];
+        for (int i = 0; i < classCount; i++) {
+            numExceptions[i] = new int[methodFlags[i].length];
+            for (int j = 0; j < methodFlags[i].length; j++) {
+                long flag = methodFlags[i][j];
+                if (layout.matches(flag)) {
+                    numExceptions[i][j] = (int) codec.decode(in);
+                }
+            }
+        }
+        for (int i = 0; i < classCount; i++) {
+            methodExceptions[i] = new ExceptionsAttribute[methodFlags[i].length];
+            for (int j = 0; j < methodFlags[i].length; j++) {
+                long flag = methodFlags[i][j];
+                int n = numExceptions[i][j];
+                if (n > 0) {
+                   CPClass[] exceptions = new CPClass[n];
+                   if (layout.matches(flag)) {
+                       for (int k = 0; k < n; k++) {
+                           long result = codec.decode(in);
+                           exceptions[k] = new CPClass(cpBands.getCpClass()[(int) result]);
+                       }
+                   }
+                   methodExceptions[i][j] = new ExceptionsAttribute(exceptions);
+                   methodAttributes[i][j].add(methodExceptions[i][j]);
+               }
+            }
+        }
+    }
+    
+
+    /**
+     * @param name
+     * @param flags
+     * @throws Pack200Exception
+     */
+    private void parseAttributeUnknown(String name, int context, long[][] flags)
+            throws Pack200Exception {
+        debug("Parsing unknown attributes for " + name);
+        AttributeLayout layout = attrMap.getAttributeLayout(
+                name, context);
+       int count = SegmentUtils.countMatches(flags, layout);
+       if (count > 0)
+           throw new Error("We've got data for " + name
+                + " and we don't know what to do with it (yet)");
+    }
+
+    /**
+     * @param in
+     * 
+     */
+    private void parseAttributeMethodSignature(InputStream in)
+            throws Pack200Exception, IOException {
+        parseAttributeUnknown(AttributeLayout.ATTRIBUTE_SIGNATURE,
+                AttributeLayout.CONTEXT_METHOD, methodFlags);
+    }
+
+    private void parseClassAttrBands(InputStream in) throws IOException,
+            Pack200Exception {
+        int classCount = header.getClassCount();
+        SegmentOptions options = header.getOptions();
+        classFlags = parseFlags("class_flags", in, classCount, Codec.UNSIGNED5,
+                options.hasClassFlagsHi());
+        for (int i = 0; i < classCount; i++) {
+            long flag = classFlags[i];
+            if ((flag & (1 << 16)) != 0)
+                classAttrCount++;
+        }
+        if (classAttrCount > 0)
+            throw new Error(
+                    "There are attribute flags, and I don't know what to do with them");
+        debug("unimplemented class_attr_count");
+        debug("unimplemented class_attr_indexes");
+        debug("unimplemented class_attr_calls");
+        AttributeLayout layout = attrMap.getAttributeLayout(
+                        AttributeLayout.ATTRIBUTE_SOURCE_FILE,
+                        AttributeLayout.CONTEXT_CLASS);
+        for (int i = 0; i < classCount; i++) {
+            long flag = classFlags[i];
+            if (layout.matches(flag)) {
+                // we've got a value to read
+                // TODO File this as a sourcefile attribute and don't generate
+                // everything below
+                long result = layout.getCodec().decode(in);
+                Object value = layout.getValue(result, cpBands.getConstantPool());
+                debug("Processed value " + value + " for SourceFile");
+            }
+        }
+        debug("unimplemented class_EnclosingMethod_RC");
+        debug("unimplemented class_EnclosingMethod_RDN");
+        debug("unimplemented class_Signature_RS");
+        parseMetadataBands(AttributeLayout.CONTEXT_CLASS);
+        debug("unimplemented class_InnerClasses_N");
+        debug("unimplemented class_InnerClasses_RC");
+        debug("unimplemented class_InnerClasses_F");
+        debug("unimplemented class_InnerClasses_outer_RCN");
+        debug("unimplemented class_InnerClasses_inner_RCN");
+        debug("unimplemented class_file_version_minor_H");
+        debug("unimplemented class_file_version_major_H");
+    }
+    
+
+    private void parseCodeBands(InputStream in) throws Pack200Exception,
+            IOException {
+        AttributeLayout layout = attrMap.getAttributeLayout(
+                AttributeLayout.ATTRIBUTE_CODE, AttributeLayout.CONTEXT_METHOD);
+
+        int codeBands = SegmentUtils.countMatches(methodFlags, layout);
+        int[] codeHeaders = decodeBandInt("code_headers", in, Codec.BYTE1,
+                codeBands);
+        int codeSpecialHeader = 0;
+        for (int i = 0; i < codeBands; i++) {
+            if (codeHeaders[i] == 0)
+                codeSpecialHeader++;
+        }
+        int[] codeMaxStackSpecials = decodeBandInt("code_max_stack", in,
+                Codec.UNSIGNED5, codeSpecialHeader);
+        int[] codeMaxNALocalsSpecials = decodeBandInt("code_max_na_locals", in,
+                Codec.UNSIGNED5, codeSpecialHeader);
+        int[] codeHandlerCountSpecials = decodeBandInt("code_handler_count",
+                in, Codec.UNSIGNED5, codeSpecialHeader);
+
+        codeMaxStack = new int[codeBands];
+        codeMaxNALocals = new int[codeBands];
+        codeHandlerCount = new int[codeBands];
+        int special = 0;
+        for (int i = 0; i < codeBands; i++) {
+            int header = 0xff & codeHeaders[i];
+            if (header < 0) {
+                throw new IllegalStateException("Shouldn't get here");
+            } else if (header == 0) {
+                codeMaxStack[i] = codeMaxStackSpecials[special];
+                codeMaxNALocals[i] = codeMaxNALocalsSpecials[special];
+                codeHandlerCount[i] = codeHandlerCountSpecials[special];
+                special++;
+            } else if (header <= 144) {
+                codeMaxStack[i] = (header - 1) % 12;
+                codeMaxNALocals[i] = (header - 1) / 12;
+                codeHandlerCount[i] = 0;
+            } else if (header <= 208) {
+                codeMaxStack[i] = (header - 145) % 8;
+                codeMaxNALocals[i] = (header - 145) / 8;
+                codeHandlerCount[i] = 1;
+            } else if (header <= 255) {
+                codeMaxStack[i] = (header - 209) % 7;
+                codeMaxNALocals[i] = (header - 209) / 7;
+                codeHandlerCount[i] = 2;
+            } else {
+                throw new IllegalStateException("Shouldn't get here either");
+            }
+        }
+        debug("unimplemented code_headers");
+        debug("unimplemented code_max_stack");
+        debug("unimplemented code_max_na_locals");
+        debug("unimplemented code_hander_count");
+        debug("unimplemented code_hander_start_P");
+        debug("unimplemented code_hander_end_PO");
+        debug("unimplemented code_hander_catch_PO");
+        debug("unimplemented code_hander_class_RC");
+        parseCodeAttrBands(in);
+    }
+    
+
+    private void parseCodeAttrBands(InputStream in) {
+        debug("unimplemented code_flags");
+        debug("unimplemented code_attr_count");
+        debug("unimplemented code_attr_indexes");
+        debug("unimplemented code_attr_calls");
+        debug("unimplemented code_LineNumberTable_N");
+        debug("unimplemented code_LineNumberTable_bci_P");
+        debug("unimplemented code_LineNumberTable_line");
+        String[] types = { "LocalVariableTable", "LocalVariableTypeTable" };
+        for (int i = 0; i < types.length; i++) {
+            String type = types[i];
+            debug("unimplemented code_" + type + "_N");
+            debug("unimplemented code_" + type + "_bci_P");
+            debug("unimplemented code_" + type + "_span_O");
+            debug("unimplemented code_" + type + "_name_RU");
+            debug("unimplemented code_" + type + "_type_RS");
+            debug("unimplemented code_" + type + "_slot");
+        }
+    }
+
+    private void parseMetadataBands(int context) throws Pack200Exception {
+        String[] RxA;
+        if (AttributeLayout.CONTEXT_METHOD == context) {
+            RxA = new String[] { "RVA", "RIA", "RVPA", "RIPA", "AD" };
+        } else if (AttributeLayout.CONTEXT_FIELD == context
+                || AttributeLayout.CONTEXT_CLASS == context) {
+            RxA = new String[] { "RVA", "RIA" };
+        } else {
+            throw new Pack200Exception("Unknown type of metadata unit "
+                 + context);
+        }
+        // AttributeLayout layout =
+        // map.get(RuntimeVisibleAnnotations,class/field/method as int)
+        // foreachheader ...
+        // if layout.matches(header[n] or whatever)
+        String contextName = (AttributeLayout.CONTEXT_METHOD == context ? "method"
+                : (AttributeLayout.CONTEXT_FIELD == context ? "field"
+                        : (AttributeLayout.CONTEXT_CLASS == context ? "class"
+                                : "unkowon")));
+        for (int i = 0; i < RxA.length; i++) {
+            String rxa = RxA[i];
+            if (rxa.indexOf("P") >= 0) {
+                debug("unimplemented " + contextName + "_" + rxa + "_param_NB");
+            }
+            if (!rxa.equals("AD")) {
+                debug("unimplemented " + contextName + "_" + rxa + "_anno_N");
+                debug("unimplemented " + contextName + "_" + rxa + "_type_RS");
+                debug("unimplemented " + contextName + "_" + rxa + "_pair_N");
+                debug("unimplemented " + contextName + "_" + rxa + "_name_RU");
+            }
+            debug("unimplemented " + contextName + "_" + rxa + "_T");
+            debug("unimplemented " + contextName + "_" + rxa + "_caseI_KI");
+            debug("unimplemented " + contextName + "_" + rxa + "_caseD_KD");
+            debug("unimplemented " + contextName + "_" + rxa + "_caseF_KF");
+            debug("unimplemented " + contextName + "_" + rxa + "_caseJ_KJ");
+            debug("unimplemented " + contextName + "_" + rxa + "_casec_RS");
+            debug("unimplemented " + contextName + "_" + rxa + "_caseet_RS");
+            debug("unimplemented " + contextName + "_" + rxa + "_caseec_RU");
+            debug("unimplemented " + contextName + "_" + rxa + "_cases_RU");
+            debug("unimplemented " + contextName + "_" + rxa + "_casearray_N");
+            debug("unimplemented " + contextName + "_" + rxa + "_nesttype_RS");
+            debug("unimplemented " + contextName + "_" + rxa + "_nestpair_N");
+            debug("unimplemented " + contextName + "_" + rxa + "_nestname_RU");
+        }
+    }
+
+    public int getClassAttrCount() {
+        return classAttrCount;
+    }
+
+    public int[] getClassFieldCount() {
+        return classFieldCount;
+    }
+
+    public long[] getClassFlags() {
+        return classFlags;
+    }
+
+    public String[][] getClassInterfaces() {
+        return classInterfaces;
+    }
+
+    public int[] getClassMethodCount() {
+        return classMethodCount;
+    }
+
+    public String[] getClassSuper() {
+        return classSuper;
+    }
+
+    public String[] getClassThis() {
+        return classThis;
+    }
+
+    public int[] getCodeMaxNALocals() {
+        return codeMaxNALocals;
+    }
+
+    public int[] getCodeMaxStack() {
+        return codeMaxStack;
+    }
+
+    public int getFieldAttrCount() {
+        return fieldAttrCount;
+    }
+
+    public ArrayList[][] getFieldAttributes() {
+        return fieldAttributes;
+    }
+
+    public String[][] getFieldDescr() {
+        return fieldDescr;
+    }
+
+    public long[][] getFieldFlags() {
+        return fieldFlags;
+    }
+
+    public int getMethodAttrCount() {
+        return methodAttrCount;
+    }
+
+    public ArrayList[][] getMethodAttributes() {
+        return methodAttributes;
+    }
+
+    public String[][] getMethodDescr() {
+        return methodDescr;
+    }
+
+    public ExceptionsAttribute[][] getMethodExceptions() {
+        return methodExceptions;
+    }
+
+    public long[][] getMethodFlags() {
+        return methodFlags;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java?rev=572686&r1=572685&r2=572686&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Codec.java Tue Sep  4 06:54:46 2007
@@ -227,4 +227,32 @@
 		}
 		return result;
 	}
+    
+    /**
+     * Decodes a sequence of <code>n</code> values from <code>in</code>.
+     * 
+     * @param n
+     *            the number of values to decode
+     * @param in
+     *            the input stream to read from
+     * @param firstValue
+     *            the first value in the band if it has already been read
+     * @return an array of <code>long</code> values corresponding to values
+     *         decoded, with firstValue as the first value in the array.
+     * @throws IOException
+     *             if there is a problem reading from the underlying input
+     *             stream
+     * @throws Pack200Exception
+     *             if there is a problem decoding the value or that the value is
+     *             invalid
+     */
+    public long[] decode(int n, InputStream in, long firstValue) throws IOException,
+            Pack200Exception {
+        long result[] = new long[n + 1];
+        long last = 0;
+        for(int i=1;i<n+1;i++) {
+            result[i] = last = decode(in,last);
+        }
+        return result;
+    }
 }

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java?rev=572686&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java Tue Sep  4 06:54:46 2007
@@ -0,0 +1,439 @@
+/*
+ *  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.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+public class CpBands extends BandSet {
+    
+    public SegmentConstantPool getConstantPool() {
+        return pool;
+    }
+    
+
+    private final SegmentConstantPool pool = new SegmentConstantPool(this);
+
+    private String[] cpClass;
+
+    private String[] cpDescriptor;
+
+    private double[] cpDouble;
+
+    private String[] cpFieldClass;
+
+    private Object cpFieldDescriptor;
+
+    private float[] cpFloat;
+
+    private String[] cpIMethodClass;
+
+    private String[] cpIMethodDescriptor;
+
+    private int[] cpInt;
+
+    private long[] cpLong;
+
+    private String[] cpMethodClass;
+
+    private String[] cpMethodDescriptor;
+
+    private String[] cpSignature;
+
+    private String[] cpString;
+
+    private String[] cpUTF8;
+
+    
+    public CpBands(Segment segment) {
+        super(segment);
+    }
+    
+    public void unpack(InputStream in) throws IOException, Pack200Exception {
+        parseCpUtf8(in);
+        parseCpInt(in);
+        parseCpFloat(in);
+        parseCpLong(in);
+        parseCpDouble(in);
+        parseCpString(in);
+        parseCpClass(in);
+        parseCpSignature(in);
+        parseCpDescriptor(in);
+        parseCpField(in);
+        parseCpMethod(in);
+        parseCpIMethod(in);
+    }
+
+    public void pack(OutputStream outputStream) {
+        
+    }
+    
+    /**
+     * Parses the constant pool class names, using {@link #cpClassCount} to
+     * populate {@link #cpClass} from {@link #cpUTF8}.
+     * 
+     * @param in
+     *            the input stream to read from
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    private void parseCpClass(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpClassCount = header.getCpClassCount();
+        cpClass = parseReferences("cp_Class", in, Codec.UDELTA5, cpClassCount,
+                cpUTF8);
+    }
+
+
+    /**
+     * Parses the constant pool descriptor definitions, using
+     * {@link #cpDescriptorCount} to populate {@link #cpDescriptor}. For ease
+     * of use, the cpDescriptor is stored as a string of the form <i>name:type</i>,
+     * largely to make it easier for representing field and method descriptors
+     * (e.g. <code>out:java.lang.PrintStream</code>) in a way that is
+     * compatible with passing String arrays.
+     * 
+     * @param in
+     *            the input stream to read from
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    private void parseCpDescriptor(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpDescriptorCount = header.getCpDescriptorCount();
+        String[] cpDescriptorNames = parseReferences("cp_Descr_name", in,
+                Codec.DELTA5, cpDescriptorCount, cpUTF8);
+        String[] cpDescriptorTypes = parseReferences("cp_Descr_type", in,
+                Codec.UDELTA5, cpDescriptorCount, cpSignature);
+        cpDescriptor = new String[cpDescriptorCount];
+        for (int i = 0; i < cpDescriptorCount; i++) {
+            cpDescriptor[i] = cpDescriptorNames[i] + ":" + cpDescriptorTypes[i]; //$NON-NLS-1$
+        }
+    }
+
+    private void parseCpDouble(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpDoubleCount = header.getCpDoubleCount();
+        cpDouble = new double[cpDoubleCount];
+        long[] hiBits = decodeBandLong("cp_Double_hi", in, Codec.UDELTA5,
+                cpDoubleCount);
+        long[] loBits = decodeBandLong("cp_Double_lo", in, Codec.DELTA5,
+                cpDoubleCount);
+        for (int i = 0; i < cpDoubleCount; i++) {
+            cpDouble[i] = Double.longBitsToDouble(hiBits[i] << 32 | loBits[i]);
+        }
+    }
+
+    /**
+     * Parses the constant pool field definitions, using {@link #cpFieldCount}
+     * to populate {@link #cpFieldClass} and {@link #cpFieldDescriptor}.
+     * 
+     * @param in
+     *            the input stream to read from
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    private void parseCpField(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpFieldCount = header.getCpFieldCount();
+        cpFieldClass = parseReferences("cp_Field_class", in, Codec.DELTA5,
+                cpFieldCount, cpClass);
+        cpFieldDescriptor = parseReferences("cp_Field_desc", in, Codec.UDELTA5,
+                cpFieldCount, cpDescriptor);
+    }
+
+    private void parseCpFloat(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpFloatCount = header.getCpFloatCount();
+        cpFloat = new float[cpFloatCount];
+        int floatBits[] = decodeBandInt("cp_Float", in, Codec.UDELTA5,
+                cpFloatCount);
+        for (int i = 0; i < cpFloatCount; i++) {
+            cpFloat[i] = Float.intBitsToFloat(floatBits[i]);
+        }
+    }
+
+    /**
+     * Parses the constant pool interface method definitions, using
+     * {@link #cpIMethodCount} to populate {@link #cpIMethodClass} and
+     * {@link #cpIMethodDescriptor}.
+     * 
+     * @param in
+     *            the input stream to read from
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    private void parseCpIMethod(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpIMethodCount = header.getCpIMethodCount();
+        cpIMethodClass = parseReferences("cp_Imethod_class", in, Codec.DELTA5,
+                cpIMethodCount, cpClass);
+        cpIMethodDescriptor = parseReferences("cp_Imethod_desc", in,
+                Codec.UDELTA5, cpIMethodCount, cpDescriptor);
+    }
+
+    private void parseCpInt(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpIntCount = header.getCpIntCount();
+        cpInt = new int[cpIntCount];
+        long last = 0;
+        for (int i = 0; i < cpIntCount; i++) {
+            last = Codec.UDELTA5.decode(in, last);
+            cpInt[i] = (int) last;
+        }
+    }
+
+    private void parseCpLong(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpLongCount = header.getCpLongCount();
+        cpLong = parseFlags("cp_Long", in, cpLongCount, new int[] { 1 },
+                Codec.UDELTA5, Codec.DELTA5)[0];
+    }
+
+    /**
+     * Parses the constant pool method definitions, using {@link #cpMethodCount}
+     * to populate {@link #cpMethodClass} and {@link #cpMethodDescriptor}.
+     * 
+     * @param in
+     *            the input stream to read from
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    private void parseCpMethod(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpMethodCount = header.getCpMethodCount();
+        cpMethodClass = parseReferences("cp_Method_class", in, Codec.DELTA5,
+                cpMethodCount, cpClass);
+        cpMethodDescriptor = parseReferences("cp_Method_desc", in,
+                Codec.UDELTA5, cpMethodCount, cpDescriptor);
+    }
+
+    /**
+     * Parses the constant pool signature classes, using
+     * {@link #cpSignatureCount} to populate {@link #cpSignature}. A signature
+     * form is akin to the bytecode representation of a class; Z for boolean, I
+     * for int, [ for array etc. However, although classes are started with L,
+     * the classname does not follow the form; instead, there is a separate
+     * array of classes. So an array corresponding to
+     * <code>public static void main(String args[])</code> has a form of
+     * <code>[L(V)</code> and a classes array of
+     * <code>[java.lang.String]</code>. The {@link #cpSignature} is a string
+     * representation identical to the bytecode equivalent
+     * <code>[Ljava/lang/String;(V)</code> TODO Check that the form is as
+     * above and update other types e.g. J
+     * 
+     * @param in
+     *            the input stream to read from
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    private void parseCpSignature(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpSignatureCount = header.getCpSignatureCount();
+        String[] cpSignatureForm = parseReferences("cp_Signature_form", in,
+                Codec.DELTA5, cpSignatureCount, cpUTF8);
+        cpSignature = new String[cpSignatureCount];
+        long last = 0;
+        for (int i = 0; i < cpSignatureCount; i++) {
+            String form = cpSignatureForm[i];
+            int len = form.length();
+            StringBuffer signature = new StringBuffer(64);
+            ArrayList list = new ArrayList();
+            for (int j = 0; j < len; j++) {
+                char c = form.charAt(j);
+                signature.append(c);
+                if (c == 'L') {
+                    int index = (int) (last = Codec.UDELTA5.decode(in, last));
+                    String className = cpClass[index];
+                    list.add(className);
+                    signature.append(className);
+                }
+            }
+            cpSignature[i] = signature.toString();
+        }
+    }
+
+    /**
+     * Parses the constant pool strings, using {@link #cpStringCount} to
+     * populate {@link #cpString} from indexes into {@link #cpUTF8}.
+     * 
+     * @param in
+     *            the input stream to read from
+     * @throws IOException
+     *             if a problem occurs during reading from the underlying stream
+     * @throws Pack200Exception
+     *             if a problem occurs with an unexpected value or unsupported
+     *             codec
+     */
+    private void parseCpString(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpStringCount = header.getCpStringCount();
+        cpString = new String[cpStringCount];
+        long last = 0;
+        for (int i = 0; i < cpStringCount; i++) {
+            int index = (int) (last = Codec.UDELTA5.decode(in, last));
+            cpString[i] = cpUTF8[index];
+        }
+    }
+
+    private void parseCpUtf8(InputStream in) throws IOException,
+            Pack200Exception {
+        int cpUTF8Count = header.getCpUTF8Count();
+        // TODO Update codec.decode -> decodeScalar
+        cpUTF8 = new String[cpUTF8Count];
+        cpUTF8[0] = ""; //$NON-NLS-1$
+        int[] prefix = new int[cpUTF8Count];
+        int[] suffix = new int[cpUTF8Count];
+        if (cpUTF8Count > 0) {
+            prefix[0] = 0;
+            suffix[0] = 0;
+            if (cpUTF8Count > 1)
+                prefix[1] = 0;
+        }
+        long last = 0;
+        for (int i = 2; i < cpUTF8Count; i++) {
+            last = prefix[i] = (int) Codec.DELTA5.decode(in, last);
+        }
+        int chars = 0;
+        int bigSuffix = 0;
+        for (int i = 1; i < cpUTF8Count; i++) {
+            last = suffix[i] = (int) Codec.UNSIGNED5.decode(in);
+            if (last == 0) {
+                bigSuffix++;
+            } else {
+                chars += last;
+            }
+        }
+        char data[] = new char[chars];
+        for (int i = 0; i < data.length; i++) {
+            data[i] = (char) Codec.CHAR3.decode(in);
+        }
+        // read in the big suffix data
+        char bigSuffixData[][] = new char[bigSuffix][];
+        last = 0;
+        for (int i = 0; i < bigSuffix; i++) {
+            last = (int) Codec.DELTA5.decode(in, last);
+            bigSuffixData[i] = new char[(int) last];
+        }
+        // initialize big suffix data
+        for (int i = 0; i < bigSuffix; i++) {
+            char[] singleBigSuffixData = bigSuffixData[i];
+            last = 0;
+            for (int j = 0; j < singleBigSuffixData.length; j++) {
+                last = singleBigSuffixData[j] = (char) Codec.DELTA5.decode(in,
+                        last);
+            }
+        }
+        // go through the strings
+        chars = 0;
+        bigSuffix = 0;
+        for (int i = 1; i < cpUTF8Count; i++) {
+            String lastString = cpUTF8[i - 1];
+            if (suffix[i] == 0) {
+                // The big suffix stuff hasn't been tested, and I'll be
+                // surprised if it works first time w/o errors ...
+                cpUTF8[i] = lastString.substring(0, prefix[i])
+                        + new String(bigSuffixData[bigSuffix++]);
+            } else {
+                cpUTF8[i] = lastString.substring(0, prefix[i])
+                        + new String(data, chars, suffix[i]);
+                chars += suffix[i];
+            }
+        }
+    }
+    
+    public String[] getCpClass() {
+        return cpClass;
+    }
+
+    public String[] getCpDescriptor() {
+        return cpDescriptor;
+    }
+
+    public double[] getCpDouble() {
+        return cpDouble;
+    }
+
+    public String[] getCpFieldClass() {
+        return cpFieldClass;
+    }
+
+    public Object getCpFieldDescriptor() {
+        return cpFieldDescriptor;
+    }
+
+    public float[] getCpFloat() {
+        return cpFloat;
+    }
+
+    public String[] getCpIMethodClass() {
+        return cpIMethodClass;
+    }
+
+    public String[] getCpIMethodDescriptor() {
+        return cpIMethodDescriptor;
+    }
+
+    public int[] getCpInt() {
+        return cpInt;
+    }
+
+    public long[] getCpLong() {
+        return cpLong;
+    }
+
+    public String[] getCpMethodClass() {
+        return cpMethodClass;
+    }
+
+    public String[] getCpMethodDescriptor() {
+        return cpMethodDescriptor;
+    }
+
+    public String[] getCpSignature() {
+        return cpSignature;
+    }
+
+    public String[] getCpString() {
+        return cpString;
+    }
+
+    public String[] getCpUTF8() {
+        return cpUTF8;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java?rev=572686&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java Tue Sep  4 06:54:46 2007
@@ -0,0 +1,147 @@
+/*
+ *  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.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+
+/**
+ * Parses the file band headers (not including the actual bits themselves).
+ * At the end of this parse call, the input stream will be positioned at the
+ * start of the file_bits themselves, and there will be Sum(file_size) bits
+ * remaining in the stream with BYTE1 compression. A decent implementation
+ * will probably just stream the bytes out to the reconstituted Jar rather
+ * than caching them.
+ * 
+ */
+public class FileBands extends BandSet {
+
+    private byte[][] fileBits;
+
+    private long[] fileModtime;
+
+    private String[] fileName;
+
+    private long[] fileOptions;
+
+    private long[] fileSize;
+
+    private String[] cpUTF8;
+    
+    /**
+     * @param header
+     */
+    public FileBands(Segment segment) {
+        super(segment);
+        this.cpUTF8 = segment.getCpBands().getCpUTF8();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.BandSet#pack(java.io.OutputStream)
+     */
+    public void pack(OutputStream outputStream) {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.BandSet#unpack(java.io.InputStream)
+     */
+    public void unpack(InputStream in) throws IOException,
+            Pack200Exception {
+        int numberOfFiles = header.getNumberOfFiles();
+        SegmentOptions options = header.getOptions();
+        if (false && System.getProperty("debug.pack200") != null) {
+            // TODO HACK
+            fileSize = new long[numberOfFiles];
+            fileModtime = new long[numberOfFiles];
+            fileOptions = new long[numberOfFiles];
+            fileName = new String[numberOfFiles];
+            Arrays.fill(fileName, "");
+            return;
+        }
+        long last;
+        fileName = parseReferences("file_name", in, Codec.UNSIGNED5,
+                numberOfFiles, cpUTF8);
+        fileSize = new long[numberOfFiles];
+        if (options.hasFileSizeHi()) {
+            last = 0;
+            for (int i = 0; i < numberOfFiles; i++) {
+                fileSize[i] = (last = Codec.UNSIGNED5.decode(in, last)) << 32;
+            }
+        }
+        last = 0;
+        for (int i = 0; i < numberOfFiles; i++) {
+            fileSize[i] |= (last = Codec.UNSIGNED5.decode(in, last));
+        }
+        fileModtime = new long[numberOfFiles];
+        if (options.hasFileModtime()) {
+            last = 0;
+            for (int i = 0; i < numberOfFiles; i++) {
+                fileModtime[i] |= (last = Codec.DELTA5.decode(in, last));
+            }
+        }
+        fileOptions = new long[numberOfFiles];
+        if (options.hasFileOptions()) {
+            last = 0;
+            for (int i = 0; i < numberOfFiles; i++) {
+                fileOptions[i] |= (last = Codec.UNSIGNED5.decode(in, last));
+            }
+        }
+    }
+    
+
+    public void processFileBits(InputStream in) throws IOException,
+            Pack200Exception {
+        // now read in the bytes
+        int numberOfFiles = header.getNumberOfFiles();
+        fileBits = new byte[numberOfFiles][];
+        for (int i = 0; i < numberOfFiles; i++) {
+            int size = (int) fileSize[i];
+            // TODO This buggers up if file_size > 2^32. Probably an array is
+            // not the right choice, and
+            // we should just serialize the bugger here?
+            fileBits[i] = new byte[size];
+            for (int j = 0; j < size; j++) {
+                fileBits[i][j] = (byte) Codec.BYTE1.decode(in);
+            }
+        }
+    }
+
+    public byte[][] getFileBits() {
+        return fileBits;
+    }
+
+    public long[] getFileModtime() {
+        return fileModtime;
+    }
+
+    public String[] getFileName() {
+        return fileName;
+    }
+
+    public long[] getFileOptions() {
+        return fileOptions;
+    }
+
+    public long[] getFileSize() {
+        return fileSize;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java?rev=572686&r1=572685&r2=572686&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IMatcher.java Tue Sep  4 06:54:46 2007
@@ -1,7 +1,23 @@
+/*
+ *  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;
 
 public interface IMatcher {
 
 	public abstract boolean matches(long value);
 
-}
\ No newline at end of file
+}

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java?rev=572686&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java Tue Sep  4 06:54:46 2007
@@ -0,0 +1,80 @@
+/*
+ *  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.InputStream;
+import java.io.OutputStream;
+
+/**
+ *
+ */
+public class IcBands extends BandSet {
+    
+    private int[] icFlags;
+
+    private Object icName;
+
+    private String[] icOuterClass;
+
+    private String[] icThisClass;
+
+    private String[] cpUTF8;
+
+    private String[] cpClass;
+
+    /**
+     * @param header
+     */
+    public IcBands(Segment segment) {
+        super(segment);
+        this.cpClass = segment.getCpBands().getCpClass();
+        this.cpUTF8 = segment.getCpBands().getCpUTF8();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.BandSet#pack(java.io.OutputStream)
+     */
+    public void pack(OutputStream outputStream) {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.BandSet#unpack(java.io.InputStream)
+     */
+    public void unpack(InputStream in) throws IOException,
+            Pack200Exception {
+        int innerClassCount = header.getInnerClassCount();
+        icThisClass = parseReferences("ic_this_class", in, Codec.UDELTA5,
+                innerClassCount, cpClass);
+        icFlags = new int[innerClassCount];
+        long last = 0;
+        int outerClasses = 0;
+        // ic_flags
+        for (int i = 0; i < innerClassCount; i++) {
+            icFlags[i] = (int) (last = Codec.UNSIGNED5.decode(in, last));
+            if ((icFlags[i] & 1 << 16) != 0)
+                outerClasses++;
+        }
+        icOuterClass = parseReferences("ic_outer_class", in, Codec.DELTA5,
+                outerClasses, cpClass);
+        icName = parseReferences("ic_name", in, Codec.DELTA5, outerClasses,
+                cpUTF8);
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message