src/HOL/MicroJava/document/introduction.tex
author kleing
Thu, 21 Feb 2002 09:54:08 +0100
changeset 12911 704713ca07ea
child 12914 71015f46b3c1
permissions -rw-r--r--
new document
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12911
704713ca07ea new document
kleing
parents:
diff changeset
     1
704713ca07ea new document
kleing
parents:
diff changeset
     2
\section*{Introduction}
704713ca07ea new document
kleing
parents:
diff changeset
     3
\label{sec:introduction}
704713ca07ea new document
kleing
parents:
diff changeset
     4
704713ca07ea new document
kleing
parents:
diff changeset
     5
This document contains the automatically generated listings of the
704713ca07ea new document
kleing
parents:
diff changeset
     6
Isabelle sources for \mJava. \mJava{} is a reduced model of JavaCard,
704713ca07ea new document
kleing
parents:
diff changeset
     7
dedicated to the study of the interaction of the source language, byte
704713ca07ea new document
kleing
parents:
diff changeset
     8
code, the byte code verifier and the compiler. In order to make the
704713ca07ea new document
kleing
parents:
diff changeset
     9
Isabelle sources more accessible, this introduction provides a brief
704713ca07ea new document
kleing
parents:
diff changeset
    10
survey of the main concepts of \mJava.
704713ca07ea new document
kleing
parents:
diff changeset
    11
704713ca07ea new document
kleing
parents:
diff changeset
    12
The \mJava{} \textbf{source language} (see \charef{cha:j})
704713ca07ea new document
kleing
parents:
diff changeset
    13
only comprises a part of the original JavaCard language. It models
704713ca07ea new document
kleing
parents:
diff changeset
    14
features such as:
704713ca07ea new document
kleing
parents:
diff changeset
    15
\begin{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    16
\item The basic ``primitive types'' of Java 
704713ca07ea new document
kleing
parents:
diff changeset
    17
\item Object orientation, in particular classes, and relevant
704713ca07ea new document
kleing
parents:
diff changeset
    18
  relations on classes (subclass, widening)
704713ca07ea new document
kleing
parents:
diff changeset
    19
704713ca07ea new document
kleing
parents:
diff changeset
    20
\item Methods and method signatures
704713ca07ea new document
kleing
parents:
diff changeset
    21
\item Inheritance and overriding of methods, dynamic binding
704713ca07ea new document
kleing
parents:
diff changeset
    22
704713ca07ea new document
kleing
parents:
diff changeset
    23
\item Representatives of ``relevant'' expressions and statements 
704713ca07ea new document
kleing
parents:
diff changeset
    24
\item Generation and propagation of system exceptions
704713ca07ea new document
kleing
parents:
diff changeset
    25
\end{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    26
704713ca07ea new document
kleing
parents:
diff changeset
    27
However, the following features are missing in \mJava{} wrt.{} JavaCard:
704713ca07ea new document
kleing
parents:
diff changeset
    28
\begin{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    29
\item Some primitive types (\texttt{byte, short})
704713ca07ea new document
kleing
parents:
diff changeset
    30
\item Interfaces and related concepts, arrays
704713ca07ea new document
kleing
parents:
diff changeset
    31
\item Most numeric operations, syntactic variants of statements
704713ca07ea new document
kleing
parents:
diff changeset
    32
  (\texttt{do}-loop, \texttt{for}-loop)
704713ca07ea new document
kleing
parents:
diff changeset
    33
\item Complex block structure, method bodies with multiple returns
704713ca07ea new document
kleing
parents:
diff changeset
    34
\item Abrupt termination (\texttt{break, continue})
704713ca07ea new document
kleing
parents:
diff changeset
    35
\item Class and method modifiers (such as \texttt{static} and
704713ca07ea new document
kleing
parents:
diff changeset
    36
  \texttt{public/private} access modifiers)
704713ca07ea new document
kleing
parents:
diff changeset
    37
\item User-defined exception classes and an explicit
704713ca07ea new document
kleing
parents:
diff changeset
    38
  \texttt{throw}-statement. Exceptions cannot be caught.
704713ca07ea new document
kleing
parents:
diff changeset
    39
\item A ``definite assignment'' check
704713ca07ea new document
kleing
parents:
diff changeset
    40
\end{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    41
In addition, features are missing that are not part of the JavaCard
704713ca07ea new document
kleing
parents:
diff changeset
    42
language, such as multithreading and garbage collection. No attempt
704713ca07ea new document
kleing
parents:
diff changeset
    43
has been made to model peculiarities of JavaCard such as the applet
704713ca07ea new document
kleing
parents:
diff changeset
    44
firewall or the transaction mechanism.
704713ca07ea new document
kleing
parents:
diff changeset
    45
704713ca07ea new document
kleing
parents:
diff changeset
    46
For a more complete Isabelle model of JavaCard, the reader should
704713ca07ea new document
kleing
parents:
diff changeset
    47
consult the Bali formalization
704713ca07ea new document
kleing
parents:
diff changeset
    48
(\url{http://isabelle.in.tum.de/verificard/Bali/document.pdf}), which
704713ca07ea new document
kleing
parents:
diff changeset
    49
models most of the source language features of JavaCard, however without
704713ca07ea new document
kleing
parents:
diff changeset
    50
describing the bytecode level.
704713ca07ea new document
kleing
parents:
diff changeset
    51
704713ca07ea new document
kleing
parents:
diff changeset
    52
The central topics of the source language formalization are:
704713ca07ea new document
kleing
parents:
diff changeset
    53
\begin{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    54
\item Description of the structure of the ``runtime environment'', in
704713ca07ea new document
kleing
parents:
diff changeset
    55
  particular structure of classes and the program state
704713ca07ea new document
kleing
parents:
diff changeset
    56
\item Definition of syntax, typing rules and operational semantics of
704713ca07ea new document
kleing
parents:
diff changeset
    57
  statements and expressions
704713ca07ea new document
kleing
parents:
diff changeset
    58
\item Definition of ``conformity'' (characterizing type safety) and a
704713ca07ea new document
kleing
parents:
diff changeset
    59
  type safety proof
704713ca07ea new document
kleing
parents:
diff changeset
    60
\end{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    61
704713ca07ea new document
kleing
parents:
diff changeset
    62
704713ca07ea new document
kleing
parents:
diff changeset
    63
The \mJava{} \textbf{virtual machine} (see \charef{cha:jvm})
704713ca07ea new document
kleing
parents:
diff changeset
    64
corresponds rather directly to the source level, in the sense that the
704713ca07ea new document
kleing
parents:
diff changeset
    65
same data types are supported and bytecode instructions required for
704713ca07ea new document
kleing
parents:
diff changeset
    66
emulating the source level operations are provided. Again, only one
704713ca07ea new document
kleing
parents:
diff changeset
    67
representative of different variants of instructions has been
704713ca07ea new document
kleing
parents:
diff changeset
    68
selected; for example, there is only one comparison operator.  The
704713ca07ea new document
kleing
parents:
diff changeset
    69
formalization of the bytecode level is purely descriptive (``no
704713ca07ea new document
kleing
parents:
diff changeset
    70
theorems'') and rather brief as compared to the source level; all
704713ca07ea new document
kleing
parents:
diff changeset
    71
questions related to type systems for and type correctness of bytecode
704713ca07ea new document
kleing
parents:
diff changeset
    72
are dealt with in chapter on bytecode verification.
704713ca07ea new document
kleing
parents:
diff changeset
    73
704713ca07ea new document
kleing
parents:
diff changeset
    74
The problem of \textbf{bytecode verification} (see \charef{cha:bv}) is
704713ca07ea new document
kleing
parents:
diff changeset
    75
dealt with in several stages:
704713ca07ea new document
kleing
parents:
diff changeset
    76
\begin{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    77
\item First, the notion of ``method type'' is introduced, which
704713ca07ea new document
kleing
parents:
diff changeset
    78
  corresponds to the notion of ``type'' on the source level.
704713ca07ea new document
kleing
parents:
diff changeset
    79
\item Well-typedness of instructions wrt. a method type is defined
704713ca07ea new document
kleing
parents:
diff changeset
    80
  (see \secref{sec:BVSpec}). Roughly speaking, determining
704713ca07ea new document
kleing
parents:
diff changeset
    81
  well-typedness is \emph{type checking}.
704713ca07ea new document
kleing
parents:
diff changeset
    82
\item It is shown that bytecode that is well-typed in this sense can
704713ca07ea new document
kleing
parents:
diff changeset
    83
  be safely executed -- a type soundness proof on the bytecode level
704713ca07ea new document
kleing
parents:
diff changeset
    84
  (\secref{sec:BVSpecTypeSafe}). 
704713ca07ea new document
kleing
parents:
diff changeset
    85
\item Given raw bytecode, one of the purposes of bytecode verification
704713ca07ea new document
kleing
parents:
diff changeset
    86
  is to determine a method type that is well-typed according to the
704713ca07ea new document
kleing
parents:
diff changeset
    87
  above definition. Roughly speaking, this is \emph{type inference}.
704713ca07ea new document
kleing
parents:
diff changeset
    88
  The Isabelle formalization presents bytecode verification as an
704713ca07ea new document
kleing
parents:
diff changeset
    89
  instance of an abstract dataflow algorithm (Kildall's algorithm, see
704713ca07ea new document
kleing
parents:
diff changeset
    90
  \secrefs{sec:Kildall} to \ref{sec:JVM}).
704713ca07ea new document
kleing
parents:
diff changeset
    91
%\item For \emph{lightweight bytecode verification}, type checking of
704713ca07ea new document
kleing
parents:
diff changeset
    92
%  bytecode can be reduced to method types with small size. 
704713ca07ea new document
kleing
parents:
diff changeset
    93
\end{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    94
704713ca07ea new document
kleing
parents:
diff changeset
    95
Bytecode verification in \mJava{} so far takes into account:
704713ca07ea new document
kleing
parents:
diff changeset
    96
\begin{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
    97
\item Operations and branching instructions
704713ca07ea new document
kleing
parents:
diff changeset
    98
\item Exceptions
704713ca07ea new document
kleing
parents:
diff changeset
    99
\end{itemize}
704713ca07ea new document
kleing
parents:
diff changeset
   100
Initialization during object creation is not accounted for in the
704713ca07ea new document
kleing
parents:
diff changeset
   101
present document 
704713ca07ea new document
kleing
parents:
diff changeset
   102
(see the formalization in
704713ca07ea new document
kleing
parents:
diff changeset
   103
\url{http://isabelle.in.tum.de/verificard/obj-init/document.pdf}),
704713ca07ea new document
kleing
parents:
diff changeset
   104
neither is the \texttt{jsr} instruction.
704713ca07ea new document
kleing
parents:
diff changeset
   105
704713ca07ea new document
kleing
parents:
diff changeset
   106
704713ca07ea new document
kleing
parents:
diff changeset
   107
%%% Local Variables:
704713ca07ea new document
kleing
parents:
diff changeset
   108
%%% mode: latex
704713ca07ea new document
kleing
parents:
diff changeset
   109
%%% TeX-master: "root"
704713ca07ea new document
kleing
parents:
diff changeset
   110
%%% End: