1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.bcel.verifier;
18
19 /***
20 * The NativeVerifier class implements a main(String[] args) method that's
21 * roughly compatible to the one in the Verifier class, but that uses the
22 * JVM's internal verifier for its class file verification.
23 * This can be used for comparison runs between the JVM-internal verifier
24 * and JustIce.
25 *
26 * @version $Id: NativeVerifier.java 386056 2006-03-15 11:31:56Z tcurdt $
27 * @author Enver Haase
28 */
29 public abstract class NativeVerifier {
30
31 /***
32 * This class must not be instantiated.
33 */
34 private NativeVerifier() {
35 }
36
37
38 /***
39 * Works only on the first argument.
40 */
41 public static void main( String[] args ) {
42 if (args.length != 1) {
43 System.out.println("Verifier front-end: need exactly one argument.");
44 System.exit(1);
45 }
46 int dotclasspos = args[0].lastIndexOf(".class");
47 if (dotclasspos != -1) {
48 args[0] = args[0].substring(0, dotclasspos);
49 }
50 args[0] = args[0].replace('/', '.');
51
52 try {
53 Class.forName(args[0]);
54 } catch (ExceptionInInitializerError eiie) {
55 System.out.println("NativeVerifier: ExceptionInInitializerError encountered on '"
56 + args[0] + "'.");
57 System.out.println(eiie);
58 System.exit(1);
59 } catch (LinkageError le) {
60 System.out.println("NativeVerifier: LinkageError encountered on '" + args[0] + "'.");
61 System.out.println(le);
62 System.exit(1);
63 } catch (ClassNotFoundException cnfe) {
64 System.out.println("NativeVerifier: FILE NOT FOUND: '" + args[0] + "'.");
65 System.exit(1);
66 } catch (Throwable t) {
67 System.out.println("NativeVerifier: Unspecified verification error on'" + args[0]
68 + "'.");
69 System.exit(1);
70 }
71 System.out.println("NativeVerifier: Class file '" + args[0] + "' seems to be okay.");
72 System.exit(0);
73 }
74 }