src/share/vm/prims/jvmtiEnv.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File classload.01 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;


 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::parse_log_arguments("stdout", "gc=off", NULL, NULL, NULL);
 634     } else {
 635       LogConfiguration::parse_log_arguments("stdout", "gc", NULL, NULL, NULL);
 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     if (log_is_enabled(Info, classload)) {
 478       outputStream* log = LogHandle(classload)::info_stream();
 479       log->print_cr("[Opened %s]", zip_entry->name());
 480     }
 481     ClassLoaderExt::append_boot_classpath(zip_entry);
 482     return JVMTI_ERROR_NONE;
 483   } else {
 484     return JVMTI_ERROR_WRONG_PHASE;
 485   }
 486 
 487 } /* end AddToBootstrapClassLoaderSearch */
 488 
 489 
 490 // segment - pre-checked for NULL
 491 jvmtiError
 492 JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
 493   jvmtiPhase phase = get_phase();
 494 
 495   if (phase == JVMTI_PHASE_ONLOAD) {
 496     for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) {
 497       if (strcmp("java.class.path", p->key()) == 0) {
 498         p->append_value(segment);
 499         break;


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


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