This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

compiling macros to class yields foo.<init>(foo.scm) error when loading


Hi,

I posted an alternative to brl-repeat to the brl-users list some time ago. I did not mention then that I had delayed sending it because I haven't yet managed to turn the .scm file into .class files. I wonder if there's a bug in Kawa or something I'm missing.

Here's how I compile:
java -cp D:/Java/jakarta-tomcat-4.1.29/shared/lib/kawa-1.7.jar;D:/Java/jakarta-tomcat-4.1.29/shared/lib/brl-2.2.1.jar;. kawa.repl -P jch. -P jch. -C patches2.scm
(compiling patches2.scm)

Then I attempt to load the class file:
#|kawa:43|# (require <jch.patches2>)
java.lang.NullPointerException
	at gnu.mapping.OutPort.write(OutPort.java:199)
	at java.io.PrintWriter.print(Unknown Source)
	at gnu.mapping.OutPort.print(OutPort.java:285)
	at java.io.PrintWriter.println(Unknown Source)
	at java.lang.Throwable.printStackTrace(Unknown Source)
	at kawa.Shell.run(Shell.java:267)
	at kawa.Shell.run(Shell.java:180)
	at kawa.Shell.run(Shell.java:167)
	at kawa.Shell.run(Shell.java:154)
	at kawa.repl.main(repl.java:609)
Process inferior-lisp exited abnormally with code 1
(right now on MS-Windows, using Kawa-1.7 and JDK 1.4.2_02)

Alternatively,
#|kawa:1|# (load"jch/patches2.class")
java.lang.NullPointerException
	at jch.patches2.<init>(patches2.scm)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at kawa.standard.load.loadClassFile(load.java:38)
[...]
#|kawa:2|# 

I got these results using either define-syntax or defmacro.

I did not look whether Bruce R. Lewis uses .class in BRL or loads plain .scm files.

----------------patches2.scm
;;; BRL sql-repeat replacement
;; group-beginning? and group-ending? are NOT supported.

(require <gnu.brl.stringfun>)
(require <gnu.brl.sqlfun>)

;;TODO? define (call-with-sql-query-results st query proc)
(define (sql-repeat-result-set+cols rs :: <java.sql.ResultSet>
                                 number-of-columns
                                 proc :: <procedure>)
  (do ((cols (sql-resultset-nextrow rs number-of-columns)
             (sql-resultset-nextrow rs number-of-columns))
       (number-of-rows 0 (+ 1 number-of-rows)))
      ((not cols) number-of-rows)
    (apply proc cols)))

#|
(defmacro jch-sql-repeat-rsmd (rsmd stmt formals query-parts . body)
  (let ((rs (gentemp)) (c (gentemp)))
    `(let* ((,rs :: <java.sql.ResultSet>
                 (sql-execute-query ,stmt (brl-string ,@query-parts)))
            ;;NB JDBC guarantees rs is never #!null
            (,rsmd :: <java.sql.ResultSetMetaData> (sql-rsmd ,rs))
            (,c (invoke ,rsmd 'getColumnCount)))
       (sql-repeat-result-set+cols ,rs ,c
         (lambda ,formals ,@body)))))
|#

;; TODO? imbed let-syntax group-* to raise error
(define-syntax sql-repeat*
  (syntax-rules ()
   ((_ stmt formals (query-parts ...) body-expr ...)
    (let* ((rs :: <java.sql.ResultSet>
               (sql-execute-query stmt (brl-string query-parts ...)))
           ;; JDBC guarantees rs is never #!null
           (rsmd :: <java.sql.ResultSetMetaData> (sql-rsmd rs))
           (c (invoke rsmd 'getColumnCount)))
      (sql-repeat-result-set+cols rs c
        (lambda formals body-expr ...))))))

I'd like to turn some of my files into .class, instead of constantly loading all from .scm (I expect to get rid of some warnings about undeclared methods in java.Object for top-level variables whose type declarations seem ignored when loading .scm files).

Thanks for your help,

Regards,
	Jorg Hohle.
java version "1.4.2_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]