| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
package org.apache.commons.compress.harmony.unpack200; |
| 20 |
|
| 21 |
import java.io.IOException; |
| 22 |
import java.io.InputStream; |
| 23 |
|
| 24 |
import org.apache.commons.compress.harmony.pack200.Codec; |
| 25 |
import org.apache.commons.compress.harmony.pack200.Pack200Exception; |
| 26 |
import org.apache.commons.compress.harmony.unpack200.bytecode.AnnotationDefaultAttribute; |
| 27 |
import org.apache.commons.compress.harmony.unpack200.bytecode.CodeAttribute; |
| 28 |
import org.apache.commons.compress.harmony.unpack200.bytecode.ConstantValueAttribute; |
| 29 |
import org.apache.commons.compress.harmony.unpack200.bytecode.DeprecatedAttribute; |
| 30 |
import org.apache.commons.compress.harmony.unpack200.bytecode.EnclosingMethodAttribute; |
| 31 |
import org.apache.commons.compress.harmony.unpack200.bytecode.ExceptionsAttribute; |
| 32 |
import org.apache.commons.compress.harmony.unpack200.bytecode.InnerClassesAttribute; |
| 33 |
import org.apache.commons.compress.harmony.unpack200.bytecode.LineNumberTableAttribute; |
| 34 |
import org.apache.commons.compress.harmony.unpack200.bytecode.LocalVariableTableAttribute; |
| 35 |
import org.apache.commons.compress.harmony.unpack200.bytecode.LocalVariableTypeTableAttribute; |
| 36 |
import org.apache.commons.compress.harmony.unpack200.bytecode.SignatureAttribute; |
| 37 |
import org.apache.commons.compress.harmony.unpack200.bytecode.SourceFileAttribute; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public class AttrDefinitionBands extends BandSet { |
| 43 |
|
| 44 |
private int[] attributeDefinitionHeader; |
| 45 |
|
| 46 |
private String[] attributeDefinitionLayout; |
| 47 |
|
| 48 |
private String[] attributeDefinitionName; |
| 49 |
|
| 50 |
private AttributeLayoutMap attributeDefinitionMap; |
| 51 |
|
| 52 |
private final String[] cpUTF8; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public AttrDefinitionBands(final Segment segment) { |
| 60 |
super(segment); |
| 61 |
this.cpUTF8 = segment.getCpBands().getCpUTF8(); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public AttributeLayoutMap getAttributeDefinitionMap() { |
| 70 |
return attributeDefinitionMap; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
@Override |
| 79 |
public void read(final InputStream in) throws IOException, Pack200Exception { |
| 80 |
final int attributeDefinitionCount = header.getAttributeDefinitionCount(); |
| 81 |
attributeDefinitionHeader = decodeBandInt("attr_definition_headers", in, Codec.BYTE1, attributeDefinitionCount); |
| 82 |
attributeDefinitionName = parseReferences("attr_definition_name", in, Codec.UNSIGNED5, attributeDefinitionCount, cpUTF8); |
| 83 |
attributeDefinitionLayout = parseReferences("attr_definition_layout", in, Codec.UNSIGNED5, attributeDefinitionCount, cpUTF8); |
| 84 |
|
| 85 |
attributeDefinitionMap = new AttributeLayoutMap(); |
| 86 |
|
| 87 |
int overflowIndex = 32; |
| 88 |
if (segment.getSegmentHeader().getOptions().hasClassFlagsHi()) { |
| 89 |
overflowIndex = 63; |
| 90 |
} |
| 91 |
for (int i = 0; i < attributeDefinitionCount; i++) { |
| 92 |
final int context = attributeDefinitionHeader[i] & 0x03; |
| 93 |
int index = (attributeDefinitionHeader[i] >> 2) - 1; |
| 94 |
if (index == -1) { |
| 95 |
index = overflowIndex++; |
| 96 |
} |
| 97 |
final AttributeLayout layout = new AttributeLayout(attributeDefinitionName[i], context, attributeDefinitionLayout[i], index, false); |
| 98 |
final NewAttributeBands newBands = new NewAttributeBands(segment, layout); |
| 99 |
attributeDefinitionMap.add(layout, newBands); |
| 100 |
} |
| 101 |
attributeDefinitionMap.checkMap(); |
| 102 |
setupDefaultAttributeNames(); |
| 103 |
} |
| 104 |
|
| 105 |
private void setupDefaultAttributeNames() { |
| 106 |
AnnotationDefaultAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("AnnotationDefault")); |
| 107 |
CodeAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("Code")); |
| 108 |
ConstantValueAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("ConstantValue")); |
| 109 |
DeprecatedAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("Deprecated")); |
| 110 |
EnclosingMethodAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("EnclosingMethod")); |
| 111 |
ExceptionsAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("Exceptions")); |
| 112 |
InnerClassesAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("InnerClasses")); |
| 113 |
LineNumberTableAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("LineNumberTable")); |
| 114 |
LocalVariableTableAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("LocalVariableTable")); |
| 115 |
LocalVariableTypeTableAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("LocalVariableTypeTable")); |
| 116 |
SignatureAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("Signature")); |
| 117 |
SourceFileAttribute.setAttributeName(segment.getCpBands().cpUTF8Value("SourceFile")); |
| 118 |
MetadataBandGroup.setRvaAttributeName(segment.getCpBands().cpUTF8Value("RuntimeVisibleAnnotations")); |
| 119 |
MetadataBandGroup.setRiaAttributeName(segment.getCpBands().cpUTF8Value("RuntimeInvisibleAnnotations")); |
| 120 |
MetadataBandGroup.setRvpaAttributeName(segment.getCpBands().cpUTF8Value("RuntimeVisibleParameterAnnotations")); |
| 121 |
MetadataBandGroup.setRipaAttributeName(segment.getCpBands().cpUTF8Value("RuntimeInvisibleParameterAnnotations")); |
| 122 |
} |
| 123 |
|
| 124 |
@Override |
| 125 |
public void unpack() throws Pack200Exception, IOException { |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
} |