Top Banner
Java: An Operational Java: An Operational Semantics Semantics Gaurav Gaurav S. S. Kc Kc B. B. Eng Eng . Project . Project Department of Computing Department of Computing
16

Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Jan 21, 2019

Download

Documents

NguyễnThúy
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Java: An Operational Java: An Operational SemanticsSemantics

GauravGaurav S. S. KcKc

B.B. EngEng. Project. ProjectDepartment of ComputingDepartment of Computing

Page 2: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Semantics of Java Semantics of Java ---- why?why?

nn Semantics:Semantics:–– Assignment of meanings to programsAssignment of meanings to programs

nn Java: Java: –– A simple, objectA simple, object--oriented, distributed, oriented, distributed,

interpreted, interpreted, robustrobust, , securesecure, architecture , architecture neutral, portable, highneutral, portable, high--performance, performance, multithreaded, and dynamic language.multithreaded, and dynamic language.

Page 3: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Why? … contd.Why? … contd.

nn Better “mental model” of languageBetter “mental model” of languagenn AcceptanceAcceptance

–– reliabilityreliability–– expected behaviourexpected behaviour

nn Java : Security v.s. functionalityJava : Security v.s. functionalitynn Widespread useWidespread usenn Reasoning: towards a compromiseReasoning: towards a compromise

Page 4: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Project GoalsProject Goals

nn Semantics extensionSemantics extension

nn Better understanding of JavaBetter understanding of Java

nn Research based Research based ---- no implementationno implementation

Page 5: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

BreakBreak--down into partsdown into parts

nn Existing features: Existing features: –– inheritanceinheritance–– instance variablesinstance variables–– overloading and overridingoverloading and overriding

nn Additions:Additions:–– access modifiersaccess modifiers–– final, static, abstractfinal, static, abstract–– constructorsconstructors

Page 6: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

An example in the new syntaxAn example in the new syntaxabstractabstract class Animal extends Object {class Animal extends Object {

intint age; age; AnimalAnimal() {() {

supersuper();} ();} int getAgeint getAge() {...} }() {...} }

public public finalfinal class Dog extends Animal {class Dog extends Animal {finalfinal intint legs = 4; legs = 4; final final staticstatic booleanboolean hasTailhasTail = yes; = yes; Dog() {Dog() {

thisthis(“(“LaikaLaika”); } ”); } Dog(String s) {Dog(String s) {

super(); … } super(); … } int getAgeint getAge(String name) {…} }(String name) {…} }

Page 7: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Access ModifiersAccess Modifiers

nn PublicPublicnn ProtectedProtectednn PrivatePrivatenn [default][default]

nn No packagesNo packages

ll Accessibility checksAccessibility checks

Semantics extension ...

Page 8: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Final and Abstract modifierFinal and Abstract modifier

nn ClassesClasses–– subsub--classing not permittedclassing not permitted–– instantiating not permittedinstantiating not permitted

nn FieldsFields–– Constant behaviour?Constant behaviour?

ll WellWell--formednessformednessll Constructor invocationConstructor invocationll AssignmentAssignment

Semantics extension ...

Page 9: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Static modifierStatic modifier

nn Fields that don’t belong to objectsFields that don’t belong to objectsnn Class and interface fieldsClass and interface fieldsnn State extension: State extension:

–– Class/interface entriesClass/interface entries–– ReferencesReferences

ll Runtime checksRuntime checksll Class or interface v.s. objectClass or interface v.s. object

Semantics extension ...

Page 10: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

ConstructorConstructor

A A constructorconstructor is used in the creation of an is used in the creation of an object that is an instance of a class.object that is an instance of a class.

It is the basis with which the runIt is the basis with which the run--time time system allocates space from memory to system allocates space from memory to objects during execution.objects during execution.

nn Instance fields & [inherited] instance fieldsInstance fields & [inherited] instance fieldsnn OutOfMemory OutOfMemory exceptionexceptionnn Static initialisationStatic initialisation

Page 11: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Syntax of a ConstructorSyntax of a Constructor

nn Explicit constructor Explicit constructor invocationinvocation–– this();this();

nn same classsame class

–– super();super();nn parent classparent classnn static initialisationstatic initialisation

nn StatementsStatements

public class public class C C extends extends B {B {intint x = 5;x = 5;publicpublic C (C (intint n) {n) {

thisthis((truetrue););print(n); print(n);

}}private private C (C (booleanboolean b) {b) {

supersuper();();ifif (b) …(b) …

}}}}

Page 12: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

[boolean] C(true), σ[] B(); x=5; if (b) …, σ

ConstructorConstructorexecutionexecution

new C(true);

Page 13: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Other research work on JavaOther research work on Java

nn Within the Department of Computing:Within the Department of Computing:–– ExceptionsExceptions SLURPSLURP@@DoCDoC–– ConcurrencyConcurrency SLURPSLURP@@DoCDoC–– Binary CompatibilityBinary Compatibility SLURPSLURP@@DoCDoC

nn In other research institutions:In other research institutions:–– GenericsGenerics PLTPLT@Rice@Rice–– Security IssuesSecurity Issues SIPSIP@Princeton@Princeton

Page 14: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

Other research, …Other research, … contdcontd..

nn A comparison perhaps?A comparison perhaps?

–– Different aspects of JavaDifferent aspects of Java

–– PostPost--grad & postgrad & post--doc workdoc work

Page 15: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

ConclusionsConclusions

nn Boring? Certainly not!Boring? Certainly not!nn Acquired skillsAcquired skillsnn Taste of pure researchTaste of pure researchnn Lots of nonLots of non--trivial worktrivial worknn State of the art technologyState of the art technologynn Continued research in Java SemanticsContinued research in Java Semantics

nn Improved knowImproved know--how of the Java systemhow of the Java system

Page 16: Java: An Operational Semantics - Columbia Universitygskc/slides/JavaSemantics.pdf · Other research work on Java nWithin the Department of Computing: – Exceptions SLURP@DoC –

AcknowledgementsAcknowledgements

nn Krysia BrodaKrysia Brodann Sophia Sophia DrossopoulouDrossopoulounn Susan Susan EisenbachEisenbach

nn Tanya Tanya ValkevychValkevych