1 /*
2 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
41 STACKMAP_ATTRIBUTE_MAJOR_VERSION = 50,
42 INVOKEDYNAMIC_MAJOR_VERSION = 51,
43 NO_RELAX_ACCESS_CTRL_CHECK_VERSION = 52
44 };
45 typedef enum { ThrowException, NoException } Mode;
46
47 /**
48 * Verify the bytecodes for a class. If 'throw_exception' is true
49 * then the appropriate VerifyError or ClassFormatError will be thrown.
50 * Otherwise, no exception is thrown and the return indicates the
51 * error.
52 */
53 static void log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS);
54 static bool verify(instanceKlassHandle klass, Mode mode, bool should_verify_class, TRAPS);
55
56 // Return false if the class is loaded by the bootstrap loader,
57 // or if defineClass was called requesting skipping verification
58 // -Xverify:all/none override this value
59 static bool should_verify_for(oop class_loader, bool should_verify_class);
60
61 // Relax certain verifier checks to enable some broken 1.1 apps to run on 1.2.
62 static bool relax_verify_for(oop class_loader);
63
64 // Print output for class+resolve
65 static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class);
66
67 private:
68 static bool is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class);
69 static Symbol* inference_verify(
70 instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS);
71 };
72
73 class RawBytecodeStream;
74 class StackMapFrame;
75 class StackMapTable;
76
77 // Summary of verifier's memory usage:
78 // StackMapTable is stack allocated.
79 // StackMapFrame are resource allocated. There is only one ResourceMark
80 // for each class verification, which is created at the top level.
81 // There is one mutable StackMapFrame (current_frame) which is updated
82 // by abstract bytecode interpretation. frame_in_exception_handler() returns
|
1 /*
2 * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
41 STACKMAP_ATTRIBUTE_MAJOR_VERSION = 50,
42 INVOKEDYNAMIC_MAJOR_VERSION = 51,
43 NO_RELAX_ACCESS_CTRL_CHECK_VERSION = 52
44 };
45 typedef enum { ThrowException, NoException } Mode;
46
47 /**
48 * Verify the bytecodes for a class. If 'throw_exception' is true
49 * then the appropriate VerifyError or ClassFormatError will be thrown.
50 * Otherwise, no exception is thrown and the return indicates the
51 * error.
52 */
53 static void log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS);
54 static bool verify(instanceKlassHandle klass, Mode mode, bool should_verify_class, TRAPS);
55
56 // Return false if the class is loaded by the bootstrap loader,
57 // or if defineClass was called requesting skipping verification
58 // -Xverify:all/none override this value
59 static bool should_verify_for(oop class_loader, bool should_verify_class);
60
61 // Relax certain access checks to enable some broken 1.1 apps to run on 1.2.
62 static bool relax_access_for(oop class_loader);
63
64 // Print output for class+resolve
65 static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class);
66
67 private:
68 static bool is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class);
69 static Symbol* inference_verify(
70 instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS);
71 };
72
73 class RawBytecodeStream;
74 class StackMapFrame;
75 class StackMapTable;
76
77 // Summary of verifier's memory usage:
78 // StackMapTable is stack allocated.
79 // StackMapFrame are resource allocated. There is only one ResourceMark
80 // for each class verification, which is created at the top level.
81 // There is one mutable StackMapFrame (current_frame) which is updated
82 // by abstract bytecode interpretation. frame_in_exception_handler() returns
|