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