Ignore:
Timestamp:
Feb 3, 2012, 1:53:24 PM (7 years ago)
Author:
gb
Message:

Use a cast in the code that sets up errno_loc in the TCR.
Revive jvm_init(), since Apple's JVM still/again clobbers Mach exception
ports.

Add kernel-import info for jvm-init for all architectures. (The kernel
import table isn't architecture-specific, though some entries effectively
are.)

Tweak jni.lisp a bit; still needs lots of work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/library/jni.lisp

    r15189 r15191  
    6363    ())
    6464
     65(defmethod print-object ((object java-object) stream)
     66  (print-unreadable-object (object stream :type t :identity t)
     67    (format stream "@#x~x" (ccl::%ptr-to-int object))))
     68
    6569(ccl::defloadvar *java-object-domain* nil)
    6670
     
    106110#+:darwin-target "/System/Library/Frameworks/JavaVM.framework/JavaVM"
    107111#+:win32-target "C:/Program Files/Java/jre6/bin/client/jvm.dll"
     112#+android-target "libdvm.so"
     113#-(or darwin-target win32-target android-target)
     114"need to define *jni-lib-path*"
    108115"Set this to point to your jvm dll prior to calling create-jvm")
    109116
     
    140147(defun load-jni-lib (&optional (libpath *jni-lib-path*))
    141148  (ccl:open-shared-library libpath))
     149
    142150
    143151(defun current-env ()
     
    152160                            :jint jni-version-1-4
    153161                            :jint))
    154         ;; On Darwin, attaching the current thread to a JVM instance
    155         ;; overwrites the thread's Mach exception ports, which CCL
    156         ;; happens to be using.  We can work around this by calling
    157         ;; a function in the CCL kernel and having that function
    158         ;; call the vm's AttachCurrentThread function and then restore
    159         ;; the thread's exception ports before returning.  Yes, that
    160         ;; -is- total nonsense.
    161162        (unless (eql jni-ok
    162163                     (ff-call
     
    166167                      :address (ccl::%null-ptr)
    167168                      :jint))
    168           (error "Can't attach thread to JVM ~s" jvm)))
    169       (let* ((result (pref pjnienv :address)))
    170         (ccl::%set-macptr-type result (load-time-value (ccl::foreign-type-ordinal (ccl::foreign-pointer-type-to (ccl::parse-foreign-type #>JNIEnv)))))
    171         result))))
     169          (error "Can't attach thread to JVM ~s" jvm))))
     170    (let* ((result (pref pjnienv :address)))
     171      (ccl::%set-macptr-type result (load-time-value (ccl::foreign-type-ordinal (ccl::foreign-pointer-type-to (ccl::parse-foreign-type #>JNIEnv)))))
     172      result)))
    172173
    173174
     
    228229
    229230(defun to-reflected-method (cls method-id is-static)
    230  
    231231  (jnienv-call ("ToReflectedMethod" :jobject)
    232232               :jclass cls
     
    241241  (jnienv-call ("IsAssignableFrom" :jboolean) :jclass sub :jclass sup))
    242242
    243 (defun to-reflected-field (cls field-id is-static)
    244  
     243(defun to-reflected-field (cls field-id is-static) 
    245244  (jnienv-call ("ToReflectedField" :jobject)
    246245               :jclass cls
     
    11521151           ;; JNI_CreateJavaVM for us.
    11531152           (let* ((result
    1154                    (ff-call (foreign-symbol-address "JNI_CreateJavaVM")
     1153                   (ff-call #+darwin-target (ccl::%kernel-import target::kernel-import-jvm-init)
     1154                            #+darwin-target :address
     1155                            (foreign-symbol-address "JNI_CreateJavaVM")
    11551156                            :address vm
    11561157                            :address env
Note: See TracChangeset for help on using the changeset viewer.