More Related Content Similar to Java Se next Generetion (20) More from Otávio Santana (20) Java Se next Generetion3. OpenJDK
hg clone http://hg.openjdk.java.net/jdk9/jdk9 jdk_1_9
sh ./get_source.sh
./configure
make install
6. Companies
AMD
Apple
Azul Systems, Inc.
Canonical
Google
IBM
Intel
Oracle
RedHat
SAP Software Company
Stratus
Twitter
8. Java 9
● Build: 31
● https://jdk9.java.net/download/
● Java 8 faster
9. Java 9
Reflections wrappers Regex Security Core
250
200
150
100
50
0
Java 8 - Process
Java 9 -Process
Java 8 - Memory
Java 9 -Memory
10. Improvements in GC
● Remove GC combinations deprecated
● Strings Deduplication
● Segmented Code Cache
● Shenandoah
11. Strings duplication
75
25
Heap
Another objects String
● 25% of Heap are Strings
● 13.5% String duplicates
String inside Heap
85
15
String Strings duplicates
15. News to coders
● Light Write and read to JSON
● Generics to primitives
● builders to Collections
● Literal to Collections
● Process API Updates
● Smart Java Compilation
● http 2.0 client
16. News
● List<String> list = List.of(a, b, c);
● Set<String> set = Set.of(d, e, f, g);
● Map<String,String> map =
Map.of(k1, V1);//not collection
● List<Integer> list = #[ 1, 2, 3 ];
17. Money Api
● Take care of money to you :)
● Formating
● Rounding
● Exchange Rate
18. Money Api
CurrencyUnit euro = MonetaryCurrencies.getCurrency("EUR");
MonetaryAmount money = Money.of(120, euro);
NumberValue number = money.getNumber();
BigDecimal value = number.numberValue(BigDecimal.class);
19. Money Api
CurrencyUnit dollar =
MonetaryCurrencies.getCurrency(Locale.US);
MonetaryAmount m = Money.of(120, dollar);
NumberValue number = m.getNumber();
BigDecimal value = number.numberValue(BigDecimal.class);
20. Money Api
MonetaryAmountFormat format =
MonetaryFormats.getAmountFormat(Locale.US);
String text = format.format(m);//12,50 USD
format =
MonetaryFormats.getAmountFormat(AmountFormatQueryBuild
er.create(Locale.US).set(CurrencyStyle.SYMBOL).build());
String text = format.format(m);//$123,456.56
21. Money Api
MonetaryAmount noMoney = Money.of(0, euro);
MonetaryAmount m1 = Money.of(10, euro);
MonetaryAmount m2 = Money.of(30, euro);
MonetaryAmount m3 = Money.of(40, euro);
List<MonetaryAmount> moneys = Arrays.asList(m1, m2, m3);
MonetaryAmount sum =
moneys.stream().reduce(MonetaryFunctions.sum()).orElse(noM
oney);
22. Welcome Lambda
List<MonetaryAmount> justDollar = moneys.stream()
.filter((MonetaryFunctions.isCurrency(DOLLAR)))
.collect(Collectors.toList());
List<MonetaryAmount> notEuro =
moneys.stream().filter((MonetaryFunctions.isNotCurrenc
y(EURO))).collect(Collectors.toList());
24. Welcome Lambda
List<MonetaryAmount> orderCurrencyValue =
moneys.stream().sorted(MonetaryFunctions.sortCurrenc
yUnit().thenComparing(MonetaryFunctions.sortNumber
())).collect(Collectors.toList());
List<MonetaryAmount> orderHighValue =
moneys.stream().sorted(MonetaryFunctions.sortCurrenc
yUnit().thenComparing(
MonetaryFunctions.sortCurrencyUnitDesc()))
.collect(Collectors.toList());
26. Welcome Lambda
MonetarySummaryStatistics summary =
getCurrencies().stream().collect(MonetaryFunctions.sum
marizingMonetary(DOLLAR));
GroupMonetarySummaryStatistics groupSummary =
getCurrencies().stream().collect(MonetaryFunctions.gro
upBySummarizingMonetary());
27. Welcome Lambda
MonetarySummaryStatistics summary = ...
MonetaryAmount min = summary.getMin();
MonetaryAmount max = summary.getMax();
MonetaryAmount sum = summary.getSum();
MonetaryAmount avarage = summary.getAverage();
Long count = summary.getCount();
29. Exchange Rate
MonetaryAmount m1 = Money.of(10, euro);
MonetaryAmount m2 = Money.of(30, dollar);
m1.add(m2); throw MonetaryException (“Currency mismatch...
30. Exchange Rate
ExchangeRateProvider provider =
MonetaryConversions.getExchangeRateProvider("ECB");
MonetaryAmount d2e =
provider.getCurrencyConversion(euro).apply(mDollar);
31. Exchange Rate
ExchangeRateProvider provider =
MonetaryConversions.getExchangeRateProvider("IMF");
MonetaryAmount d2e =
provider.getCurrencyConversion(euro).apply(mDollar);
32. Exchange Rate
List<MonetaryAmount> orderCurrencyValue =
moneys.stream().sorted(MonetaryFunctions.sortExcha
nge(provider).collect(Collectors.toList());
● 9 BRL
● 8 USD
● 7 EUR
● Because:
● 1 USD = 2.4203 BRL
● 1 USD = 2.4203 BRL
● 1 USD = 0.79 EUR
● 7 EUR
● 9 BRL
● 8 USD
33. Exchange Rate
MonetaryAmount sum =
moneys.stream().reduce(MonetafyFunctions.sum(provider
, DOLLAR)).orElse(noMoney);
MonetaryAmount min =
moneys.stream().reduce(MonetafyFunctions.min(provider
)).orElse(noMoney);
MonetaryAmount max =
moneys.stream().reduce(MonetafyFunctions.max(provide
r)).orElse(noMoney);
35. Measurement API
● Work with Measure
● Standardize measure unit
● Format
● Operations (convert, add, subtract)
37. 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
38. 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
39. 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));
40. 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
41. 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
42. 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
43. Measurement API
List<Quantity<Time>> greaterThanOneDay = times
.stream()
.filter(QuantityFunctions.isGreaterThan(oneDay)).collect(Collect
ors.toList());
List<Quantity<Time>> greaterThanOneDay = times
.stream().filter(QuantityFunctions.isBetween(oneHour,
oneDay)).collect(Collectors.toList());
44. Measurement API
Mixing Filters
QuantityFunctions.isGreaterThan(oneDay).and(QuantityFunctio
ns.fiterByUnit(SI.HOUR)));
QuantityFunctions.isGreaterThan(oneDay).or(QuantityFunction
s.fiterByExcludingUnit(SI.DAY)));
45. 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();
47. 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);
48. Measurement API
● Acceleration
● Length
● Angle
● Area
● Mass
● Power
● Energy
● Speed
● Force
● Temperature
● Time
● Information
● Volume
And more! 52 quantities
49. It isn't a Spoiler
Sunday, September 28
12:30 p.m.–3:00 p.m.
Moscone North, Hall D
Thursday, October 2
9:00 a.m.–10:45 a.m.
Marriott Marquis, Salon 7/8/9