src/share/vm/prims/jvmtiEnv.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File classload.03 Sdiff src/share/vm/prims

src/share/vm/prims/jvmtiEnv.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderExt.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "interpreter/bytecodeStream.hpp"
  30 #include "interpreter/interpreter.hpp"
  31 #include "jvmtifiles/jvmtiEnv.hpp"

  32 #include "logging/logConfiguration.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "memory/universe.inline.hpp"
  35 #include "oops/instanceKlass.hpp"
  36 #include "oops/objArrayOop.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "prims/jniCheck.hpp"
  39 #include "prims/jvm_misc.hpp"
  40 #include "prims/jvmtiAgentThread.hpp"
  41 #include "prims/jvmtiClassFileReconstituter.hpp"
  42 #include "prims/jvmtiCodeBlobEvents.hpp"
  43 #include "prims/jvmtiExtensions.hpp"
  44 #include "prims/jvmtiGetLoadedClasses.hpp"
  45 #include "prims/jvmtiImpl.hpp"
  46 #include "prims/jvmtiManageCapabilities.hpp"
  47 #include "prims/jvmtiRawMonitor.hpp"
  48 #include "prims/jvmtiRedefineClasses.hpp"
  49 #include "prims/jvmtiTagMap.hpp"
  50 #include "prims/jvmtiThreadState.inline.hpp"
  51 #include "prims/jvmtiUtil.hpp"


 456     return JVMTI_ERROR_WRONG_PHASE;
 457   } else if (phase == JVMTI_PHASE_LIVE) {
 458     // The phase is checked by the wrapper that called this function,
 459     // but this thread could be racing with the thread that is
 460     // terminating the VM so we check one more time.
 461 
 462     // create the zip entry
 463     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
 464     if (zip_entry == NULL) {
 465       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 466     }
 467 
 468     // lock the loader
 469     Thread* thread = Thread::current();
 470     HandleMark hm;
 471     Handle loader_lock = Handle(thread, SystemDictionary::system_loader_lock());
 472 
 473     ObjectLocker ol(loader_lock, thread);
 474 
 475     // add the jar file to the bootclasspath
 476     if (TraceClassLoading) {
 477       tty->print_cr("[Opened %s]", zip_entry->name());
 478     }
 479     ClassLoaderExt::append_boot_classpath(zip_entry);
 480     return JVMTI_ERROR_NONE;
 481   } else {
 482     return JVMTI_ERROR_WRONG_PHASE;
 483   }
 484 
 485 } /* end AddToBootstrapClassLoaderSearch */
 486 
 487 
 488 // segment - pre-checked for NULL
 489 jvmtiError
 490 JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
 491   jvmtiPhase phase = get_phase();
 492 
 493   if (phase == JVMTI_PHASE_ONLOAD) {
 494     for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) {
 495       if (strcmp("java.class.path", p->key()) == 0) {
 496         p->append_value(segment);
 497         break;
 498       }


 608   const char *name = JvmtiUtil::error_name(error);
 609   if (name == NULL) {
 610     return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 611   }
 612   size_t len = strlen(name) + 1;
 613   jvmtiError err = allocate(len, (unsigned char**)name_ptr);
 614   if (err == JVMTI_ERROR_NONE) {
 615     memcpy(*name_ptr, name, len);
 616   }
 617   return err;
 618 } /* end GetErrorName */
 619 
 620 
 621 jvmtiError
 622 JvmtiEnv::SetVerboseFlag(jvmtiVerboseFlag flag, jboolean value) {
 623   switch (flag) {
 624   case JVMTI_VERBOSE_OTHER:
 625     // ignore
 626     break;
 627   case JVMTI_VERBOSE_CLASS:
 628     TraceClassLoading = value != 0;
 629     TraceClassUnloading = value != 0;





 630     break;
 631   case JVMTI_VERBOSE_GC:
 632     if (value == 0) {
 633       LogConfiguration::configure_stdout(LogLevel::Off, true, LOG_TAGS(gc));
 634     } else {
 635       LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));
 636     }
 637     break;
 638   case JVMTI_VERBOSE_JNI:
 639     PrintJNIResolving = value != 0;
 640     break;
 641   default:
 642     return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 643   };
 644   return JVMTI_ERROR_NONE;
 645 } /* end SetVerboseFlag */
 646 
 647 
 648 // format_ptr - pre-checked for NULL
 649 jvmtiError


   1 /*
   2  * Copyright (c) 2003, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderExt.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "interpreter/bytecodeStream.hpp"
  30 #include "interpreter/interpreter.hpp"
  31 #include "jvmtifiles/jvmtiEnv.hpp"
  32 #include "logging/log.hpp"
  33 #include "logging/logConfiguration.hpp"
  34 #include "memory/resourceArea.hpp"
  35 #include "memory/universe.inline.hpp"
  36 #include "oops/instanceKlass.hpp"
  37 #include "oops/objArrayOop.inline.hpp"
  38 #include "oops/oop.inline.hpp"
  39 #include "prims/jniCheck.hpp"
  40 #include "prims/jvm_misc.hpp"
  41 #include "prims/jvmtiAgentThread.hpp"
  42 #include "prims/jvmtiClassFileReconstituter.hpp"
  43 #include "prims/jvmtiCodeBlobEvents.hpp"
  44 #include "prims/jvmtiExtensions.hpp"
  45 #include "prims/jvmtiGetLoadedClasses.hpp"
  46 #include "prims/jvmtiImpl.hpp"
  47 #include "prims/jvmtiManageCapabilities.hpp"
  48 #include "prims/jvmtiRawMonitor.hpp"
  49 #include "prims/jvmtiRedefineClasses.hpp"
  50 #include "prims/jvmtiTagMap.hpp"
  51 #include "prims/jvmtiThreadState.inline.hpp"
  52 #include "prims/jvmtiUtil.hpp"


 457     return JVMTI_ERROR_WRONG_PHASE;
 458   } else if (phase == JVMTI_PHASE_LIVE) {
 459     // The phase is checked by the wrapper that called this function,
 460     // but this thread could be racing with the thread that is
 461     // terminating the VM so we check one more time.
 462 
 463     // create the zip entry
 464     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
 465     if (zip_entry == NULL) {
 466       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 467     }
 468 
 469     // lock the loader
 470     Thread* thread = Thread::current();
 471     HandleMark hm;
 472     Handle loader_lock = Handle(thread, SystemDictionary::system_loader_lock());
 473 
 474     ObjectLocker ol(loader_lock, thread);
 475 
 476     // add the jar file to the bootclasspath
 477     log_info(classload)("opened: %s", zip_entry->name());


 478     ClassLoaderExt::append_boot_classpath(zip_entry);
 479     return JVMTI_ERROR_NONE;
 480   } else {
 481     return JVMTI_ERROR_WRONG_PHASE;
 482   }
 483 
 484 } /* end AddToBootstrapClassLoaderSearch */
 485 
 486 
 487 // segment - pre-checked for NULL
 488 jvmtiError
 489 JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
 490   jvmtiPhase phase = get_phase();
 491 
 492   if (phase == JVMTI_PHASE_ONLOAD) {
 493     for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) {
 494       if (strcmp("java.class.path", p->key()) == 0) {
 495         p->append_value(segment);
 496         break;
 497       }


 607   const char *name = JvmtiUtil::error_name(error);
 608   if (name == NULL) {
 609     return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 610   }
 611   size_t len = strlen(name) + 1;
 612   jvmtiError err = allocate(len, (unsigned char**)name_ptr);
 613   if (err == JVMTI_ERROR_NONE) {
 614     memcpy(*name_ptr, name, len);
 615   }
 616   return err;
 617 } /* end GetErrorName */
 618 
 619 
 620 jvmtiError
 621 JvmtiEnv::SetVerboseFlag(jvmtiVerboseFlag flag, jboolean value) {
 622   switch (flag) {
 623   case JVMTI_VERBOSE_OTHER:
 624     // ignore
 625     break;
 626   case JVMTI_VERBOSE_CLASS:
 627     if (value == 0) {
 628       LogConfiguration::parse_log_arguments("stdout", "classunload=off", NULL, NULL, NULL);
 629       LogConfiguration::parse_log_arguments("stdout", "classload=off", NULL, NULL, NULL);
 630     } else {
 631       LogConfiguration::parse_log_arguments("stdout", "classload=info", NULL, NULL, NULL);
 632       LogConfiguration::parse_log_arguments("stdout", "classunload=info", NULL, NULL, NULL);
 633     }
 634     break;
 635   case JVMTI_VERBOSE_GC:
 636     if (value == 0) {
 637       LogConfiguration::configure_stdout(LogLevel::Off, true, LOG_TAGS(gc));
 638     } else {
 639       LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));
 640     }
 641     break;
 642   case JVMTI_VERBOSE_JNI:
 643     PrintJNIResolving = value != 0;
 644     break;
 645   default:
 646     return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 647   };
 648   return JVMTI_ERROR_NONE;
 649 } /* end SetVerboseFlag */
 650 
 651 
 652 // format_ptr - pre-checked for NULL
 653 jvmtiError


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