1 package com.yworks.yguard.obf.classfile; 2 3 import java.io.DataInput ; 4 import java.io.DataOutput ; 5 import java.util.List ; 6 import java.util.Collection ; 7 import java.util.ArrayList ; 8 9 14 public class StackMapFrameInfo { 15 private VerificationTypeInfo[] verificationTypeInfoStack; 16 private int u2_offset_delta; 17 private VerificationTypeInfo[] verificationTypeInfoLocals; 18 private int u1_frameType; 19 21 22 public static StackMapFrameInfo create(DataInput din) throws java.io.IOException 24 { 25 if (din == null) throw new NullPointerException ("DataInput cannot be null!"); 26 StackMapFrameInfo smfi = new StackMapFrameInfo(); 27 smfi.read(din); 28 return smfi; 29 } 30 31 32 private StackMapFrameInfo() {} 34 35 36 protected void markUtf8Refs(ConstantPool pool) 37 { 38 if (u1_frameType < 64){ 39 } else if (u1_frameType >= 64 && u1_frameType <= 127){ 41 verificationTypeInfoStack[0].markUtf8Refs(pool); 43 } else if (u1_frameType == 247){ 44 verificationTypeInfoStack[0].markUtf8Refs(pool); 46 } else if (u1_frameType >= 248 && u1_frameType <= 250){ 47 } else if (u1_frameType == 251){ 49 } else if (u1_frameType >= 252 && u1_frameType <= 254){ 51 for (int i = 0; i < verificationTypeInfoStack.length; i++) { 53 verificationTypeInfoStack[i].markUtf8Refs(pool); 54 } 55 } else if (u1_frameType == 255){ 56 for (int i = 0; i < verificationTypeInfoLocals.length; i++) { 58 verificationTypeInfoLocals[i].markUtf8Refs(pool); 59 } 60 for (int i = 0; i < verificationTypeInfoStack.length; i++) { 61 verificationTypeInfoStack[i].markUtf8Refs(pool); 62 } 63 } else { 64 throw new IllegalArgumentException ("Unknown frame type " + u1_frameType); 65 } 66 } 67 68 69 public Collection getVerificationTypeInfos(){ 70 ArrayList result = new ArrayList (); 71 if (verificationTypeInfoLocals != null){ 72 for (int i = 0; i < verificationTypeInfoLocals.length; i++) { 73 VerificationTypeInfo verificationTypeInfo = verificationTypeInfoLocals[i]; 74 result.add(verificationTypeInfo); 75 } 76 } 77 if (verificationTypeInfoStack != null){ 78 for (int i = 0; i < verificationTypeInfoStack.length; i++) { 79 VerificationTypeInfo verificationTypeInfo = verificationTypeInfoStack[i]; 80 result.add(verificationTypeInfo); 81 } 82 } 83 return result; 84 } 85 86 private void read(DataInput din) throws java.io.IOException 87 { 88 verificationTypeInfoLocals = null; 89 verificationTypeInfoStack = null; 90 u1_frameType = din.readUnsignedByte(); 91 if (u1_frameType < 64){ 92 } else if (u1_frameType >= 64 && u1_frameType <= 127){ 94 verificationTypeInfoStack = new VerificationTypeInfo[1]; 96 verificationTypeInfoStack[0] = VerificationTypeInfo.create(din); 97 } else if (u1_frameType == 247){ 98 u2_offset_delta = din.readUnsignedShort(); 100 verificationTypeInfoStack = new VerificationTypeInfo[1]; 101 verificationTypeInfoStack[0] = VerificationTypeInfo.create(din); 102 } else if (u1_frameType >= 248 && u1_frameType <= 250){ 103 u2_offset_delta = din.readUnsignedShort(); 105 } else if (u1_frameType == 251){ 106 u2_offset_delta = din.readUnsignedShort(); 108 } else if (u1_frameType >= 252 && u1_frameType <= 254){ 109 u2_offset_delta = din.readUnsignedShort(); 111 int count = u1_frameType - 251; 112 verificationTypeInfoStack = new VerificationTypeInfo[count]; 113 for (int i = 0; i < verificationTypeInfoStack.length; i++) { 114 verificationTypeInfoStack[i] = VerificationTypeInfo.create(din); 115 } 116 } else if (u1_frameType == 255){ 117 u2_offset_delta = din.readUnsignedShort(); 119 verificationTypeInfoLocals = new VerificationTypeInfo[din.readUnsignedShort()]; 120 for (int i = 0; i < verificationTypeInfoLocals.length; i++) { 121 verificationTypeInfoLocals[i] = VerificationTypeInfo.create(din); 122 } 123 verificationTypeInfoStack = new VerificationTypeInfo[din.readUnsignedShort()]; 124 for (int i = 0; i < verificationTypeInfoStack.length; i++) { 125 verificationTypeInfoStack[i] = VerificationTypeInfo.create(din); 126 } 127 } else { 128 throw new IllegalArgumentException ("Unknown frame type " + u1_frameType); 129 } 130 } 131 132 133 public void write(DataOutput dout) throws java.io.IOException 134 { 135 dout.writeByte(u1_frameType); 136 if (u1_frameType < 64){ 137 } else if (u1_frameType >= 64 && u1_frameType <= 127){ 139 verificationTypeInfoStack[0].write(dout); 141 } else if (u1_frameType == 247){ 142 dout.writeShort(u2_offset_delta); 144 verificationTypeInfoStack[0].write(dout); 145 } else if (u1_frameType >= 248 && u1_frameType <= 250){ 146 dout.writeShort(u2_offset_delta); 148 } else if (u1_frameType == 251){ 149 dout.writeShort(u2_offset_delta); 151 } else if (u1_frameType >= 252 && u1_frameType <= 254){ 152 dout.writeShort(u2_offset_delta); 154 for (int i = 0; i < verificationTypeInfoStack.length; i++) { 155 verificationTypeInfoStack[i].write(dout); 156 } 157 } else if (u1_frameType == 255){ 158 dout.writeShort(u2_offset_delta); 160 dout.writeShort(verificationTypeInfoLocals.length); 161 for (int i = 0; i < verificationTypeInfoLocals.length; i++) { 162 verificationTypeInfoLocals[i].write(dout); 163 } 164 dout.writeShort(verificationTypeInfoStack.length); 165 for (int i = 0; i < verificationTypeInfoStack.length; i++) { 166 verificationTypeInfoStack[i].write(dout); 167 } 168 } else { 169 throw new IllegalArgumentException ("Unknown frame type " + u1_frameType); 170 } 171 } 172 } 173 | Popular Tags |