PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/findbugs-1.3.9/src/patches/obsolete/bcel-30-April-2003.patch

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Patch | 1254 lines | 1162 code | 92 blank | 0 comment | 0 complexity | 8fd271b3074f9f7a5c6ee04da9e0cd8c MD5 | raw file
  1. ? HelloWorld.class
  2. ? java
  3. ? docs/api
  4. Index: examples/TransitiveHull.java
  5. ===================================================================
  6. RCS file: /home/cvspublic/jakarta-bcel/examples/TransitiveHull.java,v
  7. retrieving revision 1.2
  8. diff -u -r1.2 TransitiveHull.java
  9. --- examples/TransitiveHull.java 10 Nov 2002 18:30:05 -0000 1.2
  10. +++ examples/TransitiveHull.java 30 Apr 2003 17:53:51 -0000
  11. @@ -24,6 +24,12 @@
  12. * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  13. */
  14. public class TransitiveHull extends org.apache.bcel.classfile.EmptyVisitor {
  15. + private static class LookupFailure extends RuntimeException {
  16. + public LookupFailure(String msg) {
  17. + super(msg);
  18. + }
  19. + }
  20. +
  21. private JavaClass _class;
  22. private ClassQueue _queue;
  23. private ClassSet _set;
  24. @@ -86,10 +92,14 @@
  25. return;
  26. }
  27. - JavaClass clazz = Repository.lookupClass(class_name);
  28. + try {
  29. + JavaClass clazz = Repository.lookupClass(class_name);
  30. - if(clazz != null && _set.add(clazz)) {
  31. - _queue.enqueue(clazz);
  32. + if(_set.add(clazz)) {
  33. + _queue.enqueue(clazz);
  34. + }
  35. + } catch (ClassNotFoundException e) {
  36. + throw new LookupFailure("Missing class: " + e.toString());
  37. }
  38. }
  39. Index: src/java/org/apache/bcel/Repository.java
  40. ===================================================================
  41. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/Repository.java,v
  42. retrieving revision 1.11
  43. diff -u -r1.11 Repository.java
  44. --- src/java/org/apache/bcel/Repository.java 11 Oct 2002 20:34:47 -0000 1.11
  45. +++ src/java/org/apache/bcel/Repository.java 30 Apr 2003 17:53:51 -0000
  46. @@ -88,33 +88,32 @@
  47. /** Lookup class somewhere found on your CLASSPATH, or whereever the
  48. * repository instance looks for it.
  49. *
  50. - * @return class object for given fully qualified class name, or null
  51. - * if the class could not be found or parsed correctly
  52. + * @return class object for given fully qualified class name
  53. + * @throws ClassNotFoundException if the class could not be found or
  54. + * parsed correctly
  55. */
  56. - public static JavaClass lookupClass(String class_name) {
  57. - try {
  58. - JavaClass clazz = _repository.findClass(class_name);
  59. + public static JavaClass lookupClass(String class_name)
  60. + throws ClassNotFoundException {
  61. - if(clazz == null) {
  62. - return _repository.loadClass(class_name);
  63. - } else {
  64. - return clazz;
  65. - }
  66. - } catch(ClassNotFoundException ex) { return null; }
  67. + return _repository.loadClass(class_name);
  68. }
  69. /**
  70. - * Try to find class source via getResourceAsStream().
  71. + * Try to find class source using the internal repository instance.
  72. * @see Class
  73. * @return JavaClass object for given runtime class
  74. + * @throws ClassNotFoundException if the class could not be found or
  75. + * parsed correctly
  76. */
  77. - public static JavaClass lookupClass(Class clazz) {
  78. - try {
  79. - return _repository.loadClass(clazz);
  80. - } catch(ClassNotFoundException ex) { return null; }
  81. + public static JavaClass lookupClass(Class clazz)
  82. + throws ClassNotFoundException {
  83. + return _repository.loadClass(clazz);
  84. }
  85. - /** @return class file object for given Java class.
  86. + /**
  87. + * @return class file object for given Java class by looking on the
  88. + * system class path; returns null if the class file can't be
  89. + * found
  90. */
  91. public static ClassPath.ClassFile lookupClassFile(String class_name) {
  92. try {
  93. @@ -156,92 +155,124 @@
  94. /**
  95. * @return list of super classes of clazz in ascending order, i.e.,
  96. * Object is always the last element
  97. + * @throws ClassNotFoundException if any of the superclasses can't be found
  98. */
  99. - public static JavaClass[] getSuperClasses(JavaClass clazz) {
  100. + public static JavaClass[] getSuperClasses(JavaClass clazz)
  101. + throws ClassNotFoundException {
  102. return clazz.getSuperClasses();
  103. }
  104. /**
  105. * @return list of super classes of clazz in ascending order, i.e.,
  106. - * Object is always the last element. return "null", if class
  107. - * cannot be found.
  108. + * Object is always the last element.
  109. + * @throws ClassNotFoundException if the named class or any of its
  110. + * superclasses can't be found
  111. */
  112. - public static JavaClass[] getSuperClasses(String class_name) {
  113. + public static JavaClass[] getSuperClasses(String class_name)
  114. + throws ClassNotFoundException {
  115. JavaClass jc = lookupClass(class_name);
  116. - return (jc == null? null : getSuperClasses(jc));
  117. + return getSuperClasses(jc);
  118. }
  119. /**
  120. * @return all interfaces implemented by class and its super
  121. * classes and the interfaces that those interfaces extend, and so on.
  122. * (Some people call this a transitive hull).
  123. + * @throws ClassNotFoundException if any of the class's
  124. + * superclasses or superinterfaces can't be found
  125. */
  126. - public static JavaClass[] getInterfaces(JavaClass clazz) {
  127. + public static JavaClass[] getInterfaces(JavaClass clazz)
  128. + throws ClassNotFoundException {
  129. return clazz.getAllInterfaces();
  130. }
  131. /**
  132. * @return all interfaces implemented by class and its super
  133. * classes and the interfaces that extend those interfaces, and so on
  134. + * @throws ClassNotFoundException if the named class can't be found,
  135. + * or if any of its superclasses or superinterfaces can't be found
  136. */
  137. - public static JavaClass[] getInterfaces(String class_name) {
  138. + public static JavaClass[] getInterfaces(String class_name)
  139. + throws ClassNotFoundException {
  140. return getInterfaces(lookupClass(class_name));
  141. }
  142. /**
  143. * Equivalent to runtime "instanceof" operator.
  144. * @return true, if clazz is an instance of super_class
  145. + * @throws ClassNotFoundException if any superclasses or superinterfaces
  146. + * of clazz can't be found
  147. */
  148. - public static boolean instanceOf(JavaClass clazz, JavaClass super_class) {
  149. + public static boolean instanceOf(JavaClass clazz, JavaClass super_class)
  150. + throws ClassNotFoundException {
  151. return clazz.instanceOf(super_class);
  152. }
  153. /**
  154. * @return true, if clazz is an instance of super_class
  155. + * @throws ClassNotFoundException if either clazz or super_class
  156. + * can't be found
  157. */
  158. - public static boolean instanceOf(String clazz, String super_class) {
  159. + public static boolean instanceOf(String clazz, String super_class)
  160. + throws ClassNotFoundException {
  161. return instanceOf(lookupClass(clazz), lookupClass(super_class));
  162. }
  163. /**
  164. * @return true, if clazz is an instance of super_class
  165. + * @throws ClassNotFoundException if super_class can't be found
  166. */
  167. - public static boolean instanceOf(JavaClass clazz, String super_class) {
  168. + public static boolean instanceOf(JavaClass clazz, String super_class)
  169. + throws ClassNotFoundException {
  170. return instanceOf(clazz, lookupClass(super_class));
  171. }
  172. /**
  173. * @return true, if clazz is an instance of super_class
  174. + * @throws ClassNotFoundException if clazz can't be found
  175. */
  176. - public static boolean instanceOf(String clazz, JavaClass super_class) {
  177. + public static boolean instanceOf(String clazz, JavaClass super_class)
  178. + throws ClassNotFoundException {
  179. return instanceOf(lookupClass(clazz), super_class);
  180. }
  181. /**
  182. * @return true, if clazz is an implementation of interface inter
  183. + * @throws ClassNotFoundException if any superclasses or superinterfaces
  184. + * of clazz can't be found
  185. */
  186. - public static boolean implementationOf(JavaClass clazz, JavaClass inter) {
  187. + public static boolean implementationOf(JavaClass clazz, JavaClass inter)
  188. + throws ClassNotFoundException {
  189. return clazz.implementationOf(inter);
  190. }
  191. /**
  192. * @return true, if clazz is an implementation of interface inter
  193. + * @throws ClassNotFoundException if clazz, inter, or any superclasses
  194. + * or superinterfaces of clazz can't be found
  195. */
  196. - public static boolean implementationOf(String clazz, String inter) {
  197. + public static boolean implementationOf(String clazz, String inter)
  198. + throws ClassNotFoundException {
  199. return implementationOf(lookupClass(clazz), lookupClass(inter));
  200. }
  201. /**
  202. * @return true, if clazz is an implementation of interface inter
  203. + * @throws ClassNotFoundException if inter or any superclasses
  204. + * or superinterfaces of clazz can't be found
  205. */
  206. - public static boolean implementationOf(JavaClass clazz, String inter) {
  207. + public static boolean implementationOf(JavaClass clazz, String inter)
  208. + throws ClassNotFoundException {
  209. return implementationOf(clazz, lookupClass(inter));
  210. }
  211. /**
  212. * @return true, if clazz is an implementation of interface inter
  213. + * @throws ClassNotFoundException if clazz or any superclasses or
  214. + * superinterfaces of clazz can't be found
  215. */
  216. - public static boolean implementationOf(String clazz, JavaClass inter) {
  217. + public static boolean implementationOf(String clazz, JavaClass inter)
  218. + throws ClassNotFoundException {
  219. return implementationOf(lookupClass(clazz), inter);
  220. }
  221. }
  222. Index: src/java/org/apache/bcel/classfile/JavaClass.java
  223. ===================================================================
  224. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/classfile/JavaClass.java,v
  225. retrieving revision 1.13
  226. diff -u -r1.13 JavaClass.java
  227. --- src/java/org/apache/bcel/classfile/JavaClass.java 11 Jul 2002 19:39:04 -0000 1.13
  228. +++ src/java/org/apache/bcel/classfile/JavaClass.java 30 Apr 2003 17:53:51 -0000
  229. @@ -685,9 +685,13 @@
  230. /** Equivalent to runtime "instanceof" operator.
  231. *
  232. - * @return true if this JavaClass is derived from teh super class
  233. + * @return true if this JavaClass is derived from the super class
  234. + * @throws ClassNotFoundException if superclasses or superinterfaces
  235. + * of this object can't be found
  236. */
  237. - public final boolean instanceOf(JavaClass super_class) {
  238. + public final boolean instanceOf(JavaClass super_class)
  239. + throws ClassNotFoundException {
  240. +
  241. if(this.equals(super_class))
  242. return true;
  243. @@ -707,9 +711,13 @@
  244. }
  245. /**
  246. - * @return true, if clazz is an implementation of interface inter
  247. + * @return true, if this class is an implementation of interface inter
  248. + * @throws ClassNotFoundException if superclasses or superinterfaces
  249. + * of this class can't be found
  250. */
  251. - public boolean implementationOf(JavaClass inter) {
  252. + public boolean implementationOf(JavaClass inter)
  253. + throws ClassNotFoundException {
  254. +
  255. if(!inter.isInterface()) {
  256. throw new IllegalArgumentException(inter.getClassName() + " is no interface");
  257. }
  258. @@ -732,25 +740,22 @@
  259. /**
  260. * @return the superclass for this JavaClass object, or null if this
  261. * is java.lang.Object
  262. + * @throws ClassNotFoundException if the superclass can't be found
  263. */
  264. - public JavaClass getSuperClass() {
  265. + public JavaClass getSuperClass() throws ClassNotFoundException {
  266. if("java.lang.Object".equals(getClassName())) {
  267. return null;
  268. }
  269. - try {
  270. - return repository.loadClass(getSuperclassName());
  271. - } catch(ClassNotFoundException e) {
  272. - System.err.println(e);
  273. - return null;
  274. - }
  275. + return repository.loadClass(getSuperclassName());
  276. }
  277. /**
  278. * @return list of super classes of this class in ascending order, i.e.,
  279. * java.lang.Object is always the last element
  280. + * @throws ClassNotFoundException if any of the superclasses can't be found
  281. */
  282. - public JavaClass[] getSuperClasses() {
  283. + public JavaClass[] getSuperClasses() throws ClassNotFoundException {
  284. JavaClass clazz = this;
  285. ClassVector vec = new ClassVector();
  286. @@ -766,17 +771,12 @@
  287. /**
  288. * Get interfaces directly implemented by this JavaClass.
  289. */
  290. - public JavaClass[] getInterfaces() {
  291. + public JavaClass[] getInterfaces() throws ClassNotFoundException {
  292. String[] interfaces = getInterfaceNames();
  293. JavaClass[] classes = new JavaClass[interfaces.length];
  294. - try {
  295. - for(int i = 0; i < interfaces.length; i++) {
  296. - classes[i] = repository.loadClass(interfaces[i]);
  297. - }
  298. - } catch(ClassNotFoundException e) {
  299. - System.err.println(e);
  300. - return null;
  301. + for(int i = 0; i < interfaces.length; i++) {
  302. + classes[i] = repository.loadClass(interfaces[i]);
  303. }
  304. return classes;
  305. @@ -785,7 +785,7 @@
  306. /**
  307. * Get all interfaces implemented by this JavaClass (transitively).
  308. */
  309. - public JavaClass[] getAllInterfaces() {
  310. + public JavaClass[] getAllInterfaces() throws ClassNotFoundException {
  311. ClassQueue queue = new ClassQueue();
  312. ClassVector vec = new ClassVector();
  313. Index: src/java/org/apache/bcel/classfile/Signature.java
  314. ===================================================================
  315. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/classfile/Signature.java,v
  316. retrieving revision 1.3
  317. diff -u -r1.3 Signature.java
  318. --- src/java/org/apache/bcel/classfile/Signature.java 11 Mar 2002 16:16:35 -0000 1.3
  319. +++ src/java/org/apache/bcel/classfile/Signature.java 30 Apr 2003 17:53:51 -0000
  320. @@ -111,7 +111,7 @@
  321. * @param v Visitor object
  322. */
  323. public void accept(Visitor v) {
  324. - System.err.println("Visiting non-standard Signature object");
  325. + //System.err.println("Visiting non-standard Signature object");
  326. v.visitSignature(this);
  327. }
  328. Index: src/java/org/apache/bcel/generic/ObjectType.java
  329. ===================================================================
  330. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/generic/ObjectType.java,v
  331. retrieving revision 1.1.1.1
  332. diff -u -r1.1.1.1 ObjectType.java
  333. --- src/java/org/apache/bcel/generic/ObjectType.java 29 Oct 2001 20:00:25 -0000 1.1.1.1
  334. +++ src/java/org/apache/bcel/generic/ObjectType.java 30 Apr 2003 17:53:51 -0000
  335. @@ -93,12 +93,13 @@
  336. * If "this" doesn't reference a class, it references an interface
  337. * or a non-existant entity.
  338. */
  339. - public boolean referencesClass(){
  340. - JavaClass jc = Repository.lookupClass(class_name);
  341. - if (jc == null)
  342. - return false;
  343. - else
  344. + public boolean referencesClass() {
  345. + try {
  346. + JavaClass jc = Repository.lookupClass(class_name);
  347. return jc.isClass();
  348. + } catch (ClassNotFoundException e) {
  349. + return false;
  350. + }
  351. }
  352. /**
  353. @@ -106,14 +107,22 @@
  354. * or a non-existant entity.
  355. */
  356. public boolean referencesInterface(){
  357. - JavaClass jc = Repository.lookupClass(class_name);
  358. - if (jc == null)
  359. - return false;
  360. - else
  361. + try {
  362. + JavaClass jc = Repository.lookupClass(class_name);
  363. return !jc.isClass();
  364. + } catch (ClassNotFoundException e) {
  365. + return false;
  366. + }
  367. }
  368. - public boolean subclassOf(ObjectType superclass){
  369. + /**
  370. + * Return true if this type is a subclass of given ObjectType.
  371. + * @throws ClassNotFoundException if any of this class's superclasses
  372. + * can't be found
  373. + */
  374. + public boolean subclassOf(ObjectType superclass)
  375. + throws ClassNotFoundException {
  376. +
  377. if (this.referencesInterface() || superclass.referencesInterface())
  378. return false;
  379. @@ -122,8 +131,10 @@
  380. /**
  381. * Java Virtual Machine Specification edition 2, � 5.4.4 Access Control
  382. + * @throws ClassNotFoundException if the class referenced by this type
  383. + * can't be found
  384. */
  385. - public boolean accessibleTo(ObjectType accessor) {
  386. + public boolean accessibleTo(ObjectType accessor) throws ClassNotFoundException {
  387. JavaClass jc = Repository.lookupClass(class_name);
  388. if(jc.isPublic()) {
  389. Index: src/java/org/apache/bcel/generic/ReferenceType.java
  390. ===================================================================
  391. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/generic/ReferenceType.java,v
  392. retrieving revision 1.5
  393. diff -u -r1.5 ReferenceType.java
  394. --- src/java/org/apache/bcel/generic/ReferenceType.java 7 Aug 2002 18:01:32 -0000 1.5
  395. +++ src/java/org/apache/bcel/generic/ReferenceType.java 30 Apr 2003 17:53:51 -0000
  396. @@ -82,8 +82,11 @@
  397. * However, because e.g. CHECKCAST doesn't throw a
  398. * ClassCastException when casting a null reference to any Object,
  399. * true is returned in this case.
  400. + *
  401. + * @throws ClassNotFoundException if any classes or interfaces required
  402. + * to determine assignment compatibility can't be found
  403. */
  404. - public boolean isCastableTo(Type t) {
  405. + public boolean isCastableTo(Type t) throws ClassNotFoundException {
  406. if (this.equals(Type.NULL))
  407. return true; // If this is ever changed in isAssignmentCompatible()
  408. @@ -97,8 +100,12 @@
  409. * Return true iff this is assignment compatible with another type t
  410. * as defined in the JVM specification; see the AASTORE definition
  411. * there.
  412. + * @throws ClassNotFoundException if any classes or interfaces required
  413. + * to determine assignment compatibility can't be found
  414. */
  415. - public boolean isAssignmentCompatibleWith(Type t) {
  416. + public boolean isAssignmentCompatibleWith(Type t)
  417. + throws ClassNotFoundException {
  418. +
  419. if (!(t instanceof ReferenceType))
  420. return false;
  421. @@ -210,8 +217,13 @@
  422. * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
  423. * If not all of the two classes' superclasses cannot be found, "null" is returned.
  424. * See the JVM specification edition 2, "�4.9.2 The Bytecode Verifier".
  425. + *
  426. + * @throws ClassNotFoundException on failure to find superclasses of this
  427. + * type, or the type passed as a parameter
  428. */
  429. - public ReferenceType getFirstCommonSuperclass(ReferenceType t) {
  430. + public ReferenceType getFirstCommonSuperclass(ReferenceType t)
  431. + throws ClassNotFoundException {
  432. +
  433. if (this.equals(Type.NULL)) return t;
  434. if (t.equals(Type.NULL)) return this;
  435. if (this.equals(t)) return this;
  436. @@ -294,8 +306,12 @@
  437. *
  438. * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
  439. * slightly changed semantics.
  440. + * @throws ClassNotFoundException on failure to find superclasses of this
  441. + * type, or the type passed as a parameter
  442. */
  443. - public ReferenceType firstCommonSuperclass(ReferenceType t) {
  444. + public ReferenceType firstCommonSuperclass(ReferenceType t)
  445. + throws ClassNotFoundException {
  446. +
  447. if (this.equals(Type.NULL)) return t;
  448. if (t.equals(Type.NULL)) return this;
  449. if (this.equals(t)) return this;
  450. Index: src/java/org/apache/bcel/util/SyntheticRepository.java
  451. ===================================================================
  452. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/util/SyntheticRepository.java,v
  453. retrieving revision 1.6
  454. diff -u -r1.6 SyntheticRepository.java
  455. --- src/java/org/apache/bcel/util/SyntheticRepository.java 10 Nov 2002 18:30:05 -0000 1.6
  456. +++ src/java/org/apache/bcel/util/SyntheticRepository.java 30 Apr 2003 17:53:51 -0000
  457. @@ -138,6 +138,10 @@
  458. public JavaClass loadClass(String className)
  459. throws ClassNotFoundException
  460. {
  461. + JavaClass alreadyLoaded = findClass(className);
  462. + if (alreadyLoaded != null)
  463. + return alreadyLoaded;
  464. +
  465. if(className == null || className.equals("")) {
  466. throw new IllegalArgumentException("Invalid class name " + className);
  467. }
  468. @@ -159,6 +163,11 @@
  469. */
  470. public JavaClass loadClass(Class clazz) throws ClassNotFoundException {
  471. String className = clazz.getName();
  472. +
  473. + JavaClass alreadyLoaded = findClass(className);
  474. + if (alreadyLoaded != null)
  475. + return alreadyLoaded;
  476. +
  477. String name = className;
  478. int i = name.lastIndexOf('.');
  479. Index: src/java/org/apache/bcel/verifier/TransitiveHull.java
  480. ===================================================================
  481. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/TransitiveHull.java,v
  482. retrieving revision 1.1.1.1
  483. diff -u -r1.1.1.1 TransitiveHull.java
  484. --- src/java/org/apache/bcel/verifier/TransitiveHull.java 29 Oct 2001 20:00:31 -0000 1.1.1.1
  485. +++ src/java/org/apache/bcel/verifier/TransitiveHull.java 30 Apr 2003 17:53:51 -0000
  486. @@ -77,7 +77,7 @@
  487. }
  488. /* Implementing VerifierFactoryObserver. */
  489. - public void update(String classname){
  490. + public void update(String classname) {
  491. System.gc(); // avoid swapping if possible.
  492. @@ -99,15 +99,19 @@
  493. System.out.println("Pass 2:\n"+vr);
  494. if (vr == VerificationResult.VR_OK){
  495. - JavaClass jc = Repository.lookupClass(v.getClassName());
  496. - for (int i=0; i<jc.getMethods().length; i++){
  497. - vr = v.doPass3a(i);
  498. - if (vr != VerificationResult.VR_OK) //System.exit(1);
  499. - System.out.println(v.getClassName()+", Pass 3a, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
  500. -
  501. - vr = v.doPass3b(i);
  502. - if (vr != VerificationResult.VR_OK) //System.exit(1);
  503. - System.out.println(v.getClassName()+", Pass 3b, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
  504. + try {
  505. + JavaClass jc = Repository.lookupClass(v.getClassName());
  506. + for (int i=0; i<jc.getMethods().length; i++){
  507. + vr = v.doPass3a(i);
  508. + if (vr != VerificationResult.VR_OK) //System.exit(1);
  509. + System.out.println(v.getClassName()+", Pass 3a, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
  510. +
  511. + vr = v.doPass3b(i);
  512. + if (vr != VerificationResult.VR_OK) //System.exit(1);
  513. + System.out.println(v.getClassName()+", Pass 3b, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
  514. + }
  515. + } catch (ClassNotFoundException e) {
  516. + System.err.println("Could not find class " + v.getClassName() + " in Repository");
  517. }
  518. }
  519. Index: src/java/org/apache/bcel/verifier/Verifier.java
  520. ===================================================================
  521. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/Verifier.java,v
  522. retrieving revision 1.7
  523. diff -u -r1.7 Verifier.java
  524. --- src/java/org/apache/bcel/verifier/Verifier.java 13 Oct 2002 21:56:16 -0000 1.7
  525. +++ src/java/org/apache/bcel/verifier/Verifier.java 30 Apr 2003 17:53:51 -0000
  526. @@ -172,7 +172,7 @@
  527. * This returns all the (warning) messages collected during verification.
  528. * A prefix shows from which verifying pass a message originates.
  529. */
  530. - public String[] getMessages(){
  531. + public String[] getMessages() throws ClassNotFoundException {
  532. ArrayList messages = new ArrayList();
  533. if (p1v != null){
  534. @@ -237,7 +237,7 @@
  535. public static void main(String [] args){
  536. System.out.println("JustIce by Enver Haase, (C) 2001-2002.\n<http://bcel.sourceforge.net>\n<http://jakarta.apache.org/bcel>\n");
  537. for(int k=0; k < args.length; k++) {
  538. -
  539. + try {
  540. if (args[k].endsWith(".class")){
  541. int dotclasspos = args[k].lastIndexOf(".class");
  542. if (dotclasspos != -1) args[k] = args[k].substring(0,dotclasspos);
  543. @@ -278,9 +278,12 @@
  544. System.out.println("\n");
  545. // avoid swapping.
  546. - v.flush();
  547. - org.apache.bcel.Repository.clearCache();
  548. - System.gc();
  549. + v.flush();
  550. + org.apache.bcel.Repository.clearCache();
  551. + System.gc();
  552. + } catch (ClassNotFoundException e) {
  553. + e.printStackTrace();
  554. + }
  555. }
  556. }
  557. }
  558. Index: src/java/org/apache/bcel/verifier/VerifierAppFrame.java
  559. ===================================================================
  560. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/VerifierAppFrame.java,v
  561. retrieving revision 1.3
  562. diff -u -r1.3 VerifierAppFrame.java
  563. --- src/java/org/apache/bcel/verifier/VerifierAppFrame.java 13 Jun 2002 09:32:50 -0000 1.3
  564. +++ src/java/org/apache/bcel/verifier/VerifierAppFrame.java 30 Apr 2003 17:53:51 -0000
  565. @@ -242,11 +242,16 @@
  566. synchronized void classNamesJList_valueChanged(ListSelectionEvent e) {
  567. if (e.getValueIsAdjusting()) return;
  568. current_class = classNamesJList.getSelectedValue().toString();
  569. - verify();
  570. + try {
  571. + verify();
  572. + } catch (ClassNotFoundException ex) {
  573. + // FIXME: report the error using the GUI
  574. + ex.printStackTrace();
  575. + }
  576. classNamesJList.setSelectedValue(current_class, true);
  577. }
  578. - private void verify(){
  579. + private void verify() throws ClassNotFoundException {
  580. setTitle("PLEASE WAIT");
  581. Verifier v = VerifierFactory.getVerifier(current_class);
  582. @@ -345,7 +350,14 @@
  583. all3aok = false;
  584. rejected = true;
  585. }
  586. - all3amsg += "Method '"+Repository.lookupClass(v.getClassName()).getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n";
  587. + JavaClass jc = null;
  588. + try {
  589. + jc = Repository.lookupClass(v.getClassName());
  590. + } catch (ClassNotFoundException ex) {
  591. + // FIXME: handle the error
  592. + ex.printStackTrace();
  593. + }
  594. + all3amsg += "Method '"+jc.getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n";
  595. }
  596. }
  597. pass3aTextPane.setText(all3amsg);
  598. @@ -370,7 +382,14 @@
  599. all3bok = false;
  600. rejected = true;
  601. }
  602. - all3bmsg += "Method '"+Repository.lookupClass(v.getClassName()).getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n";
  603. + JavaClass jc = null;
  604. + try {
  605. + jc = Repository.lookupClass(v.getClassName());
  606. + } catch (ClassNotFoundException ex) {
  607. + // FIXME: handle the error
  608. + ex.printStackTrace();
  609. + }
  610. + all3bmsg += "Method '"+jc.getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n";
  611. }
  612. }
  613. pass3bTextPane.setText(all3bmsg);
  614. Index: src/java/org/apache/bcel/verifier/VerifyDialog.java
  615. ===================================================================
  616. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/VerifyDialog.java,v
  617. retrieving revision 1.1.1.1
  618. diff -u -r1.1.1.1 VerifyDialog.java
  619. --- src/java/org/apache/bcel/verifier/VerifyDialog.java 29 Oct 2001 20:00:33 -0000 1.1.1.1
  620. +++ src/java/org/apache/bcel/verifier/VerifyDialog.java 30 Apr 2003 17:53:51 -0000
  621. @@ -539,7 +539,13 @@
  622. Verifier v = VerifierFactory.getVerifier(class_name);
  623. VerificationResult vr = v.doPass2();
  624. if (vr.getStatus() == VerificationResult.VERIFIED_OK){
  625. - JavaClass jc = Repository.lookupClass(class_name);
  626. + JavaClass jc = null;
  627. + try {
  628. + jc = Repository.lookupClass(class_name);
  629. + } catch (ClassNotFoundException ex) {
  630. + // FIXME: report the error
  631. + ex.printStackTrace();
  632. + }
  633. int nr = jc.getMethods().length;
  634. for (int i=0; i<nr; i++) {
  635. vr = v.doPass3b(i);
  636. Index: src/java/org/apache/bcel/verifier/statics/Pass1Verifier.java
  637. ===================================================================
  638. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/statics/Pass1Verifier.java,v
  639. retrieving revision 1.2
  640. diff -u -r1.2 Pass1Verifier.java
  641. --- src/java/org/apache/bcel/verifier/statics/Pass1Verifier.java 13 Jun 2002 09:32:50 -0000 1.2
  642. +++ src/java/org/apache/bcel/verifier/statics/Pass1Verifier.java 30 Apr 2003 17:53:51 -0000
  643. @@ -85,7 +85,14 @@
  644. /** Used to load in and return the myOwner-matching JavaClass object when needed. Avoids loading in a class file when it's not really needed! */
  645. private JavaClass getJavaClass(){
  646. if (jc == null){
  647. - jc = Repository.lookupClass(myOwner.getClassName());
  648. + try {
  649. + jc = Repository.lookupClass(myOwner.getClassName());
  650. + } catch (ClassNotFoundException e) {
  651. + // FIXME: currently, Pass1Verifier treats jc == null as a special
  652. + // case, so we don't need to do anything here. A better solution
  653. + // would be to simply throw the ClassNotFoundException
  654. + // out of this method.
  655. + }
  656. }
  657. return jc;
  658. }
  659. Index: src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
  660. ===================================================================
  661. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java,v
  662. retrieving revision 1.2
  663. diff -u -r1.2 Pass2Verifier.java
  664. --- src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java 13 Jun 2002 09:32:50 -0000 1.2
  665. +++ src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java 30 Apr 2003 17:53:51 -0000
  666. @@ -139,6 +139,7 @@
  667. * @see org.apache.bcel.verifier.statics.Pass3aVerifier
  668. */
  669. public VerificationResult do_verify(){
  670. + try {
  671. VerificationResult vr1 = myOwner.doPass1();
  672. if (vr1.equals(VerificationResult.VR_OK)){
  673. @@ -160,6 +161,11 @@
  674. }
  675. else
  676. return VerificationResult.VR_NOTYET;
  677. +
  678. + } catch (ClassNotFoundException e) {
  679. + // FIXME: this might not be the best way to handle missing classes.
  680. + throw new AssertionViolatedException("Missing class: " + e.toString());
  681. + }
  682. }
  683. /**
  684. @@ -176,6 +182,7 @@
  685. * @throws ClassConstraintException otherwise.
  686. */
  687. private void every_class_has_an_accessible_superclass(){
  688. + try {
  689. HashSet hs = new HashSet(); // save class names to detect circular inheritance
  690. JavaClass jc = Repository.lookupClass(myOwner.getClassName());
  691. int supidx = -1;
  692. @@ -206,6 +213,11 @@
  693. }
  694. }
  695. }
  696. +
  697. + } catch (ClassNotFoundException e) {
  698. + // FIXME: this might not be the best way to handle missing classes.
  699. + throw new AssertionViolatedException("Missing class: " + e.toString());
  700. + }
  701. }
  702. /**
  703. @@ -220,6 +232,7 @@
  704. * @see #every_class_has_an_accessible_superclass()
  705. */
  706. private void final_methods_are_not_overridden(){
  707. + try {
  708. HashMap hashmap = new HashMap();
  709. JavaClass jc = Repository.lookupClass(myOwner.getClassName());
  710. @@ -251,6 +264,11 @@
  711. jc = Repository.lookupClass(jc.getSuperclassName()); // Well, for OBJECT this returns OBJECT so it works (could return anything but must not throw an Exception).
  712. }
  713. + } catch (ClassNotFoundException e) {
  714. + // FIXME: this might not be the best way to handle missing classes.
  715. + throw new AssertionViolatedException("Missing class: " + e.toString());
  716. + }
  717. +
  718. }
  719. /**
  720. @@ -260,11 +278,17 @@
  721. * @throws ClassConstraintException otherwise.
  722. */
  723. private void constant_pool_entries_satisfy_static_constraints(){
  724. + try {
  725. // Most of the consistency is handled internally by BCEL; here
  726. // we only have to verify if the indices of the constants point
  727. // to constants of the appropriate type and such.
  728. JavaClass jc = Repository.lookupClass(myOwner.getClassName());
  729. new CPESSC_Visitor(jc); // constructor implicitely traverses jc
  730. +
  731. + } catch (ClassNotFoundException e) {
  732. + // FIXME: this might not be the best way to handle missing classes.
  733. + throw new AssertionViolatedException("Missing class: " + e.toString());
  734. + }
  735. }
  736. /**
  737. @@ -799,6 +823,7 @@
  738. // method_info-structure-ATTRIBUTES (vmspec2 4.6, 4.7) //
  739. /////////////////////////////////////////////////////////
  740. public void visitCode(Code obj){//vmspec2 4.7.3
  741. + try {
  742. // No code attribute allowed for native or abstract methods: see visitMethod(Method).
  743. // Code array constraints are checked in Pass3 (3a and 3b).
  744. @@ -945,9 +970,16 @@
  745. }
  746. }// if atts[a] instanceof LocalVariableTable END
  747. }// for all attributes atts[a] END
  748. +
  749. + } catch (ClassNotFoundException e) {
  750. + // FIXME: this might not be the best way to handle missing classes.
  751. + throw new AssertionViolatedException("Missing class: " + e.toString());
  752. + }
  753. +
  754. }// visitCode(Code) END
  755. public void visitExceptionTable(ExceptionTable obj){//vmspec2 4.7.4
  756. + try {
  757. // incorrectly named, it's the Exceptions attribute (vmspec2 4.7.4)
  758. checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
  759. @@ -992,6 +1024,11 @@
  760. if (e != t) throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
  761. }
  762. }
  763. +
  764. + } catch (ClassNotFoundException e) {
  765. + // FIXME: this might not be the best way to handle missing classes.
  766. + throw new AssertionViolatedException("Missing class: " + e.toString());
  767. + }
  768. }
  769. // SYNTHETIC: see above
  770. // DEPRECATED: see above
  771. @@ -1073,9 +1110,15 @@
  772. * @see #constant_pool_entries_satisfy_static_constraints()
  773. */
  774. private void field_and_method_refs_are_valid(){
  775. + try {
  776. JavaClass jc = Repository.lookupClass(myOwner.getClassName());
  777. DescendingVisitor v = new DescendingVisitor(jc, new FAMRAV_Visitor(jc));
  778. v.visit();
  779. +
  780. + } catch (ClassNotFoundException e) {
  781. + // FIXME: this might not be the best way to handle missing classes.
  782. + throw new AssertionViolatedException("Missing class: " + e.toString());
  783. + }
  784. }
  785. /**
  786. Index: src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
  787. ===================================================================
  788. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java,v
  789. retrieving revision 1.3
  790. diff -u -r1.3 Pass3aVerifier.java
  791. --- src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java 13 Jun 2002 09:32:50 -0000 1.3
  792. +++ src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java 30 Apr 2003 17:53:51 -0000
  793. @@ -112,6 +112,7 @@
  794. * @throws InvalidMethodException if the method to verify does not exist.
  795. */
  796. public VerificationResult do_verify(){
  797. + try {
  798. if (myOwner.doPass2().equals(VerificationResult.VR_OK)){
  799. // Okay, class file was loaded correctly by Pass 1
  800. // and satisfies static constraints of Pass 2.
  801. @@ -167,6 +168,10 @@
  802. else{ //did not pass Pass 2.
  803. return VerificationResult.VR_NOTYET;
  804. }
  805. + } catch (ClassNotFoundException e) {
  806. + // FIXME: maybe not the best way to handle this
  807. + throw new AssertionViolatedException("Missing class: " + e.toString());
  808. + }
  809. }
  810. /**
  811. @@ -330,6 +335,7 @@
  812. * @throws StaticCodeConstraintException if the verification fails.
  813. */
  814. private void pass3StaticInstructionOperandsChecks(){
  815. + try {
  816. // When building up the InstructionList, BCEL has already done all those checks
  817. // mentioned in The Java Virtual Machine Specification, Second Edition, as
  818. // "static constraints on the operands of instructions in the code array".
  819. @@ -366,6 +372,10 @@
  820. ih = ih.getNext();
  821. }
  822. + } catch (ClassNotFoundException e) {
  823. + // FIXME: maybe not the best way to handle this
  824. + throw new AssertionViolatedException("Missing class: " + e.toString());
  825. + }
  826. }
  827. /** A small utility method returning if a given int i is in the given int[] ints. */
  828. @@ -399,7 +409,12 @@
  829. * by the surrounding Pass3aVerifier instance.
  830. */
  831. private int max_locals(){
  832. + try {
  833. return Repository.lookupClass(myOwner.getClassName()).getMethods()[method_no].getCode().getMaxLocals();
  834. + } catch (ClassNotFoundException e) {
  835. + // FIXME: maybe not the best way to handle this
  836. + throw new AssertionViolatedException("Missing class: " + e.toString());
  837. + }
  838. }
  839. /**
  840. @@ -476,6 +491,7 @@
  841. /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
  842. //getfield, putfield, getstatic, putstatic
  843. public void visitFieldInstruction(FieldInstruction o){
  844. + try {
  845. indexValid(o, o.getIndex());
  846. Constant c = cpg.getConstant(o.getIndex());
  847. if (! (c instanceof ConstantFieldref)){
  848. @@ -511,6 +527,10 @@
  849. }
  850. /* TODO: Check for access modifiers here. */
  851. }
  852. + } catch (ClassNotFoundException e) {
  853. + // FIXME: maybe not the best way to handle this
  854. + throw new AssertionViolatedException("Missing class: " + e.toString());
  855. + }
  856. }
  857. /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
  858. @@ -869,6 +889,7 @@
  859. /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
  860. public void visitPUTSTATIC(PUTSTATIC o){
  861. + try {
  862. String field_name = o.getFieldName(cpg);
  863. JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
  864. Field[] fields = jc.getFields();
  865. @@ -899,10 +920,15 @@
  866. if ((!(jc.isClass())) && (!(meth_name.equals(Constants.STATIC_INITIALIZER_NAME)))){
  867. constraintViolated(o, "Interface field '"+f+"' must be set in a '"+Constants.STATIC_INITIALIZER_NAME+"' method.");
  868. }
  869. + } catch (ClassNotFoundException e) {
  870. + // FIXME: maybe not the best way to handle this
  871. + throw new AssertionViolatedException("Missing class: " + e.toString());
  872. + }
  873. }
  874. /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
  875. public void visitGETSTATIC(GETSTATIC o){
  876. + try {
  877. String field_name = o.getFieldName(cpg);
  878. JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
  879. Field[] fields = jc.getFields();
  880. @@ -920,6 +946,10 @@
  881. if (! (f.isStatic())){
  882. constraintViolated(o, "Referenced field '"+f+"' is not static which it should be.");
  883. }
  884. + } catch (ClassNotFoundException e) {
  885. + // FIXME: maybe not the best way to handle this
  886. + throw new AssertionViolatedException("Missing class: " + e.toString());
  887. + }
  888. }
  889. /* Checks if the constraints of operands of the said instruction(s) are satisfied. */
  890. @@ -934,6 +964,7 @@
  891. /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
  892. public void visitINVOKEINTERFACE(INVOKEINTERFACE o){
  893. + try {
  894. // INVOKEINTERFACE is a LoadClass; the Class where the referenced method is declared in,
  895. // is therefore resolved/verified.
  896. // INVOKEINTERFACE is an InvokeInstruction, the argument and return types are resolved/verified,
  897. @@ -956,10 +987,15 @@
  898. if (jc.isClass()){
  899. constraintViolated(o, "Referenced class '"+jc.getClassName()+"' is a class, but not an interface as expected.");
  900. }
  901. + } catch (ClassNotFoundException e) {
  902. + // FIXME: maybe not the best way to handle this
  903. + throw new AssertionViolatedException("Missing class: " + e.toString());
  904. + }
  905. }
  906. /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
  907. public void visitINVOKESPECIAL(INVOKESPECIAL o){
  908. + try {
  909. // INVOKESPECIAL is a LoadClass; the Class where the referenced method is declared in,
  910. // is therefore resolved/verified.
  911. // INVOKESPECIAL is an InvokeInstruction, the argument and return types are resolved/verified,
  912. @@ -1013,11 +1049,16 @@
  913. }
  914. }
  915. + } catch (ClassNotFoundException e) {
  916. + // FIXME: maybe not the best way to handle this
  917. + throw new AssertionViolatedException("Missing class: " + e.toString());
  918. + }
  919. }
  920. /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
  921. public void visitINVOKESTATIC(INVOKESTATIC o){
  922. + try {
  923. // INVOKESTATIC is a LoadClass; the Class where the referenced method is declared in,
  924. // is therefore resolved/verified.
  925. // INVOKESTATIC is an InvokeInstruction, the argument and return types are resolved/verified,
  926. @@ -1042,11 +1083,16 @@
  927. constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' has ACC_STATIC unset.");
  928. }
  929. + } catch (ClassNotFoundException e) {
  930. + // FIXME: maybe not the best way to handle this
  931. + throw new AssertionViolatedException("Missing class: " + e.toString());
  932. + }
  933. }
  934. /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
  935. public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){
  936. + try {
  937. // INVOKEVIRTUAL is a LoadClass; the Class where the referenced method is declared in,
  938. // is therefore resolved/verified.
  939. // INVOKEVIRTUAL is an InvokeInstruction, the argument and return types are resolved/verified,
  940. @@ -1070,6 +1116,10 @@
  941. constraintViolated(o, "Referenced class '"+jc.getClassName()+"' is an interface, but not a class as expected.");
  942. }
  943. + } catch (ClassNotFoundException e) {
  944. + // FIXME: maybe not the best way to handle this
  945. + throw new AssertionViolatedException("Missing class: " + e.toString());
  946. + }
  947. }
  948. Index: src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
  949. ===================================================================
  950. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java,v
  951. retrieving revision 1.5
  952. diff -u -r1.5 InstConstraintVisitor.java
  953. --- src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java 12 Feb 2003 10:15:29 -0000 1.5
  954. +++ src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java 30 Apr 2003 17:53:51 -0000
  955. @@ -473,6 +473,7 @@
  956. * Ensures the specific preconditions of the said instruction.
  957. */
  958. public void visitAASTORE(AASTORE o){
  959. + try {
  960. Type arrayref = stack().peek(2);
  961. Type index = stack().peek(1);
  962. Type value = stack().peek(0);
  963. @@ -493,6 +494,10 @@
  964. constraintViolated(o, "The type of 'value' ('"+value+"') is not assignment compatible to the components of the array 'arrayref' refers to. ('"+((ArrayType) arrayref).getElementType()+"')");
  965. }
  966. }
  967. + } catch (ClassNotFoundException e) {
  968. + // FIXME: maybe not the best way to handle this
  969. + throw new AssertionViolatedException("Missing class: " + e.toString());
  970. + }
  971. }
  972. /**
  973. @@ -563,6 +568,7 @@
  974. * Ensures the specific preconditions of the said instruction.
  975. */
  976. public void visitATHROW(ATHROW o){
  977. + try {
  978. // It's stated that 'objectref' must be of a ReferenceType --- but since Throwable is
  979. // not derived from an ArrayType, it follows that 'objectref' must be of an ObjectType or Type.NULL.
  980. if (! ((stack().peek() instanceof ObjectType) || (stack().peek().equals(Type.NULL))) ){
  981. @@ -577,6 +583,10 @@
  982. if ( (! (exc.subclassOf(throwable)) ) && (! (exc.equals(throwable))) ){
  983. constraintViolated(o, "The 'objectref' is not of class Throwable or of a subclass of Throwable, but of '"+stack().peek()+"'.");
  984. }
  985. + } catch (ClassNotFoundException e) {
  986. + // FIXME: maybe not the best way to handle this
  987. + throw new AssertionViolatedException("Missing class: " + e.toString());
  988. + }
  989. }
  990. /**
  991. @@ -1167,6 +1177,7 @@
  992. * Ensures the specific preconditions of the said instruction.
  993. */
  994. public void visitGETFIELD(GETFIELD o){
  995. + try {
  996. Type objectref = stack().peek();
  997. if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ){
  998. constraintViolated(o, "Stack top should be an object reference that's not an array reference, but is '"+objectref+"'.");
  999. @@ -1215,6 +1226,11 @@
  1000. if (f.isStatic()){
  1001. constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be.");
  1002. }
  1003. +
  1004. + } catch (ClassNotFoundException e) {
  1005. + // FIXME: maybe not the best way to handle this
  1006. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1007. + }
  1008. }
  1009. /**
  1010. @@ -1716,6 +1732,7 @@
  1011. * Ensures the specific preconditions of the said instruction.
  1012. */
  1013. public void visitINVOKESPECIAL(INVOKESPECIAL o){
  1014. + try {
  1015. // Don't init an object twice.
  1016. if ( (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)) && (!(stack().peek(o.getArgumentTypes(cpg).length) instanceof UninitializedObjectType)) ){
  1017. constraintViolated(o, "Possibly initializing object twice. A valid instruction sequence must not have an uninitialized object on the operand stack or in a local variable during a backwards branch, or in a local variable in code protected by an exception handler. Please see The Java Virtual Machine Specification, Second Edition, 4.9.4 (pages 147 and 148) for details.");
  1018. @@ -1796,12 +1813,17 @@
  1019. constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected.");
  1020. }
  1021. + } catch (ClassNotFoundException e) {
  1022. + // FIXME: maybe not the best way to handle this
  1023. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1024. + }
  1025. }
  1026. /**
  1027. * Ensures the specific preconditions of the said instruction.
  1028. */
  1029. public void visitINVOKESTATIC(INVOKESTATIC o){
  1030. + try {
  1031. // Method is not native, otherwise pass 3 would not happen.
  1032. Type t = o.getType(cpg);
  1033. @@ -1841,12 +1863,17 @@
  1034. }
  1035. }
  1036. }
  1037. + } catch (ClassNotFoundException e) {
  1038. + // FIXME: maybe not the best way to handle this
  1039. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1040. + }
  1041. }
  1042. /**
  1043. * Ensures the specific preconditions of the said instruction.
  1044. */
  1045. public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){
  1046. + try {
  1047. // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).
  1048. Type t = o.getType(cpg);
  1049. @@ -1912,6 +1939,10 @@
  1050. if ( ! Repository.instanceOf(objref_classname, theClass) ){
  1051. constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected.");
  1052. }
  1053. + } catch (ClassNotFoundException e) {
  1054. + // FIXME: maybe not the best way to handle this
  1055. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1056. + }
  1057. }
  1058. /**
  1059. @@ -2427,6 +2458,7 @@
  1060. * Ensures the specific preconditions of the said instruction.
  1061. */
  1062. public void visitPUTFIELD(PUTFIELD o){
  1063. + try {
  1064. Type objectref = stack().peek(1);
  1065. if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ){
  1066. @@ -2504,12 +2536,18 @@
  1067. if (f.isStatic()){
  1068. constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be.");
  1069. }
  1070. +
  1071. + } catch (ClassNotFoundException e) {
  1072. + // FIXME: maybe not the best way to handle this
  1073. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1074. + }
  1075. }
  1076. /**
  1077. * Ensures the specific preconditions of the said instruction.
  1078. */
  1079. public void visitPUTSTATIC(PUTSTATIC o){
  1080. + try {
  1081. String field_name = o.getFieldName(cpg);
  1082. JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
  1083. Field[] fields = jc.getFields();
  1084. @@ -2555,6 +2593,11 @@
  1085. }
  1086. // TODO: Interface fields may be assigned to only once. (Hard to implement in
  1087. // JustIce's execution model). This may only happen in <clinit>, see Pass 3a.
  1088. +
  1089. + } catch (ClassNotFoundException e) {
  1090. + // FIXME: maybe not the best way to handle this
  1091. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1092. + }
  1093. }
  1094. /**
  1095. Index: src/java/org/apache/bcel/verifier/structurals/LocalVariables.java
  1096. ===================================================================
  1097. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/structurals/LocalVariables.java,v
  1098. retrieving revision 1.2
  1099. diff -u -r1.2 LocalVariables.java
  1100. --- src/java/org/apache/bcel/verifier/structurals/LocalVariables.java 2 Aug 2002 11:57:51 -0000 1.2
  1101. +++ src/java/org/apache/bcel/verifier/structurals/LocalVariables.java 30 Apr 2003 17:53:51 -0000
  1102. @@ -162,6 +162,7 @@
  1103. * @see #merge(LocalVariables)
  1104. */
  1105. private void merge(LocalVariables lv, int i){
  1106. + try {
  1107. // We won't accept an unitialized object if we know it was initialized;
  1108. // compare vmspec2, 4.9.4, last paragraph.
  1109. @@ -202,6 +203,10 @@
  1110. locals[i] = Type.UNKNOWN;
  1111. }
  1112. }
  1113. + } catch (ClassNotFoundException e) {
  1114. + // FIXME: maybe not the best way to handle this
  1115. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1116. + }
  1117. }
  1118. /**
  1119. Index: src/java/org/apache/bcel/verifier/structurals/OperandStack.java
  1120. ===================================================================
  1121. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/structurals/OperandStack.java,v
  1122. retrieving revision 1.2
  1123. diff -u -r1.2 OperandStack.java
  1124. --- src/java/org/apache/bcel/verifier/structurals/OperandStack.java 2 Aug 2002 11:57:51 -0000 1.2
  1125. +++ src/java/org/apache/bcel/verifier/structurals/OperandStack.java 30 Apr 2003 17:53:51 -0000
  1126. @@ -228,6 +228,7 @@
  1127. * for details.
  1128. */
  1129. public void merge(OperandStack s){
  1130. + try {
  1131. if ( (slotsUsed() != s.slotsUsed()) || (size() != s.size()) )
  1132. throw new StructuralCodeConstraintException("Cannot merge stacks of different size:\nOperandStack A:\n"+this+"\nOperandStack B:\n"+s);
  1133. @@ -258,6 +259,10 @@
  1134. }
  1135. }
  1136. }
  1137. + } catch (ClassNotFoundException e) {
  1138. + // FIXME: maybe not the best way to handle this
  1139. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1140. + }
  1141. }
  1142. /**
  1143. Index: src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
  1144. ===================================================================
  1145. RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java,v
  1146. retrieving revision 1.3
  1147. diff -u -r1.3 Pass3bVerifier.java
  1148. --- src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java 4 Jul 2002 21:44:42 -0000 1.3
  1149. +++ src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java 30 Apr 2003 17:53:51 -0000
  1150. @@ -292,7 +292,13 @@
  1151. // Pass 3a ran before, so it's safe to assume the JavaClass object is
  1152. // in the BCEL repository.
  1153. - JavaClass jc = Repository.lookupClass(myOwner.getClassName());
  1154. + JavaClass jc;
  1155. + try {
  1156. + jc = Repository.lookupClass(myOwner.getClassName());
  1157. + } catch (ClassNotFoundException e) {
  1158. + // FIXME: maybe not the best way to handle this
  1159. + throw new AssertionViolatedException("Missing class: " + e.toString());
  1160. + }
  1161. ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool());
  1162. // Init Visitors