-
Notifications
You must be signed in to change notification settings - Fork 125
/
JustIce.lyx
14201 lines (11495 loc) · 315 KB
/
JustIce.lyx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# LyX 1.1 created this file. For more info see http://www.lyx.org/
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
\lyxformat 218
\textclass scrbook
\begin_preamble
\end_preamble
\language english
\inputencoding latin1
\fontscheme default
\graphics default
\float_placement !htp
\paperfontsize default
\spacing single
\papersize Default
\paperpackage a4wide
\use_geometry 0
\use_amsmath 0
\paperorientation portrait
\secnumdepth 2
\tocdepth 2
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 2
\paperpagestyle default
\layout Subject
\emph on
Diplomarbeit
\layout Title
JustIce
\newline
\size small
A Free Class File Verifier for Java
\latex latex
\backslash
texttrademark\SpecialChar ~
\layout Author
Enver Haase
\newline
\size tiny
<ehaase@inf.fu-berlin.de>
\layout Date
September 2001
\layout Publishers
Freie Universit�t Berlin
\newline
Institut f�r Informatik
\newline
Takustra�e 9
\newline
D-14195 Berlin
\layout Lowertitleback
\series bold
\size scriptsize
Revision
\series default
\series bold
\shape smallcaps
\layout Minisec
Erkl�rung
\begin_float footnote
\layout Standard
I declare that I wrote this
\emph on
Diplomarbeit
\emph default
completely on my own and without the help of persons not listed.
All sources of information are listed in the Bibliography section.
\end_float
\layout Standard
Hiermit versichere ich, die vorliegende Diplomarbeit selbst�ndig und ohne
fremde Hilfe verfa�t zu haben.
Es wurden nur die in der Bibliographie angegebenen Quellen benutzt.
\layout Minisec
Danksagung
\begin_float footnote
\layout Standard
The creation of this
\emph on
Diplomarbeit
\emph default
paper was supported and supervised by Prof.
Dr.
Elfriede Fehr and Dipl.-Inform.
Markus Dahm.
Keith Seymour suggested a lot of language-related improvements.
Thank you.
\end_float
\layout Standard
W�hrend der Anfertigung dieser Diplomarbeit wurde ich von Prof.
Dr.
Elfriede Fehr und Dipl.-Inform.
Markus Dahm betreut, wof�r ich mich an dieser Stelle herzlich bedanke.
\layout Standard
Desweiteren bedanke ich mich bei Keith Seymour, der mir eine Reihe sprachspezifi
scher Verbesserungsvorschl�ge sandte.
\layout Minisec
Autor
\begin_float footnote
\layout Standard
Author
\end_float
\layout Standard
Enver Haase
\newline
Gubener Stra�e 18
\newline
D-10243 Berlin
\newline
\layout Standard
\begin_inset LatexCommand \tableofcontents{}
\end_inset
\layout Addchap
Abstract
\layout Standard
When Sun Microsystems developed their
\emph on
Java Platform
\emph default
in the early 1990s, it was originally designed for use in networked and
embedded consumer-electronics applications.
But when they introduced it around 1995, it quickly became used in World
Wide Web browser software.
This was a way to bring interactive content to demanding World Wide Web
users.
Sun took great care for the robustness of the platform: they planned to
connect embedded devices and let them share data and code over a network.
Defective devices transmitting bad data or unreliable network connections
should not cause other devices to crash.
This property made Java a good choice for the code-executing engine in
World Wide Web browsers: defective server software or transmission errors
would not cause the
\emph on
Java Platform
\emph default
to crash; this is also true for purposely malicious code hidden on the
Web.
The code-executing part of the
\emph on
Java Platform
\emph default
is called
\emph on
The Java Virtual Machine
\emph default
(the
\emph on
JVM
\emph default
, for short).
This execution engine has to assure that the code to be executed is well-behave
d; it has to
\emph on
verify
\emph default
the code.
Therefore, the
\emph on
verifier
\emph default
is an integral part of every JVM, but JustIce implements a verifier that
is not integrated in a JVM.
It was implemented using a software library called the
\emph on
Byte Code Engineering Library
\emph default
(the
\emph on
BCEL
\emph default
, for short) by Markus Dahm
\begin_inset LatexCommand \cite{BCEL98,BCEL-WWW}
\end_inset
.
\layout Standard
The BCEL is intended to give users a convenient mechanism to analyze, create
and manipulate (binary) Java class files.
It offers an object-oriented view of otherwise raw data, including program
code.
This library is, therefore, well-respected especially in the compiler-writer
community whenever the JVM is chosen as the target machine of the compiler.
Compiler back-ends use the BCEL to produce code for the JVM; and as new
compilers may be faulty, they may produce bad code.
Testing these compilers often is a difficult task.
The generated code should not only be semantically correct, but it also
has to pass the verifiers of all existing JVM implementations.
Normally, a lot of human interaction is required to run test cases.
If the code is rejected by a verifier, one often does not know why.
Most verifiers emit error messages which do not identify the offending
instruction.
\layout Standard
JustIce presents an Application Programming Interface (API) that may be
used to automate the procedure sketched above.
The constraints imposed on class files are designed to be strict, therefore
eleminating the need to run several verifiers on the generated code.
If code passes the JustIce verifier, it should pass all other verifiers.
JustIce was also designed to output human-understandable messages if the
verification of some code fails.
\layout Standard
The application range of JustIce is not limited to compiler back-ends, in
the same sense as the BCEL is not only useful in this area.
Transformations of existing code and even generation of hand-crafted code
fall into its scope, too.
As a side effect, JustIce exports some data structures such as a control
flow graph; so its API may also be used for applications targeting other
problem areas such as static analyses of program code.
\layout Chapter
Introduction
\layout Section
Low Level Security as a Part of a Many-Tiered Strategy
\layout Standard
The Java programming language is well-known for its inherent security facilities
such as the lack of pointer arithmetic or the need for memory allocation
and deallocation.
Lesser known is that this is only the top of an iceberg; the
\emph on
Java Platform
\emph default
implements a many-tiered security strategy
\begin_inset LatexCommand \cite{Yellin-WWW}
\end_inset
.
It was designed to run even untrusted code -- code that possibly was not
produced by a compiler for the Java programming language, code that may
be corrupt or code that may have malicious intent (such as stealing credit
card number information from a hard disk drive).
Three considerations were made:
\layout Itemize
Untrusted code could damage hardware, software, or information on the host
machine.
\layout Itemize
It could pass unauthorized information to anyone.
\layout Itemize
It could cause the host machine to become unusable through resource depletion.
\layout Standard
While some security features such as type-safety or the already-mentioned
lack of pointer arithmetic of the Java programming language are a convenient
help for programmers, they can only help to reduce programming errors.
Of course these features do not help targeting the above problems.
At a lower level, however, the
\emph on
Java Plat\SpecialChar \-
form
\emph default
implements a so-called sandbox: an area where code can be executed but
that has well-defined boundaries shielding the rest of the system.
This is achieved by means of a
\emph on
Java Virtual Machine
\emph default
(JVM) emulation; the host platform does not directly run untrusted code,
but a
\emph on
run-time system
\emph default
which in turn runs the code, restricting its access to system resources.
\layout Standard
A run-time system cannot safely assume that untrusted code is well-behaved.
Code could cause stack overflows, stack underruns, or otherwise erroneous
behavior that may bring the run-time system into an undefined state --
possibly allowing access to protected memory areas.
One could protect the run-time system by letting it predict the effects
of every single instruction just in time while actually executing it --
but that would be too time-consuming to be applicable in practice.
\layout Standard
Therefore, good behavior of program code has to be enforced
\emph on
before
\emph default
it is actually executed -- at least as far as this is possible.
This is the lowest level of Java security; there has to be an integral
component in every JVM implementation doing so (
\begin_inset LatexCommand \cite{vmspec2}
\end_inset
, page 420).
This part of the JVM is called the
\emph on
class file verifier
\emph default
, yet better known as the
\emph on
bytecode verifier.
\emph default
Technically speaking, bytecode verification is only a part of class file
verification so
\emph on
class file verifier
\emph default
is a more embracing term.
JustIce implements a whole class file verifier.
\layout Standard
\begin_float fig
\layout Standard
\align center
\begin_inset Figure size 595 396
file chap1.eps
width 3 100
flags 9
\end_inset
\layout Caption
Concept of Class File Verification
\end_float
\layout Section
Why Another Verifier?
\layout Standard
As said before, every JVM implementation must contain a class file verifier,
so it is reasonable to ask for the motivation behind creating just another
class file verifier -- especially one that is
\emph on
not
\emph default
part of a JVM implementation.
\layout Subsection
Bytecode Engineers Need JustIce
\layout Standard
Shortly after the
\emph on
Java Platform
\emph default
was introduced, it was adopted with pleasure because of its inherent independen
ce from operating systems and concrete hardware.
Industry and educational institutions with heterogenous networked computers
could now run the same software program on different host machines.
Soon, many efforts were put into research and development of compilers
for programming languages other than the Java programming language that
use the JVM bytecode as target.
\layout Standard
Nowadays, many other programming languages do have the JVM as its target
platform; e.g.
Fortran
\begin_inset LatexCommand \cite{f2j}
\end_inset
, Ada
\begin_inset LatexCommand \cite{AppMag-WWW}
\end_inset
, Scheme
\begin_inset LatexCommand \cite{KAWA-WWW}
\end_inset
or modified Java language versions
\begin_inset LatexCommand \cite{GJ-WWW,PMG-WWW}
\end_inset
.
A vast collection of programming languages targeting the JVM can be found
on the World Wide Web
\begin_inset LatexCommand \cite{PL4JVM}
\end_inset
.
\layout Standard
All these compilers emit code for the JVM -- and so all these compilers
have to pass the JVM's verifier.
Implementors of such compilers have to consider the security related constraint
s the JVM poses on the generated code.
It is difficult to test if the emitted code works on all JVM implementations,
passing all JVM verifier implementations.
This is especially problematic if not all of the project's class files
are loaded into the JVM during a test run, because then they will not be
verified.
\layout Standard
Having an opportunity to verify the transitive hull of referenced class
files (starting with some main class file) would be of help; JustIce offers
it.
\layout Standard
The Bytecode Engineering Library by Markus Dahm is often used as a compiler
back-end to emit code, but it is also used to hand-craft code or to implement
bytecode transformations.
Because JustIce works closely together with the BCEL, users of the BCEL
do not even have to leave their development environment to run the JustIce
verifier.
\layout Standard
To our knowledge, JustIce is the only implementation of a Java class file
verifier that was written in the Java programming language
\begin_inset LatexCommand \cite{langspec2}
\end_inset
itself
\begin_float footnote
\layout Standard
In a personal communication, Robert St�rk told the author that there was
a Java implementation of the verifier discussed in
\begin_inset LatexCommand \cite{JBook}
\end_inset
, written by Joachim Schmid using the BCEL.
However, it is not released for public use yet.
\end_float
.
Because of its
\emph on
Verification API
\emph default
, it can be included in other software projects written in Java with more
ease than any other verifier implementation in a different programming
language could provide.
\layout Subsection
JustIce is Verbose
\layout Standard
Usually, when classes pass the verifier, it is mute.
JustIce, in contrast, distinguishes between verification results and messages.
Messages are often warnings, but the reason for emitting such a warning
instead of a negative verification result is because the class file does
not pose a threat to the integrity of the JVM and thus does not have to
be rejected.
\layout Standard
When a verification error occurs and the class file is rejected, even the
built-in verifiers usually produce some output saying so.
As an example, consider the following verifier run:
\newline
\newline
\family typewriter
ehaase@haneman:/home/ehaase > java Cc
\newline
Exception in thread "main" java.lang.VerifyError:
\newline
(class: Cc, method: ttt signature: ()V)
\newline
Recursive call to jsr entry
\family default
\newline
\latex latex
\newline
\layout Standard
One might ask
\emph on
which
\emph default
\begin_inset Quotes eld
\end_inset
jsr entry
\begin_inset Quotes erd
\end_inset
(a branch target of a
\latex latex
\backslash
texttt{jsr}
\latex default
or a
\latex latex
\backslash
texttt{jsr
\backslash
_w}
\latex default
instruction) is called recursively and which instructions may be responsible
for this.
Compare this to JustIce's output:
\newline
\newline
[...]
\layout Standard
\family typewriter
Pass 3b, method number 0 ['public static void ttt()']:
\layout Standard
\family typewriter
VERIFIED_REJECTED
\layout Standard
\family typewriter
Constraint violated in method 'public static void ttt()':
\layout Standard
\family typewriter
Subroutine with local variable '1', JSRs '[ 36: jsr[168](3) -> astore_1,
8: jsr[168](3) -> astore_1, 30: jsr[168](3) -> astore_1, 23: jsr[168](3)
-> astore_1]', RET ' 62: ret[169](2) 1' is called by a subroutine which
uses the same local variable index as itself; maybe even a recursive call?
JustIce's clean definition of a subroutine forbids both.
\newline
\family default
[...]
\layout Standard
\family typewriter
Warnings:
\layout Standard
\family typewriter
Pass 2: Attribute 'LineNumber(0, 4), LineNumber(0, 5), LineNumber(15, 8),
LineNumber(39, 11), LineNumber(47, 12), LineNumber(57, 13), LineNumber(64,
15)' as an attribute of Code attribute '<CODE>' (method 'public static
void ttt()') will effectively be ignored and is only useful for debuggers
and such.
\layout Standard
\family typewriter
Pass 2: Attribute 'LineNumber(0, 1), LineNumber(4, 1)' as an attribute of
Code attribute '<CODE>' (method 'public void <init>()') will effectively
be ignored and is only useful for debuggers and such.
\layout Standard
\family typewriter
Pass 3a: LineNumberTable attribute 'LineNumber(0, 4), LineNumber(0, 5),
LineNumber(15, 8), LineNumber(39, 11), LineNumber(47, 12), LineNumber(57,
13), LineNumber(64, 15)' refers to the same code offset ('0') more than
once which is violating the semantics [but is sometimes produced by IBM's
'jikes' compiler].
\newline
\layout Standard
This output obviously has an answer to the above question; it shows the
only
\latex latex
\backslash
texttt{jsr}
\latex default
or
\latex latex
\backslash
texttt{jsr
\backslash
_w}
\latex default
instructions possibly responsible for a recursive call (which is not allowed
by the specification of the JVM).
For the special --but clean-- definition of subroutines JustIce uses, please
see section
\begin_inset LatexCommand \ref{Subroutines_Def}
\end_inset
.
\layout Standard
Note also the warning messages.
Class files that were not generated by Sun's
\emph on
javac
\emph default
compiler have a tendency to look a little different in some corner cases.
IBM's
\emph on
jikes
\emph default
compiler, for instance, produces LineNumberTable attributes (see
\begin_inset LatexCommand \ref{LineNumberTableAttribute}
\end_inset
) which look different from those created by
\emph on
javac
\emph default
.
Detecting such differences is desirable because future JVMs will have stricter
verification checks
\begin_float footnote
\layout Standard
The Solaris port of Sun's JVM, version 1.3.0_01, already has (some of) the
stricter checks built in.
You may enable them using the command-line option '-Xfuture'.
Nothing about this issue is mentioned in the specification
\begin_inset LatexCommand \cite{vmspec2}
\end_inset
.
\end_float
(which most old
\emph on
javac
\emph default
-compiled class files will probably still pass).
JustIce guides bytecode engineers to create class files that are indistinguisha
ble from those created by
\emph on
javac
\emph default
to retain compatibility with Sun's future JVM implementations.
Figure
\begin_inset LatexCommand \ref{FigVenn}
\end_inset
graphically shows the relationship between class files and the verifier
\begin_float footnote
\layout Standard
This is a simplicistic figure; unfortunately, there are class files produced
by the
\emph on
javac
\emph default
compiler that do not pass the verifier.
Please see section
\begin_inset LatexCommand \ref{javacRejected}
\end_inset
for more details.
\end_float
.
\begin_float fig
\layout Standard
\align center
\begin_inset Figure size 595 378
file VennDiag.eps
width 3 100
height 3 45
flags 9
\end_inset
\layout Caption
\begin_inset LatexCommand \label{FigVenn}
\end_inset
Venn diagram showing the operating domain of the Java verifier.
\end_float
\layout Subsection
JustIce is Free
\layout Standard
Currently, there is no other free and complete open source verifier available
known to the author.
You may have a look at the JVM's source code by Sun Microsystems but you
are not allowed to use the knowledge from that inspection for your own
projects or even use their code.
JustIce is a clean-room implementation: the author wrote JustIce by only
reading the Java
\latex latex
\backslash
texttrademark
\latex default
\SpecialChar ~
Virtual Machine Specification, Second Edition
\begin_inset LatexCommand \cite{vmspec2}
\end_inset
and comparing the behavior of JustIce with the behavior of commercial
implementations of Sun Microsystems and IBM Corporation.
\layout Standard
The open source JVM implementation
\emph on
Kaffe
\emph default
\begin_inset LatexCommand \cite{Kaffe-WWW}
\end_inset
, for example
\emph on
,
\emph default
does not have a
\emph on
complete
\emph default
verifier built in (although mandated by the JVM specification).
\layout Standard
\emph on
Kissme
\emph default
\begin_inset LatexCommand \cite{kissme-WWW}
\end_inset
, another open source JVM implementation, currently does not include any
verifier at all.
\layout Standard
The JVM implementations
\emph on
SableVM
\emph default
\begin_inset LatexCommand \cite{SableVM-WWW}
\end_inset
and Intel Corporation's
\emph on
Open Runtime Platform
\emph default
\begin_inset LatexCommand \cite{ORP-WWW}
\end_inset
are platforms to experiment with performance-enhancements.
They are not intended to work as general-purpose JVMs so they do not need
to implement verifiers.
\layout Standard
Other open source projects that could make use of a free verifier include
the Java compiler
\emph on
gcj
\emph default
which is part of the GNU compiler collection
\begin_inset LatexCommand \cite{GCC-WWW}
\end_inset
.
\layout Standard
JustIce is covered by the well-known and respected software license
\emph on
GNU General Public License
\emph default
(GPL); see section
\begin_inset LatexCommand \ref{GPL}
\end_inset
.
The author hopes other free software will benefit from it; from the JustIce
software
\begin_inset LatexCommand \cite{JustIce}
\end_inset
as well as from this paper describing some of the inner workings of JustIce.
\layout Chapter
The Java Virtual Machine
\layout Standard
The Java Virtual Machine (JVM) is an abstract machine specified in
\begin_inset LatexCommand \cite{vmspec2}
\end_inset
.
It has no knowledge about the Java programming language; but only of a
certain binary file format: the class file format.
A class file contains machine instructions for the JVM (called
\emph on
bytecodes
\emph default
), a symbol table (called
\emph on
constant pool
\emph default
) and some other ancillary information.
\layout Standard
On method invocation, a local stack frame is set up called the
\emph on
execution frame
\emph default
.
It consists of an
\emph on
operand stack
\emph default
and
\emph on
local variables
\emph default
(which may be compared to registers of traditional machines).
\layout Standard
The instructions in the code arrays of class files are interpreted by the
JVM.
There are 212 legal instructions; they have read-access to the class file's
constant pool and they can modify the operand stack and the local variables
in their execution frame.
An invoked method reads its arguments from the local variables.
Certain instructions pass a return value to the invoking method.
\layout Section
\begin_inset LatexCommand \label{Classfile Structure}
\end_inset
The ClassFile Structure
\layout Standard
Traditionally, the JVM loads its programs from files stored on file systems
of host machines; these files have names that end with
\emph on
\begin_inset Quotes eld
\end_inset
.class
\begin_inset Quotes erd
\end_inset
\emph default
.
It is possible to store the files in various other ways; a so-called
\emph on
class loader
\emph default
is then used to transform the files internally to the desired, basic class
file format.
Therefore, it suffices to explain the structure of traditional class files.
Every class file consists of a single
\family typewriter
ClassFile
\family default
structure as defined below.
It defines a single class as known from the Java Programming Language
\begin_inset LatexCommand \cite{langspec2}
\end_inset
.
The terms
\emph on
class
\emph default
and
\emph on
class file
\emph default
may therefore be used interchangeably.
\begin_float fig
\layout Standard
\align center
\begin_inset Figure size 595 526
file classfile.eps
width 3 100
flags 9
\end_inset
\layout Standard
A class file consists of constants, fields, methods, attributes and some
ancillary information.
This figure was taken from
\begin_inset LatexCommand \cite{BCEL98}
\end_inset
, used with permission of the author.
\layout Caption
A Class File
\end_float
\layout Standard
As we will see, the
\family typewriter
ClassFile
\family default
structure and its sub-structures are defined for upwards compatibility,
i.e., new structure definitions can be added to the specification easily
at a later time.
\newline
\newline
\family typewriter
ClassFile {
\newline
\SpecialChar \-
\SpecialChar ~
\SpecialChar ~
u4 magic;
\newline
\SpecialChar \-