How to Troubleshoot Apps for the Modern Connected Worker
Java Semantics
1. Java: An Operational Semantics Gaurav S. Kc B. Eng. Project Department of Computing
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12. Constructor execution [boolean] C(true), [AT] = [boolean] constrBody = []super(); if (b) ... cc = []SuperC(P,C)(); = []B(); [] B(); x=5; if (b) …, new C(true); I = (x=5;) Expr
13.
14.
15.
16.
Notas do Editor
My research project was on the semantics of Java. Got email link … and these slides will also be available on the web along with report.
Semantics definition Definition of Java given by Sun, where it was developed. Just how robust and secure is it? Not very, so there’s so much research in the field.
Studying the semantics of any prog. lang. Helps to get a better grasp of how programs written in the language actually execute For any prog lang, public acceptance is heavily dependent on it being reliable, more importantly for mission-critical projects where unexpected behaviour could be very detrimental Java is a very versatile general programming language. There’s virtually nothing that cannot be done with Java yet can be done with some other imperative programming language. However, to some extent, this functionality might come at a cost of the security of the systems involved and a trade-off involving a lot less functionality is often necessary. Even so, Java has already come into widespread use, and its here to stay. Research in Java is so often done with the intention of determining feasible compromises with maximum functionality while maintaining adequate security.
Sophia and Susan developed a semantics for a substantial subset of Java. Java is still growing, and we felt the need to expand this subset as well to keep up with Java. Since my project was mainly theoretical, I have no software product to demonstrate. I hope those of you that didn’t know this will not be disappointed!
What we had before: Java is class-based, class has members which can be inherited by child-classes. Access mod: use to control the degree of accessibility of classes/interfaces, their members and constructors from other objects Other modifiers: final, abstract: class; final static: field; abstract final: method Constructors: the most interesting part of the project
Red: depicts Java features that can now be studied using the semantics
Public: accessible everywhere where the class is accessible Protected: accessible in subclasses Private: inaccessible from any other class default: package access … not dealt with packages due to time constraints CHECKING: required to see fields, methods, constructors are accessible
Final class: implementation is complete, and shouldn’t be subclassed Abstract class: insufficient information for instantiation, so defer partial implementation to be completed in subclasses Final field: cannot change value .. compares with constants in other languages definitions are well formed if a class does not try to subclass a final classs or an constructor is not invoked to create an abstract class check if assignment is attempted on a field declared final
Static fields: no more only instance fields Classes and interfaces have fields … shared between all instances In the SCDSE semantics, the runtime system could only store arrays and objects, now this system has been extended for Classes and interfaces, and these too can be referenced like normal objects … too technical
Has to determine all declared and inherited instance fields if out of memory, must exit and report error initialise static fields
Explicit can be: this or super if this, has statements if super, has initialisation before statements
We have “new C(true)”; compiled to [bool]C(true) looking at rewrite rule for constructor invocation, arg type AT is [boolean] use AT to determine most specific constructor in class in the mostspec constructor, explicit turned to be super replace that by SuperC(P,C)() which is B() determine initialisers that must be taken into consideration for class C only one … x = 5; so InitExpr is simple so eventually, the whole term is rewritten to a sequence of statements
Java entices a lot of programmers and researchers Even within IC, we have people in Distributed Software Engineering … and there are others in universities and research institutions like: people trying best way of extending Java: generics types to Java (Programming Language Techniques) people trying to find and eradicate loopholes in the Java security system Secure Internet Programming have discovered many important flaws in the Java and Netscape Navigator Java Virtual Machine systems.
I’m happy to have managed to work reasonably well in this project and get some results. There are a lot more qualified people working on similar things.
* 2-3 weeks spent on access modifiers for instance fields * anticipated same amount of time for methods and constructors, turned out that my rules for the fields were equally well-suited for methods and constructors * formalising the constructor rules is the most interesting part of the project for me … because this is a completely new entry in the semantics. * Skills learned: used LaTeX for report writeup … will be useful in later research work coz it’s the choice of the academics must have improved my creativity after designing semantic rules for a wide variety of test cases * is a new thing-- no one has succeeded in completely formalising Java semantics … is at the forefront of technology! Is something novel. * I hope someone in Doc will take what I’ve done and continue from there because this is a very interesting field. Most people don’t realise that studying semantics helps improve the understanding of programming language systems and is as equally important as understanding how hardware actually executes machine code. * Most important part of the project must be fact that I know a lot more about Java systems than before I started the project.
KB - second marker -- UROP supervisor 98 … SCD - supervisor + lots of help with semantics and other things tanya - whose work was invaluable in writing my report