Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OSGI functionality to JSS, minor fixes to invoke, engage #1" reader #410

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

alanruttenberg
Copy link
Collaborator

Engage the #1".." reader, which allows java expressions e.g. #1"System.out.printLn("foo")"
Code was already there but needed a couple of lines in read-invoke that check for #1 and load javaparser.

I'm updating to your master. These were the remaining changes in my version that you don't have.

Other minor fixes in invoke.lisp
Engage the armedbear#1".." reader, which allows java expressions e.g. armedbear#1"System.out.printLn("foo")"
Copy link
Collaborator

@easye easye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What is being fixed in invoke.lisp? Do you have a small test that demonstrates a before and after?

  2. Can you provide an example of an OSGI bundle that I can test?

…ind-java-class and lookup-class-name that I missed in the earlier merge
@alanruttenberg
Copy link
Collaborator Author

To test OSGI grab https://github.com/alanruttenberg/lsw2/blob/owlapiv4/owl2/lib/uk.ac.manchester.cs.owl.factplusplus-1.6.5.jar and put it in the same directory as the following sysdef

(defpackage :asdf/owl2libs (:use :asdf :cl))
(in-package :asdf/owl2libs)

(require 'asdf-mvn-module)

(defun open-osgi-for-lsw ()
  (loop for wedge in '("org.osgi.framework.system.packages.extra" "org.osgi.framework.bootdelegation")
	do (jss::add-to-comma-separated-osgi-config
	    wedge
	    '("com.google.common.collect" "com.google.common.collect.*"
             "gnu.trove" "gnu.trove.*" "javax.swing" "javax.swing.*"
	     "javax.xml.datatype" "javax.xml.datatype.*" "org.apache.log4j" "org.apache.log4j.*"
	     "org.semanticweb.owlapi.model" "org.semanticweb.owlapi.model.*"
	     "org.semanticweb.owlapi.reasoner" "org.semanticweb.owlapi.reasoner.*"
	     "org.semanticweb.owlapi.reasoner.impl" "org.semanticweb.owlapi.reasoner.impl.*"
	     "org.semanticweb.owlapi.reasoner.knowledgeexploration" "org.semanticweb.owlapi.reasoner.knowledgeexploration.*"
	     "org.semanticweb.owlapi.util" "org.semanticweb.owlapi.util.*"
	      "org.semanticweb.owlapi.vocab" "org.semanticweb.owlapi.vocab.*"))))

(defvar cl-user::*before-osgi-starting-hooks* nil)
(pushnew 'open-osgi-for-lsw cl-user::*before-osgi-starting-hooks*)

(asdf:defsystem test
  :components
  ((:mvn-module maven
   :dependencies 
   ("javax.xml.bind:jaxb-api:LATEST"
    "net.sourceforge.owlapi/owlapi-distribution/4.2.6"
    "net.sourceforge.owlapi/owlexplanation/2.0.0"
    ) 
   :managed-dependencies
   ("org.slf4j/slf4j-api/1.7.21"
    "org.apache.httpcomponents:httpcore:4.4.5"
    "org.apache.httpcomponents:httpclient:4.5"
    "net.sourceforge.owlapi:owlapi-distribution:4.2.6")
   :exclusions
   ("net.sourceforge.owlapi:owlapi-osgidistribution"
    "edu.stanford.protege:org.protege.editor.owl"
    "org.jgrapht:jgrapht-jdk1.5:0.7.3"
    ))
   (:bundle "uk.ac.manchester.cs.owl.factplusplus-1.6.5"))
  :serial t
)

Load the system and then

(jss::find-java-class "uk.ac.manchester.cs.factplusplus.FaCTPlusPlusException")

Return value should be the following, a class defined in the bundle.

#<java class uk.ac.manchester.cs.factplusplus.FaCTPlusPlusException>

Other tests coming...

@alanruttenberg
Copy link
Collaborator Author

maybe-resolve-class-against-imports - add ability to look up bundle classes

invoke line 181: object-as-class wasn't used. Could probably drop object-as-class-name in the "or"

read-invoke: Try (let ((thread (threads::current-thread))) #1"thread.javaThread.getState().toString()")

lookup-class-name: add ability to look up bundle classes
line 306: symbol names are upper case, so used char-equal to make sure match works

shortest-unambiguous-java-class-abbreviation: new function, helper
(japropos 'Md5Crypt) finds 2 classes
org.apache.commons.codec.digest.Md5Crypt: Java Class
org.apache.maven.wagon.providers.http.commons.codec.digest.Md5Crypt: Java Class
(jss::shortest-unambiguous-java-class-abbreviation "org.apache.commons.codec.digest.Md5Crypt")
-> apache.commons.codec.digest.md5crypt

japropos: add ability to find bundle classes

jclass-method-names: if "class" argument is instead an object then the methods for the class of the object are returned.

@easye
Copy link
Collaborator

easye commented Nov 10, 2021

I'm having problems with the way this patch defines the OSGI hook function. Once I load things under SLIME, I can't restart my session getting errors

abcl-introspectASDF could not load  because
The symbol "*BEFORE-OSGI-STARTING-HOOKS*" is not external in package COMMON-LISP-USER..
;; 
;; Error loading /Users/evenson/.slime/fasl/2.26.1/armedbear-1.8.1-dev-darwin-aarch64/abcl.abcl:
;;   JSS is not the name of a package.
;; 
Error loading /Users/evenson/.slime/fasl/2.26.1/armedbear-1.8.1-dev-darwin-aarch64/abcl.abcl at line 581 (offset 44939)
#<THREAD "interpreter" {90800E6}>: Debugger invoked on condition of type ERROR
  JSS is not the name of a package.

I think it is rather improper abstraction to have the osgi.lisp code in the ABCL-ASDF add code JSS package. And I don't like the use of the hook symbol defined in CL-USER, and imported into JSS.

I'll do some hacking to see if I can get things in the places I want them.

@easye
Copy link
Collaborator

easye commented Nov 10, 2021

See #412 for my preferred approach to adding OSGI.

…jar and asdj-osgi-bundle to avoid re-adding bundle and always thinking the asdf operation succeeded.
…fer the class over the class name so that the right classloader is used. For the bundle, don't inherit the compile-op method which was adding the bundle jar to the classpath too, which confused find-java-class. Verified to work in java 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants