DOC PREVIEW
MSU CSE 870 - java-dillon

This preview shows page 1-2-3-4-28-29-30-31-58-59-60-61 out of 61 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 61 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

JAVAGoals for JavaGoals for Java (cont.)Java Virtual MachineHow it WorksJava combines benefits ofOther benefits of JavaThree levels of SecurityJava doesn’t haveJava and the WebJava classesInheritance in JavaJava coding conventionsClasses in JavaVariables in JavaA simple Java appletA simple Java applet (cont.)Slide 18Lifetime of an AppletPart of the Java Class HierarchySubclassing and InheritanceSubclassing ExampleInterfaces in JavaInterface ExampleInterface Example (cont.)Slide 26Abstract class v.s. Interface classExceptional ConditionsApproaches for Handling Exceptional ConditionsI. Each method handles its own exceptional conditionsSlide 31II. A low level class/method handles exceptional conditionsII. A low level class/method handles exceptional conditionsIII. Methods return status information so that client methods can respond to exceptional conditionsExceptions were added to languages to help with error processingA method can catch an exception and specialize its responseException Handling MechanismsException Handling Mechanisms (cont.)Exceptions in JavaHandling ExceptionsHandling multiple exceptionsTry/Catch StatementFinding Exception HandlersMultiple Levels of PropagationExplanationThrowing ExceptionsTypes of Java ExceptionsSummary of Exception HandlingConcurrent SystemThreads in JavaDefining the behavior of a threadDefining thread behavior: Subclassing ThreadDefining thread behavior: Implementing runnableWhen should you implement Runnable?Life Cycle of a Thread in JavaSynchronizing Threads in JavaSynchronizing Threads in Java (cont.)Producer/Consumer ExampleProducer/Consumer Example (cont.)Slide 60Concurrency SummaryDillon: CSE470: JAVA, EXCEPTIONS & THREADS 1JAVADeveloped at SUN by James Gosling with support from Bill JoyNet-based languageDescended from Oak»platform independent»object oriented»smallThe Java Tutorial: http://java.sun.com/docs/books/tutorialDillon: CSE470: JAVA, EXCEPTIONS & THREADS 2Goals for JavaSimple»easy to learn–based on C/C++»smallObject oriented»single inheritanceDistributed»libraries supply protocolsRobuststrongly typedsafe pointer modelSecurePlatform independentvirtual machinePortableno implementation dependent data typesDillon: CSE470: JAVA, EXCEPTIONS & THREADS 3Goals for Java (cont.)Compiled and interpretedMultithreadedDynamicDillon: CSE470: JAVA, EXCEPTIONS & THREADS 4Java Virtual MachineCompiler translates Java into J-codeStack-based virtual machine (JVM)No undefined or platform specific data typesOther languages can be translated to J-codeInterpreter is lightweight, easy to implement»use widely available language, like CJ-code is highly optimizedJ-code can be compiled on the flyDillon: CSE470: JAVA, EXCEPTIONS & THREADS 5How it WorksThe JVM may be»an interpreter»an applet viewer»a web browser»part of an OSClasses could be loaded from filesystem or over a networkJVMs use an environment variable, CLASSPATH, to find byte code (.class files) to executeJava sourceJava compiler (javac)J-code (JVM byte codes)Other classes Native codeJava interpreter (a JVM)Platform independente.g., AWTPlatform dependentDillon: CSE470: JAVA, EXCEPTIONS & THREADS 6Java combines benefits ofA strongly typed, OO languageFlexibility of an interpreted language»Lisp, Perl, TclA smalltalk virtual machine with security protection»Java byte code verifier reduces runtime checksPackage structure for organizing classes into subsystemsDillon: CSE470: JAVA, EXCEPTIONS & THREADS 7Other benefits of JavaException handlingSupport for multi-threading»Based on Hoare’s monitorsHighly optimized»Easy debugging–make debugging statements dependent on a constant value, which programmer sets when done debugging–compiler automatically removes unexecutable statementsDillon: CSE470: JAVA, EXCEPTIONS & THREADS 8Three levels of SecuritySecurity manager»controls access to system resources»highlight windows of untrusted applicationsClass loader»restricts classes loaded from network to interact with classes from the same locationVerifier»checks that incoming classes can’t forge pointers, violate access permissions, over/under flow operator stack, etc.»ensures type safetyDillon: CSE470: JAVA, EXCEPTIONS & THREADS 9Java doesn’t haveMacros and preprocessor»mostly used for platform dependenciesOperator overloading, except for +(Very many) automatic type coercionsPointer arithmetic»references are a higher level type and can only point to class objects, not to class methodsExplicit memory management »provides automatic garbage collectionDillon: CSE470: JAVA, EXCEPTIONS & THREADS 10Java and the WebA web browser can incorporate a JVM and run Java applets as executable codeLife of an applet»Loaded by a web browser and asked to initialize itself»Informed each time it is displayed and hidden»Informed when it is no longer neededSecurity manager prevents applet from accessing system resources or interacting with outside applicationsDillon: CSE470: JAVA, EXCEPTIONS & THREADS 11Java classesClass is the basic computation unit»encapsulates data and associated operations»found and loaded dynamically as needed22 architecture specific classes: “gateway to the real world”»networking, windowing, filesystem, etc.Rest of Java is written in JavaDillon: CSE470: JAVA, EXCEPTIONS & THREADS 12Inheritance in JavaSingle inheritance hierarchyMultiple inheritance of interfaces»Interface specifies the operations but not the implementations»A class can “implement” multiple interfacesDillon: CSE470: JAVA, EXCEPTIONS & THREADS 13Java coding conventionsClass names begin with upper case lettersVariables and method names begin with lower case lettersConstants are all upper caseSeparate words with uppercase letter instead of underscorese.g. aVariableName AClassName aMethodName ACONSTANTDillon: CSE470: JAVA, EXCEPTIONS & THREADS 14Classes in JavaDefine an abstract data type»operations called methods»data called variables or fieldsMany class instances or objects can exist»each instance may have a different state–e.g., different values for variables»all instances have the same methodsArranged in a hierarchy»each class has a unique superclass (parent)»subclass (child) can add or modify methods or variables of the superclassDillon: CSE470: JAVA, EXCEPTIONS & THREADS 15Variables in JavaMaintain state of a class


View Full Document

MSU CSE 870 - java-dillon

Documents in this Course
HW2

HW2

3 pages

splc1

splc1

21 pages

Lessons

Lessons

3 pages

revision

revision

13 pages

ft1

ft1

12 pages

john.dsn

john.dsn

21 pages

Survey

Survey

2 pages

revision

revision

38 pages

Load more
Download java-dillon
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view java-dillon and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view java-dillon 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?