1 19 20 package org.netbeans.modules.classfile; 21 22 import java.io.DataInputStream ; 23 import java.io.IOException ; 24 25 35 public abstract class VerificationTypeInfo { 36 private int tag; 37 38 39 public static final int ITEM_Top = 0; 40 41 public static final int ITEM_Integer = 1; 42 43 public static final int ITEM_Float = 2; 44 45 public static final int ITEM_Double = 3; 46 47 public static final int ITEM_Long = 4; 48 49 public static final int ITEM_Null = 5; 50 51 public static final int ITEM_UninitializedThis = 6; 52 53 public static final int ITEM_Object = 7; 54 55 public static final int ITEM_Uninitialized = 8; 56 57 static VerificationTypeInfo loadVerificationTypeInfo(DataInputStream in, ConstantPool pool) 58 throws IOException { 59 int tag = in.readUnsignedByte(); 60 switch (tag) { 61 case ITEM_Top: return new TopVariableInfo(); 62 case ITEM_Integer: return new IntegerVariableInfo(); 63 case ITEM_Float: return new FloatVariableInfo(); 64 case ITEM_Long: return new LongVariableInfo(); 65 case ITEM_Double: return new DoubleVariableInfo(); 66 case ITEM_Null: return new NullVariableInfo(); 67 case ITEM_UninitializedThis: return new UninitializedThisVariableInfo(); 68 case ITEM_Object: { 69 int cpool_index = in.readUnsignedShort(); 70 return new ObjectVariableInfo(pool.get(cpool_index)); 71 } 72 case ITEM_Uninitialized: { 73 int offset = in.readUnsignedShort(); 74 return new UninitializedVariableInfo(offset); 75 } 76 default: 77 throw new InvalidClassFormatException("invalid verification_type_info tag: " + tag); 78 } 79 } 80 81 82 VerificationTypeInfo(int tag) { 83 this.tag = tag; 84 } 85 86 92 public int getTag() { 93 return tag; 94 } 95 96 100 public static final class TopVariableInfo extends VerificationTypeInfo { 101 TopVariableInfo() { 102 super(ITEM_Top); 103 } 104 } 105 106 110 public static final class IntegerVariableInfo extends VerificationTypeInfo { 111 IntegerVariableInfo() { 112 super(ITEM_Integer); 113 } 114 } 115 116 120 public static final class FloatVariableInfo extends VerificationTypeInfo { 121 FloatVariableInfo() { 122 super(ITEM_Float); 123 } 124 } 125 126 130 public static final class LongVariableInfo extends VerificationTypeInfo { 131 LongVariableInfo() { 132 super(ITEM_Long); 133 } 134 } 135 136 140 public static final class DoubleVariableInfo extends VerificationTypeInfo { 141 DoubleVariableInfo() { 142 super(ITEM_Double); 143 } 144 } 145 146 150 public static final class NullVariableInfo extends VerificationTypeInfo { 151 NullVariableInfo() { 152 super(ITEM_Null); 153 } 154 } 155 156 160 public static final class UninitializedThisVariableInfo extends VerificationTypeInfo { 161 UninitializedThisVariableInfo() { 162 super(ITEM_UninitializedThis); 163 } 164 } 165 166 170 public static final class ObjectVariableInfo extends VerificationTypeInfo { 171 CPEntry cpEntry; 172 ObjectVariableInfo(CPEntry entry) { 173 super(ITEM_Object); 174 cpEntry = entry; 175 } 176 177 180 public CPEntry getConstantPoolEntry() { 181 return cpEntry; 182 } 183 } 184 185 189 public static final class UninitializedVariableInfo extends VerificationTypeInfo { 190 int offset; 191 UninitializedVariableInfo(int offset) { 192 super(ITEM_Object); 193 this.offset = offset; 194 } 195 196 200 public int getOffset() { 201 return offset; 202 } 203 } 204 } 205 | Popular Tags |