java me api next
TRANSCRIPT
OpenJDK
• Java 7• Java 8• Java 9
OpenJDK
hg clone http://hg.openjdk.java.net/jdk9/jdk9 jdk_1_9sh ./get_source.sh./configuremake install
Launched the Java 8
● Lambda● Metaspace● Stream
Java 9
Reflections wrappers Regex Security Core0
50
100
150
200
250
Java 8 - Process
Java 9 -Process
Java 8 - Memory
Java 9 -Memory
Improvements in GC
● Remove GC combinations deprecated ● Strings Deduplication● Segmented Code Cache● Shenandoah
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
Segmented Code Cache
● JVM internal (non-method) code● Profiled-code● Non-profiled code
JigSaw
● Scalable● Performance● Small computing devices
Java ME
● Java ME 8.2● 2015● Language Improvements
Java ME 8Java ME 8
Java SE 8
Language
News Features
● Collections● Generics● AutoBoxing● Enum● Try with
resources● LoggingJava ME 8
Java SE 8
API
But still hasn't
● BigDecimal● Reflection● DI● Lambda● Streams
Java ME 8
Java SE 8
API
Zero-Assembler Project
● Portability● C++● Processor
Architecture
Java SE 8
Shark
● LLVM-based JIT● Panama● JEP 191
Java SE 8
AArch64 Port Project
● 64-bit mode of ARMv8
● Panama● JEP 191
Java SE 8
JVM on Modules
● Modules● Profiles
Java SE 8
Mobile OpenJDK
● Java 9● Java 8's
compact2
Java SE 8
Mobile OpenJDK
● iOS x64 and arm64● Android x86 and
arm32● Windows 10 x64
Surface Pro● JavaLauncher helper
interface
Java SE 8
Java
● Java ME● Java Embedded● OpenJDK Mobile● Java SE
Java SE 8
Measurement API
● Work with Measure● Standardize measure unit● Format● Operations (convert, add, subtract)
Measurement API
5,898 ??????A Measurement
A UnitLondon
São Paulo
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
Measurement API
LEARNING FROM THE PAST…
Sea Level
Some real-life mishaps...
NASA “Star Wars” Initiative, 1983
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.”
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;
Measurement API
QuantityFactory<Mass> massFactory = QuantityFactoryProvider.getQuantityFactory(Mass.class);
Quantity<Mass> tenKilogram = massFactory.create(10, SI.KILOGRAM);
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
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
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));
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
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
●
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
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());
Measurement API
Mixing Filters
QuantityFunctions.isGreaterThan(oneDay).and(QuantityFunctions.fiterByUnit(SI.HOUR)));
QuantityFunctions.isGreaterThan(oneDay).or(QuantityFunctions.fiterByExcludingUnit(SI.DAY)));
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();
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);
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);
Measurement API
● Acceleration ● Length● Angle● Area● Mass● Power
● Energy● Speed● Force● Temperature● Time● Information● Volume
And more! 52 quantities
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)
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
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)
Thank you
Otávio Santana @otaviojava