At 06:35 PM 1/11/01 -0500, Sam Steingold wrote:
>> * In message <[EMAIL PROTECTED]>
>> * On the subject of "Re: feature request: java exception handling"
>> * Sent on Thu, 11 Jan 2001 12:47:34 -0500
>> * Honorable Paul Kinnucan <[EMAIL PROTECTED]> writes:
>>
>> Has anyone actually tried it? How well does it work? Are there any
>> major limitations? Phil says it does not work when a JIT is
>> running. This seems a serious limitation as JIT has been the default
>> mode for jvms fo a long time now.
>
>I simplified the code and now it does work for me with the patch to
>jde-db.el I sent to Paul today.
>
This code does not work for me. I found at least two problems with it. If
you use the mouse (i.e., jde-stack-show-at-mouse) to click on the first
line of the following exception:
java.lang.NullPointerException
at jmath.LinearSystem.<init>(LinearSystem.java:53)
at jmath.Test.main(Test.java:49)
Exception in thread "main"
Process jmath.Test exited abnormally with code 1
Emacs reports a
(wrong-type-argument stringp nil)
error. The reason is that jde-stack-show-at-mouse never intializes the
marker used to find the run buffer. The command jde-stack-show-at-point
does initialize the marker and extract the unqualified name of the first
class on the stack (LinearSystem) from the message. Unfortunately, the rest
of the code requires the FULLY QUALIFIED name of the class to find the
source for the class.
These problems need to be fixed before I can include this code in the JDE.
The docstrings should also explain more clearly how to use the commands.
For example, they don't really tell you where to click or put point to get
the commands to work properly. I'd do this myself but it requires more work
than I have time for at the moment.
- Paul
>Code:
>-----------------------------
>(require 'jde)
>(require 'compile)
>
>(defvar jde-stack-current-marker (cons (make-marker) (make-marker))
> "Stores a marker where the last stack was.")
>
>(defun jde-stack-current-marker (&optional next)
> "update `cdr' of `jde-stack-current-marker' from its `car'."
> (let ((here (car jde-stack-current-marker))
> (there (cdr jde-stack-current-marker))
> class line file buf)
> (save-excursion
> (set-buffer (marker-buffer here))
> (goto-char here)
> (forward-line (or next 0))
> (re-search-forward "(\\([a-zA-Z0-9]+\\)\\.java:\\([0-9]+\\))")
> (setq class (match-string 1)
> line (car (read-from-string (match-string 2)))
> file (jde-class-source class)
> buf (find-file-noselect file))
> (set-buffer buf) (goto-line line)
> (set-marker there (point) buf)))
> jde-stack-current-marker)
>
>(defun jde-stack-goto (&optional next)
> "Display the current stack using `compilation-goto-locus'."
> (compilation-goto-locus (jde-stack-current-marker next)))
>
>(defun jde-stack-show-at-mouse (event)
> "Jump to the stack at the mouse click."
> (interactive "e")
> (save-excursion
> (set-buffer (window-buffer (posn-window (event-start event))))
> (goto-char (posn-point (event-start event)))
> (jde-stack-goto)))
>
>(defun jde-stack-show-at-point ()
> "Displays the stack on this current line"
> (interactive)
> (set-marker (car jde-stack-current-marker) (point) (current-buffer))
> (jde-stack-goto))
>
>(defun jde-stack-next ()
> "Show the next source in the stack trace."
> (interactive)
> (jde-stack-goto 1))
>
>(defun jde-stack-prev ()
> "Shows the previous source in the stack trace."
> (interactive)
> (jde-stack-goto -1))
>
>(add-hook
> 'jde-run-mode-hook
> (lambda ()
> (define-key (current-local-map) "\C-c\C-v\C-[" 'jde-stack-prev)
> (define-key (current-local-map) "\C-c\C-v\C-]" 'jde-stack-next)
> (define-key (current-local-map) [mouse-2] 'jde-stack-show-at-mouse)))
>
>(define-key jde-mode-map "\C-c\C-v\C-[" 'jde-stack-prev)
>(define-key jde-mode-map "\C-c\C-v\C-]" 'jde-stack-next)
>
>(provide 'jde-stack)
>-----------------------------
>
>Patch:
>-----------------------------
>cd c:/gnu/sitelisp/jde/lisp/
>diff -u -b -w -i -B "c:/gnu/sitelisp/jde/lisp/jde-db.el.old"
"c:/gnu/sitelisp/jde/lisp/jde-db.el"
>--- c:/gnu/sitelisp/jde/lisp/jde-db.el.old Wed Dec 20 01:18:38 2000
>+++ c:/gnu/sitelisp/jde/lisp/jde-db.el Thu Jan 11 16:43:57 2001
>@@ -763,27 +763,30 @@
>
> (defun jde-find-class-source (class)
> "*Find the source file for a specified class.
>-CLASS is the fully qualified name of the class. This
>-function searchs the source file paths specified by
>-`jde-db-source-directories' for the source file
>-corresponding to CLASS. If it finds the source file,
>-it opens the file in a buffer."
>+Calls `jde-class-source' to do the search.
>+If it finds the source file, it opens the file in a buffer."
> (interactive "sClass: ")
>- (string-match
"^\\(\\(\\(\\w\\|[_]\\)*[.]\\)*\\)\\(\\(\\w\\|[_]\\)+$\\)" class)
>- (let* ((package-name
>- (substring class (match-beginning 1) (match-end 1)))
>- (class-name
>- (substring class (match-beginning 4) (match-end 4)))
>+ (let ((source (jde-class-source class)))
>+ (when source
>+ (find-file source))))
>+
>+(defun jde-class-source (class)
>+ "Find out the source file name for the specified class.
>+CLASS is the fully qualified name of the class.
>+This function searches the source file paths specified by
>+`jde-db-source-directories' for the source file
>+corresponding to CLASS.
>+If it cannot find the file, it returns nil."
>+ (string-match "^\\(\\(\\(\\w\\|[_]\\)*[.]\\)*\\)\\(\\(\\w\\|[_]\\)+$\\)"
>+ class)
>+ (let* ((package-name (substring class (match-beginning 1) (match-end 1)))
>+ (class-name (substring class (match-beginning 4) (match-end 4)))
> (file-name (concat class-name ".java"))
>- (source-dir
>- (jde-db-search-src-dirs
>- file-name
>- package-name)))
>+ (source-dir (jde-db-search-src-dirs file-name package-name)))
> (if source-dir
>- (find-file (concat source-dir file-name))
>- (message (concat "JDE error: Could not find source for %s. "
>- "See `jde-db-source-directories' for more information." )
>- class))))
>+ (concat source-dir file-name)
>+ (message "JDE error: Could not find source for %s. See
`jde-db-source-directories' for more information." class)
>+ nil)))
>
> (defvar jde-db-minibuffer-local-map nil
> "Keymap for minibuffer prompting of jdb startup command.")
>
>Diff finished at Thu Jan 11 18:34:20
>-----------------------------
>
>--
>Sam Steingold (http://www.podval.org/~sds)
>Support Israel's right to defend herself!
<http://www.i-charity.com/go/israel>
>Read what the Arab leaders say to their people on <http://www.memri.org/>
>Failure is not an option. It comes bundled with your Microsoft product.
>
>