View
2.782
Download
0
Category
Preview:
DESCRIPTION
Palestra sobre as Novidades do OpenJDK 7 apresentadas por Leandro Nunes no FISL 11.
Citation preview
2. whoami
3. Coordenador RSJUG 4. Blog
5. O projeto OpenJDK 6. O projeto OpenJDK
7. Libera o cdigo fonte da implementao de Java da Sun sob uma licena livre 8. Hoje isso uma realidade... 9. Project Coin 10. Configurao do NetBeans
11. Passos
12. Add Platform > Selecione o diretrio de instalao 13. Sources > Source/Binary Format: JDK 7 14. Configurao do NetBeans 15. Configurao do NetBeans 16. Project Coin
17. http://openjdk.java.net/projects/coin/ 18. Grande parte dessas mudanas j est disponvel nos builds de desenvolvimento 19. Nesta palestra, estamos usando o build de 15 de julho de 2010
20. Strings emswitch Strings="abc" ; switch( s ) { case"abc" : processAbc(s); break; case"def" : case"DEF" : processDef(s); break; case"ghi" : processGhi(s); default: processDefault(s); break; }
Disponvel 21. Verificao automtica denull s
String aMember = null; if (g != null && g.members != null && g.members[0].name != null ) { aMember = g.members[0].name; } else { aMember = "nobody"; } 22. Verificao automtica denull s
final StringaMember= g?.members?[0]?.name ?: "nobody"; Ainda no disponvel 23. Tipos Inteiros
24. Separadores para aumentar a legibilidade
Novos sufixos para inteiros
25. s: short 26. Representao de binrios
//equivalente ao numero 12, em decimal int numeroDecimal =12 ; int numeroBinario =0b1100 ; Disponvel 27. Separadores de inteiros
28. Destinam-se exclusivamente para aumentar a legibilidade int numeroDoTelefone =555_555_1212 ; int numeroDoCartao =5555_5555_5555_5555 ; Disponvel 29. Sufixos parabyteeshort
30. Para os tiposbytee short, a mudana explcita de tipo devia ser feita com casting Ainda no disponvel byte [] stuff = { (byte)0x80, (byte)0xFF}; byte [] java7 = { 0x80 y , 0xFF y}; 31. Sufixos parabyteeshort
32. Para os tipos byte eshort , a mudana explcita de tipo devia ser feita com casting short[] stuff = {(short) 0x80,(short) 0xFF}; short[] java7 = { 0x80 s , 0xFF s}; Ainda no disponvel 33. Declao de Generics Simplificada
Map >anagrams = new HashMap > (); Map >anagrams = new HashMap (); Disponvel 34. Acesso indexado listas e mapas
35. Map:myMap[keyObject] Ainda no disponvel 36. Inicializao de Collections
37. Na verso Java 7 fica assim.. final List piDigits = Collections.unmodifiableList( Arrays.asList(3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9) ); final ListpiDigits= [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9] ; Ainda no disponvel 38. Inicializao de Collections
final Map platonicSolids; static { solids = new LinkedHashMap; solids.put(4, "tetrahedron"); solids.put(6, "cube"); solids.put(8, "octahedron"); solids.put(12, "dodecahedron"); solids.put(20, "icosahedron") ; PlatonicSolids = Collections.immutableMap(solids); } 39. Inicializao de Collections final Map platonicSolids = { 4 : "tetrahedron", 6 : "cube", 8 : "octahedron", 12 : "dodecahedron", 20 : "icosahedron" }; Ainda no disponvel 40. Tratamento de Excees
} catch (Exception1 ex) { LOGGER.log(Level.SEVERE, ex); throw ex; } catch (Exception2 ex) { LOGGER.log(Level.SEVERE, ex); throw ex; } 41. Tratamento de Excees
} catch (Exception1 | Exception2 ex) { LOGGER.log(Level.SEVERE, ex); throw ex; } 42. Gerenciamento de recursos
static String readFirstLineFromFile(String path) throws IOException { BufferedReader br = new BufferedReader(new FileReader(path)); try { return br.readLine(); } finally { br.close(); } } 43. Gerenciamento de Recursos
44. Modificao no blocotry static String readFirstLineFromFile2(String path) throws IOException { try ( BufferedReader br = new BufferedReader(new FileReader(path) ){ return br.readLine(); } } Aqui o recurso automaticamente fechado Ainda no disponvel 45. Project Lambda 46. Project Lambda
47. http://openjdk.java.net/projects/lambda/ 48. Embora esteja nos builds de desenvolvimento, ainda poder sofrer mudanas 49. Project Lambda
Exemplo de expresses lambda simples # (int x) (2*x) # (int x, int y) (x+y) 50. Project Lambda
# (int x) (2*x) .(7) 51. Project Lambda
#int(int)doubler=# (int x) (2*x); int n =doubler .(3) ; //n = 6 Retorno Parametro 52. Project Lambda
#int(int, int)min=# (int x, int y){if (x
Recommended