Lombok: javac์—์„œ ํ™•์ธ๋˜์ง€ ์•Š์€ ์บ์ŠคํŠธ ๊ฒฝ๊ณ 

์— ๋งŒ๋“  2016๋…„ 01์›” 05์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: projectlombok/lombok

์ด ์ฝ”๋“œ๋Š” javac๋กœ ์ปดํŒŒ์ผํ•  ๋•Œ ๊ฒฝ๊ณ ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

public class WarningDemo {
    List<Integer> makeList() {
        return null;
    }

    @Getter(lazy=true) private final List<Integer> list = makeList();
}

-Xlint ํ•˜๋ฉด

src/WarningDemo.java:10: warning: [unchecked] unchecked cast
    @Getter(lazy=true) private final List<Integer> list = makeList();
    ^
  required: List<Integer>
  found:    Object

delomboked ์ฝ”๋“œ์—๋Š” @java.lang.SuppressWarnings("all") ๊ฐ€ ์žˆ์ง€๋งŒ ๋„์›€์ด ๋˜์ง€ ์•Š๊ฑฐ๋‚˜ ์ปดํŒŒ์ผ์ด ๋‹ค๋ฅด๊ฒŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ด๊ฒƒ์€ ์‹ค์ œ๋กœ ๋„์›€์ด ๋˜์ง€๋งŒ

 @Getter(lazy = true, onMethod = @__({@SuppressWarnings("all")}))

ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ "๋ชจ๋‘"๋Š” "๋ชจ๋‘"๋ฅผ ์˜๋ฏธํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ๋„ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

 @Getter(lazy = true, onMethod = @__({@SuppressWarnings({"unchecked", "all"})}))

๋ชจ๋“  3 ๋Œ“๊ธ€

์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

@Getter(lazy = true, onMethod = @__({@SuppressWarnings("unchecked")}))

์ด๊ฒƒ์€ ์‹ค์ œ๋กœ ๋„์›€์ด ๋˜์ง€๋งŒ

 @Getter(lazy = true, onMethod = @__({@SuppressWarnings("all")}))

ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ "๋ชจ๋‘"๋Š” "๋ชจ๋‘"๋ฅผ ์˜๋ฏธํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ๋„ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

 @Getter(lazy = true, onMethod = @__({@SuppressWarnings({"unchecked", "all"})}))
์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰