JavaOne 2010 Summary
- Coin: Small language changes.
- No new keywords.
- New "diamond" syntax:
List<List<String>> list = new ArrayList<>();
- Compiler desugars try-with-resources into nested try-finally's
- Coin team picked "complex" type inference strategy (include
constructor params) since it made implementation easier.
- Change requiring most effort: try-with-resources
- Change with most design complexity: Diamond
- Change requiring most syntax change: try-with-resources
Performance: Java versus C
- Summary: "It Depends"
- Debian language shootout compares different algorithms, not
languages, so it isn't a fair comparison.
- Virtual call to a function with a constant return: Java wins
since it optimizes to final value, C++ must make call.
Swing Tips and Tricks
- Main rule: access Swing components only on Event Dispatch Thread
- Break the main rule and you'll get exceptions and painting artifacts.
- However, put expensive operations on EDT and app will become sluggish.
- Use SwingWorker to offload slow tasks. Be sure to catch
doInBackground() so they don't get lost.
- Use EventListenerList when implementing an Observer.
- Use EDTHangMonitor to find EDT hogs
- Cache images instead of reloading.
- Precompute displays/images rather than doing it on the fly.
- Change push to pull: Refresh at fixed intervals instead of faster data change rate.
- Force on OpenGL and other hardware acceleration via
- Java 2D: Widely-used API for drawing 2D shapes, text, colors, and images.
- Has concepts and API similar to PostScript.
- Can us multithreaded rendering if you have a BufferedImage.
Each thread gets its own Graphics and writes to different sections.
- Use Logical Fonts (SanSerif, Dialog, etc.)
- Logical fonts support multiple languages.
- Graphics.setCompoiste() lets you combine the new shape with the
existing surface using alpha blending. Allows fade in/out effects.
- For animation, use Swing Timer. It calls you back on the EDT
so you can call into Swing components.
- The timing framewoek on java.net makes animation easy.
- Java2D is high performance and cross-platform.
- Subjectively attractive interfaces are preferred even if
- Read O'Reilly's Effective UI.
JPA Best Practices
- Create a separate Primary Key class instead of an embedded PK.
- @Id is now allowed on @ManyToOne relations.
- In JPA 2.0, @Access(PROPERTY) allows overriding getter/setter
to customize value from what is stored. Unit conversions,
- Avoid Embeddeded objects. They can't be queried. Make them
- Use explicit, named join instead of long dotted expression
- If your queries don't care about prior writes, the use COMMIT
- Use TypedQuery, it lets you specify the return cast and avoid
- Use criteria queries when you need to construct queries
- Parameters are faster than composing queries with strings.
- Prefer named parameters to positional ones.
- Use detach(obj) when you need to remove one object from the
transaction without affecting all others.
- Prefer optimistic locking to pessimistic locking, unless there
is tons of contentions and retries.
LambdaJ is a library for concisely expressing operations on
collections. For example, creating a list of top speeds from a
collection of cars, which would take 4-5 lines using a for loop, takes
one with LambdaJ:
List speeds = extract(cars, on(Car.class).getSpeed());
Good stats were presented (min/max/avg) comparing LambdaJ against
iterative code. The framework added 200% overhead, a reasonable price
for concise code operating on small to medium datasets.
Java Technical Keynote
- Java SE
- Java EE
- In EE6, web.xml is now optional. Moving away from XML
- When JDK8 arrives with module support, the server will be
able to download dependencies from repositories, no need
to bundle all JARs into the WAR any more.
- Java ME
- Java ME and Web interop will be bidirectional:
- Java ME code will be able to call to WS
- Java ME GUI will be able to embed an HTML View in
2011 (JSR 290)
ME classes. (Release TBD)
Oracle Develop Keynote
- Cut your Batch Size: Some people release to production
multiple times per day.
- Used JavaFX to consume Rally WS and produce new UI with
live charts and other rich UI features.
- Rich Enterprise Applications
- "Native Mobile": an app written with the
primary UI toolkit for a mobile device.
- ADF Mobile Client is in Developer Preview.
- It renders an ADF app to a native mobile client.
- Stores local changes in an SQLite or Berkeley DB.
- Showed some sort of Excel integration, but on windows only.
- Service Providers should:
- Prevent up-front threats:
- Use a firewall to limit entry points.
- Have a plan to limit the effect of DoS attacks.
- Control Access
- Require authentication on each request.
- Authorize application access using authenticated credentials.
- Log access.
- Propgate Identity across service calls.
- A tool to test regular expressions
- Images can come from anywhere, even on a page normally
restricted to a single host. So an attacker who can inject
- If you have a customer-facing web server that talks to internal
services, it should pass along authentication info to the called service.
- For data integrity, use SSL
- For Confidentiality, use SSL on the wire, and store sensitive
information encrypted on-disk.
ADF on Mobile
- ADF Mobile for JDeveloper is trying to address fragmentation in
the Mobile Market.
- Users are demanding device native (mobile native) interfaces on
different OSes and form factors.
- Two ways in ADF Mobile:
- ADF Mobile Browser: web-served UI that automatically
tunes itself to the mobile browser, from Opera to WebKit (Android/iPhone).
- ADF Mobile Client: native client with proper LAF, access
to contacts, etc. Works when offline.
- ADF Mobile Client platform support:
- Blackberry now
- Android 2011
- Long-term (sounds very long-term):
- Mobile Client
- Is beta-quality right now, some labels weren't
line up in the demo properly.
- Uses Panels and Layouts, like Swing, to allow stretching
and shrinking for different resolutions and form factors.
- Provided missing Java libraries on all platforms
(Android, BB). However, all of this requires a license
for each user, approximately $5/named user.
- A few things do need to be customized per-platform:
Oracle Linux has the Nimbus theme now.
- LiveScribe pen demoed
- Pen records what you write and say
- Can playback what was said at any point from what you
wrote by tapping on the page
- Can recognize text and translate it
- Has apps that recognize symbols written on the page
- Can sync, generate PDF, and e-mail
- Volkswagen demoed a driverless car that can drive up Pike's
Peak at 3x the speed limit
- VNC client used to show their Swing app on mobile devices.
- Java is the primary language for JavaFX 2.0.
- All APIs will be available in Java (and hence in any JVM langauge).
- Embedded HTML with seamless DOM integration
- Birdirectional HTML: Embed HTML in JavaFX, JavaFX in HTML
- 2D and 3D graphics will fast HW acceleration
- Full Swing integraion: Will be able to embed in Swing in a
- 2011 release dates:
- JavaFX binding to replace JSR-295 bean binding
- JavaFX script is dead
Last modified on 24 Sep 2010 by AO
Copyright © 2020 Andrew Oliver