110 ConstantTag ctag = method().getConstants().getTagAt(index()); |
110 ConstantTag ctag = method().getConstants().getTagAt(index()); |
111 return ctag.isKlass() || ctag.isUnresolvedKlass(); |
111 return ctag.isKlass() || ctag.isUnresolvedKlass(); |
112 } |
112 } |
113 |
113 |
114 // return Symbol (if unresolved) or Klass (if resolved) |
114 // return Symbol (if unresolved) or Klass (if resolved) |
115 public Oop getKlass() { |
115 public Object getKlass() { |
116 if (Assert.ASSERTS_ENABLED) { |
116 if (Assert.ASSERTS_ENABLED) { |
117 Assert.that(isKlassConstant(), "not a klass literal"); |
117 Assert.that(isKlassConstant(), "not a klass literal"); |
118 } |
118 } |
119 // tag change from 'unresolved' to 'klass' does not happen atomically. |
119 // tag change from 'unresolved' to 'klass' does not happen atomically. |
120 // We just look at the object at the corresponding index and |
120 // We just look at the object at the corresponding index and |
121 // decide based on the oop type. |
121 // decide based on the oop type. |
122 ConstantPool cpool = method().getConstants(); |
122 ConstantPool cpool = method().getConstants(); |
123 int cpIndex = index(); |
123 int cpIndex = index(); |
124 Oop oop = cpool.getObjAt(cpIndex); |
124 ConstantPool.CPSlot oop = cpool.getSlotAt(cpIndex); |
125 if (oop.isKlass()) { |
125 if (oop.isOop()) { |
126 return (Klass) oop; |
126 return (Klass) oop.getOop(); |
127 } else if (oop.isSymbol()) { |
127 } else if (oop.isMetaData()) { |
128 return (Symbol) oop; |
128 return oop.getSymbol(); |
129 } else { |
129 } else { |
130 throw new RuntimeException("should not reach here"); |
130 throw new RuntimeException("should not reach here"); |
131 } |
131 } |
132 } |
132 } |
133 |
133 |
163 return "<double " + Double.toString(cpool.getDoubleAt(cpIndex)) + "D>"; |
163 return "<double " + Double.toString(cpool.getDoubleAt(cpIndex)) + "D>"; |
164 } else if (ctag.isString() || ctag.isUnresolvedString()) { |
164 } else if (ctag.isString() || ctag.isUnresolvedString()) { |
165 // tag change from 'unresolved' to 'string' does not happen atomically. |
165 // tag change from 'unresolved' to 'string' does not happen atomically. |
166 // We just look at the object at the corresponding index and |
166 // We just look at the object at the corresponding index and |
167 // decide based on the oop type. |
167 // decide based on the oop type. |
168 Oop obj = cpool.getObjAt(cpIndex); |
168 ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex); |
169 if (obj.isSymbol()) { |
169 if (obj.isMetaData()) { |
170 Symbol sym = (Symbol) obj; |
170 Symbol sym = obj.getSymbol(); |
171 return "<String \"" + sym.asString() + "\">"; |
171 return "<String \"" + sym.asString() + "\">"; |
172 } else if (obj.isInstance()) { |
172 } else if (obj.isOop()) { |
173 return "<String \"" + OopUtilities.stringOopToString(obj) + "\">"; |
173 return "<String \"" + OopUtilities.stringOopToString(obj.getOop()) + "\">"; |
174 } else { |
174 } else { |
175 throw new RuntimeException("should not reach here"); |
175 throw new RuntimeException("should not reach here"); |
176 } |
176 } |
177 } else if (ctag.isKlass() || ctag.isUnresolvedKlass()) { |
177 } else if (ctag.isKlass() || ctag.isUnresolvedKlass()) { |
178 // tag change from 'unresolved' to 'klass' does not happen atomically. |
178 // tag change from 'unresolved' to 'klass' does not happen atomically. |
179 // We just look at the object at the corresponding index and |
179 // We just look at the object at the corresponding index and |
180 // decide based on the oop type. |
180 // decide based on the oop type. |
181 Oop obj = cpool.getObjAt(cpIndex); |
181 ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex); |
182 if (obj.isKlass()) { |
182 if (obj.isOop()) { |
183 Klass k = (Klass) obj; |
183 Klass k = (Klass) obj.getOop(); |
184 return "<Class " + k.getName().asString() + "@" + k.getHandle() + ">"; |
184 return "<Class " + k.getName().asString() + "@" + k.getHandle() + ">"; |
185 } else if (obj.isSymbol()) { |
185 } else if (obj.isMetaData()) { |
186 Symbol sym = (Symbol) obj; |
186 Symbol sym = obj.getSymbol(); |
187 return "<Class " + sym.asString() + ">"; |
187 return "<Class " + sym.asString() + ">"; |
188 } else { |
188 } else { |
189 throw new RuntimeException("should not reach here"); |
189 throw new RuntimeException("should not reach here"); |
190 } |
190 } |
191 } else if (ctag.isMethodHandle()) { |
191 } else if (ctag.isMethodHandle()) { |
192 Oop x = getCachedConstant(); |
192 Oop x = getCachedConstant(); |