SJC – Small Java Compiler

Total Page:16

File Type:pdf, Size:1020Kb

Load more

SJC – Small Java Compiler

User Manual Stefan Frenz

Translation: Jonathan Brase

original version: 2011/06/08 latest document update: 2011/08/24
Compiler Version: 182

Java is a registered trademark of Oracle/Sun

Table of Contents

  • 1
  • Quick introduction.............................................................................................................................4

1.1 Windows...........................................................................................................................................4 1.2 Linux.................................................................................................................................................5 1.3 JVM Environment.............................................................................................................................5 1.4 QEmu................................................................................................................................................5

2

3
Hello World.......................................................................................................................................6
2.1 Source Code......................................................................................................................................6 2.2 Compilation and Emulation...............................................................................................................8 2.3 Details...............................................................................................................................................9

Introduction.....................................................................................................................................11
3.1 Origins, Legal Matters, Resources, and Acknowledgements...........................................................11 3.2 Basic Principles and Objectives.......................................................................................................11 3.3 Memory Image Format....................................................................................................................12 3.4 Object Format..................................................................................................................................12 3.5 Stack Frame Format........................................................................................................................13 3.6 Compiler Structure..........................................................................................................................13 3.7 Implemented Modules.....................................................................................................................15 3.8 Differences from Sun Java..............................................................................................................16

4

56
Frontend Modules for non-Java Files..............................................................................................17
4.1 Importing Binary Files....................................................................................................................17 4.2 Source File Lists..............................................................................................................................17

Compiler Functions.........................................................................................................................18
5.1 Compile Options..............................................................................................................................18 5.2 Symbol Information.........................................................................................................................22

Runtime Environment.....................................................................................................................25
6.1 Root Object.....................................................................................................................................25 6.2 Strings.............................................................................................................................................25 6.3 Typesystem and Code Related Classes............................................................................................25 6.4 Definition of the Runtime Environment for Allocation and Type Checking...................................26 6.5 Example Implementation of Required 32 Bit Runtime Routines.....................................................27 6.6 Runtime Extensions for the Use of Java Exceptions........................................................................30 6.7 Runtime Extensions for the Use of Synchronized Blocks................................................................31 6.8 Runtime Extensions for Stack Limit Checking................................................................................32 6.9 Runtime Extensions for the Use of Assert Statements.....................................................................32 6.10 Definition of the Optional Arithmetic Library.................................................................................32

  • 7
  • Special Classes................................................................................................................................34

7.1 MAGIC...........................................................................................................................................34 7.2 SJC Annotations..............................................................................................................................38 7.3 STRUCT.........................................................................................................................................40 7.4 FLASH............................................................................................................................................40
89
Inline Arrays....................................................................................................................................41
8.1 Changes to the Object Structure......................................................................................................41

Indirect Scalars................................................................................................................................43
9.1 Changes to the Object Structure......................................................................................................43 9.2 Changes to the Runtime Environment.............................................................................................44

10

11 12
In-Image Symbol Information.........................................................................................................46
10.1 raw Symbol Information..................................................................................................................46 10.2 rte Symbol Information...................................................................................................................47 10.3 Mthd Symbol Information...............................................................................................................48

Native Linux and Windows Programs.............................................................................................49
11.1 Basic Functionality..........................................................................................................................49 11.2 Native Linux Programs....................................................................................................................49 11.3 Native Microsoft Windows Programs.............................................................................................52

Examples.........................................................................................................................................54
12.1 Use of Inlining.................................................................................................................................54 12.2 Access to I/O Ports..........................................................................................................................54 12.3 Writing Interrupt Handlers..............................................................................................................54 12.4 Use of STRUCTs.............................................................................................................................55 12.5 Initialization in Embedded Mode....................................................................................................56 12.6 Handcoded Method Calls................................................................................................................56 12.7 TextualCall......................................................................................................................................57

13 14
Bootloader.......................................................................................................................................59 References.......................................................................................................................................64

1 Quick introduction

For a quick introduction, download the executable package (see [sjc] in the References section), which contains all the necessary files for the development of 32 and 64-bit operating systems:

  • File
  • Description

b64_dsk.bin Floppy bootloader for 64-bit target systems bootconf.txt Configuration file for the boot image writer bts_dsk.bin Floppy bootloader for 32-bit target systems

  • compile
  • Compiler executable for Linux

compile.exe Compiler executable for Windows hello.java Example "Hello World" program

  • rte.java
  • Basic runtime environment framework

No programs outside this package are necessary for the compilation of an operating system. However, testing the compiled system requires a PC emulator such as QEmu (see [qemu]). This introduction assumes that a QEmu installation is available.

The next four sections of this chapter demonstrate the invocation of the compiler under Windows, Linux, and a JVM, as well as booting the resulting system in QEmu. These instructions will compile the included "Hello World" program (discussed in chapter 2) for a 32-bit target system.

In developing a new system with the compiler, it is reccomended that the user read at least chapters 2, 3.4, 3.8, 5.1, 6.5 and 7. Examples can be found in chapter 12. Furthermore, an example system supporting 32-bit protected mode and 64-bit long mode can be found in the reference section under [picos].

1.1 Windows

If the executable package has been unpacked into C:\Compiler, the installation can be tested with this command line:

C:\Compiler>compile hello.java rte.java -o boot

This should produce approximately the following output (shown here with a few extra status messages):

The above command line will also produce the files BOOT_FLP.IMG and syminfo.txt. The first contains a floppy image of the example program, the second contains symbol information, described in detail in chapter 5.2.

1.2 Linux

If the executable package has been unpacked into ~/compiler, it may be necessary to set the executable flag:

smf@linplu:~/compiler> chmod a+x compile

The installation can then be tested with the following command line:

smf@linplu:~/compiler> ./compile hello.java rte.java -o boot

This should produce approximately the following output: As under Windows (see the previous section), the files BOOT_FLP.IMG (a floppy image) and syminfo.txt (containing symbol information) will be produced.

1.3 JVM Environment

In addition to the Windows and Linux versions, there is also, since version 181, a precompiled JAR version of the compiler. Instead of the native compilers, the JVM is executed with sjc.jar as a parameter. All other parameters, as well as the output, correspond to the Linux and Windows versions:

C:\Compiler>compile hello.java rte.java -o boot

1.4 QEmu

The following command lines can be used to boot the compiled floppy image in QEmu:

"C:\Compiler>\Program Files\QEmu\qemu.exe" -m 32 -boot a -fda BOOT_FLP.IMG smf@linplu:~/compiler> qemu -m 32 -boot a -fda BOOT_FLP.IMG

These should (depending on the versions of QEmu and its BIOS) result in the following output: If the system starts, but hangs without any error message, the cause could be a faulty KVM module. This can be deactivated with -no-kvm, the resulting command line would then be:

> qemu -no-kvm -m 32 -boot a -fda BOOT_FLP.IMG

2 Hello World

This chapter will introduce the source code for a simple "Hello World" program, and the command lines to compile it (all necessary files are in the executable package, see [sjc]), and to boot it in QEmu. Afterwards, the individual steps in this process and the default options assumed by the compiler will be explained.

2.1 Source Code

Program (hello.java)

package kernel; public class Kernel {   private static int vidMem=0xB8000;   public static void main() {     print("Hello World");     while(true);   }   public static void print(String str) {     int i;     for (i=0; i<str.length(); i++) print(str.charAt(i));   }   public static void print(char c) {     MAGIC.wMem8(vidMem++, (byte)c);     MAGIC.wMem8(vidMem++, (byte)0x07);   } }

Runtime Environment (rte.java)

package java.lang; import rte.SClassDesc; public class Object {   public final SClassDesc _r_type;   public final Object _r_next;   public final int _r_relocEntries, _r_scalarSize; }package java.lang; public class String {   private char[] value;   private int count;   @SJC.Inline   public int length() {     return count;   }   @SJC.Inline   public char charAt(int i) {     return value[i];   } }package rte; public class SArray {   public final int length=0, _r_dim=0, _r_stdType=0;   public final Object _r_unitType=null; }package rte; public class SClassDesc {   public SClassDesc parent;   public SIntfMap implementations; }package rte; public class SIntfDesc { /*optional: public SIntfDesc[] parents;*/ } package rte; public class SIntfMap {   public SIntfDesc owner;   public SIntfMap next; }package rte; public class SMthdBlock { } package rte; public class DynamicRuntime {   public static Object newInstance(int scalarSize, int relocEntries,       SClassDesc type) { while(true); }   public static SArray newArray(int length, int arrDim, int entrySize,       int stdType, Object unitType) { while(true); }   public static void newMultArray(SArray[] parent, int curLevel,       int destLevel, int length, int arrDim, int entrySize, int stdType,       Object unitType) { while(true); }   public static boolean isInstance(Object o, SClassDesc dest,       boolean asCast) { while(true); }   public static SIntfMap isImplementation(Object o, SIntfDesc dest,       boolean asCast) { while(true); }   public static boolean isInstance(Object o, SClassDesc dest,       Object unitType, int arrDim, boolean asCast) { while(true); }   public static void checkArrayStore(SArray dest, Object newEntry) {       while (true); } }

Bootloader configuration (bootconf.txt)

section floppy32 section default destfile boot_flp.img blocksize 512 maximagesize 1474048 readbuf bts_dsk.bin offset 30.l4 value imageaddr offset 34.l4 value unitaddr offset 38.l4 value codeaddr offset 42.l4 crc 0x82608EDB offset 46.l2 value blockcnt writebuf appendimage endsection

2.2 Compilation and Emulation

If the files designated in the last subchapter have been placed in the same directory, along with a compiler executable appropriate to the platform and the file bts_dsk.bin (required to setup the bootsector), the "Hello World" program can be compiled with:

compile hello.java rte.java -o boot

bts_dsk.bin is contained in the executable package (see [sjc]) or can be assembled with yasm (see [yasm]) from the source code found in chapter 13. The output of the compiler should look something like this (for a screenshot see chapter 1):

Welcome to the smfCompiler SJC (v178) Compiling static fullsized objects for 32-bit, assign pointers directly Parse file "rte.java"...    progress: . Parse file "hello.java"... Created 20 objects for 11 units, 12 methods and 1 strings. Included 244 b code and 11 string-chars (80 b) in an 724 b image.

A successful compilation will create the file BOOT_FLP.IMG, which can either be written to a floppy (on Windows this can be accomplished with programs such as rawrite (see [rawrite]), on Linux it can be done with dd), or can be used directly with an emulator such as QEmu. If QEmu (see [qemu]) has been properly installed to C:\Program Files\QEmu, the floppy image can be booted with:

"C:\Program Files\Qemu\qemu.exe" -m 32 -boot a -fda BOOT_FLP.IMG

A screenshot can be found in chapter 1. Under some circumstances, QEmu's KVM module may be defective. The module can be deactivated with the option -no-kvm.

2.3 Details

Program

The static variable vidMem is created by the compiler as a class variable. Its value in the disk image is initialized to 0xB8000, the address of the beginning of video memory for VGA compatible graphics cards.

The method main() is called by the code in the bootsector and is the entry point to the Java code. It calls a method to print a string, and then puts the processor into an infinite loop.

String output is implemented in the method print(String str), which, for each character in the given string, calls a character output method.

The method print(char c) copies the lower 8 bits of the given character, with the help of

MAGIC.wMem8(.), to the address given by the current value of vidMem. The graphics card then, in text mode, interprets the copied value as an ASCII character. The post-increment of vidMem causes it to point to the next byte, which determines the color of the character that has just been written. A second use of MAGIC.wMem8(.) sets the color byte to 0x07, which signifies "gray on black", and vidMem is then post-incremented to point to the next character in video memory.

Runtime Environment

The root of the type hierarchy is the class java.lang.Object, which requires the instance variables

_r_type, _r_next, _r_relocEntries and _r_scalarSize (in this order). However, the given "Hello World" program does not use _r_next, _r_relocEntries und _r_scalarSize so these can

be omitted by means of the compiler option -l. The implementation of String for this example conforms to the Java standard, so the array and length variables cannot be directly accessed. The array type used, char[] also conforms to the Java standard, but in this example no use of Unicode characters is made and thus a byte[] implementation (compiler option -y) would be sufficient.

The @SJC.Inline annotation is used to mark the methods length() and charAt(int) so that the

compiler tries to insert the body of the method in question directly into the calling method, instead of making a subroutine call (See section 7.2).

Recommended publications
  • Java (Programming Langua a (Programming Language)

    Java (Programming Langua a (Programming Language)

    Java (programming language) From Wikipedia, the free encyclopedialopedia "Java language" redirects here. For the natural language from the Indonesian island of Java, see Javanese language. Not to be confused with JavaScript. Java multi-paradigm: object-oriented, structured, imperative, Paradigm(s) functional, generic, reflective, concurrent James Gosling and Designed by Sun Microsystems Developer Oracle Corporation Appeared in 1995[1] Java Standard Edition 8 Update Stable release 5 (1.8.0_5) / April 15, 2014; 2 months ago Static, strong, safe, nominative, Typing discipline manifest Major OpenJDK, many others implementations Dialects Generic Java, Pizza Ada 83, C++, C#,[2] Eiffel,[3] Generic Java, Mesa,[4] Modula- Influenced by 3,[5] Oberon,[6] Objective-C,[7] UCSD Pascal,[8][9] Smalltalk Ada 2005, BeanShell, C#, Clojure, D, ECMAScript, Influenced Groovy, J#, JavaScript, Kotlin, PHP, Python, Scala, Seed7, Vala Implementation C and C++ language OS Cross-platform (multi-platform) GNU General Public License, License Java CommuniCommunity Process Filename .java , .class, .jar extension(s) Website For Java Developers Java Programming at Wikibooks Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few impimplementation dependencies as possible.ble. It is intended to let application developers "write once, run ananywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to rurun on another. Java applications ns are typically compiled to bytecode (class file) that can run on anany Java virtual machine (JVM)) regardless of computer architecture. Java is, as of 2014, one of tthe most popular programming ng languages in use, particularly for client-server web applications, witwith a reported 9 million developers.[10][11] Java was originallyy developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems'Micros Java platform.
  • The Java® Language Specification Java SE 8 Edition

    The Java® Language Specification Java SE 8 Edition

    The Java® Language Specification Java SE 8 Edition James Gosling Bill Joy Guy Steele Gilad Bracha Alex Buckley 2015-02-13 Specification: JSR-337 Java® SE 8 Release Contents ("Specification") Version: 8 Status: Maintenance Release Release: March 2015 Copyright © 1997, 2015, Oracle America, Inc. and/or its affiliates. 500 Oracle Parkway, Redwood City, California 94065, U.S.A. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. The Specification provided herein is provided to you only under the Limited License Grant included herein as Appendix A. Please see Appendix A, Limited License Grant. To Maurizio, with deepest thanks. Table of Contents Preface to the Java SE 8 Edition xix 1 Introduction 1 1.1 Organization of the Specification 2 1.2 Example Programs 6 1.3 Notation 6 1.4 Relationship to Predefined Classes and Interfaces 7 1.5 Feedback 7 1.6 References 7 2 Grammars 9 2.1 Context-Free Grammars 9 2.2 The Lexical Grammar 9 2.3 The Syntactic Grammar 10 2.4 Grammar Notation 10 3 Lexical Structure 15 3.1 Unicode 15 3.2 Lexical Translations 16 3.3 Unicode Escapes 17 3.4 Line Terminators 19 3.5 Input Elements and Tokens 19 3.6 White Space 20 3.7 Comments 21 3.8 Identifiers 22 3.9 Keywords 24 3.10 Literals 24 3.10.1 Integer Literals 25 3.10.2 Floating-Point Literals 31 3.10.3 Boolean Literals 34 3.10.4 Character Literals 34 3.10.5 String Literals 35 3.10.6 Escape Sequences for Character and String Literals 37 3.10.7 The Null Literal 38 3.11 Separators
  • Building Useful Program Analysis Tools Using an Extensible Java Compiler

    Building Useful Program Analysis Tools Using an Extensible Java Compiler

    Building Useful Program Analysis Tools Using an Extensible Java Compiler Edward Aftandilian, Raluca Sauciuc Siddharth Priya, Sundaresan Krishnan Google, Inc. Google, Inc. Mountain View, CA, USA Hyderabad, India feaftan, [email protected] fsiddharth, [email protected] Abstract—Large software companies need customized tools a specific task, but they fail for several reasons. First, ad- to manage their source code. These tools are often built in hoc program analysis tools are often brittle and break on an ad-hoc fashion, using brittle technologies such as regular uncommon-but-valid code patterns. Second, simple ad-hoc expressions and home-grown parsers. Changes in the language cause the tools to break. More importantly, these ad-hoc tools tools don’t provide sufficient information to perform many often do not support uncommon-but-valid code code patterns. non-trivial analyses, including refactorings. Type and symbol We report our experiences building source-code analysis information is especially useful, but amounts to writing a tools at Google on top of a third-party, open-source, extensible type-checker. Finally, more sophisticated program analysis compiler. We describe three tools in use on our Java codebase. tools are expensive to create and maintain, especially as the The first, Strict Java Dependencies, enforces our dependency target language evolves. policy in order to reduce JAR file sizes and testing load. The second, error-prone, adds new error checks to the compilation In this paper, we present our experience building special- process and automates repair of those errors at a whole- purpose tools on top of the the piece of software in our codebase scale.
  • SUBJECT-COMPUTER CLASS-12 CHAPTER 9 – Compiling and Running Java Programs

    SUBJECT-COMPUTER CLASS-12 CHAPTER 9 – Compiling and Running Java Programs

    SUBJECT-COMPUTER CLASS-12 CHAPTER 9 – Compiling and Running Java Programs Introduction to Java programming JAVA was developed by Sun Microsystems Inc in 1991, later acquired by Oracle Corporation. It was developed by James Gosling and Patrick Naughton. It is a simple programming language. Writing, compiling and debugging a program is easy in java. It helps to create modular programs and reusable code. Bytecode javac compiler of JDK compiles the java source code into bytecode so that it can be executed by JVM. The bytecode is saved in a .class file by compiler. Java Virtual Machine (JVM) This is generally referred as JVM. Before, we discuss about JVM lets see the phases of program execution. Phases are as follows: we write the program, then we compile the program and at last we run the program. 1) Writing of the program is of course done by java programmer. 2) Compilation of program is done by javac compiler, javac is the primary java compiler included in java development kit (JDK). It takes java program as input and generates java bytecode as output. 3) In third phase, JVM executes the bytecode generated by compiler. This is called program run phase. So, now that we understood that the primary function of JVM is to execute the bytecode produced by compiler. Characteristics of Java Simple Java is very easy to learn, and its syntax is simple, clean and easy to understand. Multi-threaded Multithreading capabilities come built right into the Java language. This means it is possible to build highly interactive and responsive apps with a number of concurrent threads of activity.
  • Coqjvm: an Executable Specification of the Java Virtual Machine Using

    Coqjvm: an Executable Specification of the Java Virtual Machine Using

    CoqJVM: An Executable Specification of the Java Virtual Machine using Dependent Types Robert Atkey LFCS, School of Informatics, University of Edinburgh Mayfield Rd, Edinburgh EH9 3JZ, UK [email protected] Abstract. We describe an executable specification of the Java Virtual Machine (JVM) within the Coq proof assistant. The principal features of the development are that it is executable, meaning that it can be tested against a real JVM to gain confidence in the correctness of the specification; and that it has been written with heavy use of dependent types, this is both to structure the model in a useful way, and to constrain the model to prevent spurious partiality. We describe the structure of the formalisation and the way in which we have used dependent types. 1 Introduction Large scale formalisations of programming languages and systems in mechanised theorem provers have recently become popular [4–6, 9]. In this paper, we describe a formalisation of the Java virtual machine (JVM) [8] in the Coq proof assistant [11]. The principal features of this formalisation are that it is executable, meaning that a purely functional JVM can be extracted from the Coq development and – with some O’Caml glue code – executed on real Java bytecode output from the Java compiler; and that it is structured using dependent types. The motivation for this development is to act as a basis for certified consumer- side Proof-Carrying Code (PCC) [12]. We aim to prove the soundness of program logics and correctness of proof checkers against the model, and extract the proof checkers to produce certified stand-alone tools.
  • Chapter 9: Java

    Chapter 9: Java

    ,ch09.6595 Page 159 Friday, March 25, 2005 2:47 PM Chapter 9 CHAPTER 9 Java Many Java developers like Integrated Development Environments (IDEs) such as Eclipse. Given such well-known alternatives as Java IDEs and Ant, readers could well ask why they should even think of using make on Java projects. This chapter explores the value of make in these situations; in particular, it presents a generalized makefile that can be dropped into just about any Java project with minimal modification and carry out all the standard rebuilding tasks. Using make with Java raises several issues and introduces some opportunities. This is primarily due to three factors: the Java compiler, javac, is extremely fast; the stan- dard Java compiler supports the @filename syntax for reading “command-line param- eters” from a file; and if a Java package is specified, the Java language specifies a path to the .class file. Standard Java compilers are very fast. This is primarily due to the way the import directive works. Similar to a #include in C, this directive is used to allow access to externally defined symbols. However, rather than rereading source code, which then needs to be reparsed and analyzed, Java reads the class files directly. Because the symbols in a class file cannot change during the compilation process, the class files are cached by the compiler. In even medium-sized projects, this means the Java com- piler can avoid rereading, parsing, and analyzing literally millions of lines of code compared with C. A more modest performance improvement is due to the bare mini- mum of optimization performed by most Java compilers.
  • Lecture 1: Introduction to Java®

    Lecture 1: Introduction to Java®

    Lecture 1: Introduction to Java MIT-AITI Kenya 2005 1 Lecture Outline • What a computer program is • How to write a computer program • The disadvantages and advantages of using Java • How a program that you write in Java is changed into a form that your computer can understand • Sample Java code and comments MIT-Africa Internet Technology Initiative ©2005 2 Computer Program vs. Food Recipe Food Recipe Computer Program A chef writes a set of A programmer writes a set of instructions called a recipe instructions called a program The recipe requires specific The program requires specific ingredients inputs The cook follows the The computer follows the instructions step-by-step instructions step-by-step The food will vary depending on The output will vary depending the amount of ingredients and on the values of the inputs and the cook the computer MIT-Africa Internet Technology Initiative ©2005 3 Recipe and Program Examples Student’s Student’s Ingredient # 1 Ingredient # 2 Name Grade Recipe Program Dinner “Bilha got an A on the exam!” MIT-Africa Internet Technology Initiative ©2005 4 What is a computer program? • For a computer to be able to perform specific tasks (i.e. print what grade a student got on an exam), it must be given instructions to do the task • The set of instructions that tells the computer to perform specific tasks is known as a computer program MIT-Africa Internet Technology Initiative ©2005 5 Writing Computer Programs • We write computer programs (i.e. a set of instructions) in programming languages such as C, Pascal, and
  • Metaprogramming: Interpretaaon Interpreters

    Metaprogramming: Interpretaaon Interpreters

    How to implement a programming language Metaprogramming InterpretaAon An interpreter wriDen in the implementaAon language reads a program wriDen in the source language and evaluates it. These slides borrow heavily from Ben Wood’s Fall ‘15 slides. TranslaAon (a.k.a. compilaAon) An translator (a.k.a. compiler) wriDen in the implementaAon language reads a program wriDen in the source language and CS251 Programming Languages translates it to an equivalent program in the target language. Spring 2018, Lyn Turbak But now we need implementaAons of: Department of Computer Science Wellesley College implementaAon language target language Metaprogramming 2 Metaprogramming: InterpretaAon Interpreters Source Program Interpreter = Program in Interpreter Machine M virtual machine language L for language L Output on machine M Data Metaprogramming 3 Metaprogramming 4 Metaprogramming: TranslaAon Compiler C Source x86 Target Program C Compiler Program if (x == 0) { cmp (1000), $0 Program in Program in x = x + 1; bne L language A } add (1000), $1 A to B translator language B ... L: ... x86 Target Program x86 computer Output Interpreter Machine M Thanks to Ben Wood for these for language B Data and following pictures on machine M Metaprogramming 5 Metaprogramming 6 Interpreters vs Compilers Java Compiler Interpreters No work ahead of Lme Source Target Incremental Program Java Compiler Program maybe inefficient if (x == 0) { load 0 Compilers x = x + 1; ifne L } load 0 All work ahead of Lme ... inc See whole program (or more of program) store 0 Time and resources for analysis and opLmizaLon L: ... (compare compiled C to compiled Java) Metaprogramming 7 Metaprogramming 8 Compilers... whose output is interpreted Interpreters..
  • 1 Compiling Java Programs

    1 Compiling Java Programs

    CS 61B P. N. Hilfinger Basic Compilation: javac, gcc, g++ 1 Compiling Java Programs [The discussion in this section applies to Java 1.2 tools from Sun Microsystems. Tools from other manufac- turers and earlier tools from Sun differ in various details.] Programming languages do not exist in a vacuum; any actual programming done in any language one does within a programming environment that comprises the various programs, libraries, editors, debuggers, and other tools needed to actually convert program text into action. The Scheme environment that you used in CS61A was particularly simple. It provided a component called the reader, which read in Scheme-program text from files or command lines and converted it into internal Scheme data structures. Then a component called the interpreter operated on these translated pro- grams or statements, performing the actions they denoted. You probably weren’t much aware of the reader; it doesn’t amount to much because of Scheme’s very simple syntax. Java’s more complex syntax and its static type structure (as discussed in lecture) require that you be a bit more aware of the reader—or compiler, as it is called in the context of Java and most other “production” programming languages. The Java compiler supplied by Sun Microsystems is a program called javac on our systems. You first prepare programs in files (called source files) using any appropriate text editor (Emacs, for example), giving them names that end in ‘.java’. Next you compile them with the java compiler to create new, translated files, called class files, one for each class, with names ending in ‘.class’.
  • Java Virtual Machine Guide

    Java Virtual Machine Guide

    Java Platform, Standard Edition Java Virtual Machine Guide Release 14 F23572-02 May 2021 Java Platform, Standard Edition Java Virtual Machine Guide, Release 14 F23572-02 Copyright © 1993, 2021, Oracle and/or its affiliates. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are "commercial computer software" or "commercial computer software documentation" pursuant to the applicable Federal Acquisition
  • Java (Software Platform) from Wikipedia, the Free Encyclopedia Not to Be Confused with Javascript

    Java (Software Platform) from Wikipedia, the Free Encyclopedia Not to Be Confused with Javascript

    Java (software platform) From Wikipedia, the free encyclopedia Not to be confused with JavaScript. This article may require copy editing for grammar, style, cohesion, tone , or spelling. You can assist by editing it. (February 2016) Java (software platform) Dukesource125.gif The Java technology logo Original author(s) James Gosling, Sun Microsystems Developer(s) Oracle Corporation Initial release 23 January 1996; 20 years ago[1][2] Stable release 8 Update 73 (1.8.0_73) (February 5, 2016; 34 days ago) [±][3] Preview release 9 Build b90 (November 2, 2015; 4 months ago) [±][4] Written in Java, C++[5] Operating system Windows, Solaris, Linux, OS X[6] Platform Cross-platform Available in 30+ languages List of languages [show] Type Software platform License Freeware, mostly open-source,[8] with a few proprietary[9] compo nents[10] Website www.java.com Java is a set of computer software and specifications developed by Sun Microsyst ems, later acquired by Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment . Java is used in a wide variety of computing platforms from embedded devices an d mobile phones to enterprise servers and supercomputers. While less common, Jav a applets run in secure, sandboxed environments to provide many features of nati ve applications and can be embedded in HTML pages. Writing in the Java programming language is the primary way to produce code that will be deployed as byte code in a Java Virtual Machine (JVM); byte code compil ers are also available for other languages, including Ada, JavaScript, Python, a nd Ruby.
  • A Large-Scale Analysis of Java API Usage Diplomarbeit Zur Erlangung Des Grades Eines Diplom-Informatikers Im Studiengang Informatik

    A Large-Scale Analysis of Java API Usage Diplomarbeit Zur Erlangung Des Grades Eines Diplom-Informatikers Im Studiengang Informatik

    A Large-Scale Analysis of Java API Usage Diplomarbeit zur Erlangung des Grades eines Diplom-Informatikers im Studiengang Informatik vorgelegt von Jürgen Starek Koblenz, im November 2010 Erstgutachter: Prof. Dr. Ralf Lämmel Institut für Informatik, AG Softwaresprachen Zweitgutachter: Dipl. Math. Ekaterina Pek ebd. Erklärung Ich versichere, dass ich die vorliegende Arbeit selbständig verfasst und keine anderen als die angegebenen Quellen und Hilfsmittel benutzt habe. Mit der Einstellung dieser Arbeit in die Bibliothek bin ich einverstanden. Der Veröf- fentlichung dieser Arbeit im Internet stimme ich zu. ............................................................................................... (Ort, Datum) (Unterschrift) Deutsche Zusammenfassung Die vorliegende Arbeit stellt eine Methode für die korpusbasierte Analyse der Verwendung von Softwarebibliotheken in Java-Programmen vor. Die meisten größeren Softwareprojekte verwenden Softwarebibliotheken, die als Schnittstelle für den Programmierer sogenannte APIs (application programming interfaces) bereitstellen. Um den Umstieg von einer solchen API auf eine andere zu unterstützen, strebt man Werkzeuge zur automatisierten API-Migration an. Zur Entwicklung solcher Werkzeuge fehlen allerdings noch Basisdaten. Statistiken und Beobachtungen zur Verwendung von APIs in der Praxis wurden bisher nur mit sehr kleinen Korpora von Projekten und APIs durchgeführt. Wir stellen in dieser Arbeit daher eine Analysemethode vor, die für Messungen an großen Ko- rpora geeignet ist. Hierzu erzeugen wir zunächst einen Korpus von auf SourceForge gehosteten Open-Source-Projekten sowie einen Korpus von Softwarebibliotheken. In der Folge werden alle Projekte des Korpus compiliert, wobei ein Compiler-Plugin für den javac detaillierte Informatio- nen über jede einzelne Methode liefert, die der Compiler erstellt. Diese Informationen werden in einer Datenbank gespeichert und analysiert. i Contents 1 Introduction 1 1.1 Motivation . 1 1.2 Research Questions and Contributions .