Class file has a larger 4 byte value then emacs can handle
Eric Warmenhoven <[email protected]>
| Newsgroups | gmane.emacs.jdee.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello, In one of the java files in the project I'm working on, there is a switch statement that uses very large values (0x70000000 - 0x7000000f) for the cases. javac turns it into a tableswitch opcode with the low and high values "larger than emacs can handle". Because tableswitch is only going to be used if the values are somewhat close together, there's really no reason for this error to happen here. I've attached a diff (against svn branches/2.4.0) that changes the tableswitch handling so that instead of getting the low and high values independently and subtracting, it will get both values at the same time and do the subtraction in line with reconstructing a 4-byte value. Thanks, Eric ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ jdee-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jdee-devel
tableswitch.diff
(text/x-diff, 2.7 KB)
*** /home/ewarmenhoven/jde-parse-class.el Thu Sep 17 14:01:29 2009
--- /home/ewarmenhoven/jde-parse-class-mod.el Fri Sep 11 15:33:13 2009
***************
*** 328,336 ****
;; The second mod is to make sure on an offset of 4 we really don't skip anything
(forward-char (mod (- 4 (mod (- (point) begin-point) 4)) 4))
(forward-char 4) ;; we don't care about default
! (let ((low (jde-parse-class-get-next-4-bytes-as-signed))
! (high (jde-parse-class-get-next-4-bytes-as-signed)))
! (forward-char (* 4 (+ (- high low) 1)))))
((eq opcode-val 'lookupswitch)
(forward-char (mod (- 4 (mod (- (point) begin-point) 4)) 4))
(forward-char 4)
--- 328,335 ----
;; The second mod is to make sure on an offset of 4 we really don't skip anything
(forward-char (mod (- 4 (mod (- (point) begin-point) 4)) 4))
(forward-char 4) ;; we don't care about default
! (let ((diff (jde-parse-class-diff-next-two-4-bytes-as-signed)))
! (forward-char (* 4 (+ diff 1)))))
((eq opcode-val 'lookupswitch)
(forward-char (mod (- 4 (mod (- (point) begin-point) 4)) 4))
(forward-char 4)
***************
*** 492,498 ****
(defun jde-parse-class-get-next-4-bytes-as-signed (&optional ignore-large-val)
(let ((db1 (jde-parse-class-get-next-2-bytes))
(db2 (jde-parse-class-get-next-2-bytes)))
! (if (> (logand 32768 db1) 0) ;; if it's high-bit is set, then it's negative.
(if (> db1 63488)
(- (+ 1 (+ (* (- 65535 db1) 65536) (- 65535 db2))))
(if ignore-large-val
--- 491,497 ----
(defun jde-parse-class-get-next-4-bytes-as-signed (&optional ignore-large-val)
(let ((db1 (jde-parse-class-get-next-2-bytes))
(db2 (jde-parse-class-get-next-2-bytes)))
! (if (> (logand 32768 db1) 0) ;; if its high-bit is set, then it's negative.
(if (> db1 63488)
(- (+ 1 (+ (* (- 65535 db1) 65536) (- 65535 db2))))
(if ignore-large-val
***************
*** 500,505 ****
--- 499,514 ----
(error "Class file has an unsigned int who is smaller than emacs can handle")))
(jde-parse-class-get-4byte (- (point) 4)))))
+ (defun jde-parse-class-diff-next-two-4-bytes-as-signed ()
+ (let ((low1 (jde-parse-class-get-next-2-bytes))
+ (low2 (jde-parse-class-get-next-2-bytes))
+ (high1 (jde-parse-class-get-next-2-bytes))
+ (high2 (jde-parse-class-get-next-2-bytes)))
+ (if (and (> (logand 32768 low1) 0)
+ (<= (logand 32768 high1) 0))
+ (+ (* 65536 (- (+ high1 65535) low1)) (- (+ high2 65536) low2))
+ (+ (* 65535 (- high1 low1)) (- high2 low2)))))
+
(defun jde-parse-class-get-next-4-bytes (&optional ignore-large-val)
(do-and-advance-chars 4
(jde-parse-class-get-4byte (point) ignore-large-val)))
signature.asc
(application/pgp-signature, 196 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkqypBQACgkQBLcxcFStIbXumgCfZ/WCOcLp1WjNC7SQW8T6VZKs OYsAnje+W3Oj5K6HtFBRloUKNEBhI+Gz =mikH -----END PGP SIGNATURE-----