当前位置: 首页>>代码示例>>C++>>正文


C++ VM::get_properties方法代码示例

本文整理汇总了C++中VM::get_properties方法的典型用法代码示例。如果您正苦于以下问题:C++ VM::get_properties方法的具体用法?C++ VM::get_properties怎么用?C++ VM::get_properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VM的用法示例。


在下文中一共展示了VM::get_properties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initialize

void HPI::initialize() // REMOVEME
{
	TRACESUBSYSTEMINITIALIZATION("hpi_init");

	// Load libhpi.so
	VM* vm = VM::get_current();
	Properties& properties = vm->get_properties();
	const char* boot_library_path = properties.get("sun.boot.library.path");

	// Use Buffer to assemble library path.
	Buffer<> buf;

	buf.write(boot_library_path);
	buf.write("/native_threads/libhpi.so");

	Utf8String u = buf.utf8_str();

    if (opt_TraceHPI)
		log_println("HPI::initialize: Loading HPI %s ", buf.c_str());

	NativeLibrary nl(u);
	void* handle = nl.open();

	if (handle == NULL)
		if (opt_TraceHPI)
			os::abort("HPI::initialize: HPI open failed");

	// Resolve the DLL_Initialize function from the library.
	void* dll_initialize = os::dlsym(handle, "DLL_Initialize");

    jint (JNICALL *DLL_Initialize)(GetInterfaceFunc*, void*);
    DLL_Initialize = (jint (JNICALL *)(GetInterfaceFunc*, void*)) (uintptr_t) dll_initialize;

    if (opt_TraceHPI && DLL_Initialize == NULL)
		log_println("hpi_init: HPI dlsym of DLL_Initialize failed: %s", os::dlerror());

    if (DLL_Initialize == NULL || (*DLL_Initialize)(&_get_interface, &callbacks) < 0) {
        if (opt_TraceHPI)
			vm_abort("hpi_init: HPI DLL_Initialize failed");
    }

	NativeLibraries& nls = vm->get_nativelibraries();
	nls.add(nl);

    if (opt_TraceHPI)
		log_println("HPI::initialize: HPI loaded successfully");

	// Resolve the interfaces.
	/* NOTE: The intptr_t-case is only to prevent the a compiler
	   warning with -O2: warning: dereferencing type-punned pointer
	   will break strict-aliasing rules */

	int result;

	result = (*_get_interface)((void**) (uintptr_t) &_file, "File", 1);

	if (result != 0)
		os::abort("hpi_init: Can't find HPI_FileInterface");

	result = (*_get_interface)((void**) (uintptr_t) &_library, "Library", 1);

	if (result != 0)
		os::abort("hpi_init: Can't find HPI_LibraryInterface");

	result = (*_get_interface)((void**) (uintptr_t) &_system, "System", 1);

	if (result != 0)
		os::abort("hpi_init: Can't find HPI_SystemInterface");
}
开发者ID:zapster,项目名称:cacao-travis,代码行数:69,代码来源:hpi.cpp


注:本文中的VM::get_properties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。