01: /*
02: * Copyright 2000-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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: * Works only on the first argument.
39: */
40: public static void main(String[] args) {
41: if (args.length != 1) {
42: System.out
43: .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: //System.out.println(args[0]);
52: try {
53: Class.forName(args[0]);
54: } catch (ExceptionInInitializerError eiie) { //subclass of LinkageError!
55: System.out
56: .println("NativeVerifier: ExceptionInInitializerError encountered on '"
57: + args[0] + "'.");
58: System.out.println(eiie);
59: System.exit(1);
60: } catch (LinkageError le) {
61: System.out
62: .println("NativeVerifier: LinkageError encountered on '"
63: + args[0] + "'.");
64: System.out.println(le);
65: System.exit(1);
66: } catch (ClassNotFoundException cnfe) {
67: System.out.println("NativeVerifier: FILE NOT FOUND: '"
68: + args[0] + "'.");
69: System.exit(1);
70: } catch (Throwable t) {
71: System.out
72: .println("NativeVerifier: Unspecified verification error on'"
73: + args[0] + "'.");
74: System.exit(1);
75: }
76: System.out.println("NativeVerifier: Class file '" + args[0]
77: + "' seems to be okay.");
78: System.exit(0);
79: }
80: }
|