java me api next

44
Java API ME next Otávio Santana @otaviojava [email protected] [email protected]

Upload: otavio-goncalves-de-santana

Post on 21-Jan-2017

382 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Java ME API Next

Java API ME next

Otávio Santana @otaviojava

[email protected]@apache.org

Page 2: Java ME API Next

OpenJDK

• Java 7• Java 8• Java 9

Page 3: Java ME API Next

OpenJDK

hg clone http://hg.openjdk.java.net/jdk9/jdk9 jdk_1_9sh ./get_source.sh./configuremake install

Page 4: Java ME API Next

Launched the Java 8

● Lambda● Metaspace● Stream

Page 5: Java ME API Next

Java 9

● Build: 85● https://jdk9.java.net/download/● Java 8 faster

Page 6: Java ME API Next

Java 9

Reflections wrappers Regex Security Core0

50

100

150

200

250

Java 8 - Process

Java 9 -Process

Java 8 - Memory

Java 9 -Memory

Page 7: Java ME API Next

Improvements in GC

● Remove GC combinations deprecated ● Strings Deduplication● Segmented Code Cache● Shenandoah

Page 8: Java ME API Next

Strings duplication

● 25% of Heap are Strings● 13.5% String duplicates

75

25

Heap

Another objects String

85

15

String inside Heap

String Strings duplicates

Page 9: Java ME API Next

Segmented Code Cache

● JVM internal (non-method) code● Profiled-code● Non-profiled code

Page 10: Java ME API Next

JigSaw

● Scalable● Performance● Small computing devices

Page 11: Java ME API Next

Java ME

● Java ME 8.2● 2015● Language Improvements

Java ME 8Java ME 8

Java SE 8

Language

Page 12: Java ME API Next

News Features

● Collections● Generics● AutoBoxing● Enum● Try with

resources● LoggingJava ME 8

Java SE 8

API

Page 13: Java ME API Next

But still hasn't

● BigDecimal● Reflection● DI● Lambda● Streams

Java ME 8

Java SE 8

API

Page 14: Java ME API Next

Zero-Assembler Project

● Portability● C++● Processor

Architecture

Java SE 8

Page 15: Java ME API Next

Shark

● LLVM-based JIT● Panama● JEP 191

Java SE 8

Page 16: Java ME API Next

AArch64 Port Project

● 64-bit mode of ARMv8

● Panama● JEP 191

Java SE 8

Page 17: Java ME API Next

JVM on Modules

● Modules● Profiles

Java SE 8

Page 18: Java ME API Next

Mobile OpenJDK

● Java 9● Java 8's

compact2

Java SE 8

Page 19: Java ME API Next

Mobile OpenJDK

● iOS x64 and arm64● Android x86 and

arm32● Windows 10 x64

Surface Pro● JavaLauncher helper

interface

Java SE 8

Page 20: Java ME API Next

Java

● Java ME● Java Embedded● OpenJDK Mobile● Java SE

Java SE 8

Page 21: Java ME API Next

Measurement API

● Work with Measure● Standardize measure unit● Format● Operations (convert, add, subtract)

Page 22: Java ME API Next

Measurement API

5,898 ??????A Measurement

A UnitLondon

São Paulo

Page 23: Java ME API Next

Measurement API

int distance = 5898; //in milesfloat speed = airplane.getSpeed(); //in km/hSystem.out.println(“ETA: “ + (distance/speed) + “ hours”);

int distance = 5898; //in milesfloat speed = airplane.getSpeed(); //in km/hSystem.out.println(“ETA: “ + (distance/speed) + “ hours”);

5,898 ??????A Measurement

A Unit

Page 24: Java ME API Next

Measurement API

LEARNING FROM THE PAST…

Page 25: Java ME API Next

Sea Level

Some real-life mishaps...

NASA “Star Wars” Initiative, 1983

Page 26: Java ME API Next

Some real-life mishaps...

NASA Mars Orbiter, 1999

“Preliminary findings indicate that one team used US/English units (e.g. inches, feet and pounds) while the other used metric units for a key spacecraft operation.”

Page 27: Java ME API Next

Conversion problems

These are examples of confusion on the units in application.

But there is also ambiguity on the unit itself:

10 Gallons … Gallon Dry / Gallon Liquid - Gallon US / Gallon UK

28 Days … Day Sidereal / Day Calendar

38 Degrees … Degree Celsius / Degree Fahrenheit / Degree Angle

And the wrong conversion factors:

static final double PIXEL_TO_INCH = 1 / 72;

double pixels = inches * PIXEL_TO_INCH;

Page 28: Java ME API Next

Measurement API

QuantityFactory<Mass> massFactory = QuantityFactoryProvider.getQuantityFactory(Mass.class);

Quantity<Mass> tenKilogram = massFactory.create(10, SI.KILOGRAM);

Page 29: Java ME API Next

Measurement API

QuantityFactory<Time> timeFactory = QuantityFactory.getInstance(Time.class);

Quantity<Time> m1 = timeFactory.create(40, MINUTE);

Quantity<Time> m2 = timeFactory.create(20, MINUTE);

Quantity<Time> h1 = m1.add(m2).to(HOUR); //1 hour

Page 30: Java ME API Next

Measurement API

QuantityFactory<Time> timeFactory = QuantityFactory.getInstance(Time.class);

Quantity<Time> m1 = timeFactory.create(1, DAY);

Quantity<Time> m2 = timeFactory.create(12, HOUR);

Quantity<Time> result = m1.add(m2); //1.5 day

Page 31: Java ME API Next

Measurement API

Quantity<Time> minutes = Quantities.getQuantity(15, SI.MINUTE);

Quantity<Time> hours = Quantities.getQuantity(18, SI.HOUR);

Quantity<Time> day = Quantities.getQuantity(1, SI.DAY);

Quantity<Time> seconds = Quantities.getQuantity(100, SI.SECOND);

List<Quantity<Time>> times = new ArrayList<>();

times.addAll(Arrays.asList(minutes, hours, day, seconds));

Page 32: Java ME API Next

Measurement API

List<Quantity<Time>> sortNaturalList = times.stream()

.sorted(QuantityFunctions.sortNatural())

.collect(Collectors.toList());

● seconds - 100 seconds

● minutes - 15 minutes

● hours - 18 hours

● day - 1 day

Page 33: Java ME API Next

Measurement API

List<Quantity<Time>> sortNaturalList = times.stream()

.sorted(QuantityFunctions.sortNaturalDesc())

.collect(Collectors.toList());

● day - 1 day

● hours - 18 hours

● minutes - 15 minutes

● seconds - 100 seconds

Page 34: Java ME API Next

Measurement API

times.add(Quantities.getQuantity(24, SI.HOUR));

Comparator<Quantity<Time>> sortNatural = QuantityFunctions.sortNatural();

Comparator<Quantity<Time>> sortSymbol = QuantityFunctions.sortSymbol();

List<Quantity<Time>> sortNaturaAndSymbolList = times.stream()

.sorted(sortNatural.thenComparing(sortSymbol)) .collect(Collectors.toList());

● seconds - 100 seconds

● minutes - 15 minutes

● hours - 18 hours

● day - 1 day

● dayInHour – 24 hours

Page 35: Java ME API Next

Measurement API

List<Quantity<Time>> greaterThanOneDay = times

.stream() .filter(QuantityFunctions.isGreaterThan(oneDay)).collect(Collectors.toList());

List<Quantity<Time>> greaterThanOneDay = times

.stream().filter(QuantityFunctions.isBetween(oneHour, oneDay)).collect(Collectors.toList());

Page 36: Java ME API Next

Measurement API

Mixing Filters

QuantityFunctions.isGreaterThan(oneDay).and(QuantityFunctions.fiterByUnit(SI.HOUR)));

QuantityFunctions.isGreaterThan(oneDay).or(QuantityFunctions.fiterByExcludingUnit(SI.DAY)));

Page 37: Java ME API Next

Measurement API

QuantitySummaryStatistics<Time> summary = times.stream().collect(QuantityFunctions.summarizingMeasure(SI.HOUR)); //result in hours

summary.getCount();

summary.getAverage();

summary.getMax();

summary.getMin();

summary.getSum();

Page 38: Java ME API Next

Measurement API

QuantitySummaryStatistics<Time> summaryDay = summary.to(SI.DAY);

summary.getMin(SI.MINUTE);

summary.getMax(SI.MINUTE);

summary.getSum(SI.MINUTE);

summary.getAverage(SI.MINUTE);

Page 39: Java ME API Next

Measurement API

Quantity<Time> t1 = timeFactory.create(1, DAY);

Quantity<Mass> m1 = timeFactory.create(12, KILOGRAM);

Quantity<Length> l1 = timeFactory.create(12, KILOGRAM);

t1.add(m1); //error

Quantity<Speed> s1 = l1.divide(t1).asType(Speed.class);

Page 40: Java ME API Next

Measurement API

● Acceleration ● Length● Angle● Area● Mass● Power

● Energy● Speed● Force● Temperature● Time● Information● Volume

And more! 52 quantities

Page 41: Java ME API Next

Measurement API

Package Description

javax.measure Core API interfaces (e.g. Dimension, Quantity, Unit)

javax.measure.format [optional] Interfaces for quantity/unit formatting and parsing

javax.measure.quantity [optional] Interfaces for quantity types (e.g. Mass, Length)

javax.measure.spi [optional] Service Provider Interface (implementation discovery)

Page 42: Java ME API Next

Measurement API

Quantity<Length> distance = Quantities.getQuantity(5898, US.MILE);Quantity<Speed> airplaneSpeed = getAirplaneSpeed();Quantity<Time> eta = (Quantity<Time>)distance.divide(airplaneSpeed);System.out.println(“ETA: “+ eta.to(SI.HOUR));

ETA: 10.54655… h

Quantity<Length> distance = Quantities.getQuantity(5898, US.MILE);Quantity<Speed> airplaneSpeed = getAirplaneSpeed();Quantity<Time> eta = (Quantity<Time>)distance.divide(airplaneSpeed);System.out.println(“ETA: “+ eta.to(SI.HOUR));

ETA: 10.54655… h

Page 43: Java ME API Next

JSR 377● dependency injection via JSR330● common application structure● application life-cycle● localized resources● resource injection● localized configuration● decouple state from UI (binding)● persistence session state (preferences)● action management● component life-cycle● light-weight event bus● honor threading concerns (specific to UI toolkit)● application extensibility via plugins (implies modularity)

Page 44: Java ME API Next

Thank you

Otávio Santana @otaviojava