You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TypeData.java 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. Alternatively, the contents of this file may be used under
  8. * the terms of the GNU Lesser General Public License Version 2.1 or later,
  9. * or the Apache License Version 2.0.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. */
  16. package javassist.bytecode.stackmap;
  17. import javassist.ClassPool;
  18. import javassist.CtClass;
  19. import javassist.NotFoundException;
  20. import javassist.bytecode.ConstPool;
  21. import javassist.bytecode.Descriptor;
  22. import javassist.bytecode.StackMapTable;
  23. import javassist.bytecode.BadBytecode;
  24. import java.util.HashSet;
  25. import java.util.Iterator;
  26. import java.util.ArrayList;
  27. public abstract class TypeData {
  28. /* Memo:
  29. * array type is a subtype of Cloneable and Serializable
  30. */
  31. public static TypeData[] make(int size) {
  32. TypeData[] array = new TypeData[size];
  33. for (int i = 0; i < size; i++)
  34. array[i] = TypeTag.TOP;
  35. return array;
  36. }
  37. protected TypeData() {}
  38. /**
  39. * Sets the type name of this object type. If the given type name is
  40. * a subclass of the current type name, then the given name becomes
  41. * the name of this object type.
  42. *
  43. * @param className dot-separated name unless the type is an array type.
  44. */
  45. private static void setType(TypeData td, String className, ClassPool cp) throws BadBytecode {
  46. td.setType(className, cp);
  47. }
  48. public abstract int getTypeTag();
  49. public abstract int getTypeData(ConstPool cp);
  50. public TypeData join() { return new TypeVar(this); }
  51. /**
  52. * If the type is a basic type, this method normalizes the type
  53. * and returns a BasicType object. Otherwise, it returns null.
  54. */
  55. public abstract BasicType isBasicType();
  56. public abstract boolean is2WordType();
  57. /**
  58. * Returns false if getName() returns a valid type name.
  59. */
  60. public boolean isNullType() { return false; }
  61. public boolean isUninit() { return false; }
  62. public abstract boolean eq(TypeData d);
  63. public abstract String getName();
  64. public abstract void setType(String s, ClassPool cp) throws BadBytecode;
  65. // depth-first search
  66. public int dfs(ArrayList order, int index, ClassPool cp)
  67. throws NotFoundException
  68. {
  69. return index;
  70. }
  71. /**
  72. * Returns this if it is a TypeVar or a TypeVar that this
  73. * type depends on. Otherwise, this method returns null.
  74. * It is used by dfs().
  75. */
  76. protected TypeVar toTypeVar() { return null; }
  77. // see UninitTypeVar and UninitData
  78. public void constructorCalled(int offset) {}
  79. /**
  80. * Primitive types.
  81. */
  82. protected static class BasicType extends TypeData {
  83. private String name;
  84. private int typeTag;
  85. public BasicType(String type, int tag) {
  86. name = type;
  87. typeTag = tag;
  88. }
  89. public int getTypeTag() { return typeTag; }
  90. public int getTypeData(ConstPool cp) { return 0; }
  91. public TypeData join() {
  92. if (this == TypeTag.TOP)
  93. return this;
  94. else
  95. return super.join();
  96. }
  97. public BasicType isBasicType() { return this; }
  98. public boolean is2WordType() {
  99. return typeTag == StackMapTable.LONG
  100. || typeTag == StackMapTable.DOUBLE;
  101. }
  102. public boolean eq(TypeData d) { return this == d; }
  103. public String getName() {
  104. return name;
  105. }
  106. public void setType(String s, ClassPool cp) throws BadBytecode {
  107. throw new BadBytecode("conflict: " + name + " and " + s);
  108. }
  109. public String toString() { return name; }
  110. }
  111. // a type variable
  112. public static abstract class AbsTypeVar extends TypeData {
  113. public AbsTypeVar() {}
  114. public abstract void merge(TypeData t);
  115. public int getTypeTag() { return StackMapTable.OBJECT; }
  116. public int getTypeData(ConstPool cp) {
  117. return cp.addClassInfo(getName());
  118. }
  119. public boolean eq(TypeData d) { return getName().equals(d.getName()); }
  120. }
  121. /* a type variable representing a class type or a basic type.
  122. */
  123. public static class TypeVar extends AbsTypeVar {
  124. protected ArrayList lowers; // lower bounds of this type. ArrayList<TypeData>
  125. protected ArrayList usedBy; // reverse relations of lowers
  126. protected ArrayList uppers; // upper bounds of this type.
  127. protected String fixedType;
  128. private boolean is2WordType; // cache
  129. public TypeVar(TypeData t) {
  130. uppers = null;
  131. lowers = new ArrayList(2);
  132. usedBy = new ArrayList(2);
  133. merge(t);
  134. fixedType = null;
  135. is2WordType = t.is2WordType();
  136. }
  137. public String getName() {
  138. if (fixedType == null)
  139. return ((TypeData)lowers.get(0)).getName();
  140. else
  141. return fixedType;
  142. }
  143. public BasicType isBasicType() {
  144. if (fixedType == null)
  145. return ((TypeData)lowers.get(0)).isBasicType();
  146. else
  147. return null;
  148. }
  149. public boolean is2WordType() {
  150. if (fixedType == null) {
  151. return is2WordType;
  152. // return ((TypeData)lowers.get(0)).is2WordType();
  153. }
  154. else
  155. return false;
  156. }
  157. public boolean isNullType() {
  158. if (fixedType == null)
  159. return ((TypeData)lowers.get(0)).isNullType();
  160. else
  161. return false;
  162. }
  163. public boolean isUninit() {
  164. if (fixedType == null)
  165. return ((TypeData)lowers.get(0)).isUninit();
  166. else
  167. return false;
  168. }
  169. public void merge(TypeData t) {
  170. lowers.add(t);
  171. if (t instanceof TypeVar)
  172. ((TypeVar)t).usedBy.add(this);
  173. }
  174. public int getTypeTag() {
  175. /* If fixedType is null after calling dfs(), then this
  176. type is NULL, Uninit, or a basic type. So call
  177. getTypeTag() on the first element of lowers. */
  178. if (fixedType == null)
  179. return ((TypeData)lowers.get(0)).getTypeTag();
  180. else
  181. return super.getTypeTag();
  182. }
  183. public int getTypeData(ConstPool cp) {
  184. if (fixedType == null)
  185. return ((TypeData)lowers.get(0)).getTypeData(cp);
  186. else
  187. return super.getTypeData(cp);
  188. }
  189. public void setType(String typeName, ClassPool cp) throws BadBytecode {
  190. if (uppers == null)
  191. uppers = new ArrayList();
  192. uppers.add(typeName);
  193. }
  194. protected TypeVar toTypeVar() { return this; }
  195. private int visited = 0;
  196. private int smallest = 0;
  197. private boolean inList = false;
  198. // depth-first serach
  199. public int dfs(ArrayList preOrder, int index, ClassPool cp) throws NotFoundException {
  200. if (visited > 0)
  201. return index; // MapMaker.make() may call an already visited node.
  202. visited = smallest = ++index;
  203. preOrder.add(this);
  204. inList = true;
  205. int n = lowers.size();
  206. for (int i = 0; i < n; i++) {
  207. TypeVar child = ((TypeData)lowers.get(i)).toTypeVar();
  208. if (child != null)
  209. if (child.visited == 0) {
  210. index = child.dfs(preOrder, index, cp);
  211. if (child.smallest < smallest)
  212. smallest = child.smallest;
  213. }
  214. else if (child.inList)
  215. if (child.visited < smallest)
  216. smallest = child.visited;
  217. }
  218. if (visited == smallest) {
  219. ArrayList scc = new ArrayList(); // strongly connected component
  220. TypeVar cv;
  221. do {
  222. cv = (TypeVar)preOrder.remove(preOrder.size() - 1);
  223. cv.inList = false;
  224. scc.add(cv);
  225. } while (cv != this);
  226. fixTypes(scc, cp);
  227. }
  228. return index;
  229. }
  230. private void fixTypes(ArrayList scc, ClassPool cp) throws NotFoundException {
  231. HashSet lowersSet = new HashSet();
  232. boolean isBasicType = false;
  233. TypeData kind = null;
  234. int size = scc.size();
  235. for (int i = 0; i < size; i++) {
  236. ArrayList tds = ((TypeVar)scc.get(i)).lowers;
  237. int size2 = tds.size();
  238. for (int j = 0; j < size2; j++) {
  239. TypeData d = (TypeData)tds.get(j);
  240. BasicType bt = d.isBasicType();
  241. if (kind == null) {
  242. if (bt == null) {
  243. isBasicType = false;
  244. kind = d;
  245. /* If scc has only an UninitData, fixedType is kept null.
  246. So lowerSet must be empty. If scc has not only an UninitData
  247. but also another TypeData, an error must be thrown but this
  248. error detection has not been implemented. */
  249. if (d.isUninit())
  250. break;
  251. }
  252. else {
  253. isBasicType = true;
  254. kind = bt;
  255. }
  256. }
  257. else {
  258. if ((bt == null && isBasicType)
  259. || (bt != null && kind != bt)) {
  260. isBasicType = true;
  261. kind = TypeTag.TOP;
  262. break;
  263. }
  264. }
  265. if (bt == null && !d.isNullType())
  266. lowersSet.add(d.getName());
  267. }
  268. }
  269. if (isBasicType) {
  270. for (int i = 0; i < size; i++) {
  271. TypeVar cv = (TypeVar)scc.get(i);
  272. cv.lowers.clear();
  273. cv.lowers.add(kind);
  274. is2WordType = kind.is2WordType();
  275. }
  276. }
  277. else {
  278. String typeName = fixTypes2(scc, lowersSet, cp);
  279. for (int i = 0; i < size; i++) {
  280. TypeVar cv = (TypeVar)scc.get(i);
  281. cv.fixedType = typeName;
  282. }
  283. }
  284. }
  285. private String fixTypes2(ArrayList scc, HashSet lowersSet, ClassPool cp) throws NotFoundException {
  286. Iterator it = lowersSet.iterator();
  287. if (lowersSet.size() == 0)
  288. return null; // only NullType
  289. else if (lowersSet.size() == 1)
  290. return (String)it.next();
  291. else {
  292. CtClass cc = cp.get((String)it.next());
  293. while (it.hasNext())
  294. cc = commonSuperClassEx(cc, cp.get((String)it.next()));
  295. if (cc.getSuperclass() == null || isObjectArray(cc))
  296. cc = fixByUppers(scc, cp, new HashSet(), cc);
  297. if (cc.isArray())
  298. return Descriptor.toJvmName(cc);
  299. else
  300. return cc.getName();
  301. }
  302. }
  303. private static boolean isObjectArray(CtClass cc) throws NotFoundException {
  304. return cc.isArray() && cc.getComponentType().getSuperclass() == null;
  305. }
  306. private CtClass fixByUppers(ArrayList users, ClassPool cp, HashSet visited, CtClass type)
  307. throws NotFoundException
  308. {
  309. if (users == null)
  310. return type;
  311. int size = users.size();
  312. for (int i = 0; i < size; i++) {
  313. TypeVar t = (TypeVar)users.get(i);
  314. if (!visited.add(t))
  315. return type;
  316. if (t.uppers != null) {
  317. int s = t.uppers.size();
  318. for (int k = 0; k < s; k++) {
  319. CtClass cc = cp.get((String)t.uppers.get(k));
  320. if (cc.subtypeOf(type))
  321. type = cc;
  322. }
  323. }
  324. type = fixByUppers(t.usedBy, cp, visited, type);
  325. }
  326. return type;
  327. }
  328. }
  329. /**
  330. * Finds the most specific common super class of the given classes
  331. * by considering array types.
  332. */
  333. public static CtClass commonSuperClassEx(CtClass one, CtClass two) throws NotFoundException {
  334. if (one == two)
  335. return one;
  336. else if (one.isArray() && two.isArray()) {
  337. CtClass ele1 = one.getComponentType();
  338. CtClass ele2 = two.getComponentType();
  339. CtClass element = commonSuperClassEx(ele1, ele2);
  340. if (element == ele1)
  341. return one;
  342. else if (element == ele2)
  343. return two;
  344. else
  345. return one.getClassPool().get(element == null ? "java.lang.Object"
  346. : element.getName() + "[]");
  347. }
  348. else if (one.isPrimitive() || two.isPrimitive())
  349. return null; // TOP
  350. else if (one.isArray() || two.isArray()) // but !(one.isArray() && two.isArray())
  351. return one.getClassPool().get("java.lang.Object");
  352. else
  353. return commonSuperClass(one, two);
  354. }
  355. /**
  356. * Finds the most specific common super class of the given classes.
  357. * This method is a copy from javassist.bytecode.analysis.Type.
  358. */
  359. public static CtClass commonSuperClass(CtClass one, CtClass two) throws NotFoundException {
  360. CtClass deep = one;
  361. CtClass shallow = two;
  362. CtClass backupShallow = shallow;
  363. CtClass backupDeep = deep;
  364. // Phase 1 - Find the deepest hierarchy, set deep and shallow correctly
  365. for (;;) {
  366. // In case we get lucky, and find a match early
  367. if (eq(deep, shallow) && deep.getSuperclass() != null)
  368. return deep;
  369. CtClass deepSuper = deep.getSuperclass();
  370. CtClass shallowSuper = shallow.getSuperclass();
  371. if (shallowSuper == null) {
  372. // right, now reset shallow
  373. shallow = backupShallow;
  374. break;
  375. }
  376. if (deepSuper == null) {
  377. // wrong, swap them, since deep is now useless, its our tmp before we swap it
  378. deep = backupDeep;
  379. backupDeep = backupShallow;
  380. backupShallow = deep;
  381. deep = shallow;
  382. shallow = backupShallow;
  383. break;
  384. }
  385. deep = deepSuper;
  386. shallow = shallowSuper;
  387. }
  388. // Phase 2 - Move deepBackup up by (deep end - deep)
  389. for (;;) {
  390. deep = deep.getSuperclass();
  391. if (deep == null)
  392. break;
  393. backupDeep = backupDeep.getSuperclass();
  394. }
  395. deep = backupDeep;
  396. // Phase 3 - The hierarchy positions are now aligned
  397. // The common super class is easy to find now
  398. while (!eq(deep, shallow)) {
  399. deep = deep.getSuperclass();
  400. shallow = shallow.getSuperclass();
  401. }
  402. return deep;
  403. }
  404. static boolean eq(CtClass one, CtClass two) {
  405. return one == two || (one != null && two != null && one.getName().equals(two.getName()));
  406. }
  407. public static void aastore(TypeData array, TypeData value, ClassPool cp) throws BadBytecode {
  408. if (array instanceof AbsTypeVar)
  409. if (!value.isNullType())
  410. ((AbsTypeVar)array).merge(ArrayType.make(value));
  411. if (value instanceof AbsTypeVar)
  412. if (array instanceof AbsTypeVar)
  413. ArrayElement.make(array); // should call value.setType() later.
  414. else if (array instanceof ClassName) {
  415. if (!array.isNullType()) {
  416. String type = ArrayElement.typeName(array.getName());
  417. value.setType(type, cp);
  418. }
  419. }
  420. else
  421. throw new BadBytecode("bad AASTORE: " + array);
  422. }
  423. /* A type variable representing an array type.
  424. * It is a decorator of another type variable.
  425. */
  426. public static class ArrayType extends AbsTypeVar {
  427. private AbsTypeVar element;
  428. private ArrayType(AbsTypeVar elementType) {
  429. element = elementType;
  430. }
  431. static TypeData make(TypeData element) throws BadBytecode {
  432. if (element instanceof ArrayElement)
  433. return ((ArrayElement)element).arrayType();
  434. else if (element instanceof AbsTypeVar)
  435. return new ArrayType((AbsTypeVar)element);
  436. else if (element instanceof ClassName)
  437. if (!element.isNullType())
  438. return new ClassName(typeName(element.getName()));
  439. throw new BadBytecode("bad AASTORE: " + element);
  440. }
  441. public void merge(TypeData t) {
  442. try {
  443. if (!t.isNullType())
  444. element.merge(ArrayElement.make(t));
  445. }
  446. catch (BadBytecode e) {
  447. // never happens
  448. throw new RuntimeException("fatal: " + e);
  449. }
  450. }
  451. public String getName() {
  452. return typeName(element.getName());
  453. }
  454. public AbsTypeVar elementType() { return element; }
  455. public BasicType isBasicType() { return null; }
  456. public boolean is2WordType() { return false; }
  457. /* elementType must be a class name. Basic type names
  458. * are not allowed.
  459. */
  460. public static String typeName(String elementType) {
  461. if (elementType.charAt(0) == '[')
  462. return "[" + elementType;
  463. else
  464. return "[L" + elementType.replace('.', '/') + ";";
  465. }
  466. public void setType(String s, ClassPool cp) throws BadBytecode {
  467. element.setType(ArrayElement.typeName(s), cp);
  468. }
  469. protected TypeVar toTypeVar() { return element.toTypeVar(); }
  470. public int dfs(ArrayList order, int index, ClassPool cp) throws NotFoundException {
  471. return element.dfs(order, index, cp);
  472. }
  473. }
  474. /* A type variable representing an array-element type.
  475. * It is a decorator of another type variable.
  476. */
  477. public static class ArrayElement extends AbsTypeVar {
  478. private AbsTypeVar array;
  479. private ArrayElement(AbsTypeVar a) { // a is never null
  480. array = a;
  481. }
  482. public static TypeData make(TypeData array) throws BadBytecode {
  483. if (array instanceof ArrayType)
  484. return ((ArrayType)array).elementType();
  485. else if (array instanceof AbsTypeVar)
  486. return new ArrayElement((AbsTypeVar)array);
  487. else if (array instanceof ClassName)
  488. if (!array.isNullType())
  489. return new ClassName(typeName(array.getName()));
  490. throw new BadBytecode("bad AASTORE: " + array);
  491. }
  492. public void merge(TypeData t) {
  493. try {
  494. if (!t.isNullType())
  495. array.merge(ArrayType.make(t));
  496. }
  497. catch (BadBytecode e) {
  498. // never happens
  499. throw new RuntimeException("fatal: " + e);
  500. }
  501. }
  502. public String getName() {
  503. return typeName(array.getName());
  504. }
  505. public AbsTypeVar arrayType() { return array; }
  506. /* arrayType must be a class name. Basic type names are
  507. * not allowed.
  508. */
  509. public BasicType isBasicType() { return null; }
  510. public boolean is2WordType() { return false; }
  511. private static String typeName(String arrayType) {
  512. if (arrayType.length() > 1 && arrayType.charAt(0) == '[') {
  513. char c = arrayType.charAt(1);
  514. if (c == 'L')
  515. return arrayType.substring(2, arrayType.length() - 1).replace('/', '.');
  516. else if (c == '[')
  517. return arrayType.substring(1);
  518. }
  519. return "java.lang.Object"; // the array type may be NullType
  520. }
  521. public void setType(String s, ClassPool cp) throws BadBytecode {
  522. array.setType(ArrayType.typeName(s), cp);
  523. }
  524. protected TypeVar toTypeVar() { return array.toTypeVar(); }
  525. public int dfs(ArrayList order, int index, ClassPool cp) throws NotFoundException {
  526. return array.dfs(order, index, cp);
  527. }
  528. }
  529. public static class UninitTypeVar extends AbsTypeVar {
  530. protected TypeData type; // UninitData or TOP
  531. public UninitTypeVar(UninitData t) { type = t; }
  532. public int getTypeTag() { return type.getTypeTag(); }
  533. public int getTypeData(ConstPool cp) { return type.getTypeData(cp); }
  534. public BasicType isBasicType() { return type.isBasicType(); }
  535. public boolean is2WordType() { return type.is2WordType(); }
  536. public boolean isUninit() { return type.isUninit(); }
  537. public boolean eq(TypeData d) { return type.eq(d); }
  538. public String getName() { return type.getName(); }
  539. protected TypeVar toTypeVar() { return null; }
  540. public TypeData join() { return type.join(); }
  541. public void setType(String s, ClassPool cp) throws BadBytecode {
  542. type.setType(s, cp);
  543. }
  544. public void merge(TypeData t) {
  545. if (!t.eq(type))
  546. type = TypeTag.TOP;
  547. }
  548. public void constructorCalled(int offset) {
  549. type.constructorCalled(offset);
  550. }
  551. public int offset() {
  552. if (type instanceof UninitData)
  553. return ((UninitData)type).offset;
  554. else // if type == TypeTag.TOP
  555. throw new RuntimeException("not available");
  556. }
  557. }
  558. /**
  559. * Type data for OBJECT.
  560. */
  561. public static class ClassName extends TypeData {
  562. private String name; // dot separated.
  563. public ClassName(String n) {
  564. name = n;
  565. }
  566. public String getName() {
  567. return name;
  568. }
  569. public BasicType isBasicType() { return null; }
  570. public boolean is2WordType() { return false; }
  571. public int getTypeTag() { return StackMapTable.OBJECT; }
  572. public int getTypeData(ConstPool cp) {
  573. return cp.addClassInfo(getName());
  574. }
  575. public boolean eq(TypeData d) { return name.equals(d.getName()); }
  576. public void setType(String typeName, ClassPool cp) throws BadBytecode {}
  577. }
  578. /**
  579. * Type data for NULL or OBJECT.
  580. * The types represented by the instances of this class are
  581. * initially NULL but will be OBJECT.
  582. */
  583. public static class NullType extends ClassName {
  584. public NullType() {
  585. super("null-type"); // type name
  586. }
  587. public int getTypeTag() {
  588. return StackMapTable.NULL;
  589. }
  590. public boolean isNullType() { return true; }
  591. public int getTypeData(ConstPool cp) { return 0; }
  592. }
  593. /**
  594. * Type data for UNINIT.
  595. */
  596. public static class UninitData extends ClassName {
  597. int offset;
  598. boolean initialized;
  599. UninitData(int offset, String className) {
  600. super(className);
  601. this.offset = offset;
  602. this.initialized = false;
  603. }
  604. public UninitData copy() { return new UninitData(offset, getName()); }
  605. public int getTypeTag() {
  606. return StackMapTable.UNINIT;
  607. }
  608. public int getTypeData(ConstPool cp) {
  609. return offset;
  610. }
  611. public TypeData join() {
  612. if (initialized)
  613. return new TypeVar(new ClassName(getName()));
  614. else
  615. return new UninitTypeVar(copy());
  616. }
  617. public boolean isUninit() { return true; }
  618. public boolean eq(TypeData d) {
  619. if (d instanceof UninitData) {
  620. UninitData ud = (UninitData)d;
  621. return offset == ud.offset && getName().equals(ud.getName());
  622. }
  623. else
  624. return false;
  625. }
  626. public String toString() { return "uninit:" + getName() + "@" + offset; }
  627. public int offset() { return offset; }
  628. public void constructorCalled(int offset) {
  629. if (offset == this.offset)
  630. initialized = true;
  631. }
  632. }
  633. public static class UninitThis extends UninitData {
  634. UninitThis(String className) {
  635. super(-1, className);
  636. }
  637. public UninitData copy() { return new UninitThis(getName()); }
  638. public int getTypeTag() {
  639. return StackMapTable.THIS;
  640. }
  641. public int getTypeData(ConstPool cp) {
  642. return 0;
  643. }
  644. public String toString() { return "uninit:this"; }
  645. }
  646. }