Changeset 15134


Ignore:
Timestamp:
11/01/19 15:52:46 (4 years ago)
Author:
Mark Evenson
Message:

Broadly establishes buildability across java8 and java11 targets

Location:
trunk/abcl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/jss/invoke.lisp

    r15133 r15134  
    421421  (set-java-field object field value try-harder))
    422422
    423 
    424423(defconstant +for-name+
    425424  (jmethod "java.lang.Class" "forName" "java.lang.String" "boolean" "java.lang.ClassLoader"))
     
    439438
    440439(defun do-auto-imports ()
     440  (if (sys::system-artifacts-are-jars-p)
     441      (do-auto-imports-from-jars)
     442      (progn
     443        ;;; First, import all the classes available from the module system
     444        (do-auto-imports-from-modules)
     445        ;;; Then, introspect any jars that appear on the classpath
     446        (loop :for entry :in (second (multiple-value-list (sys::java.class.path)))
     447             :doing (let ((p (pathname entry)))
     448                      (when (string-equal (pathname-type p) "jar")
     449                        (jar-import p)))))))
     450
     451(defun do-auto-imports-from-modules ()
     452  (loop :for (name . full-class-name) :in (all-class-names-from-modules)
     453     :doing
     454       (pushnew full-class-name (gethash name *class-name-to-full-case-insensitive*)
     455                :test 'equal)))
     456
     457(defun all-class-names-from-modules ()
     458  (let ((class-pattern (jstatic "compile" "java.util.regex.Pattern" ".*\\.class$"))
     459        (name-pattern (jstatic "compile" "java.util.regex.Pattern" ".*?([^.]*)$")))
     460    (loop
     461       :for module :across (chain (jstatic "boot" "java.lang.ModuleLayer")
     462                                  "configuration" "modules" "stream" "toArray")
     463       :appending
     464         (loop
     465            :for class-as-path :across (chain module "reference" "open" "list" "toArray")
     466            :when
     467              (jcall "matches" (jcall "matcher" class-pattern class-as-path))
     468            :collect
     469              (let* ((full-name (jcall "substring" (jcall "replace" class-as-path #\/ #\.)
     470                                           0
     471                                           (- (jcall "length" class-as-path) (jcall "length" ".class"))))
     472                     (matcher (jcall "matcher" name-pattern full-name))
     473                     (name (progn
     474                             (jcall "matches" matcher)
     475                             (jcall "group" matcher 1))))
     476                (cons name full-name))))))
     477
     478(defun do-auto-imports-from-jars ()
    441479  (labels ((expand-paths (cp)
    442480             (loop :for s :in cp
  • trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp

    r15133 r15134  
    1111    (java:jcall get-classloader boot-class)))
    1212
    13 ;;; java1.[678] packages the JVM system artifacts as jar files
     13;;; java[678] packages the JVM system artifacts as jar files
     14;;; java11 uses the module system
    1415(defun system-artifacts-are-jars-p ()
    1516  (java:jinstance-of-p (boot-classloader) "java.net.URLClassLoader"))
     
    7071
    7172(defun java.class.path ()
     73  "Return a list of the directories as pathnames referenced in the JVM classpath."
    7274  (let* ((separator (java:jstatic "getProperty" "java.lang.System" "path.separator"))
    73    (path (java:jcall "split"
     75   (paths (coerce (java:jcall "split"
    7476         (java:jstatic "getProperty" "java.lang.System"
    7577           "java.class.path")
    76          separator)))
    77     (setf path (coerce path 'list))
    78     (values
    79      (mapcar (lambda (jar)
    80          (make-pathname :defaults jar
    81             :name nil
    82             :type nil))
    83        path)
    84      path)))
     78         separator)
     79                        'list))
     80         (p (coerce paths 'list)))
     81    (flet ((directory-of (p) (make-pathname :defaults p :name nil :type nil)))
     82      (values
     83       (mapcar #'directory-of p)
     84       p))))
    8585
    8686(defun enumerate-resource-directories ()
     
    105105        (t
    106106         (format *standard-output*
    107                  "Skipping enumeration of resource ~a with type ~a"
     107                 "~&Skipping enumeration of resource '~a' with type '~a'.~%"
    108108                 entry (type-of entry)))))
    109109      result)))
     
    152152returns the pathname of the contrib if it can be found."
    153153   (if *abcl-contrib*
    154        (format verbose "~&; Using already initialized value of SYS:*ABCL-CONTRIB* '~A'.~%"
     154       (format verbose "~&; Finding contribs utilizing previously initialized value of SYS:*ABCL-CONTRIB* '~A'.~%"
    155155               *abcl-contrib*)
    156156       (progn
     
    231231(export '(find-system
    232232          find-contrib
     233          system-artifacts-are-jars-p
     234          java.class.path
    233235          *abcl-contrib*)
    234236        :system)
Note: See TracChangeset for help on using the changeset viewer.