KAnnotator: Inferring Type Information from Java Byte Codes Alexey Sedunov Andrey Breslav Svetlana Isakova Evgeny Gerashchenko JetBrains, s. r. o. 2013.

Slides:



Advertisements
Similar presentations
Static Analysis for Security
Advertisements

Program Verification Using the Spec# Programming System ETAPS Tutorial K. Rustan M. Leino, Microsoft Research, Redmond Rosemary Monahan, NUIM Maynooth.
11 Copyright © 2005, Oracle. All rights reserved. Using Arrays and Collections.
Using Java without BlueJ BlueJ projects A BlueJ project is stored in a directory on disk. A BlueJ package is stored in several different files.
Introduction to Compiler Construction
R O O T S Field-Sensitive Points-to-Analysis Eda GÜNGÖR
ALG0183 Algorithms & Data Structures Lecture 23 a acyclic with neg. weights (topological sort algorithm) 8/25/20091 ALG0183 Algorithms & Data Structures.
Uncovering Performance Problems in Java Applications with Reference Propagation Profiling PRESTO: Program Analyses and Software Tools Research Group, Ohio.
Linked Lists Linear collections.
Eiffel: Analysis, Design and Programming Bertrand Meyer (Nadia Polikarpova) Chair of Software Engineering.
1 Joe Meehean. Ordered collection of items Not necessarily sorted 0-index (first item is item 0) Abstraction 2 Item 0 Item 1 Item 2 … Item N.
Semantic Analysis and Symbol Tables
1. Define the concept of assertions. 1 Explain the use of assertions. 2 Create Java program using assertions. 3 Run Java program using assertions. 4 2.
1 After completing this lesson, you will be able to: Check spelling in a document. Check for grammatical errors. Find specific text. Replace specific text.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
The List ADT Textbook Sections
Microsoft.NET Object Oriented Software Engineering Based on a presentation by Murat Can Ganiz.
Copyright © 2013 by John Wiley & Sons. All rights reserved. HOW TO CREATE LINKED LISTS FROM SCRATCH CHAPTER Slides by Rick Giles 16 Only Linked List Part.
Lilian Blot VARIABLE SCOPE EXCEPTIONS FINAL WORD Final Lecture Spring 2014 TPOP 1.
De necessariis pre condiciones consequentia sine machina P. Consobrinus, R. Consobrinus M. Aquilifer, F. Oratio.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Chapter 1 Writing a Program Fall Class Overview Course Information –On the web page and Blackboard –
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Pointer Analysis – Part I Mayur Naik Intel Research, Berkeley CS294 Lecture March 17, 2009.
Introduction to Exceptions in Java. 2 Runtime Errors What are syntax errors? What are runtime errors? Java differentiates between runtime errors and exceptions.
Exceptions and Exception Handling Carl Alphonce CSE116 March 9, 2007.
COP 2800 Lake Sumter State College Mark Wilson, Instructor.
Generic programming in Java
Java Generics.
Pointer and Shape Analysis Seminar Context-sensitive points-to analysis: is it worth it? Article by Ondřej Lhoták & Laurie Hendren from McGill University.
Program analysis Mooly Sagiv html://
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Program analysis Mooly Sagiv html://
IPT Readings on Instrumentation, Profiling, and Tracing Seminar presentation by Alessandra Gorla University of Lugano December 7, 2006.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Overview of program analysis Mooly Sagiv html://
Overview of program analysis Mooly Sagiv html://
From last class. The above is Click’s solution (PLDI 95)
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
Su Ping and Ma Xiao-xing Department of Computer Science and Technology Nanjing University Automated Analysis of Dynamic Dependences between Java Components.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
What is.NET?.NET is a "revolutionary new platform, built on open Internet protocols and standards, with tools and services that meld computing and communications.
1 Generics and Using a Collection Generics / Parameterized Classes Using a Collection Customizing a Collection using Inheritance Inner Classes Use of Exceptions.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
G ENERICS I N J AVA BY: Ankit Goyal Sankalp Singh.
2013-T2 Lecture 18 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
Spec# Andreas Vida. Motivation Correct and maintainable software Correct and maintainable software Cost effective software production Cost effective software.
Demo of Scalable Pluggable Types Michael Ernst MIT Dagstuhl Seminar “Scalable Program Analysis” April 17, 2008.
1 Features of Java (2) CS 3331 Sections 4.5 and 4.6.
List Interface and Linked List Mrs. Furman March 25, 2010.
Java FilesOops - Mistake Java lingoSyntax
Java Annotations for Types and Expressions Mathias Ricken October 24, 2008 COMP 617 Seminar.
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
2015-T2 Lecture 19 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 10: Programming Exceptionally.
Fall, Privacy&Security - Virginia Tech – Computer Science Click to edit Master title style JFlow: Practical Mostly-Static Information Flow Control.
Secure Coding Rules for C++ Copyright © 2016 Curt Hill
Proof Carrying Code and Proof Preserving Program Transformations
Introduction to Exceptions in Java
Introduction to Exceptions in Java
Secure Coding Rules for C++ Copyright © Curt Hill
A quick introduction.
עקרונות תכנות מונחה עצמים תרגול 21: Generics
Generic programming in Java
statically-typed JVM-targeted programming language
Compiler Construction
Chap 1. Getting Started Objectives
Presentation transcript:

KAnnotator: Inferring Type Information from Java Byte Codes Alexey Sedunov Andrey Breslav Svetlana Isakova Evgeny Gerashchenko JetBrains, s. r. o. 2013

Annotation Inference Several languages on the Java platform refine Java type system to ensure program safety at compile-time Kotlin: nullable/non-nullable types In practice interoperability with existing Java code requires developers to provide missing type information, e.g. in a form of annotations. KAnnotator is a tool which automatically infers type annotations for a given set of classes (libraries) based on their bytecode 2

KAnnotator Features Annotation inference based on the bytecode of library Support of predefined annotations Internal vs. external annotations Verification mode Extensible context-insensitive inference engine Open-source 3

Comparison Julia general framework more precise longer runtime JQual general framework more precise mutability AST-driven NIT sound theory more precise treatment of fields specialized longer runtime 4

Inference Process Overview 5 Load predefined annotations Propagate annotations Apply inference to dependency graph Construct dependency & inheritance graphs Load class files Process conflicts

Bytecode Inference Engine Inference engine is based on the ObjectWeb 2 ASM data-flow analysis framework Compatible with ASM bytecode representation Does not require explicit construction of CFG Analyzer iterates over execution paths until all frames are stabilized Improvements to the ASM analyzer: Pseudo-errors corresponding to possible abnormal terminations Detection of unreachable paths Analysis-specific frame transformers 6

Mutability: Motivation 7

Mutability: Mutating Invocations void Collection Collection to ) { for (T fromElement : from) { //mutating invocation to.add(fromElement); } 8

Mutability: Propagating Invocations void Iterable a ) { //mutability propagating invocation Iterator it = a.iterator(); if (it.hasNext()) { it.remove(); } 9

Nullability: Motivation fun sort( a: Collection ? ):List ? 10 List sort(Collection a) { List list = new ArrayList (a); Collections.sort(list); return list; } JAVA KOTLIN fun sort( a: Collection ):List No type information

Nullability: Annotation Criteria Null does not reach ANY error node Null or Not Null reach SOME return Null does not reach ANY return node Null reaches SOME error node No Null is lost UNKNOWN

void String s) { if (s == null) return; bar(s); // null reaches return } 12 void String s) { if (s == null) s = "empty"; bar(s); // not-null reaches return }

void String s) { if (s == null) { throw new RuntimeException(); } bar(s); } 13 void String s) { if (s.isEmpty()) return; bar(s); }

Nullability: Unknown void foo5(String s) { if (check(s)) { throw new RuntimeException(); } if (s == null) { s = "empty"; } bar(s); } 14

Statistics Size (MB) Number of methods Time (Preproces s (%) OW2 ASM <1s/~40s70.3/0.2 Guava ~3s/~11s50.5/0.3 Java3D Core ~2s/~70s86.7/0.0 Soot ~6s/~4min94.2/0.6 JRE (rt.jar) public packages only ~15s/~3min74.2/0.25 JRE (rt.jar) full, restricted to public dependencies ~22s/~11mi n 79.7/0.3 JRE (rt.jar) full ~23s/ ~35min 85.6/0.5 15

Summary KAnnotator provides general framework for data- flow analysis It supports nullability and collection mutability analysis We used KAnnotator to generate annotations for some java libraries and several versions of the JRE standard library We also built the IntelliJ Idea plugin which automatically annotates jar files of the project libraries Future Work: Extend data-flow framework to support context- sensitive analysis Implement context-sensitive nullability analysis for generics Increase precision of field nullability analysis Implement more general mutability analysis 16

The End JetBrains, s. r. o. 2013