1 30 31 package jbet; 32 import java.io.*; 33 import java.util.*; 34 35 46 47 class InnerClassInfo implements Cloneable { 48 boolean good; int accessFlags; 52 String inner = null; String outer = null; String simpleName = null; 59 int innerIndex; 60 int outerIndex; 61 int simpleIndex = 0; 62 63 65 71 InnerClassInfo() { } 72 73 80 public InnerClassInfo(Lexer lexer) { 81 lexer.push(Lexer.ST_ASM); 82 if (!lexer.match(Token.TAG).text.equals(".inner")) 83 lexer.unexpected(lexer.justread()); 84 lexer.state = Lexer.ST_ASM_ARG; 85 inner = lexer.parse_name(); 86 outer = lexer.parse_name(); 87 simpleName = lexer.parse_name(); 88 accessFlags = lexer.parse_flags(ClassInfo.ACC_ALL_INNER_CFLAGS); 89 lexer.term(); 90 lexer.pop(); 91 } 92 93 public InnerClassInfo(String i, String o, String s, int a) { 94 inner = i; 95 outer = o; 96 simpleName = s; 97 accessFlags = a; 98 } 99 100 public InnerClassInfo (String i, int a) { 101 inner = i; 102 outer = i.substring (0, i.lastIndexOf ('$')); 103 simpleName = i.substring (i.lastIndexOf ('$') + 1); 104 accessFlags = a; 105 } 106 107 112 public InnerClassInfo (DataInputStream dataIn, 113 ConstantPool constantPool) throws IOException, 114 ClassFileException { 115 innerIndex = dataIn.readUnsignedShort(); 116 outerIndex = dataIn.readUnsignedShort(); 117 simpleIndex = dataIn.readUnsignedShort(); 118 119 if (innerIndex != 0) 120 inner = constantPool.cpClassAt(innerIndex).string(); 121 122 if (outerIndex != 0) 123 outer = constantPool.cpClassAt(outerIndex).string(); 124 125 if (simpleIndex != 0) 126 simpleName = constantPool.utf8At(simpleIndex); 127 128 accessFlags = dataIn.readUnsignedShort(); 129 } 130 131 132 133 InnerClassInfo dup() { 134 try { 135 return (InnerClassInfo) clone(); 136 } catch (Exception e) { 137 return null; 138 } 139 } 140 141 142 149 void relocate (Hashtable subs) { 150 inner = Util.relocate(inner, subs); 151 outer = Util.relocate(outer, subs); 152 } 153 154 155 public void disassemble(LineWriter out, String prefix) { 156 out.println(prefix + ".inner " + inner + " " + outer + " " + simpleName + 157 " " + Util.flags2str(accessFlags, true)); 158 } 159 160 void writeFile (DataOutputStream dataOut) throws IOException { 161 dataOut.writeShort ( inner == null ? 0 : innerIndex ); 162 dataOut.writeShort ( outer == null ? 0 : outerIndex ); 163 dataOut.writeShort ( simpleIndex ); 164 dataOut.writeShort ( accessFlags & ClassInfo.ACC_ALL_INNER_CFLAGS); 165 } 166 167 void resolveConstants (ConstantPool constantPool) { 168 if (inner != null) 169 innerIndex = constantPool.internClass(inner); 170 if (outer != null) 171 outerIndex = constantPool.internClass(outer); 172 if (simpleName != null) 173 simpleIndex = constantPool.internUtf8 (simpleName); 174 } 175 176 String recString() { 177 return "inner(" + inner + ") outer(" + outer + 178 ") simple(" + simpleName + ")"; 179 } 180 181 } 182 183 184 | Popular Tags |