Changeset 13739
- Timestamp:
- 01/09/12 22:55:37 (11 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/jvm-class-file.lisp
r13727 r13739 82 82 83 83 (defstruct (jvm-class-name (:conc-name class-) 84 84 (:constructor %make-jvm-class-name)) 85 85 "Used for class identification. 86 86 … … 374 374 "Returns the index of the constant-pool class item for `class'. 375 375 376 `class' must be an instance of `class-name'." 377 (let ((entry (gethash class (pool-entries pool)))) 378 (unless entry 379 (let ((utf8 (pool-add-utf8 pool (class-name-internal class)))) 380 (setf entry 381 (make-constant-class (incf (pool-index pool)) utf8) 382 (gethash class (pool-entries pool)) entry)) 383 (push entry (pool-entries-list pool))) 384 (constant-index entry))) 376 `class' must be an instance of `class-name' or a string (which will be converted 377 to a `class-name')." 378 (let ((class (if (jvm-class-name-p class) 379 class 380 (make-jvm-class-name class)))) 381 (let ((entry (gethash class (pool-entries pool)))) 382 (unless entry 383 (let ((utf8 (pool-add-utf8 pool (class-name-internal class)))) 384 (setf entry 385 (make-constant-class (incf (pool-index pool)) utf8) 386 (gethash class (pool-entries pool)) entry)) 387 (push entry (pool-entries-list pool))) 388 (constant-index entry)))) 385 389 386 390 (defun pool-add-field-ref (pool class name type) … … 1349 1353 elements) 1350 1354 1351 (defstruct annotation-element namevalue)1355 (defstruct annotation-element (name "value") value) 1352 1356 1353 1357 (defstruct annotation-element-value tag finalizer writer) … … 1361 1365 (boolean 1362 1366 (setf (annotation-element-value-tag self) 1363 (char-code #\ B)1367 (char-code #\Z) 1364 1368 (primitive-or-string-annotation-element-value self) 1365 (pool-add-int (class-file-constants class) (if value 1 0)))))))) 1369 (pool-add-int (class-file-constants class) (if value 1 0)))) 1370 (fixnum 1371 (setf (annotation-element-value-tag self) 1372 (char-code #\I) 1373 (primitive-or-string-annotation-element-value self) 1374 (pool-add-int (class-file-constants class) value))) 1375 (string 1376 (setf (annotation-element-value-tag self) 1377 (char-code #\s) 1378 (primitive-or-string-annotation-element-value self) 1379 (pool-add-utf8 (class-file-constants class) value))))))) 1366 1380 (writer (lambda (self stream) 1367 1381 (write-u1 (annotation-element-value-tag self) stream) … … 1369 1383 value) 1370 1384 1385 (defstruct (enum-value-annotation-element-value 1386 (:conc-name enum-value-annotation-element-) 1387 (:include annotation-element-value 1388 (finalizer (lambda (self class) 1389 (setf (annotation-element-value-tag self) 1390 (char-code #\e) 1391 (enum-value-annotation-element-type self) 1392 (pool-add-utf8 (class-file-constants class) 1393 (enum-value-annotation-element-type self)) ;;Binary name as string 1394 (enum-value-annotation-element-name self) 1395 (pool-add-utf8 (class-file-constants class) 1396 (enum-value-annotation-element-name self))))) 1397 (writer (lambda (self stream) 1398 (write-u1 (annotation-element-value-tag self) stream) 1399 (write-u2 (enum-value-annotation-element-type self) stream) 1400 (write-u2 (enum-value-annotation-element-name self) stream))))) 1401 type 1402 name) 1403 1371 1404 (defstruct (runtime-visible-annotations-attribute 1372 1405 (:include annotations-attribute 1373 (name "RuntimeVisibleAnnotations") 1374 (finalizer #'finalize-annotations) 1375 (writer #'write-annotations))) 1406 (name "RuntimeVisibleAnnotations"))) 1376 1407 "4.8.15 The RuntimeVisibleAnnotations attribute 1377 1408 The RuntimeVisibleAnnotations attribute is a variable length attribute in the … … 1389 1420 (dolist (ann (annotations-list annotations)) 1390 1421 (setf (annotation-type ann) 1391 (pool-add-class (class-file-constants class) 1392 (if (jvm-class-name-p (annotation-type ann)) 1393 (annotation-type ann) 1394 (make-jvm-class-name (annotation-type ann))))) 1422 (pool-add-class (class-file-constants class) (annotation-type ann))) 1395 1423 (dolist (elem (annotation-elements ann)) 1396 1424 (setf (annotation-element-name elem) … … 1406 1434 (write-u2 (length (annotation-elements annotation)) stream) 1407 1435 (dolist (elem (reverse (annotation-elements annotation))) 1408 (funcall (annotation-element-value-writer elem) elem stream)))) 1436 (write-u2 (annotation-element-name elem) stream) 1437 (funcall (annotation-element-value-writer (annotation-element-value elem)) 1438 (annotation-element-value elem) stream)))) 1409 1439 1410 1440 #| -
trunk/abcl/src/org/armedbear/lisp/runtime-class.lisp
r13727 r13739 2 2 (require "JVM-CLASS-FILE") 3 3 4 ;;The package is set to :jvm for convenience, since most of the symbols used 5 ;;here come from that package. However, the functions we're definining belong 6 ;;to the :java package. 4 7 (in-package :jvm) 5 8 … … 139 142 (list "foo" :void '("java.lang.Object") 140 143 (lambda (this that) (print (list this that))) 141 :annotations (list (make-annotation :type "java.lang.Deprecated"))) 144 :annotations (list (make-annotation :type "java.lang.Deprecated") 145 (make-annotation :type "java.lang.annotation.Retention" 146 :elements (list (make-annotation-element 147 :value (make-enum-value-annotation-element-value 148 :type "java.lang.annotation.RetentionPolicy" 149 :name "RUNTIME")))) 150 (make-annotation :type "javax.xml.bind.annotation.XmlAttribute" 151 :elements (list (make-annotation-element 152 :name "required" 153 :value (make-primitive-or-string-annotation-element-value :value t)))))) 142 154 (list "bar" :int '("java.lang.Object") 143 155 (lambda (this that) (print (list this that)) 23))))
Note: See TracChangeset
for help on using the changeset viewer.