src/share/vm/prims/jvmtiRedefineClasses.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2011, 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  *


3219   // methods have been rewritten
3220   {
3221     ResourceMark rm(THREAD);
3222     // no exception should happen here since we explicitly
3223     // do not check loader constraints.
3224     // compare_and_normalize_class_versions has already checked:
3225     //  - classloaders unchanged, signatures unchanged
3226     //  - all instanceKlasses for redefined classes reused & contents updated
3227     the_class->vtable()->initialize_vtable(false, THREAD);
3228     the_class->itable()->initialize_itable(false, THREAD);
3229     assert(!HAS_PENDING_EXCEPTION || (THREAD->pending_exception()->is_a(SystemDictionary::ThreadDeath_klass())), "redefine exception");
3230   }
3231 
3232   // Leave arrays of jmethodIDs and itable index cache unchanged
3233 
3234   // Copy the "source file name" attribute from new class version
3235   the_class->set_source_file_name(scratch_class->source_file_name());
3236 
3237   // Copy the "source debug extension" attribute from new class version
3238   the_class->set_source_debug_extension(
3239     scratch_class->source_debug_extension());


3240 
3241   // Use of javac -g could be different in the old and the new
3242   if (scratch_class->access_flags().has_localvariable_table() !=
3243       the_class->access_flags().has_localvariable_table()) {
3244 
3245     AccessFlags flags = the_class->access_flags();
3246     if (scratch_class->access_flags().has_localvariable_table()) {
3247       flags.set_has_localvariable_table();
3248     } else {
3249       flags.clear_has_localvariable_table();
3250     }
3251     the_class->set_access_flags(flags);
3252   }
3253 
3254   // Replace class annotation fields values
3255   typeArrayOop old_class_annotations = the_class->class_annotations();
3256   the_class->set_class_annotations(scratch_class->class_annotations());
3257   scratch_class->set_class_annotations(old_class_annotations);
3258 
3259   // Replace fields annotation fields values


   1 /*
   2  * Copyright (c) 2003, 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.
   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  *


3219   // methods have been rewritten
3220   {
3221     ResourceMark rm(THREAD);
3222     // no exception should happen here since we explicitly
3223     // do not check loader constraints.
3224     // compare_and_normalize_class_versions has already checked:
3225     //  - classloaders unchanged, signatures unchanged
3226     //  - all instanceKlasses for redefined classes reused & contents updated
3227     the_class->vtable()->initialize_vtable(false, THREAD);
3228     the_class->itable()->initialize_itable(false, THREAD);
3229     assert(!HAS_PENDING_EXCEPTION || (THREAD->pending_exception()->is_a(SystemDictionary::ThreadDeath_klass())), "redefine exception");
3230   }
3231 
3232   // Leave arrays of jmethodIDs and itable index cache unchanged
3233 
3234   // Copy the "source file name" attribute from new class version
3235   the_class->set_source_file_name(scratch_class->source_file_name());
3236 
3237   // Copy the "source debug extension" attribute from new class version
3238   the_class->set_source_debug_extension(
3239     scratch_class->source_debug_extension(),
3240     scratch_class->source_debug_extension() == NULL ? 0 :
3241     (int)strlen(scratch_class->source_debug_extension()));
3242 
3243   // Use of javac -g could be different in the old and the new
3244   if (scratch_class->access_flags().has_localvariable_table() !=
3245       the_class->access_flags().has_localvariable_table()) {
3246 
3247     AccessFlags flags = the_class->access_flags();
3248     if (scratch_class->access_flags().has_localvariable_table()) {
3249       flags.set_has_localvariable_table();
3250     } else {
3251       flags.clear_has_localvariable_table();
3252     }
3253     the_class->set_access_flags(flags);
3254   }
3255 
3256   // Replace class annotation fields values
3257   typeArrayOop old_class_annotations = the_class->class_annotations();
3258   the_class->set_class_annotations(scratch_class->class_annotations());
3259   scratch_class->set_class_annotations(old_class_annotations);
3260 
3261   // Replace fields annotation fields values