Upload
andreas-schreiber
View
8.188
Download
3
Embed Size (px)
DESCRIPTION
TechTalk von Arne Bachmann (DLR Köln-Porz, 07.10.2008).
Citation preview
Folie 1Was ist neu in Java 6, 7, 8, … 15.10.2008
Was ist neu in Java 6, 7, 8, ...
Arne Bachmann
Simulations- und Softwaretechnik
Deutsches Zentrum für Luft- und Raumfahrt
KP SC-VK
07.10.2008
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 2
Historischer Überblick
JDK 1.0 (1996-01-23) Highlights
JDK 1.1 (1998-02-19) Inner classes, JDBC, RMI
J2SE 1.2 Playground (1998-12-08) Collections, J2EE beta, JIT
J2SE 1.3 Kestrel (2000-05-08) Hotspot JVM, JNDI, JPDA
J2SE 1.4 Merlin (2002-02-06) assert, REs, Webstart, XML
J2SE 5.0 Tiger (2004-09-30) Annotations, enum, Generics
Java SE 6 Mustang (2006-12-11) JDBC4, Scripting, div. APIs
Java SE 6 Update 10 (2008) Better end user experience
Java SE 7 Dolphin (2009) Dyn. lang. support, multi-core
Java SE 8 … Closures?
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 3
Historischer Überblick
Benennungsschema
Alle Versionen ab JDK 1.2 hießen Java 2
Rückwirkend mit Java 1.5.0 wurden 1.2 - 1.5 in J2SE x umbenannt
Ab Java SE 6 sollen keine Codenamen mehr genutzt werden
Entwicklungsprozess
1998: JCP (Java community process) und JSRs (215: JCP 2.6)
Mai 2006: Rich Green (Sun) spricht von Java als Open Source
13. November 2006: Sun veröffentlicht erste Quellen unter GPLv2
8. Mai 2007: Alle Klassen-Bibliotheken veröffentlicht
2007: JRE 6 wird veröffentlicht (das JDK kam 2006)
Mai 2007: OpenJDKTM startet, wird JDK 7 mit binären „plugs“ sein
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 4
Ältere interessante Features
J2SE 1.2: Das strictfp keyword
public strictfp class Example1 {float calculate(float x) {
return x / 13.333f;}
}
// oder
public class Example2 {strictfp float calculate(float x) {
return x / 13.333f;}
}
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 5
Ältere interessante Features
J2SE 1.4: Das assert keyword für Pre-/Postconditions oder Invarianten
Start der JVM mit java -enableassertion TestClass(standardmäßig nicht aktiviert = Produktionsbetrieb)
class TestClass {void someStupidMethod(final String a) {
assert a != null;assert a.length() == 1: "nicht 1
Zeichen";System.out.println(a);
}}
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 6
Ältere interessante Features
J2SE 5.0: static import um das Constant Interface Antipattern zu vermeiden:
Auto-(un)boxing
// import static java.lang.Math.*;import static java.lang.Math.PI;
double r = cos(PI * theta);
int i = new Integer(2); // unboxingFloat f = 3.5f; // boxingVector<Long> vl = new Vector<Long>();vl.add(0l);
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 7
Ältere interessante Features
J2SE 5.0: Variable Argumentenzahl (= syntaktischer Zucker für Arrays)
int min(int firstArg, int... remainingArgs) {int min = firstArg;for (int arg: remainingArgs) {
if (arg < min) { min = arg; }}return min;
}
// Anwendung:
x = min(2,1);y = min(2,1,3);z = min(2,1,4,0,7,4,5,5,5,8,2,4);
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 8
Java SE 6
java.lang.String.isEmpty
java.util.{NavigableMap, NavigableSet}java.util.concurrent.ConcurrentNavigableMap
higherKey, higherEntry
pollFirstEntry
descendingKeySet
if( !randWord.isEmpty() ) { // no "length" check/*do something */
}
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 9
Java SE 6
JVMNeue class file version 50.0 (JSR 202) 0xCAFEBABE, schnellertype checking verifier (zweigeteilt, inspiriert von Java ME)
Neue Tools im JDKJava DB Derby (nur 2MB, default Standalone-DB)Rhino 1.6r2 JavaScript engine direkt dabei
Profiling und ProblemsucheMonitoring + Management-Tools ohne Neustart der JVM nutzenjconsole, jps, jmap, jstack, neu: jhat
Performance von Java wächst stetig, für Desktop und Server
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 10
Java SE 6Desktop Performanz
Grafik: Danny Coward (2007)
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 11
Java SE 6Server Performanz
Grafik: Danny Coward (2007)
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 12
Java SE 6APIs
Java API for XML Web Services (JAX-WS, JSR 224) for Java EE
Spec Lead (2003): Roberto Chinnici (Sun Microsystems, Inc.)
Maintenance Lead (heute): Jitendra Kotamraju (Sun)
Erzeugen der WS-Klassen mit wsgen –cp . CircleFunction
@WebServicepublic class CircleFunction {
public double getArea(final double r) {return java.lang.Math.PI * (r * r);
}public static void main(String[] args) {
Endpoint.publish( "http://localhost:8080/" +"WS/function", new CircleFunction());
}}
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 13
Java SE 6APIs
Scripting for the Java Platform (JSR 223), ursprünglich für Java EE
Spec Lead (2003-2006): Mike Grogan (Sun Microsystems, Inc.)
Mindestens 25 (java.net) + 10 (sonstige) Script-Engines, u. a.BeanShell, CajuScript, Jelly, Python, Sleep
ScriptEngineManager factory = new ScriptEngineManager();ScriptEngine js = factory.getEngineByName("JavaScript");js.put("myVariable", 100);js.eval("print('Hello, World ' + String(myVariable))");
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 14
Java SE 6APIs
JDBC 4.0 (JSR 221)
Spec Lead (2003 - 2006): Lance Andersen (Sun)
Auto-loading der Treiberklassen (kein Class.forName() mehr)
Neue SQLException Unterklassen (inkl. Iterable Interface)
National Character Sets (NCHAR, (LONG)NVARCHAR, NCLOB)
BLOB/CLOB support, RowID support (wie in DB2 + Oracle)
SQL Annotationen für Java-Methoden, siehe Beispiel:
interface ABQuery extends BaseQuery {
@Select(sql = "SELECT * from table where a = ?1 and b = ?2") DataSet<LoanApplication> getAB(String A, String B);
}
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 15
Java SE 6APIs
GUIJTable sortieren und filtern (statt z. B. GlazedLists)Splash screen vor dem Laden der JVM per CL oder ManifestNative TrayIcon UnterstützungBessere Drag'n'Drop Fähigkeiten (Drop Actions)
Monitoring & Management (JMX 1.0: JSR 3)Spec Lead (1998 - 2006): Eamonn McManus (Sun)Neu: Attach on demand
Viele Security enhancements, z. B.XML Digital Signature API (JSR 105)Kerberos integrationSmartcard API (JSR 268)
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 16
Java SE 6APIs
Java Compiler API (JSR 199) javax.tools
Spec Lead (2002): Neal Gafter (Microsoft)
Spec Lead (2006): Peter von der Ahe (Sun)
Pluggable Annotation Processing API (JSR 269)
Spec Lead (2005 - heute): Joseph "Joey" D. Darcy (Sun)
Standardisierung des Annotation-Processing im Gegensatz zur Annotationsdefinition in J2SE 5 (JSR 175)
Hilfreich für Metaprogramming-Tools
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 17
Java SE 6APIs
Java Architecture for XML Binding (JAXB) 2.0 (JSR 222)
Spec Lead (2003): Sekhar Vajjhala (Sun)
Spec Lead (heute): Kohsuke Kawaguchi (Sun)
Streaming API for XML (JSR 173)
Spec Lead (2002): Christopher Fry (BEA)
Spec Lead (heute): Larry Cable (BEA) & Thorick Chow (BEA)
Common Annotations for the Java Platform (JSR 181)
Spec Lead (2004-2006): Rajiv Mordani (Sun)
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 18
Java SE 6 Update 10
"Consumer JRE"-Release
Startet schneller (lädt gefüllten Cache vor dem Start)
Besseres Installations-"Gefühl"
Modular: Java "Kernel" = minimaler Satz von Bibliotheken
Reicht für "Hallo Welt"
Download und Installation von Rest wenn benötigt
Neue Applet-Technologie: Direkt auf Desktop ziehbar = Widget
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 19
Java SE 6 Update 10
Grafik: Danny Coward (2007)
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 20
Java SE 6 Update 10
Grafik: Danny Coward (2007)
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 21
Java SE 7
enum-Werte definierbar:
switch/case über String-Literale:
enum Typ {eins (1),drei (3),zehn (10);
}
switch (answer.toLowerCase()) {case "yes": /* code */case "no": /* error */
}
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 22
Java SE 7APIs
Unterstützung von dynamisch typisierten Sprachen in JVM (JSR 292)
Spec Lead (2006): Gilad Bracha
Spec Lead (heute): Danny Coward
Neuer Bytecode invokedynamic
Evtl. mitgeliefert: BeanShell (JSR 274), Groovy, JRuby, Jython
Java FXTM Script → Eigener TechTalk?
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 23
Java SE 7APIs
Neue Version: JMX 2.0 (JSR 255)
Spec Lead (2004 - heute): Eamonn McManus (Sun)
Namespaces
"Federated JMX technology servers"
Web Services Connector for JMX Agents (JSR 262)
Spec Lead (2004 - heute): Eamonn McManus (Sun)
Grafik: Sun JSR
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 24
Java SE 7Modularisierung
Improved modularity support (JSR 294)
Spec Lead (2006): Gilad Bracha
Spec Lead (heute): Alex Buckley (Sun)
Führt u. a. zu Änderungen an der Klassendateiendefinition
superpackage de.dlr.test {// super-package exports:export de.dlr.test.Class1;export de.dlr.test.doc.*;
// super-package members:member de.dlr.test.Class1;member de.dlr.test.doc.*member de.dlr.test.secret.*;
}
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 25
Java SE 7Modularisierung
Java Module System (JSR 277, hängt von JSR 294 ab)
Spec Lead (2005): Stanley M. Ho (Sun)
Spec Lead (heute): Stanley M. Ho & Alex Buckley (Sun)
Features:
JAR wird erweitert zu JAM (Java Module) und enthält
Abhängigkeiten (Name + Version)
Erweiterbare Metadaten (z. B. Name, Main-Klasse, Members, Export, Import = Abhängigkeit)
Lokale Repositories für jedes Java-System/Nutzer-Login
Repositories unterschieden in global, Application-, URL-
Security (signing) ähnlich zu JARs
Kompatibilität der Abhängigkeiten zu gewöhnlichen JARs
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 26
Java SE 7GUI
Swing Application Framework (JSR 296)
Spec Lead (2006 - heute): Hans Muller (Sun)
Lebenszyklus einer Swing Applikation (z. B. ExitListener mit Veto)
Action-Manager (@Action)
Resource Management (+ Convention over Configuration)
Data injection (@Resource)
Task < SwingWorker < Future
TaskService, TaskMonitor
Storage / Session state (per XML, per User)
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 27
Java SE 7
Concurrency utilities update (JSR 166y)
Spec Lead (2002 - 2004): Doug Lea
Ursprünglich in J2SE 5 eingeführt, in x- und y-Versionen erweitert
Ermöglicht einfache Nutzung von Multicore-Rechnern
Fork/Join
Worker thread-Pool
Work-stealing
Grafik: Doug Lea
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 28
Java SE 7
Beans binding (JSR 295)
Spec Lead (2006 - heute): Scott Violet (Sun)
Anwendungsgebiet beispielsweise:
Swing-Properties binden
Konverter ermöglichen Typumwandlung
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 29
Java SE 7
Bean validation (JSR 303)
Spec Lead (2006): Jason Carreira
Spec Lead (heute): Emmanuel Bernard (Red Hat Middleware LLC)
JSR 303 bietet Annotations- und Validierklassen für validierende Annotationen (!), z. B. @NotNull
Custom constraints mit Validator<T>
Auch für java.util.{Collection, Set, List, Map}
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 30
Java SE 7
Annotations on Java Types (JSR 308)
Spec Lead (2006): Michael Ernst & Danny Coward (Sun)
Spec Lead (heute): Alex Buckley (Sun) & Michael Ernst
@NonNull
@ReadOnly
@Interned
@Tainted
@Mutable
Map<@NonNull String, @NonEmpty List<@Readonly Document>> files;
void monitorTemperature() throws @Critical TemperatureException{};
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 31
Java SE 7
More new I/O APIs for the Java Platform (JSR 203) java.nio
Spec Lead (2003): Mark Reinhold (Sun)
Spec Lead (heute): Alan Bateman (Sun)
Änderungen im Dateisystem verfolgen
Sicherheitsattribute (ACLs, Dateiberechtigungen)
Symbolische Links
Path, Directory, Visitors
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 32
Java SE 7
Enterprise Beans 3.0 (JSR 220)
Spec Lead (2003): Linda DeMichiel (Sun)
Spec Lead (2007): Linda DeMichiel & Michael Keith (Oracle)
JavadocTM Tag Technology Update (JSR 260)
Spec Lead (2004): Denis Mikhalkin (Sun) & Amy Fowler (Sun) & Kathy Walrath (Sun)
Spec Lead (heute): Danny Coward (Sun)
seit 1995 fast unverändert
Einbetten von Beispielen und Anwendungsfällen
Semantischer Index von Klassen und Packages
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 33
Java SE 7
Date and Time API (JSR 310)
Spec Lead (2007 - heute): Stephen Colebourne (Google) &Michael Nascimento Santos (Sun)
Dritter Versuch nach Date (JDK 1.1) und Calendar (JDK 1.4)
Definiert Instant, Interval, Duration
Matchers, Adjusters, Resolvers
Fußt auf ISO 8601 (XML), um Zeitzonen ergänzt
Existierende Klassen wie util.Date, sql.Date und sql.Time sollen neue Interfaces implementieren, nicht deprecated werden
Todo: Periods, Formatting, Parsing
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 34
Java SE 7
Units specification (JSR 275, nur Java SE) javax.measure
Spec Lead (2005): Steve Metsker (CapTech Ventures)
Spec Lead (heute): Jean-Marie Dautelle & Werner Keil
Quantity (λ), Dimension (nm), Measure (10), Unit (Wellenlänge)
Typsicher und beliebig erweiterbar
Datenbank mit Unterstützung von ISO 1000, ISO 31 (BIPM), NIST
class Person {void setWeight(Measurable<Mass> weight);
}
double weightInKg = weight.doubleValue(KILOGRAM); // Oder lb.double weightInLiter = weight.doubleValue(LITER); // Error!
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 35
Java SE 7, 8, …Mögliche Spracherweiterungen
Array-Syntax für Collections erlaubt (wie in Scriptsprachen)
Property-Literale (genaue Syntax diskutierbar)
Automatische Typ-Ermittlung durch den Compiler
List content = new LinkedList(10);Content[1] = "Hallo";
Point p = new Point();p->X = 56;
final map = new HashMap<String, Integer>();
// oder
map := new HashMap<String, Integer>();
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 36
Java SE 7, 8, …Mögliche Spracherweiterungen
Factory-Methoden für Typisierung per Unterklasse
BigInteger-Operationen endlich voll unterstützt / überladen
Operator-Überladen, wie beispielsweise aus C++ bekannt
für BigInteger bereits angedeutet, auch für Enums geplant
Closures
Lead: Neal Gafter (Microsoft, früher Sun + Google)
Veto durch Joshua Bloch (Google, früher Sun)
Foo f2 = Foo.new(SubclassOfFoo.class, 1, 2);
BigInteger bi = new BigInt("1") + new BigInteger("1");
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 37
Java SE 7, 8, …Mögliche Spracherweiterungen
XML Integration in Java
Mehrere Exceptions in einer Anweisung fangen:
Entspricht einem return mit variablen Typ} catch (IOException, NullPointerException io_or_npe) {
feature.add(<reviewed>
<who>{ reviewer }</who>;<when>{ dc.encode(time) }</when>;
</reviewed>
);
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 38
QuellenJDK 1.0 – J2SE 5.0
Java – Geschichte
http://www.java.com/en/javahistory/timeline.jsp
http://en.wikipedia.org/wiki/Java_version_history
http://en.wikipedia.org/wiki/Java_Community_Process
http://openjdk.java.net ersetzt http://openjdk.dev.java.net
http://www.sun.com/software/opensource/java/faq.jsp
http://jcp.org/en/jsr/stage?listBy=final
Ältere Features
http://en.wikipedia.org/wiki/Strictfp
http://java.sun.com/developer/technicalArticles/JavaLP/assertions/
Joshua Bloch (2008): Effective Java, (2nd ed.), Addison Wesley
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 39
QuellenJava SE 6
Java SE 6
http://www.tutego.com/java/java-6-mustang-news.htm
https://scripting.dev.java.net
http://weblogs.java.net/blog/shan_man/archive/2006/02/choosing_the_dr.html
Java SE 6 Update 10
http://java.sun.com/developer/technicalArticles/javase/java6u10/
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 40
QuellenJava SE 7
Features
http://tech.puredanger.com/java7/
http://www.tutego.com/java/jdk7-Java-SE-7.htm
http://www.infoq.com/news/2007/07/concurrency-java-se-7
GUI
https://appframework.dev.java.net
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 41
QuellenJava SE 8, …
http://www.cafeaulait.org/slides/nycjava/java7/Java_7_and_Beyond.html
http://wiki.java.net/bin/view/JDK/ClosuresSyntaxInJava7
Sonstiges
http://www.sun.com/aboutsun/media/ceo/
Die meisten Portraits stammen von den Blog-Seiten der Spec Leads
Wall-E ist von http://www.walle-derfilm.de
Was ist neu in Java 6, 7, 8, … 15.10.2008
Folie 42
Fragen?