Changeset 13078 for trunk/abcl/src/org


Ignore:
Timestamp:
12/01/10 22:44:34 (11 years ago)
Author:
Mark Evenson
Message:

The classfile writer now handles the creation of interfaces.

JVM::MAKE-CLASS-INTERFACE-FILE will create a classfile structure
suitable for defining a Java interface. Simply add abstract methods
to complete the definition.

JVM::ADD-SUPERINTERFACE adds an interface definition to a classfile.
For a classfile denoting a Java object, these interfaces correspond
to the contents of a Java language "implements" clause. For a classfile
denoting a Java interface, these interfaces are all added to the
contract defined by this interfaces corresponding to the Java language
"extends" clause.

[Includes accidental update of NetBeans? project files.]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/jvm-class-file.lisp

    r13071 r13078  
    512512  class
    513513  superclass
    514   ;; support for implementing interfaces not yet available
    515   ;; interfaces
     514  interfaces
    516515  fields
    517516  methods
    518517  attributes)
     518
     519(defun make-class-interface-file (class)
     520  "Create the components of a class file representing a public Java
     521interface."
     522  (make-class-file class +java-object+ '(:public :abstract :interface)))
    519523
    520524(defun class-add-field (class field)
     
    552556  (push attribute (class-file-attributes class)))
    553557
     558(defun class-add-superinterface (class interface)
     559  "Adds the java-class-name contained in `interface' as a superinterface of the `class'.
     560
     561For a class that represents an object, the requirements in `interface'
     562must then be implemented in the class.  For a class that represents an
     563interface, the `interface' imposes additional requirements to the
     564classes which implement this class."
     565  (push interface (class-file-interfaces class)))
     566
    554567(defun class-attribute (class name)
    555568  "Returns the attribute which is named `name'."
     
    557570        :test #'string= :key #'attribute-name))
    558571
     572(defun finalize-interfaces (class)
     573  "Finalize the interfaces for `class'.
     574
     575Interface finalization first ensures that all the classes referenced
     576by the interfaces members exist in the pool.  Then, it destructively
     577modfies the interfaces members with a list of the references to the
     578corresponding pool indices."
     579  (let ((interface-refs nil))
     580    (dolist (interface (class-file-interfaces class))
     581      (push
     582       (pool-add-class (class-file-constants class)
     583                       interface)
     584       interface-refs))
     585    (setf (class-file-interfaces class) interface-refs)))
    559586
    560587(defun finalize-class-file (class)
     
    575602        (pool-add-class (class-file-constants class)
    576603                        (class-file-class class)))
    577   ;;  (finalize-interfaces)
     604  (finalize-interfaces class)
    578605  (dolist (field (class-file-fields class))
    579606    (finalize-field field class))
     
    685712
    686713  ;; interfaces
    687   (write-u2 0 stream)
     714  (if (class-file-interfaces class)
     715      (progn
     716        (write-u2 (length (class-file-interfaces class)) stream)
     717        (dolist (interface-ref (class-file-interfaces class))
     718          (write-u2 interface-ref stream)))
     719      (write-u2 0 stream))
    688720
    689721  ;; fields
Note: See TracChangeset for help on using the changeset viewer.