CSE 331 Annotations slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

Slides:



Advertisements
Similar presentations
1 CSE 331 Enumerated types ( enum ) slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Advertisements

Lecture 6 Annotations Advanced Java Programming 1 dr hab. Szymon Grabowski dr inż. Wojciech Bieniecki
Preventing bugs with pluggable type checking Michael D. Ernst University of Washington Object x)
GUI Threading Explained and Verified Michael Ernst U. of Washington, Seattle, USA IMDEA Software Institute, Madrid, Spain joint work with Colin Gordon,
Java Annotations. Annotations  Annotations are metadata or data about data. An annotation indicates that the declared element should be processed in.
Detecting and preventing bugs with pluggable type-checking Michael D. Ernst University of Washington Joint work with Mahmood Ali, Werner Dietl, …
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Interfaces besides classes, Java recognizes another type, an interface interface is used to completely shield off all implementation from the programmer.
1 Documenting with Javadoc CS 3331 Fall 2009 How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
CSE 403 Lecture 11 Static Code Analysis Reading: IEEE Xplore, "Using Static Analysis to Find Bugs" slides created by Marty Stepp
Usable code verification: balancing costs and benefits Two nuggets: User-defined verifiers Crowd-sourced verification Michael D. Ernst University of Washington.
Java 1.5 Annotations. Motivation Computer scientists and engineers are always trying to add new features to programming languages Sometimes they are genuine.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Object x) { List lst; … } Detecting and preventing null pointer errors with pluggable type-checking CSE 331 University of Washington.
Fun with Java Annotations Brian McGinnis. Java Annotations Introduced in “Tiger” release (Java 1.5) Introduced in “Tiger” release (Java 1.5) One of most.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Slide: 1 Copyright © AdaCore Subprograms Presented by Quentin Ochem university.adacore.com.
User-defined type checkers for error detection and prevention in Java Michael D. Ernst MIT Computer Science & AI Lab
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
© Keren Kalif Advanced Java Topics Written by Keren Kalif, Edited by Liron Blecher.
Javadoc A very short tutorial. What is it A program that automatically generates documentation of your Java classes in a standard format For each X.java.
Documentation Dr. Andrew Wallace PhD BEng(hons) EurIng
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Demo of Scalable Pluggable Types Michael Ernst MIT Dagstuhl Seminar “Scalable Program Analysis” April 17, 2008.
Java 1 Introduction Why annotations?  Enhance ease-of-development  Shift some code generation from programmer to compiler What are annotations?
1 CSE 331 Generics (Parametric Polymorphism) slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
JSR 308: Type Annotations Making Java annotations more general and more useful Spec leads: Michael Ernst & Alex Buckley Implementation lead: Werner Dietl.
1 Documenting with Javadoc CS 3331 Section and Appendix B of [Jia03] How to Write Doc Comments for the Javadoc TM Tool available from
Java Annotations. Annotations  Annotations are metadata or data about data. An annotation indicates that the declared element should be processed in.
1 CSE 331 Hash codes; annotations slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Java Annotations for Types and Expressions Mathias Ricken October 24, 2008 COMP 617 Seminar.
Detecting and preventing bugs with pluggable type-checking Michael D. Ernst University of Washington Joint work with Werner Dietl, and many others
Documentation Javadocs. Design/Documentation An essential ingredient of good Object Oriented programming is known as design by contract. This means that.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
1 CSE 331 The Object class; Object equality and the equals method slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R.
C. Thomas Wu An Intro O-O Java Programming javadoc Utility.
Preventing bugs with pluggable type checking Michael Ernst University of Washington Joint work with Mahmood Ali and Matthew Papi Object.
Winter 2006CISC121 - Prof. McLeod1 Stuff We had better discuss a midterm date… –27 Feb. to 3 March or –6 to 10 March.
Preventing bugs with pluggable type-checking Michael Ernst MIT
1 CSE 331 Comparing objects; Comparable, compareTo, and Comparator slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R.
Zach Tatlock / Winter 2016 CSE 331 Software Design and Implementation Lecture 16 Checker Framework.
1 CSE 331 Memento Pattern and Serialization slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
CSE 331 Software Design and Implementation
More Sophisticated Behavior
Software Development Handing Errors and Creating Documentation
Methods Attributes Method Modifiers ‘static’
Fundamental of Java Programming
Using local variable without initialization is an error.
CSE 331 Cloning objects slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Enumerations & Annotations
Enumerations & Annotations
Generics (Parametric Polymorphism)
Conditional Statements
CSE 143 Lecture 24 Inheritance and the Object class; Polymorphism
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
Enumerations & Annotations
Java Programming Course
Applying OO Concepts Using Java
CSE 331 Memento Pattern slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
CS520 Web Programming Java Annotations
JUnit Reading: various web pages
CSE 143 Lecture 24 Inheritance and the Object class; Polymorphism
CSE 143 Lecture 24 Inheritance and the Object class; Polymorphism
Java Annotations.
CSE 143 Lecture 23 Inheritance and the Object class; Polymorphism
Java Annotations for Invariant Specification
Software Specifications
Presentation transcript:

CSE 331 Annotations slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

Annotations annotation: Markup that provides information to the compiler. Can also be used for deployment-time or run-time processing. Common uses for annotations: To detect problems or errors in code To suppress compiler warnings For unit tests, e.g. JUnit

Annotation usage @AnnotationName @AnnotationName(param=value, ..., param=value) Examples: @SuppressWarnings @Test(timeout=2000) An annotation can be placed on: a class a method a field a local variable, ...

Common annotations The following annotation types come with the JDK: name description @SuppressWarnings turn off compiler warnings @Override border line around component @Deprecated code that is discouraged from use @Documented sets another annotation to appear in Javadoc @Retention makes annotation data available at runtime

Creating an annotation type public @interface Name {} Example: public @interface GradingScript {} ... @GradingScript public class TestElection {...}

An annotation with params public @interface Name { type name(); // parameters type name() default value; // optional } Example: public @interface ClassPreamble { String author(); String date(); int currentRevision() default 1; String lastModified() default "N/A"; String[] reviewers(); Most programmers don't commonly need to create annotations.

Using custom annotation @ClassPreamble( author = "John Doe", date = "3/17/2002", currentRevision = 6, lastModified = "4/12/2004", reviewers = {"Alice", "Bob", "Cindy"} ) public class FamilyTree { ... }

Prof. Ernst's annotations UW's own Prof. Michael Ernst and his research team have contributed a set of custom annotations that can be used to provide sophisticated type checking and nullness checking for Java: name description @Immutable a class of objects that cannot mutate @Readonly a temporarily unmodifiable value @Nullable, @NonNull a value for which null can/cannot be passed @Encrypted, @Untainted for security and encryption @GuardedBy for concurrency @Localized for internationalization @Regex for tagging regular expressions @Interned for flyweighted objects