langtools/src/share/classes/com/sun/mirror/overview.html
author ohair
Wed, 26 May 2010 20:22:54 -0700
changeset 5568 8450cc6bc21c
parent 5520 86e4b9a9da40
permissions -rw-r--r--
6956202: Fix a few missed rebranding issues, please contact lines etc. Reviewed-by: darcy, jjg, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
<html>
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
<head>
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
<!--
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     6
Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    11
published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    13
by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
5568
8450cc6bc21c 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5520
diff changeset
    25
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8450cc6bc21c 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5520
diff changeset
    26
or visit www.oracle.com if you need additional information or have any
8450cc6bc21c 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5520
diff changeset
    27
questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
-->
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
</head>
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
<body bgcolor="white">
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
The Mirror API is used to model the semantic structure of a program.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
It provides representations of the entities
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
declared in a program, such as classes, methods, and fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
Constructs below the method level, such as 
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
individual statements and expressions, are not represented.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
<p> Also included is support for writing
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
{@linkplain com.sun.mirror.apt.AnnotationProcessor annotation processors}
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
to examine and process the annotations
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
of program elements.  An annotation processor may, as an example, create
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
new source files and XML documents to be used in conjunction with the
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
original code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
<h4> Characteristics of the API </h4>
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
A program is represented at the language level, rather than at the
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
level of the virtual machine.  Nested classes, for example, are
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
handled as first-class constructs, 
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
rather than in the translated form understood by the VM.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
Both source code and compiled code (class files) may be modeled
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
in this way.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
<p> Programs are modeled in their static, or build-time, form.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
This differs from the {@linkplain java.lang.reflect reflection} API,
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
which provides run-time information about classes and objects.
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
<p> The API does not provide direct support for generating new code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
<h4> Declarations and Types </h4>
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
  
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
The mirror API represents program constructs principally through the
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
{@link com.sun.mirror.declaration.Declaration} interface
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
and its hierarchy of subinterfaces in the package {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
com.sun.mirror.declaration}.  A <tt>Declaration</tt> represents a
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
program element such as a package, class, or method.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
The interface hierarchy is depicted
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
<a href="com/sun/mirror/declaration/package-tree.html"> here</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
<p> Types are represented by the {@link com.sun.mirror.type.TypeMirror}
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
interface and its hierarchy of subinterfaces in the
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
package {@link com.sun.mirror.type}.  Types include primitive types,
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
class and interface types, array types, type variables, and wildcards.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
The interface hierarchy is depicted
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
<a href="com/sun/mirror/type/package-tree.html"> here</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
<p> The API makes a clear distinction between declarations and types.
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
This is most significant for generic types, where a single declaration
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
can define an infinite family of types.  For example, the declaration of
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
<tt>java.util.Set</tt> defines the raw type <tt>java.util.Set</tt>,
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
the parameterized type {@code java.util.Set<String>},
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
and much more.  Only the declaration can be annotated, for example,
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
and only a type can appear in a method signature.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
<p> A program being modeled may be incomplete, in that
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
it may depend on an unknown class or interface type.
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
This may be the result of a processing error such as a missing class file,
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
or perhaps the missing type is to be created by an annotation processor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
See {@link com.sun.mirror.type.DeclaredType} for information on
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
how such unknown types are handled.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
<h4> Utilities and Tool Support </h4>
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
The {@link com.sun.mirror.util} package provides
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
utilities to assist in the processing of declarations and types.
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
Included is support for using the visitor design pattern when
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
operating on declaration and type objects.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
<p> The {@link com.sun.mirror.apt} package supports the writing
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
of annotation processors.  It provides the mechanism for them to
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
interact with an annotation processing tool.
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
@since 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
</body>
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
</html>