Commit 15e23a7d authored by thatcher's avatar thatcher
Browse files

Reviewed by Maciej.

        Moved KJS_GetCreatedJavaVMs to jni_utility.cpp.
        Switched KJS_GetCreatedJavaVMs over to use dlopen and dlsym
        now that NSAddImage, NSLookupSymbolInImage and NSAddressOfSymbol
        are deprecated in Leopard.

        * JavaScriptCore.exp:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * bindings/jni/jni_utility.cpp:
        (KJS::Bindings::KJS_GetCreatedJavaVMs):
        * bindings/softlinking.c: Removed.
        * bindings/softlinking.h: Removed.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15241 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 965a62f1
2006-07-08 Timothy Hatcher <timothy@apple.com>
Reviewed by Maciej.
Moved KJS_GetCreatedJavaVMs to jni_utility.cpp.
Switched KJS_GetCreatedJavaVMs over to use dlopen and dlsym
now that NSAddImage, NSLookupSymbolInImage and NSAddressOfSymbol
are deprecated in Leopard.
* JavaScriptCore.exp:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bindings/jni/jni_utility.cpp:
(KJS::Bindings::KJS_GetCreatedJavaVMs):
* bindings/softlinking.c: Removed.
* bindings/softlinking.h: Removed.
2006-07-08 Geoffrey Garen <ggaren@apple.com>
 
Reviewed by Anders.
......
......@@ -70,7 +70,6 @@ _JSValueIsUndefined
_JSValueToBoolean
_JSValueToNumber
_JSValueToObject
_KJS_GetCreatedJavaVMs
_KJS_JSCreateNativeJSObject
_KJS_JSObject_JSFinalize
_KJS_JSObject_JSObjectCall
......
......@@ -236,7 +236,6 @@
932F5BCB0822A1C700736975 /* npruntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5199B1BD061B65BC0070C006 /* npruntime.cpp */; };
932F5BCE0822A1C700736975 /* WebScriptObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51863FC406542D3100E9E8DD /* WebScriptObject.mm */; };
932F5BCF0822A1C700736975 /* jni_objc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517EF37306D695930007C1BA /* jni_objc.mm */; };
932F5BD00822A1C700736975 /* softlinking.c in Sources */ = {isa = PBXBuildFile; fileRef = 8442A376074175C2000AE2ED /* softlinking.c */; };
932F5BD30822A1C700736975 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */; };
932F5BD40822A1C700736975 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A63D04B3B69F008AE952 /* CoreServices.framework */; };
932F5BD50822A1C700736975 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51F0EB6105C86C6B00E6DF1B /* Foundation.framework */; };
......@@ -257,7 +256,6 @@
93E26BFD08B151D400F85226 /* ucp.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E26BFB08B151D400F85226 /* ucp.h */; };
93E26BFE08B151D400F85226 /* ucpinternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E26BFC08B151D400F85226 /* ucpinternal.h */; };
93E26C1308B1523D00F85226 /* ucptable.c in Headers */ = {isa = PBXBuildFile; fileRef = 93E26C0D08B1520900F85226 /* ucptable.c */; };
93E26CCF08B2921900F85226 /* softlinking.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E26CCE08B2921900F85226 /* softlinking.h */; };
93E26CF708B29A1C00F85226 /* pcre_get.c in Sources */ = {isa = PBXBuildFile; fileRef = 93E26CF608B29A1C00F85226 /* pcre_get.c */; };
93E26DDC08B2A4F400F85226 /* pcre_printint.c in Sources */ = {isa = PBXBuildFile; fileRef = 93E26DDB08B2A4F400F85226 /* pcre_printint.c */; };
93F0B3AB09BB4DC00068FCE3 /* Parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F0B3A909BB4DC00068FCE3 /* Parser.cpp */; };
......@@ -474,7 +472,6 @@
7073BE3D0581291E005EE2C9 /* runtime_array.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = runtime_array.h; path = bindings/runtime_array.h; sourceTree = "<group>"; tabWidth = 8; };
70B16A260569A10900DB756D /* runtime_object.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; name = runtime_object.cpp; path = bindings/runtime_object.cpp; sourceTree = "<group>"; tabWidth = 8; };
70B16A270569A10900DB756D /* runtime_object.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = runtime_object.h; path = bindings/runtime_object.h; sourceTree = "<group>"; tabWidth = 8; };
8442A376074175C2000AE2ED /* softlinking.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; name = softlinking.c; path = bindings/softlinking.c; sourceTree = "<group>"; tabWidth = 8; };
84ABF1DE070B628C00A3AC05 /* npruntime_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = npruntime_impl.h; path = bindings/npruntime_impl.h; sourceTree = "<group>"; tabWidth = 8; };
9303F567099118FA00AD71B8 /* OwnPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OwnPtr.h; sourceTree = "<group>"; };
9303F5690991190000AD71B8 /* Noncopyable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Noncopyable.h; sourceTree = "<group>"; };
......@@ -510,7 +507,6 @@
93E26BFB08B151D400F85226 /* ucp.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = ucp.h; path = pcre/ucp.h; sourceTree = "<group>"; tabWidth = 8; };
93E26BFC08B151D400F85226 /* ucpinternal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = ucpinternal.h; path = pcre/ucpinternal.h; sourceTree = "<group>"; tabWidth = 8; };
93E26C0D08B1520900F85226 /* ucptable.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; indentWidth = 4; name = ucptable.c; path = pcre/ucptable.c; sourceTree = "<group>"; tabWidth = 8; };
93E26CCE08B2921900F85226 /* softlinking.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = softlinking.h; path = bindings/softlinking.h; sourceTree = "<group>"; tabWidth = 8; };
93E26CF608B29A1C00F85226 /* pcre_get.c */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.c; name = pcre_get.c; path = pcre/pcre_get.c; sourceTree = "<group>"; tabWidth = 8; };
93E26DDB08B2A4F400F85226 /* pcre_printint.c */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.c; name = pcre_printint.c; path = pcre/pcre_printint.c; sourceTree = "<group>"; tabWidth = 8; };
93F0B3A909BB4DC00068FCE3 /* Parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Parser.cpp; sourceTree = "<group>"; };
......@@ -773,8 +769,6 @@
70B16A270569A10900DB756D /* runtime_object.h */,
5114F47B05E4426200D1BBBD /* runtime_root.cpp */,
5114F47C05E4426200D1BBBD /* runtime_root.h */,
8442A376074175C2000AE2ED /* softlinking.c */,
93E26CCE08B2921900F85226 /* softlinking.h */,
51863F6F065420E800E9E8DD /* WebScriptObject.h */,
51863FC406542D3100E9E8DD /* WebScriptObject.mm */,
700DA117065984CE00747C0B /* WebScriptObjectPrivate.h */,
......@@ -1076,7 +1070,6 @@
93E26BFD08B151D400F85226 /* ucp.h in Headers */,
93E26BFE08B151D400F85226 /* ucpinternal.h in Headers */,
93E26C1308B1523D00F85226 /* ucptable.c in Headers */,
93E26CCF08B2921900F85226 /* softlinking.h in Headers */,
652C107F08DA7B1E0020887D /* protected_reference.h in Headers */,
65E217BD08E7EECC0023E5F6 /* Assertions.h in Headers */,
65E217C008E7EECC0023E5F6 /* FastMalloc.h in Headers */,
......@@ -1389,7 +1382,6 @@
932F5BCB0822A1C700736975 /* npruntime.cpp in Sources */,
932F5BCE0822A1C700736975 /* WebScriptObject.mm in Sources */,
932F5BCF0822A1C700736975 /* jni_objc.mm in Sources */,
932F5BD00822A1C700736975 /* softlinking.c in Sources */,
65621E6D089E859700760F35 /* property_slot.cpp in Sources */,
930754C108B0F68000AB3056 /* pcre_compile.c in Sources */,
930754D008B0F74600AB3056 /* pcre_tables.c in Sources */,
......
......@@ -31,12 +31,28 @@
#include "jni_runtime.h"
#include "runtime_array.h"
#include "runtime_object.h"
#include "softlinking.h"
#include <dlfcn.h>
namespace KJS {
namespace Bindings {
static jint KJS_GetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs)
{
static void* javaVMFramework = 0;
if (!javaVMFramework)
javaVMFramework = dlopen("/System/Library/Frameworks/JavaVM.framework/JavaVM", RTLD_LAZY);
if (!javaVMFramework)
return JNI_ERR;
static jint(*functionPointer)(JavaVM**, jsize, jsize *) = 0;
if (!functionPointer)
functionPointer = (jint(*)(JavaVM**, jsize, jsize *))dlsym(javaVMFramework, "JNI_GetCreatedJavaVMs");
if (!functionPointer)
return JNI_ERR;
return functionPointer(vmBuf, bufLen, nVMs);
}
static JavaVM *jvm = 0;
JavaVM *getJavaVM()
......
/*
* Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "softlinking.h"
#include <mach-o/dyld.h>
static const struct mach_header *loadFramework(const char *execPath)
{
return NSAddImage(execPath, NSADDIMAGE_OPTION_WITH_SEARCHING | NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME);
}
static void *getFunctionPointer(const struct mach_header *header, const char *functionName)
{
NSSymbol symbol = NSLookupSymbolInImage(header, functionName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND);
if (symbol!=NULL) {
return NSAddressOfSymbol(symbol);
}
return 0;
}
jint KJS_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs)
{
static const struct mach_header *header = 0;
if (!header) {
header = loadFramework("/System/Library/Frameworks/JavaVM.framework/JavaVM");
}
static jint(*functionPointer)(JavaVM **, jsize, jsize *) = 0;
if (!functionPointer) {
functionPointer = getFunctionPointer(header, "_JNI_GetCreatedJavaVMs");
}
return functionPointer(vmBuf, bufLen, nVMs);
}
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <JavaVM/jni.h>
#ifdef __cplusplus
extern "C"
#endif
jint KJS_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment