src/share/vm/prims/jvmtiClassFileReconstituter.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7086585 Sdiff src/share/vm/prims

src/share/vm/prims/jvmtiClassFileReconstituter.cpp

Print this page




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/symbolTable.hpp"
  27 #include "interpreter/bytecodeStream.hpp"

  28 #include "prims/jvmtiClassFileReconstituter.hpp"
  29 #include "runtime/signature.hpp"
  30 #ifdef TARGET_ARCH_x86
  31 # include "bytes_x86.hpp"
  32 #endif
  33 #ifdef TARGET_ARCH_sparc
  34 # include "bytes_sparc.hpp"
  35 #endif
  36 #ifdef TARGET_ARCH_zero
  37 # include "bytes_zero.hpp"
  38 #endif
  39 #ifdef TARGET_ARCH_arm
  40 # include "bytes_arm.hpp"
  41 #endif
  42 #ifdef TARGET_ARCH_ppc
  43 # include "bytes_ppc.hpp"
  44 #endif
  45 // FIXME: add Deprecated, LVT, LVTT attributes
  46 // FIXME: fix Synthetic attribute
  47 // FIXME: per Serguei, add error return handling for constantPoolOopDesc::copy_cpool_bytes()
  48 
  49 
  50 // Write the field information portion of ClassFile structure
  51 // JVMSpec|     u2 fields_count;
  52 // JVMSpec|     field_info fields[fields_count];
  53 void JvmtiClassFileReconstituter::write_field_infos() {
  54   HandleMark hm(thread());
  55   typeArrayHandle fields(thread(), ikh()->fields());
  56   int fields_length = fields->length();
  57   int num_fields = fields_length / instanceKlass::next_offset;
  58   objArrayHandle fields_anno(thread(), ikh()->fields_annotations());
  59 
  60   write_u2(num_fields);
  61   for (int index = 0; index < fields_length; index += instanceKlass::next_offset) {
  62     AccessFlags access_flags;
  63     int flags = fields->ushort_at(index + instanceKlass::access_flags_offset);
  64     access_flags.set_flags(flags);
  65     int name_index = fields->ushort_at(index + instanceKlass::name_index_offset);
  66     int signature_index = fields->ushort_at(index + instanceKlass::signature_index_offset);
  67     int initial_value_index = fields->ushort_at(index + instanceKlass::initval_index_offset);

  68     guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field");
  69     int offset = ikh()->offset_from_fields( index );
  70     int generic_signature_index =
  71                         fields->ushort_at(index + instanceKlass::generic_signature_offset);
  72     typeArrayHandle anno(thread(), fields_anno.not_null() ?
  73                                  (typeArrayOop)(fields_anno->obj_at(index / instanceKlass::next_offset)) :
  74                                  (typeArrayOop)NULL);
  75 
  76     // JVMSpec|   field_info {
  77     // JVMSpec|         u2 access_flags;
  78     // JVMSpec|         u2 name_index;
  79     // JVMSpec|         u2 descriptor_index;
  80     // JVMSpec|         u2 attributes_count;
  81     // JVMSpec|         attribute_info attributes[attributes_count];
  82     // JVMSpec|   }
  83 
  84     write_u2(flags & JVM_RECOGNIZED_FIELD_MODIFIERS);
  85     write_u2(name_index);
  86     write_u2(signature_index);
  87     int attr_count = 0;
  88     if (initial_value_index != 0) {
  89       ++attr_count;
  90     }
  91     if (access_flags.is_synthetic()) {
  92       // ++attr_count;
  93     }
  94     if (generic_signature_index != 0) {
  95       ++attr_count;
  96     }
  97     if (anno.not_null()) {
  98       ++attr_count;     // has RuntimeVisibleAnnotations attribute
  99     }
 100 
 101     write_u2(attr_count);
 102 
 103     if (initial_value_index != 0) {
 104       write_attribute_name_index("ConstantValue");




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/symbolTable.hpp"
  27 #include "interpreter/bytecodeStream.hpp"
  28 #include "oops/fieldStreams.hpp"
  29 #include "prims/jvmtiClassFileReconstituter.hpp"
  30 #include "runtime/signature.hpp"
  31 #ifdef TARGET_ARCH_x86
  32 # include "bytes_x86.hpp"
  33 #endif
  34 #ifdef TARGET_ARCH_sparc
  35 # include "bytes_sparc.hpp"
  36 #endif
  37 #ifdef TARGET_ARCH_zero
  38 # include "bytes_zero.hpp"
  39 #endif
  40 #ifdef TARGET_ARCH_arm
  41 # include "bytes_arm.hpp"
  42 #endif
  43 #ifdef TARGET_ARCH_ppc
  44 # include "bytes_ppc.hpp"
  45 #endif
  46 // FIXME: add Deprecated, LVT, LVTT attributes
  47 // FIXME: fix Synthetic attribute
  48 // FIXME: per Serguei, add error return handling for constantPoolOopDesc::copy_cpool_bytes()
  49 
  50 
  51 // Write the field information portion of ClassFile structure
  52 // JVMSpec|     u2 fields_count;
  53 // JVMSpec|     field_info fields[fields_count];
  54 void JvmtiClassFileReconstituter::write_field_infos() {
  55   HandleMark hm(thread());



  56   objArrayHandle fields_anno(thread(), ikh()->fields_annotations());
  57 
  58   // Compute the real number of Java fields
  59   int java_fields = ikh()->java_fields_count();
  60 
  61   write_u2(java_fields * FieldInfo::field_slots);
  62   for (JavaFieldStream fs(ikh()); !fs.done(); fs.next()) {
  63     AccessFlags access_flags = fs.access_flags();
  64     int name_index = fs.name_index();
  65     int signature_index = fs.signature_index();
  66     int initial_value_index = fs.initval_index();
  67     guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field");
  68     // int offset = ikh()->field_offset( index );
  69     int generic_signature_index = fs.generic_signature_index();

  70     typeArrayHandle anno(thread(), fields_anno.not_null() ?
  71                                  (typeArrayOop)(fields_anno->obj_at(fs.index())) :
  72                                  (typeArrayOop)NULL);
  73 
  74     // JVMSpec|   field_info {
  75     // JVMSpec|         u2 access_flags;
  76     // JVMSpec|         u2 name_index;
  77     // JVMSpec|         u2 descriptor_index;
  78     // JVMSpec|         u2 attributes_count;
  79     // JVMSpec|         attribute_info attributes[attributes_count];
  80     // JVMSpec|   }
  81 
  82     write_u2(access_flags.as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS);
  83     write_u2(name_index);
  84     write_u2(signature_index);
  85     int attr_count = 0;
  86     if (initial_value_index != 0) {
  87       ++attr_count;
  88     }
  89     if (access_flags.is_synthetic()) {
  90       // ++attr_count;
  91     }
  92     if (generic_signature_index != 0) {
  93       ++attr_count;
  94     }
  95     if (anno.not_null()) {
  96       ++attr_count;     // has RuntimeVisibleAnnotations attribute
  97     }
  98 
  99     write_u2(attr_count);
 100 
 101     if (initial_value_index != 0) {
 102       write_attribute_name_index("ConstantValue");


src/share/vm/prims/jvmtiClassFileReconstituter.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File