The Source for Java Technology Collaboration
User: Password:



Alexander Schunk

Alexander Schunk's Blog

OpenJDK 7: Inside javac continued...

Posted by alexanderschunk on March 26, 2007 at 01:14 PM | Comments (5)

Code content

Last time I talked a bit about the organization of the code. This time, I tell something about its content. The code of the compiler is basically divided into two parts:

  • Interfaces
  • Classes and Methods

These interfaces are hold in the following packages:

  • javax.lang.model.element
  • javax.lang.model.type
  • javax.lang.model.util
  • javax.util

The interfaces provide methods and/or contants that are implemented by classes. Almost all core concepts of the java language - variables, annotation types, arrays, etc. - are described by interfaces. Some of these interfaces do not any line of code so I assume these interfaces are defined later.

Samples

The following interfaces describe Java primitive types as used by the compiler:

public interface PrimitiveType extends TypeMirror { }

public interface ArrayType extends ReferenceType {
/** * Returns the component type of this array type. * * @return the component type of this array type */ TypeMirror getComponentType();
}

public interface ReferenceType extends TypeMirror {
}

The interfaces shown above describe primitive types, Array types and Reference types. If you want to use the - not yet? provided methods or constants - of these interfaces you have to implement them in a concrete class.

class MyArrayType implements ArrayType{
}

Then you can provide a concrete implementation of an ArrayType.

Besides these type interfaces there are also interfaces for Executable types.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Some of these interfaces do not any line of code so I assume these interfaces are defined later. - huh?

    Posted by: kirillcool on March 27, 2007 at 02:20 PM

  • I mean: I assume methods or attrbiutes of these interfaces will be defined later.

    Why would anyone define a "blank" interface withouts methods or constants? What will you implement if there is nothing to implement? So I assume that methods or constants will be provided later.

    Thanks for any clarifying comments.

    Posted by: alexanderschunk on March 27, 2007 at 11:36 PM

  • Ok. You can use these interfaces to subclass them however, then there is nothing to inherit from these interfaces but a blank interface.

    See I just wonder why ther is no method or constant provided in these interface that you could use to overwrite.

    Posted by: alexanderschunk on March 27, 2007 at 11:39 PM

  • Nothing wrong with interfaces without methods. They're marker interfaces. Just a way of identifying some type heirarchy. they dont neccessarily have to 'do' anything.

    Besides, methods wouldnt be defined later. Golden rule of interfaces: Once defined, methods should never be added to an interface later on.

    Posted by: benloud on March 28, 2007 at 04:44 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds