Changeset 15134
- Timestamp:
- 11/01/19 15:52:46 (4 years ago)
- Location:
- trunk/abcl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/contrib/jss/invoke.lisp
r15133 r15134 421 421 (set-java-field object field value try-harder)) 422 422 423 424 423 (defconstant +for-name+ 425 424 (jmethod "java.lang.Class" "forName" "java.lang.String" "boolean" "java.lang.ClassLoader")) … … 439 438 440 439 (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 () 441 479 (labels ((expand-paths (cp) 442 480 (loop :for s :in cp -
trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp
r15133 r15134 11 11 (java:jcall get-classloader boot-class))) 12 12 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 14 15 (defun system-artifacts-are-jars-p () 15 16 (java:jinstance-of-p (boot-classloader) "java.net.URLClassLoader")) … … 70 71 71 72 (defun java.class.path () 73 "Return a list of the directories as pathnames referenced in the JVM classpath." 72 74 (let* ((separator (java:jstatic "getProperty" "java.lang.System" "path.separator")) 73 (path (java:jcall "split"75 (paths (coerce (java:jcall "split" 74 76 (java:jstatic "getProperty" "java.lang.System" 75 77 "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)))) 85 85 86 86 (defun enumerate-resource-directories () … … 105 105 (t 106 106 (format *standard-output* 107 " Skipping enumeration of resource ~a with type ~a"107 "~&Skipping enumeration of resource '~a' with type '~a'.~%" 108 108 entry (type-of entry))))) 109 109 result))) … … 152 152 returns the pathname of the contrib if it can be found." 153 153 (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'.~%" 155 155 *abcl-contrib*) 156 156 (progn … … 231 231 (export '(find-system 232 232 find-contrib 233 system-artifacts-are-jars-p 234 java.class.path 233 235 *abcl-contrib*) 234 236 :system)
Note: See TracChangeset
for help on using the changeset viewer.