-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: The well-grounded java developer - Part 1
- Loading branch information
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
--- | ||
layout : wiki | ||
title : κΈ°λ³ΈκΈ°κ° ννν μλ° κ°λ°μ(The well-grounded java developer) | ||
summary : | ||
date : 2024-12-21 18:00:00 +0900 | ||
updated : 2024-12-21 18:00:00 +0900 | ||
tag : java | ||
toc : true | ||
public : true | ||
parent : [[how-to]] | ||
latex : true | ||
--- | ||
* TOC | ||
{:toc} | ||
|
||
# κΈ°λ³ΈκΈ°κ° ννν μλ° κ°λ°μ(The well-grounded java developer) | ||
|
||
## λͺ¨λ μλ° | ||
|
||
### μΈμ΄μ νλ«νΌ | ||
- μλ° μΈμ΄: μ μ νμ μ κ°μ²΄μ§ν₯ μΈμ΄. | ||
- μλ° νλ«νΌ: ν΄λμ€ νμΌ ννλ‘ μ 곡λ μ½λλ₯Ό λ§ν¬νκ³ μ€ννλ JVM | ||
|
||
μλ° μμ€ν μ κ°λ³ μ¬μ | ||
- JLS(Java Language Specification) | ||
- JVMSpec: νμ¬ JVMμ μ€ννλ λ° μμ΄μ μΈμ΄μ ꡬμ λ°μ§ μλλ€. | ||
|
||
λΆλ¦¬λ μ¬μμ΄ λͺ¨μ¬ μλ° μμ€ν μ ꡬμ±νλ μ리 | ||
- `.java` -(javac)-> `.class` -(class loader)-> `λ³νλ .class` -(interpreter)-> `μ€νμ½λ` -(JIT Compiler)-> `κΈ°κ³μ΄` | ||
- μλ°λ **μ»΄νμΌ μΈμ΄**μ΄λ©΄μ **μΈν°νλ¦¬ν° μΈμ΄**μ΄λ€. | ||
|
||
### λ¦΄λ¦¬μ¦ λ‘λ맡 | ||
|
||
![image](https://github.com/user-attachments/assets/6eaa7350-7a0b-40e3-8c78-223daa6e37a0) | ||
|
||
- 6κ°μλ§λ€ μ£Όμ λ¦΄λ¦¬μ¦ | ||
|
||
### ν₯μλ νμ μΆλ‘ | ||
|
||
- [LVTI Guide](https://openjdk.org/projects/amber/guides/lvti-style-guide) | ||
- λ¨μν μ΄κΈ°νμμ, μ€λ₯Έμͺ½μ΄ μμ±μ λλ μ μ ν©ν 리 λ©μλμ λν νΈμΆμΈ κ²½μ° | ||
- λͺ μμ νμ μ μ κ±°νλ©΄ λ°λ³΅λκ±°λ μ€λ³΅λ μ λ³΄κ° μμ λλ κ²½μ° | ||
- λ³μ μ΄λ¦λ§μΌλ‘λ νμ μ μ μ μλ κ²½μ° | ||
- λ‘컬 λ³μμ λ²μμ μ¬μ©λ²μ΄ μ§§κ³ κ°λ¨ν κ²½μ° | ||
|
||
type interface | ||
```java | ||
List<Integer> before = Collections.<Integer>emptyList(); | ||
List<Integer> after = Collections.emptyList(); | ||
``` | ||
|
||
diamond syntax | ||
```java | ||
Map<Integer, Map<String, String>> beforeUserLists = new HashMap<Integer, Map<String, String>>(); | ||
Map<Integer, Map<String, String>> afterUserLists = new HashMap<>(); | ||
``` | ||
|
||
lambda | ||
```java | ||
Function<String, Integer> lengthFn = s -> s.length(); | ||
``` | ||
|
||
LVTI, local variable type interface | ||
- λ‘컬 λ³μμ μ μΈλ§μ κ²μ¬νλ€. | ||
- μ μ½ μ‘°κ±΄ ν΄κ²° μκ³ λ¦¬μ¦μ μ μ©νλ€. | ||
```java | ||
var names = new ArrayList<String>(); | ||
``` | ||
|
||
Bad case | ||
```java | ||
public class Var { | ||
private static Var var = null; | ||
|
||
public static Var var() { | ||
return var; | ||
} | ||
|
||
public static void var(Var var) { | ||
Var.var = var; | ||
} | ||
} | ||
``` | ||
|
||
```java | ||
void var_test() { | ||
var var = Var.var(); | ||
if (var == null) { | ||
Var.var(new Var()); | ||
} | ||
} | ||
``` | ||
|
||
Fail example | ||
- μΆλ‘ μκ° ν΄κ²°ν΄μΌ νλ νμ μ μ½ μ‘°κ±΄ λ°©μ μμ **κ³Όμκ²°μ μ°λ¦½λ°©μ μ**μ΄λΌ νλ€. | ||
```java | ||
var fn = s -> s.length(); | ||
var n = null; | ||
``` | ||
|
||
Nondenotable type | ||
```java | ||
var duck = new Object() { | ||
void quack() { | ||
System.out.println("Quack!"); | ||
} | ||
}; | ||
|
||
duck.quack(); | ||
``` |