Smalltalk on the JVM By James Ladd - ESUG 2011.

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Dynamic Code Generation in Java. Class Loading Class loading is the process of transforming a byte code (e.g., a.class file) into a Java class A Java.
1 InTroToJCL Introduction to Java Class Loaders. 2 class loader l ia an object responsible for loading classes. The class ClassLoader is an abstract class.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
Copyright © 2001 Qusay H. Mahmoud Case Study A Global Compute Engine Here we will discuss some implementation details: – Class Loaders – Compute Engine.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Remote Method Invocation
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Packages and Class Visibility The objectives of this chapter are: To understand logical class groupings using packages To explain the environment variable.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Dynamic Code Generation in Java. Class Loading Class loading is the process of transforming a byte code (e.g., a.class file) into a Java class A Java.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Unit 061 Java Virtual Machine (JVM) What is Java Virtual Machine? The Class Loader Subsystem Linking oVerification oPreparation oResolution Class Initialization.
1 Further OO Concepts II – Java Program at run-time Overview l Steps in Executing a Java Program. l Loading l Linking l Initialization l Creation of Objects.
1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
Writing Methods. Create the method Methods, like functions, do something They contain the code that performs the job Methods have two parts.
Protection of Agent Teamwork By Jeremy Hall. Agent Teamwork Overview ● Mobile agent framework  AgentTeamwork 2 is a mobile-agent based middleware system.
COP4020 Programming Languages
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
The Terminator to Android Hardening Services
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
Lecture 2: Classes and Objects, using Scanner and String.
Java Security Nathan Moore CS 665. Overview Survey of Java Inherent Security Properties Java Runtime Environment Java Virtual Machine Java Security Model.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Introduction to Object Oriented Programming CMSC 331.
CORBA/IDL Common Object Resource Broker Architecture (CORBA) Interface Definition Language (IDL) Object Management Group (OMG) ( Specification.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
CS 4244: Internet Programming Network Programming in Java 1.0.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
Chapter 2. System Structures
CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)
 2005 Pearson Education, Inc. All rights reserved. 1 Classes and Objects: A Deeper Look.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
Modules. Modules Modules are the highest level program organization unit, usually correspond to source files and serve as libraries of tools. Each file.
Introduction to Programming 1 1 2Introduction to Java.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
RealTimeSystems Lab Jong-Koo, Lim
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Design issues for Object-Oriented Languages
Chapter 7: Cloning and RTTI
Variables in Java A variable holds either
Introduction to Compiler Construction
Topic: Java Class Loader
Java Primer 1: Types, Classes and Operators
Remote Method Invocation
Running An Encrypted Java Program
Knowledge Byte In this section, you will learn about:
Writing Methods.
Packages and Interfaces
Constructors, GUI’s(Using Swing) and ActionListner
COSC Assignment 3 - Part 1 Java Security Susan Kovacs 19 April 2019 COSC Assignment 3 - Part 1.
Python Modules.
Chapter 1 c++ structure C++ Input / Output
Java phoneME CDC AMS July, 15, 2008 by Wooram Noh.
Presentation transcript:

Smalltalk on the JVM By James Ladd - ESUG 2011

JVM Implementation Challenges

JVM Implementation Challenges: JVM Unit of execution is a class Sequence of bytes in class format Class is not an Object (more like data structure)

JVM Implementation Challenges: JVM Unit of execution is a class Load Class newInstance() called

JVM Implementation Challenges: JVM loads classes with a Class Loader loadClass("java.lang.String")

JVM Implementation Challenges: JVM loads classes with a Class Loader SmalltalkClassLoader loadClass('Object') = Object.st

JVM Implementation Challenges: JVM classes are namespaced java.lang, st.redline Package Must specify fully qualified name

JVM Implementation Challenges: Calling methods is cumbersome Very static Must specify exact type

JVM Implementation Challenges: Calling methods is cumbersome St/redline/ProtoObject (Ljava/lang/Object;)Ljava/lang/StringBuilder;

JVM Implementation Challenges: Calling methods is cumbersome Luckily everything in Smalltalk is an Object (ProtoObject)

JVM Implementation Challenges: Methods are part of a class Change class to change method

Redline Smalltalk Internals

Uses ANTLR Smalltalk.g PreProc.g

Redline Smalltalk Internals Users ANTLR Jim Idle wrote pre-processor Will eventually make grammar skinnable

Redline Smalltalk Internals Uses ObjectWeb ASM Bytecode class writing library

Redline Smalltalk Internals Base of hierarchy is ProtoObject Java object that implements primitives Each primitive is a static Java method

Redline Smalltalk Internals Base of hierarchy is ProtoObject Smalltalk Objects built using message sends to ProtoObject Compiler's job is to generate message sends

Redline Smalltalk Internals Two other Java Objects ProtoMethod ProtoBlock

Redline Smalltalk Internals Redline Java Class Loader SmalltalkClassLoader Searches for source (.st file)

Redline Smalltalk Internals Redline Java Class Loader Can use Smalltalk classes from Java

Redline Smalltalk Internals Namespace support Modelled on Java Packages File path is package

Redline Smalltalk Internals Namespace support st/redline/Object = st/redline package Each class has own 'set' of imports

Redline Smalltalk Internals SmalltalkClassLoader Partitions applications within single JVM

Redline Execution

What happens when st.redline.Example is Executed?

Redline Execution: executing st.redline.Example Invoke class from command line./stic st.redline.Example

Redline Execution: executing st.redline.Example Stic Creates instance of SmalltalkClassLoader Sets as context ClassLoader

Redline Execution: executing st.redline.Example Stic Asks SmalltalkClassLoader to bootstrap Asks ProtoObject to resolve 'st.redline.Example'

Redline Execution: executing st.redline.Example ProtoObject loads class Class.forName(“st.redline.Example”);

Redline Execution: executing st.redline.Example SmalltalkClassLoader Checks cache – returns object if present Searches source path for 'Example.st' ie: src/main/smalltalk/st/redline/Example.st

Redline Execution: executing st.redline.Example SmalltalkClassLoader Invokes compiler on source file Resulting class loaded into JVM Instance created class.newInstance()

Redline Execution: executing st.redline.Example Method newInstance() Runs Class method method contains message sends from Source

Redline Execution: executing st.redline.Example Compiler Creates Java class to contain logic Class is subclass of ProtoObject Package is based on file path

Redline Execution: executing st.redline.Example Compiler Creates method, which is executed when instance created. Logic in 'st.redline.Example' is encoded as message sends: ProtoObject.primitiveSend(...)

Redline Execution: executing st.redline.Example Compiler – Smalltalk Methods Methods are encoded as a message send to compile the method source. Because class doesn't exist yet.

Redline Execution: executing st.redline.Example Method Compilation Methods are 1 st class objects Subclass of ProtoMethod Added to receivers method dictionary

Redline Execution: executing st.redline.Example Method Compilation All Methods Objects have only 1 method applyTo(...) Contains logic embodied in Smalltalk method

Redline Execution: executing st.redline.Example Block Compilation Blocks are 1 st class objects Subclass of ProtoBlock

Redline Execution: executing st.redline.Example Block Compilation Blocks instance created when used Have a Java applyTo(...) method ^ semantics handled correctly

Redline Demo

Questions? Please visit: