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.]
parent 125ac6dd
This diff is collapsed.
......@@ -4,8 +4,8 @@ build.xml.stylesheet.CRC32=be360661
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=742204ce
nbproject/build-impl.xml.script.CRC32=29122cc4
nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45
nbproject/build-impl.xml.script.CRC32=330b50b7
nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45
nbproject/profiler-build-impl.xml.data.CRC32=71623fcd
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
nbproject/profiler-build-impl.xml.stylesheet.CRC32=42cb6bcf
......@@ -511,12 +511,16 @@ class file as UTF-8 encoded data."
access-flags
class
superclass
;; support for implementing interfaces not yet available
;; interfaces
interfaces
fields
methods
attributes)
(defun make-class-interface-file (class)
"Create the components of a class file representing a public Java
interface."
(make-class-file class +java-object+ '(:public :abstract :interface)))
(defun class-add-field (class field)
"Adds a `field' created by `make-field'."
(push field (class-file-fields class)))
......@@ -551,11 +555,34 @@ class file as UTF-8 encoded data."
structure classes which include the `attribute' structure class."
(push attribute (class-file-attributes class)))
(defun class-add-superinterface (class interface)
"Adds the java-class-name contained in `interface' as a superinterface of the `class'.
For a class that represents an object, the requirements in `interface'
must then be implemented in the class. For a class that represents an
interface, the `interface' imposes additional requirements to the
classes which implement this class."
(push interface (class-file-interfaces class)))
(defun class-attribute (class name)
"Returns the attribute which is named `name'."
(find name (class-file-attributes class)
:test #'string= :key #'attribute-name))
(defun finalize-interfaces (class)
"Finalize the interfaces for `class'.
Interface finalization first ensures that all the classes referenced
by the interfaces members exist in the pool. Then, it destructively
modfies the interfaces members with a list of the references to the
corresponding pool indices."
(let ((interface-refs nil))
(dolist (interface (class-file-interfaces class))
(push
(pool-add-class (class-file-constants class)
interface)
interface-refs))
(setf (class-file-interfaces class) interface-refs)))
(defun finalize-class-file (class)
"Transforms the representation of the class-file from one
......@@ -574,7 +601,7 @@ The class can't be modified after finalization."
(class-file-class class)
(pool-add-class (class-file-constants class)
(class-file-class class)))
;; (finalize-interfaces)
(finalize-interfaces class)
(dolist (field (class-file-fields class))
(finalize-field field class))
(dolist (method (class-file-methods class))
......@@ -684,7 +711,12 @@ The class can't be modified after finalization."
(write-u2 (class-file-superclass class) stream)
;; interfaces
(write-u2 0 stream)
(if (class-file-interfaces class)
(progn
(write-u2 (length (class-file-interfaces class)) stream)
(dolist (interface-ref (class-file-interfaces class))
(write-u2 interface-ref stream)))
(write-u2 0 stream))
;; fields
(write-u2 (length (class-file-fields class)) stream)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment