source: trunk/abcl/patches/cl-plus-ssl-abcl.patch

Last change on this file was 15311, checked in by Mark Evenson, 4 years ago

ci: cl-plus-ssl now tests easye/stream-fd-20200603a

c.f. <https://github.com/armedbear/cl-plus-ssl/tree/easye/stream-fd-20200603a>

File size: 2.2 KB
  • src/streams.lisp

    # HG changeset patch
    # User Anton Vodonosov <avodonosov@yandex.ru>
    # Date 1591183464 -10800
    #      Wed Jun 03 14:24:24 2020 +0300
    # Node ID fa084b0f7b141aad916af88f1dbc24dbbe1153a5
    # Parent  e997fa4665748951d229e8622102c67fca5f22f9
    # Parent  ed980cfac3a263beb45a189d5e546df84f24011e
    
    abcl: fix accessing underlying fd with openjdk8 and openjdk14
    
    Merged as <https://github.com/cl-plus-ssl/cl-plus-ssl/pull/103>
    
    diff -r e997fa466574 -r fa084b0f7b14 src/streams.lisp
    a b  
    493493  (require :jss)
    494494
    495495  ;;; N.b. Getting the file descriptor from a socket is not supported
    496   ;;; by any published JVM API, but the following private data
    497   ;;; structures have been present from openjdk6 through openjdk14 so
    498   ;;; there's hope that this is somewhat unofficially official.
     496  ;;; by any published JVM API, so every JVM implementation may behave
     497  ;;; somewhat differently.  By using the ability of
     498  ;;; jss:get-java-fields to access private fields, it is usually
     499  ;;; possible to "find" an access path to read the underlying integer
     500  ;;; value of the file decriptor, which is all we need to pass to
     501  ;;; SSL.
    499502  (defmethod stream-fd ((stream system::socket-stream))
    500503    (flet ((get-java-fields (object fields) ;; Thanks to Cyrus Harmon
    501504             (reduce (lambda (x y)
    502505                       (jss:get-java-field x y t))
    503506                     fields
    504                      :initial-value object)))
     507                     :initial-value object))
     508           (jvm-version ()
     509             (read
     510              (make-string-input-stream
     511               (java:jstatic "getProperty" "java.lang.System"
     512                                          "java.specification.version")))))
    505513      (ignore-errors
    506514       (get-java-fields (java:jcall "getWrappedInputStream"  ;; TODO: define this as a constant
    507515                                    (two-way-stream-input-stream stream))
    508                         '("in" "ch" "fdVal"))))))
    509 
    510 
     516                        (if (< (jvm-version) 14)
     517                            '("in" "ch" "fdVal")
     518                            '("in" "this$0" "sc" "fd" "fd")))))))
Note: See TracBrowser for help on using the repository browser.