src/share/native/common/check_code.c
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File jdk Sdiff src/share/native/common

src/share/native/common/check_code.c

Print this page


   1 /*
   2  * Copyright (c) 1994, 2012, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 966         const char *classname = JVM_GetClassNameUTF(env, cb);
 967         const char *methodname =
 968             JVM_GetMethodIxNameUTF(env, cb, method_index);
 969         const char *signature =
 970             JVM_GetMethodIxSignatureUTF(env, cb, method_index);
 971         jio_fprintf(stdout, "Looking at %s.%s%s\n",
 972                     (classname ? classname : ""),
 973                     (methodname ? methodname : ""),
 974                     (signature ? signature : ""));
 975         JVM_ReleaseUTF(classname);
 976         JVM_ReleaseUTF(methodname);
 977         JVM_ReleaseUTF(signature);
 978     }
 979 #endif
 980 
 981     if (((access_bits & JVM_ACC_PUBLIC) != 0) &&
 982         ((access_bits & (JVM_ACC_PRIVATE | JVM_ACC_PROTECTED)) != 0)) {
 983         CCerror(context, "Inconsistent access bits.");
 984     }
 985 






 986     /* Run through the code.  Mark the start of each instruction, and give
 987      * the instruction a number */
 988     for (i = 0, offset = 0; offset < code_length; i++) {
 989         int length = instruction_length(&code[offset], code + code_length);
 990         int next_offset = offset + length;
 991         if (length <= 0)
 992             CCerror(context, "Illegal instruction found at offset %d", offset);
 993         if (next_offset > code_length)
 994             CCerror(context, "Code stops in the middle of instruction "
 995                     " starting at offset %d", offset);
 996         code_data[offset] = i;
 997         while (++offset < next_offset)
 998             code_data[offset] = -1; /* illegal location */
 999     }
1000     instruction_count = i;      /* number of instructions in code */
1001 
1002     /* Allocate a structure to hold info about each instruction. */
1003     idata = NEW(instruction_data_type, instruction_count);
1004 
1005     /* Initialize the heap, and other info in the context structure. */


   1 /*
   2  * Copyright (c) 1994, 2013, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 966         const char *classname = JVM_GetClassNameUTF(env, cb);
 967         const char *methodname =
 968             JVM_GetMethodIxNameUTF(env, cb, method_index);
 969         const char *signature =
 970             JVM_GetMethodIxSignatureUTF(env, cb, method_index);
 971         jio_fprintf(stdout, "Looking at %s.%s%s\n",
 972                     (classname ? classname : ""),
 973                     (methodname ? methodname : ""),
 974                     (signature ? signature : ""));
 975         JVM_ReleaseUTF(classname);
 976         JVM_ReleaseUTF(methodname);
 977         JVM_ReleaseUTF(signature);
 978     }
 979 #endif
 980 
 981     if (((access_bits & JVM_ACC_PUBLIC) != 0) &&
 982         ((access_bits & (JVM_ACC_PRIVATE | JVM_ACC_PROTECTED)) != 0)) {
 983         CCerror(context, "Inconsistent access bits.");
 984     }
 985 
 986     // If this method is an overpass method, which is generated by the VM,
 987     // we trust the code and no check needs to be done.
 988     if (JVM_IsVMGeneratedMethodIx(env, cb, method_index)) {
 989       return;
 990     }
 991 
 992     /* Run through the code.  Mark the start of each instruction, and give
 993      * the instruction a number */
 994     for (i = 0, offset = 0; offset < code_length; i++) {
 995         int length = instruction_length(&code[offset], code + code_length);
 996         int next_offset = offset + length;
 997         if (length <= 0)
 998             CCerror(context, "Illegal instruction found at offset %d", offset);
 999         if (next_offset > code_length)
1000             CCerror(context, "Code stops in the middle of instruction "
1001                     " starting at offset %d", offset);
1002         code_data[offset] = i;
1003         while (++offset < next_offset)
1004             code_data[offset] = -1; /* illegal location */
1005     }
1006     instruction_count = i;      /* number of instructions in code */
1007 
1008     /* Allocate a structure to hold info about each instruction. */
1009     idata = NEW(instruction_data_type, instruction_count);
1010 
1011     /* Initialize the heap, and other info in the context structure. */


src/share/native/common/check_code.c
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File