Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. CLDC 8: New Features and Opportunities for the Small Java Core Libraries Michael Lagally Principal Member of Technical Staff Roger Riggs, Consulting Member of Technical Staff The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. CLDC 8 New Features and Opportunities for the Small Java Core Abstract: CLDC has been the Java platform for connected devices such as feature phones since 2000. It is a platform for devices with very limited memory and CPU power. Oracle is leading an effort to update the CLDC platform with support for Java 8 language features and new library APIs. The platform defines a state-of-the-art runtime environment for small embedded devices and provides a set of carefully defined libraries that are most useful on resource-constrained devices. CLDC 8 targets embedded devices such as wireless modules, smart meters, and healthcare monitoring and other M2M devices. The CLDC 8 configuration is standardized in the Java community process as JSR 360, with experts from the embedded and mobile industry in the expert group. 4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Program Agenda Java ME Evolution Connected Limited Device Configuration (CLDC) Generic Connection Framework (GCF) 5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. The Next Generation: Java ME 8 Platform Themes Key Features • First step in Java ME Java SE alignment • Dedicated embedded application platform • Address increased range of use cases and markets • • • • Java ME CLDC 8: Updated VM + alignment with Java SE 8 Java ME Embedded Profile 8: Embedded application platform Value-add new and enhanced APIs and features for embedded Improved configurability and optimized footprint for deployment • Target requirements starting at 128 KB RAM, 1 MB Flash/ROM Target Markets 6 • Small to mid-embedded covering wide range of use cases/markets • Intelligent edge devices, communication nodes, healthcare devices, smart sensors, smart meters, general IoT and M2M Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Java ME 8 Focus Platform Footprint Java SE Java ME 10MB-100MB 1MB-10MB Java Card 50KB-1MB ARM 7 Cortex M ARM9/11 7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. MIPS32 - ARM Cortex A – PPC - Intel Atom Device CPU/ GPU/I-O Towards a Common Java Ensure close alignment between ME/SE 8 Key Principles • • • • CLDC is a strict subset of Java SE CLDC code works on Java SE Java ME vs. Java SE is a footprint/functionality tradeoff Java ME & Java SE release cycles are in sync Benefits • • • • Modern and flexible platform for delivering embedded software Unified development experience & community across Java Aligned Java language, core APIs, development, and tools Enable 9+ Million Java developers to develop for Java Embedded Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Java ME 8 Platform Overview Additional APIs (Examples) Messaging Wireless Communication Protocols and Data Conversion Security and Management Additional Optional APIs Location Web Services Sensors Additional Optional JSRs Vertical Specific APIs On-Device I/O Access Device I/O API Generic Connection Framework Java VM 9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. GCF Application Platform Java ME Embedded Profile (MEEP 8, JSR 361) Security and Trust Services Java ME CLDC 8 (JSR 360, aligned with Java SE 8) SATSA Constraints of small embedded devices An embedded device is not a PC • • • • • • • • • • • 10 Low cost Small Memory footprint (512k - several MB) Limited CPU horsepower Many devices have no display, no mouse, no keyboard No PC user interface UI often based on task-oriented direct manipulation sensors Very few external interfaces Small or no persistent storage (disk, flash memory) Typically very limited OS Typically dedicated use case, not a general purpose device Low power Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Sample prototyping board Small Embedded STM32F4 Discovery Board (Very Low Cost, ca. 15 USD) STM32F407VGT6 microcontroller – 32-bit ARM Cortex-M4F core – 1 MB Flash – 192 KB RAM 3-axis accelerometer Omni-directional digital microphone Audio DAC with integrated class D speaker driver Eight LEDs, two push buttons (user and reset) USB OTG FS with micro-AB connector Source: http://www.st.com/st-web-ui/static/active/en/resource/technical/document/data_brief/DM00037955.pdf 11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Sample prototyping board Small Embedded Raspberry Pi (Low Cost, ca. 25 USD) Broadcom BCM2835 – 700 MHz ARM1176JZF-S core – 512 MB RAM 2 USB ports SD card slot Onboard Network Audio / Video output 12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Program Agenda Java ME Evolution Connected Limited Device Configuration (CLDC) Generic Connection Framework (GCF) 13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. CLDC 8: an Evolutionary update for CLDC • Key Features • Synchronize with Java SE 8 Language Features into Java ME • Add developer friendly APIs to Java ME from Java SE • Virtual Machine Update to align with developer tools • Remain small and enable footprint optimizations • Specification Characteristics • CLDC 8 is an extended strict subset of Java SE 8 • Consolidated Generic Connection Framework • Backward binary compatibility 14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Java SE 8 CLDC 8 CLDC 8 architecture GCF 8 Multicast Secure Datagram Modem Connection HTTP HTTPS Socket Server Socket Datagram CLDC 8 NIO files Compact Configuration NIO channels NIO buffers java.lang java.io Logging Java VM 15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. java.security java.util Configurations CLDC is scalable to small and very small devices 16 The “CLDC Configuration” is the complete set of CLDC APIs Provides maximum functionality for applications Typical CLDC platform footprint is 1-2 MB ROM The CLDC Compact Configuration defines a subset for very small target platforms Omits Logging, NIO Files, and NIO Channels Tailored for very constrained devices (512 K ROM) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. CLDC 8 Footprint Considerations Optimizing Footprint Even Further Stripping On Deployment – For fixed-function, minimal footprint deployments – Allows bundling application with the runtime and then stripping away unnecessary components – Result: Minimal, non-modifiable binary containing application and runtime 17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New Java Language Features Assertions • private void setInterval(int interval) { assert interval > 0 && interval <= 1000 : "Invalid value?”; } Generics • Added support for AbstractCollection, AbstractList, AbstractSet, Collection, Collections, Enumeration, Iterator, List, ListIterator Enhanced for Loop Autoboxing 18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. • void processList(Vector<String> list) { for (String item : list) { ... } •Hashtable<Integer, String> data = new Hashtable<>(); void add(int id, String value) { data.put(id, value); } New Java Language Features Enumerations Varargs Static imports Annotations 19 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. •enum Season {WINTER, SPRING, SUMMER, FALL}; private Season season; void setSeason(Season newSeason) { season = newSeason; •void warning(String format, String... parameters) { for(String p : parameters) { process(p); } } • import static data.Constants.RATIO; ... double r = Math.cos(RATIO * theta); •SuppressWarnings, Deprecated, Override @Deprecated public void clear(); •(JLS 7 section 9.6.3.2 @Retention - SOURCE retentions policy only.) New Java Language Features Strings in switches Binary integral literals and underscores in numeric literals Multi-catch and more precise rethrow Improved Type Inference for Gen. Instance Creation (diamond) Try-with-resources statement 20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. • switch (arg) { case "-data": ... case "-out": ... • long mask = 0xfff0_ff08_4fff_0fffl; byte flags = 0b01001111; •catch (IOException | InterruptedException ex) { logger.log(ex); throw ex; • Hashtable<String, String> map = new Hashtable<>(); •try (DataInputStream is = new DataInputStream(...)){ return is.readDouble(); } Library Updates CLDC Library – Platform extensibility via Service Providers (ServiceLoader) – EventObject and EventListener – Subset of NIO Buffers – NIO Files and NIO Channels – Logging – StringBuilder and String Formatter – Comparable interface – Try with resources – Closeable and AutoCloseable 21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Library Updates New Collections – List – ArrayList, LinkedList – Map – HashMap, LinkedHashMap, WeakHashMap – Set – HashSet, LinkedHashSet – Queue – Deque, ArrayDeque – Iterable and Iterator, ListIterator 22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Focus on: Service Providers An extension mechanism for the Java platform A service is a well-known set of interfaces and abstract classes that is implemented by a (service) provider. Providers can be installed to extend the Java platform. Providers are located and instantiated on demand. Providers are identified via a provider-configuration file in the META-INF/services resource directory. 23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Service Providers - Example An extension mechanism for the Java platform import com.XYZ.ServiceA; ServiceLoader<ServiceA> sl1= ServiceLoader.load(ServiceA.class); Resources: META-INF/services/com.XYZ.ServiceA: ServiceAProvider1 ServiceAProvider2 ServiceAProvider3 META-INF/services/ServiceB: ServiceBProvider1 ServiceBProvider2 24 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. com.XYZ.ServiceA ServiceA Provider1 ServiceB ServiceA Provider3 ServiceB Provider1 ServiceA Provider3 ServiceB Provider2 Updates to CLDC Virtual Machine CLDC 8 supports the Java VM Specification for SE 7 with some limitations • Target devices are not able to support InvokeDynamic • No support for reflection or retention of runtime annotations Verification by Type Checking • For classfile versions 51 and 52 • without a preverifier Legacy Verification (Preverifier) • For classfile versions 48 and older 25 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Unsupported Java SE 8 Features No reflection No serialization No InvokeDynamic/Lambda expressions No JNI and application native code No User-defined class loaders No runtime annotations No thread groups and daemon threads No concurrency utilities Limited Math APIs (No BigDecimals) Limited security APIs Limited collection APIs (No sorted collection classes) 26 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. CLDC Summary Language Alignment with SE 8 VM Alignment with SE 8 Library Alignment with SE 8 Compact Configuration for very small devices GCF 8 to provides flexible networking Developer leverage to tools, apis and knowledge 27 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Program Agenda Java ME Evolution Connected Limited Device Configuration (CLDC) Generic Connection Framework (GCF) 28 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Generic Connection Framework (GCF) Consolidates GCF specification from CLDC, MIDP, CDC, and JSR 197 • Consistent IPv6 support • Generic ConnectionOption mechanism to parameterize connections • Permissions apply per protocol • Extended failure information via exceptions from java.net New and enhanced protocols • File support via StreamConnection • IP Multicast • Latest version of security protocols via TLS 1.2 • Secure datagram connection via DTLS 1.2 • Modem connection enhances CommConnection with control of hardware handshake 29 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Generic Connection Framework (GCF) 30 CLDC CLDC 8 DatagramConnection ContentConnection InputConnection OutputConnection StreamConnection SecureServerConnection SecureDatagramConnection ModemConnection UDPMulticastConnection CommConnection HttpConnection HttpsConnection SecureConnection ServerSocketConnection SocketConnection UDPDatagramConnection Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features IPv6 • GCF consistently supports IPv6 addresses • The value of the host field on Connector.open must be a symbolic hostname, an IPv4 address or an IPv6 address surrounded by square brackets ('[', ']’). • datagram://[2001:db8::7]:4567 • multicast://[FF0X::101]:4444 31 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features UDP Multicast • GCF includes support for UDP Multicast • 1 to n communication of UDP datagrams • Multicast is important for distributed services: Used for service announcement and discovery, media streaming • Dynamic Discovery for configuration and rendezvous (mDNS, Bonjour) • The new protocol class UDPMulticastConnection enables • Client and server scenarios • Joining multicast groups • Creating a multicast server socket 32 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features TLS protocol enhancements • SecureConnection and SecureServerConnection support TLS 1.2 • SecureServerConnection provides the server-side of a TLS connection • Both can be parameterized to: • Select a set of cipher suites • Select a minimum protocol version • Request client authentication 33 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features DTLS protocol support for TLS over UDP • SecureDatagramConnection provides client-side support for DTLS • It can be parameterized to: • Select a set of cipher suites • Select a minimum protocol version • Request client authentication 34 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features NetworkUtilities • Utility functions for name lookup, reverse name lookup and for testing the reachability of a host (ping): • getCanonicalHostName(String host) • isReachable(String host, int ttl, int timeout) • getByName(String host) 35 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features Modem Connection • Purpose: monitor and control the signal lines of a serial interface • Getter and setter for the line mode (input/output) • Getter and setter for the line state • Listener for changes to the state of an input line 36 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features Additional protocol parameters ConnectionOptions • Type-safe mechanism for protocol-specific additional parameters • Useful for selecting access points, proxy settings, proprietary protocol extensions • Multiple connection options can be used with varargs Example •ConnectionOption <String> keep = new ConnectionOption<> ("KeepAlive", "KEEP_ALIVE"); ConnectionOption <Integer> port = new ConnectionOption<>("ProxyPort", 80); Connection c = Connector.open(“my.server.com”, keep, port) 37 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features: Access Point Selecting a Network Access Point The AccessPoint API enables: – Obtaining a list of available network access points – Querying the access technology (e.g. 3GPP, CDMA, Wi-Fi, Wired) – Getting Access-point technology-specific properties (e.g. 3GPP country code, network code) – Selection of an access point for a connection – Detection of connect/disconnect situations 38 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. New GCF Features: Access Point Example AccessPoint aps[] = AccessPoint.getAccessPoints(true); AccessPoint ap = aps[0]; // attach an event listener to the first access point ap.addListener(new AccessPointListener() { public void notifyEvent(AccessPoint accessPoint, int eventType) { if ((eventType == AccessPointListener.EVENT_TYPE_AVAILABLE)) System.out.println(“signalstrength = ”+ ap.getProperty(“signalstrength")); } }); // select the first access point for communication ConnectionOption<String> id = new ConnectionOption<>("AccessPoint”, ap.getId()); Connection c = Connector.open("http://www.oracle.com/index.html", id); 39 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Development Tools for CLDC 8 Standard JDK 7 or 8 tools can be used for application development Embedded-specific hints & warning messages – Provides developer with additional information to optimize code Debug structures are optional – Debug features can be ignored/filtered out to save footprint Future tools under consideration may include – Optimizing converter/compiler plugin for optimizing CLDC 8 applications Integrated with Java ME SDK and IDEs 40 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Java ME 8 - JCP Activities and Schedule JSR 360: CLDC 8 – EG Kick-off: February 2013 – Early Draft: May 2013 – Public Review: September 2013 – Final Draft: December 2013 JSR 361: Java ME Embedded Profile – On Parallel Schedule 41 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Summary CLDC 8 New and Improved Long anticipated updates to CLDC to align with SE 8 features Created for resource constrained devices Library updates – Collection API updates – NIO Buffers, NIO Files, NIO Channels, Logging – Service Loader Consolidated GCF Connections – Plus Multicast connection, Connection options, IPV6 – Secure Server Socket and Secure Datagrams Tools and support for embedded platforms 42 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. References and Related Sessions CLDC8 – www.jcp.org/en/jsr/detail?id=360 Java.net project – java.net/projects/jsr360 Related sessions: – MEEP: A New Java Profile for the Embedded World [CON5330] – Oracle Java ME Embedded: Small Embedded with Big Opportunities [CON2796] – Java ME 8 Overview: A New Platform for Embedded Development for Small Devices [CON2267] 43 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 44 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Graphic Section Divider 45 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 46 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.