< prev index next >

src/share/vm/prims/jvm.cpp

Print this page
rev 6864 : 8061651: Interface to the Lookup Index Cache to improve URLClassPath search time
Summary: Implemented the interface in sun.misc.URLClassPath and corresponding JVM_XXX APIs
Reviewed-by: mchung, acorn, jiangli, dholmes


   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/classLoader.hpp"

  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/javaClasses.hpp"
  29 #include "classfile/symbolTable.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #if INCLUDE_CDS
  32 #include "classfile/sharedClassUtil.hpp"
  33 #include "classfile/systemDictionaryShared.hpp"
  34 #endif
  35 #include "classfile/vmSymbols.hpp"
  36 #include "gc_interface/collectedHeap.inline.hpp"
  37 #include "interpreter/bytecode.hpp"
  38 #include "memory/oopFactory.hpp"
  39 #include "memory/universe.inline.hpp"
  40 #include "oops/fieldStreams.hpp"
  41 #include "oops/instanceKlass.hpp"
  42 #include "oops/objArrayKlass.hpp"
  43 #include "oops/method.hpp"
  44 #include "prims/jvm.h"
  45 #include "prims/jvm_misc.hpp"
  46 #include "prims/jvmtiExport.hpp"


 376 #endif // 64bit
 377 
 378 #ifdef TIERED
 379     const char* compiler_name = "HotSpot " CSIZE "Tiered Compilers";
 380 #else
 381 #if defined(COMPILER1)
 382     const char* compiler_name = "HotSpot " CSIZE "Client Compiler";
 383 #elif defined(COMPILER2)
 384     const char* compiler_name = "HotSpot " CSIZE "Server Compiler";
 385 #else
 386     const char* compiler_name = "";
 387 #endif // compilers
 388 #endif // TIERED
 389 
 390     if (*compiler_name != '\0' &&
 391         (Arguments::mode() != Arguments::_int)) {
 392       PUTPROP(props, "sun.management.compiler", compiler_name);
 393     }
 394   }
 395 








 396   return properties;
 397 JVM_END
 398 
 399 
 400 /*
 401  * Return the temporary directory that the VM uses for the attach
 402  * and perf data files.
 403  *
 404  * It is important that this directory is well-known and the
 405  * same for all VM instances. It cannot be affected by configuration
 406  * variables such as java.io.tmpdir.
 407  */
 408 JVM_ENTRY(jstring, JVM_GetTemporaryDirectory(JNIEnv *env))
 409   JVMWrapper("JVM_GetTemporaryDirectory");
 410   HandleMark hm(THREAD);
 411   const char* temp_dir = os::get_temp_directory();
 412   Handle h = java_lang_String::create_from_platform_dependent_str(temp_dir, CHECK_NULL);
 413   return (jstring) JNIHandles::make_local(env, h());
 414 JVM_END
 415 


 749   JVMWrapper("JVM_FindPrimitiveClass");
 750   oop mirror = NULL;
 751   BasicType t = name2type(utf);
 752   if (t != T_ILLEGAL && t != T_OBJECT && t != T_ARRAY) {
 753     mirror = Universe::java_mirror(t);
 754   }
 755   if (mirror == NULL) {
 756     THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf);
 757   } else {
 758     return (jclass) JNIHandles::make_local(env, mirror);
 759   }
 760 JVM_END
 761 
 762 
 763 JVM_ENTRY(void, JVM_ResolveClass(JNIEnv* env, jclass cls))
 764   JVMWrapper("JVM_ResolveClass");
 765   if (PrintJVMWarnings) warning("JVM_ResolveClass not implemented");
 766 JVM_END
 767 
 768 






























 769 // Returns a class loaded by the bootstrap class loader; or null
 770 // if not found.  ClassNotFoundException is not thrown.
 771 //
 772 // Rationale behind JVM_FindClassFromBootLoader
 773 // a> JVM_FindClassFromClassLoader was never exported in the export tables.
 774 // b> because of (a) java.dll has a direct dependecy on the  unexported
 775 //    private symbol "_JVM_FindClassFromClassLoader@20".
 776 // c> the launcher cannot use the private symbol as it dynamically opens
 777 //    the entry point, so if something changes, the launcher will fail
 778 //    unexpectedly at runtime, it is safest for the launcher to dlopen a
 779 //    stable exported interface.
 780 // d> re-exporting JVM_FindClassFromClassLoader as public, will cause its
 781 //    signature to change from _JVM_FindClassFromClassLoader@20 to
 782 //    JVM_FindClassFromClassLoader and will not be backward compatible
 783 //    with older JDKs.
 784 // Thus a public/stable exported entry point is the right solution,
 785 // public here means public in linker semantics, and is exported only
 786 // to the JDK, and is not intended to be a public API.
 787 
 788 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,




   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/classLoader.hpp"
  27 #include "classfile/classLoaderExt.hpp"
  28 #include "classfile/javaAssertions.hpp"
  29 #include "classfile/javaClasses.hpp"
  30 #include "classfile/symbolTable.hpp"
  31 #include "classfile/systemDictionary.hpp"
  32 #if INCLUDE_CDS
  33 #include "classfile/sharedClassUtil.hpp"
  34 #include "classfile/systemDictionaryShared.hpp"
  35 #endif
  36 #include "classfile/vmSymbols.hpp"
  37 #include "gc_interface/collectedHeap.inline.hpp"
  38 #include "interpreter/bytecode.hpp"
  39 #include "memory/oopFactory.hpp"
  40 #include "memory/universe.inline.hpp"
  41 #include "oops/fieldStreams.hpp"
  42 #include "oops/instanceKlass.hpp"
  43 #include "oops/objArrayKlass.hpp"
  44 #include "oops/method.hpp"
  45 #include "prims/jvm.h"
  46 #include "prims/jvm_misc.hpp"
  47 #include "prims/jvmtiExport.hpp"


 377 #endif // 64bit
 378 
 379 #ifdef TIERED
 380     const char* compiler_name = "HotSpot " CSIZE "Tiered Compilers";
 381 #else
 382 #if defined(COMPILER1)
 383     const char* compiler_name = "HotSpot " CSIZE "Client Compiler";
 384 #elif defined(COMPILER2)
 385     const char* compiler_name = "HotSpot " CSIZE "Server Compiler";
 386 #else
 387     const char* compiler_name = "";
 388 #endif // compilers
 389 #endif // TIERED
 390 
 391     if (*compiler_name != '\0' &&
 392         (Arguments::mode() != Arguments::_int)) {
 393       PUTPROP(props, "sun.management.compiler", compiler_name);
 394     }
 395   }
 396 
 397   const char* enableSharedLookupCache = "false";
 398 #if INCLUDE_CDS
 399   if (ClassLoaderExt::is_lookup_cache_enabled()) {
 400     enableSharedLookupCache = "true";
 401   }
 402 #endif
 403   PUTPROP(props, "sun.cds.enableSharedLookupCache", enableSharedLookupCache);
 404 
 405   return properties;
 406 JVM_END
 407 
 408 
 409 /*
 410  * Return the temporary directory that the VM uses for the attach
 411  * and perf data files.
 412  *
 413  * It is important that this directory is well-known and the
 414  * same for all VM instances. It cannot be affected by configuration
 415  * variables such as java.io.tmpdir.
 416  */
 417 JVM_ENTRY(jstring, JVM_GetTemporaryDirectory(JNIEnv *env))
 418   JVMWrapper("JVM_GetTemporaryDirectory");
 419   HandleMark hm(THREAD);
 420   const char* temp_dir = os::get_temp_directory();
 421   Handle h = java_lang_String::create_from_platform_dependent_str(temp_dir, CHECK_NULL);
 422   return (jstring) JNIHandles::make_local(env, h());
 423 JVM_END
 424 


 758   JVMWrapper("JVM_FindPrimitiveClass");
 759   oop mirror = NULL;
 760   BasicType t = name2type(utf);
 761   if (t != T_ILLEGAL && t != T_OBJECT && t != T_ARRAY) {
 762     mirror = Universe::java_mirror(t);
 763   }
 764   if (mirror == NULL) {
 765     THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf);
 766   } else {
 767     return (jclass) JNIHandles::make_local(env, mirror);
 768   }
 769 JVM_END
 770 
 771 
 772 JVM_ENTRY(void, JVM_ResolveClass(JNIEnv* env, jclass cls))
 773   JVMWrapper("JVM_ResolveClass");
 774   if (PrintJVMWarnings) warning("JVM_ResolveClass not implemented");
 775 JVM_END
 776 
 777 
 778 JVM_ENTRY(jboolean, JVM_KnownToNotExist(JNIEnv *env, jobject loader, const char *classname))
 779   JVMWrapper("JVM_KnownToNotExist");
 780 #if INCLUDE_CDS
 781   return ClassLoaderExt::known_to_not_exist(env, loader, classname, CHECK_(false));
 782 #else
 783   return false;
 784 #endif
 785 JVM_END
 786 
 787 
 788 JVM_ENTRY(jobjectArray, JVM_GetResourceLookupCacheURLs(JNIEnv *env, jobject loader))
 789   JVMWrapper("JVM_GetResourceLookupCacheURLs");
 790 #if INCLUDE_CDS
 791   return ClassLoaderExt::get_lookup_cache_urls(env, loader, CHECK_NULL);
 792 #else
 793   return NULL;
 794 #endif
 795 JVM_END
 796 
 797 
 798 JVM_ENTRY(jintArray, JVM_GetResourceLookupCache(JNIEnv *env, jobject loader, const char *resource_name))
 799   JVMWrapper("JVM_GetResourceLookupCache");
 800 #if INCLUDE_CDS
 801   return ClassLoaderExt::get_lookup_cache(env, loader, resource_name, CHECK_NULL);
 802 #else
 803   return NULL;
 804 #endif
 805 JVM_END
 806 
 807 
 808 // Returns a class loaded by the bootstrap class loader; or null
 809 // if not found.  ClassNotFoundException is not thrown.
 810 //
 811 // Rationale behind JVM_FindClassFromBootLoader
 812 // a> JVM_FindClassFromClassLoader was never exported in the export tables.
 813 // b> because of (a) java.dll has a direct dependecy on the  unexported
 814 //    private symbol "_JVM_FindClassFromClassLoader@20".
 815 // c> the launcher cannot use the private symbol as it dynamically opens
 816 //    the entry point, so if something changes, the launcher will fail
 817 //    unexpectedly at runtime, it is safest for the launcher to dlopen a
 818 //    stable exported interface.
 819 // d> re-exporting JVM_FindClassFromClassLoader as public, will cause its
 820 //    signature to change from _JVM_FindClassFromClassLoader@20 to
 821 //    JVM_FindClassFromClassLoader and will not be backward compatible
 822 //    with older JDKs.
 823 // Thus a public/stable exported entry point is the right solution,
 824 // public here means public in linker semantics, and is exported only
 825 // to the JDK, and is not intended to be a public API.
 826 
 827 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,


< prev index next >