CON3736_Vandettex - ACTIVEevents.com

birdsowlΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 10 μήνες)

134 εμφανίσεις

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

1

CON3736: JDK 8 Compact Profiles
for Embedded and ADF
-
Mobile on
iOS

devices

Bob
Vandette

Java SE Mobile & Embedded Lead


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

3

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.



Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

4

Program Agenda


Compact Profiles Overview


Building Compact Profiles from
OpenJDK


Reference Implementation Details


Java SE Embedded Compact Profile Support


Creating Embedded Compact Profiles


Compact Profile based Products and Use Cases


Demos

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

5

Java SE 8 Compact Profiles


Three new Java SE Runtimes (Compact Profiles) in JDK 8


Described in
OpenJDK

Java Enhancement Proposal 161 (http://openjdk.java.net/jeps/161)


Java SE compatible subsets


Developers can choose an appropriate runtime based on the resources available in their
target hardware


Benefits


Significantly smaller base Java runtime


Platform for smaller FX only graphical UI stack


New tool for Java SE Embedded which allows selection of runtime options


Quicker download


Basis for Java ME / CDC Converged product


Similar to Foundation profile & optional packages


Enables migration of CDC headless applications

Profiles Introduction

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

6

Java SE 8 Compact Profiles

Profiles Introduction

SE Full JRE

Hotspot VM

Lang & Util Base Libraries

Other Base Libraries

Integration Libraries

UI & Toolkits

Optional Components

Hotspot VM

Base Compact1 Classes

SE 8 Compact
Profiles

Compact2 Class libraries

Compact3 Class libraries

1

2

3

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

7

Contents

compact1



Smallest set of API packages without omitting classes.
Logging and SSL included as they are expected to be
needed.



Provides migration path for applications that target
CDC/Foundation Profile

compact2



Adds XML, JDBC and RMI



Migration path from JSR
-
280, JSR
-
169 and JSR
-
66

compact3



Adds management, naming, more security, and the
compiler API



Intended for applications that require most of Java SE

Full Java SE



Adds Desktop APIs, Web Services and CORBA

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

8

Java SE

8 APIs


java.io

java.lang

java.lang.annotation

java.lang.invoke

java.lang.ref

java.lang.reflect

java.math

java.net

java.nio

java.nio.channels

java.nio.channels.spi

java.nio.charset

java.nio.charset.spi

java.nio.file

java.nio.file.attribute

java.nio.file.spi

java.security

java.security.cert

java.security.interfaces

java.security.spec

java.text

java.text.spi

java.time

java.time.chrono

java.time.format

java.time.temporal

java.time.zone

java.util

java.util.concurrent

java.util.concurrent.atomic

java.util.concurrent.locks

java.util.function

java.util.jar

java.util.logging

java.util.regex

java.util.spi

java.util.stream

java.util.zip

javax.crypto

javax.crypto.interfaces

javax.crypto.spec

javax.net

javax.net.ssl

javax.script

javax.security.auth

javax.security.auth.callback

javax.security.auth.login

javax.security.auth.spi

javax.security.auth.x500

javax.security.cert

java.rmi

java.rmi.activation

java.rmi.dgc

java.rmi.registry

java.rmi.server

java.sql

javax.rmi.ssl

javax.sql

javax.transaction

javax.transaction.xa

javax.xml

javax.xml.datatype

javax.xml.namespace

javax.xml.parsers

javax.xml.stream

javax.xml.stream.events

javax.xml.stream.util

javax.xml.transform

javax.xml.transform.dom

javax.xml.transform.sax

javax.xml.transform.stax

javax.xml.transform.stream

javax.xml.validation

javax.xml.xpath

org.w3c.dom

org.w3c.dom.bootstrap

org.w3c.dom.events

org.w3c.dom.ls

org.xml.sax

org.xml.sax.ext

org.xml.sax.helpers

java.lang.instrument

java.lang.management

java.security.acl

java.util.prefs

javax.annotation.processing

javax.lang.model

javax.lang.model.element

javax.lang.model.type

javax.lang.model.util

javax.management

javax.management.loading

javax.management.modelmbean

javax.management.monitor

javax.management.openmbean

javax.management.relation

javax.management.remote

javax.management.remote.rmi

javax.management.timer

javax.naming

javax.naming.directory

javax.naming.event

javax.naming.ldap

javax.naming.spi

javax.security.auth.kerberos

javax.security.sasl

javax.sql.rowset

javax.sql.rowset.serial

javax.sql.rowset.spi

javax.tools

javax.xml.crypto

javax.xml.crypto.dom

javax.xml.crypto.dsig

javax.xml.crypto.dsig.dom

javax.xml.crypto.dsig.keyinfo

javax.xml.crypto.dsig.spec

org.ietf.jgss

java.applet

java.awt .**(13 packages)

java.beans

java.beans.beancontext

javax.accessibility

javax.activation

javax.activity

javax.annotation

javax.imageio

javax.imageio.event

javax.imageio.metadata

javax.imageio.plugins.bmp

javax.imageio.plugins.jpeg

javax.imageio.spi

javax.imageio.stream

javax.jws

javax.jws.soap

javax.print

javax.print.attribute

javax.print.attribute.standard

javax.print.event

javax.rmi

javax.rmi.CORBA

javax.sound.midi

javax.sound.midi.spi

javax.sound.sampled

javax.sound.sampled.spi

javax.swing.** (18 packages)

javax.xml.bind

javax.xml.bind.annotation

javax.xml.bind.annotation.adapters

javax.xml.bind.attachment

javax.xml.bind.helpers

javax.xml.bind.util

javax.xml.soap

javax.xml.ws

javax.xml.ws.handler

javax.xml.ws.handler.soap

javax.xml.ws.http

javax.xml.ws.soap

javax.xml.ws.spi

javax.xml.ws.spi.http

javax.xml.ws.wsaddressing

org.omg.** (28 packages)

compact1

compact1

compact2

compact2

compact3

compact3

Full Java SE

http://openjdk.java.net/jeps/161

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

9

More on Contents


Aside from APIs, no sub
-
setting of JLS, JVMS or other specifications


API packages for all types referenced in JLS for Java SE 8 are in compact1


Aside from API wrinkles below, the contents of each API packages is identical to the full
Java SE platform


No super
-
setting, no sub
-
setting


API wrinkles to deal with dependency on java.beans


The following 6 methods are not present in subset Profiles:

java.util.logging.LogManager.addPropertyChangeListener

java.util.logging.LogManager.removePropertyChangeListener

java.util.jar.Pack200.Packer.addPropertyChangeListener

java.util.jar.Pack200.Packer.removePropertyChangeListener

java.util.jar.Pack200.Unpacker.addPropertyChangeListener

java.util.jar.Pack200.Unpacker.removePropertyChangeListener


The 6 methods are

deprecated
in Java SE 8


The 6 methods are proposed to be removed in a future release

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

10

Profiles builds


New Linux
-
only “profiles” make target


Creates 3 compact profile images


JRE layout


Not upgradable
-

can't add to compact1 image to get compact2 for example


Different class files


Build
generates sun.misc.Version for each profile


Build runs tool to remove add/removePropertyChangeListener methods

so different
LogManager, Packer, Unpacker classes

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

11

$ hg fclone
http://hg.openjdk.java.net/jdk8/jdk8/

$
cd

jdk8

$
make images
profiles

:

## Finished profiles (build time 00:00:27)


-----

Build times
-------

Start 2013
-
03
-
17 14:47:35

End 2013
-
03
-
17 14:58:26

00:00:25 corba

00:00:15 demos

00:01:50 hotspot

00:00:24 images

00:00:21 jaxp

00:00:31 jaxws

00:05:37 jdk

00:00:43 langtools

00:00:18 nashorn

00:00:27 profiles

00:10:51 TOTAL

-------------------------

Finished building Java(TM) for target 'images profiles'


$ cd images

$ ls
-
d *image

j2re
-
compact1
-
image j2re
-
compact2
-
image j2re
-
compact3
-
image

j2re
-
image j2sdk
-
image

Building Linux x86 Compact Profiles

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

12

Profiles configuration in build


Profile contents defined in
:


jdk/makefiles/profiles
-
includes.txt


jdk/makefiles/profiles
-
rtjar
-
includes.txt


May need to update when adding new API packages or doing other maintenance


Profiles builds runs a simple

dependency
analyzer to check images


Checks for references to types that do not exist


Checks both boot class path and JAR files in extensions directory


Build fails if reference to unknown type found


refs.allowed

file for cases where this is necessary (jsse.jar for example)


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

13

$
make profiles

:

Creating rt.jar profile_1 Compressed=false

Creating resources.jar

Updating rt.jar profile_1

Analyzing /u/alanb/ws/tl/build/linux
-
x86_64
-
normal
-
server
-
release/images/j2re
-
compact1
-
image/lib/rt.jar

Analyzing /u/alanb/ws/tl/build/linux
-
x86_64
-
normal
-
server
-
release/images/j2re
-
compact1
-
image/lib/tzdb.jar

Analyzing /u/alanb/ws/tl/build/linux
-
x86_64
-
normal
-
server
-
release/images/j2re
-
compact1
-
image/lib/resources.jar

Analyzing /u/alanb/ws/tl/build/linux
-
x86_64
-
normal
-
server
-
release/images/j2re
-
compact1
-
image/lib/jce.jar

Analyzing /u/alanb/ws/tl/build/linux
-
x86_64
-
normal
-
server
-
release/images/j2re
-
compact1
-
image/lib/jsse.jar

java.lang.Thread
-
> java.lang.management.ThreadMXBean (unknown type)

One or more unexpected references encountered

Check /u/alanb/ws/tl/jdk/make/build/tools/deps/refs.allowed is up to date

make[2]: *** [/u/alanb/ws/tl/build/linux
-
x86_64
-
normal
-
server
-
release/images/libprofile_1/_jars_checked] Error 255

make[1]: *** [profile_1] Error 2

make: *** [profiles
-
only] Error 2


Suppose we add a method to java.lang.Thread that returns a
java.lang.management.ThreadMXbean (compact3)


Keep module graph in mind when adding new dependencies


When in doubt, ask!

Breaking the build

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

14

Identification


No API or system property to identify profile at runtime
-

this is deliberate!


Easy for tests to use reflection to determine profile at runtime if needed


Applications that make optional use of APIs can use reflection guard to check if type
exists before using it.


Profile name in java
-
version output and release file

$ java
-
version

Java(TM) SE Runtime Environment (build 1.8.0
-
internal, profile
compact1
)

Java HotSpot(TM) 32
-
Bit Client VM (build 25.0
-
b22, mixed mode)


$ cat j2re
-
compact1
-
image/release

JAVA_VERSION="1.8.0"

OS_NAME="Linux"

OS_VERSION="2.6"

OS_ARCH="i586"

JAVA_PROFILE="compact1"


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

15

Compiling with javac


Compile against target runtime with
javac


bootclasspath
, or


javac


profile <profile>


15

$
javac
-
profile compact2

Test.java

Test.java:7: error: ThreadMXBean is not available in profile 'compact2'


ThreadMXBean bean = ManagementFactory.getThreadMXBean();


^

Test.java:7: error: ManagementFactory is not available in profile 'compact2'


ThreadMXBean bean = ManagementFactory.getThreadMXBean();



^

2 errors


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

16

16

NetBeans

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

17

Analyzing existing code/libraries with jdeps

$ jdeps

Usage: jdeps <options> <classes...>

where <classes> can be a pathname to a .class file, a directory, a JAR file,

or a fully
-
qualified classname or wildcard "*". Possible options include:


-
s
--
summary Print dependency summary only


-
v
--
verbose Print additional information


-
V <level>
--
verbose
-
level=<level> Print package
-
level or class
-
level dependencies


Valid levels are: "package" and "class"


-
c <path>
--
classpath=<path> Specify where to find class files


-
p <pkg name>
--
package=<pkg name> Restrict analysis to classes in this package


(may be given multiple times)


-
e <regex>
--
regex=<regex> Restrict analysis to packages matching pattern


(
-
p and
-
e are exclusive)


-
P
--
profile Show profile or the file containing a package


-
R
--
recursive Recursively traverse all dependencies


--
version Version information

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

18

javadoc/
doclet

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

19

Products derived from Java SE 8 sources

JDK8

repositories

Standard Java
SE 8
distributions

Java SE 8
Profiles RI

Java SE
Embedded 8
w
/Profiles

ADF Mobile
[future]

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

20

Java SE 8 Compact Profiles

Reference Implementation (RI) versus Embedded


RI


Compact Profiles Reference Implementation


Implementation of Compact Profiles Only


No Embedded Features or addition size reductions


Linux x86 only


Embedded Compact Profiles


Commercial Product


Size reduced
JREs

are possible


Embedded JRE customization tool provided (
jrecreate
)


Additional reductions can be applied using tool


Minimal VM available in bundle (3MB VM versus 6
-
9MB)


Multiple architectures supported (ARM (3), PPC (2), x86)


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

21

Java SE 8 Compact Profiles

Bundle types

Java SE 8 Embedded Bundles

Description

ejdk
-
8
-
ea
-
b104
-
linux
-
arm
-
vfp
-
hflt
-
14_sept_2013.tar.gz

The “embedded” Java development Kit.
Bundle containing all profiles, full
jre

and
customization tool (
jrecreate
).

New embedded bundle available for
external download.

jre
-
8
-
ea
-
b104
-
compact1
-
linux
-
i586
-
14_sept_2013.tar.gz

jre
-
8
-
ea
-
b104
-
compact2
-
linux
-
i586
-
14_sept_2013.tar.gz

jre
-
8
-
ea
-
b104
-
compact3
-
linux
-
i586
-
14_sept_2013.tar.gz


Compact Profile Reference
Implementation bundles. There
are pre
-
generated
bundles for compact1,
compact2 and compact3.

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

22

Java SE 8 Embedded Profiles

ejdk1.8.0

ejdk1.8.0/bin









jrecreate script

ejdk1.8.0/lib












JRECreate.jar

ejdk1.8.0/{arch}










ejdk1.8.0/{arch}/compact1

ejdk1.8.0/{arch}/compact2

ejdk1.8.0/{arch}/compact3

ejdk1.8.0/{arch}/jre

ejdk1.8.0/{arch}/extensions





optional components




What’s an
ejdk
? Java SE Embedded Download Package Contents

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

23

Java SE 8 Embedded Compact Profiles

Process used to create custom Java Embedded 8 Runtimes

Download

EJDK

Execute

jrecreate

Custom

Embedded

JRE

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

24

Java SE 8 Embedded Profiles

jrecreate tool

jrecreate option

Details

-
?,
-
h,
--
help

Displays help message

-
d,
--
dest

Specifies the target Java Runtime directory

-
g,
--
debug

Include Java level debugging support.

--
ejdk
-
home <File:path>

Specify the path to the root of the ejdk distribution

-
k,
--
keep
-
debug
-
info

Do not strip debug attributes from class/jar files during JRE generation

-
n,
--
dry
-
run

Dry run the requested operation

-
p,
--
profile <name>

Specify one of the profiles to be generated. Valid profile names are: compact1, compact2, compact3

If no profile option is specified, a full JRE will be created.

-
v ,
--
verbose

Enable verbose output

--
vm <string>

Specify the VM to be used in the target runtime. Valid options are: minimal, client, server, all. More than one
VM can be selected. The default is minimal for compact1 and 2, client for compact3, all for jre.

-
x,
--
extension <name>

Select optional components to be included in generated runtime. Valid values are:
fx:graphics
,
fx:controls
,
sunec
, sunpkcs11, locales,
charsets
,
nashorn
.

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

25

Java SE 8 Embedded Profiles

To create the smallest JRE (~12MB) into /
home/myjre/smallest
-
jre


%
sh

jrecreate.sh

-
d

/
home/myjres/smallest
-
jre


vm

minimal
--
profile compact1


To create a traditional full JRE in /
home/myjre/full
-
jre

with the server VM


%
sh

jrecreate.sh

-
d

/
home/myjre/full
-
jre


vm

server

Example of jrecreate use

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

26

Java SE 8 Embedded Profiles

Currently Supported Platforms and Releases

Embedded Compact
Profile Platforms

Linux x86

Linux ARM soft float

Linux ARM VFP soft float

Linux ARM VFP hard float

Linux Power PC

Linux Power PC e500v2

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

27

Java SE 8 Embedded Profiles


Optional components that can be
added to any compact profile


FX embedded graphics stack


Localization support


Optional security providers


Debugging/Profiling support (JVMTI)


Nashorn

JavaScript Engine

Optional Components

Java FX Embedded

Minimal Hotspot VM

Compact1 Profile

Embedded Java FX App

FX Embedded Example

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

28

Embedded Specific Graphic Stack


Enable Java SE deployments on
smart graphical embedded
devices


Provide high quality (GPU
accelerated) graphics stack for
resource constrained devices


Provide a common graphics
architecture across all Java SE
platforms

Goals

FX Component

Embedded?

Base

Yes

Graphics

Yes

Controls

Yes

FXML

Yes, compact2+

Web

Not yet

Media

Not yet

Swing

No

SWT

No

Even FX has Profiles

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

29

Java SE 8 Compact Profiles Sizes

Current Static Footprint Sizes (JDK 8 B104)

Compact1

Compact2

Compact3

Full

JRE

Java SE Embedded 8

Linux x86


VM

11MB



Minimal

15MB



Minimal

21MB



Client

49MB



Client

Java SE Embedded 8
Linux ARM hard
-
float


VM

11MB



Minimal

15MB



Minimal

20MB



Client

48MB



Client

Java SE 8 Linux x86

Reference Implementation


VM

16MB



Client

23MB



Client

27MB



Client

97MB



Client

Headless

compact1

10.4 MB

FX base graphics

7.8 MB

FX controls

2.2 MB

Total
w
/FX Base

Total + controls

18.2 MB

20.4 MB

Embedded

FX Size

arm hard
-
float

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

30

Java SE 8 Embedded Profiles

Graphics Footprint Savings over traditional SE Embedded

Swing/AWT/Java2D Classes

Hotspot VM

SE Embedded Runtime

Swing/AWT App

SE Embedded Graphics Stack

Java FX Embedded Runtime

Minimal Hotspot VM

Compact1 Profile

Embedded Java FX App

FX Embedded Stack

X Server

Desktop/Window/Session Managers

Native Toolkit & X11 Libraries

Linux Kernel + Framebuffer driver

OpenGLES2 Library

Linux Kernel + Framebuffer driver

52MB

18MB

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

31

Java SE 8 Embedded Profiles


Reference Platform


BeagleBoard XM with PowerVR SGx530 GPU


Sanity testing for portability on other platforms


Raspberry Pi


Freescale iMX53 & IMX6 boards


PandaBoard

FX Embedded Hardware Platforms

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

32

Compact Profile Use Case 1: Java SE Embedded 8

Java FX Embedded

Minimal Hotspot VM

Compact1 Profile

Java
FX

Kiosk App

Examples

Kiosks

Java Embedded Suite

Minimal Hotspot VM

Compact2
Profile

Home

Security

App

Home Gateway

Lighting

Control


App

Minimal Hotspot VM

Compact2 Profile

Electronic

Tollbooth


Vehicle

Detection

Provisioning

Support

HVAC

Control

App

Customer

Billing

Violator

Ticketing

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

33

VMChannel

Compact2

Profile

Minimum


VM

ADFMC
Framework

User
Java Code

UIView

Cordova

UIWebView

ADFMC
iOS

Framework

iOS

Java

SE Mobile 8
Components

Compact Profile Use Case 2: ADF Mobile

Future release of ADF
-
Mobile

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

34

Potential Use Case: App Store Deployment


Currently no support for Windows or Mac Compact Profiles


Would require compact profile implementation on these
OS’s


Could enable Application Store deployment


Apple OSX Store deployment


Windows 8 App Store deployment


Java SE 8 on Mobile devices


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

35

DEMO

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

36

Any

Questions?

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

37

Graphic
Section Divider