# [Effective Java] Item 3. private ์ƒ์„ฑ์ž๋‚˜ enum ํƒ€์ž…์œผ๋กœ ์‹ฑ๊ธ€ํ†ค์ž„์„ ๋ณด์žฅํ•˜์ž.
Study Repository

[Effective Java] Item 3. private ์ƒ์„ฑ์ž๋‚˜ enum ํƒ€์ž…์œผ๋กœ ์‹ฑ๊ธ€ํ†ค์ž„์„ ๋ณด์žฅํ•˜์ž.

by rlaehddnd0422

์‹ฑ๊ธ€ํ†ค์ด๋ž€?

์‹ฑ๊ธ€ํ†ค์ด๋ž€ ์ธ์Šคํ„ด์Šค๋ฅผ ๋‹จ 1๊ฐœ๋งŒ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ํด๋ž˜์Šค๋ฅผ ๋งํ•ฉ๋‹ˆ๋‹ค. 

ex) ๋ฌด์ƒํƒœ ๊ฐ์ฒด, ์„ค๊ณ„ ์ƒ ์œ ์ผํ•ด์•ผ ํ•˜๋Š” ์‹œ์Šคํ…œ ์ปดํฌ๋„ŒํŠธ (service, repository)

 


์‹ฑ๊ธ€ํ†ค ์žฅ์ 

  • ํ•œ ๋ฒˆ์˜ ๊ฐ์ฒด ์ƒ์„ฑ์œผ๋กœ ์žฌ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๋ฉ”๋ชจ๋ฆฌ ๋‚ญ๋น„๋ฅผ ์ค„์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์‹ฑ๊ธ€ํ†ค์œผ๋กœ ์ƒ์„ฑ๋œ ๊ฐ์ฒด๋Š” ์ „์—ญ์„ฑ์„ ๋„๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค๋ฅธ ๊ฐ์ฒด์™€ ๊ณต์œ ๊ฐ€ ์šฉ์ดํ•ฉ๋‹ˆ๋‹ค.

์‹ฑ๊ธ€ํ†ค ๋‹จ์ 

  • ํด๋ผ์ด์–ธํŠธ๋ฅผ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์–ด๋ ต์Šต๋‹ˆ๋‹ค.
  • private ์ƒ์„ฑ์ž๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ƒ์†์ด ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
  • ์„œ๋ฒ„์—์„œ ํด๋ž˜์Šค ๋กœ๋”๋ฅผ ์–ด๋–ป๊ฒŒ ๊ตฌ์„ฑํ•˜๊ณ  ์žˆ๋Š”์ง€์— ๋”ฐ๋ผ ๋˜๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ JVM์— ๋ถ„์‚ฐ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ ์‹ฑ๊ธ€ํ†ค ํด๋ž˜์Šค์—ฌ๋„ ํ•˜๋‚˜ ์ด์ƒ์˜ ์ธ์Šคํ„ด์Šค๊ฐ€ ๋งŒ๋“ค์–ด์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์ „์—ญ ์ƒํƒœ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ”๋žŒ์งํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค.
    • ์‚ฌ์‹ค ์•„๋ฌด ๊ฐ์ฒด๋‚˜ ์ž์œ ๋กญ๊ฒŒ ์ ‘๊ทผํ•˜๊ณ  ์ˆ˜์ •ํ•˜๊ณ  ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๋Š” ์ „์—ญ ์ƒํƒœ๋ฅผ ๊ฐ–๋Š” ๊ฒƒ์€ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋žจ์ด์—์„œ๋Š” ๊ถŒ์žฅ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์‹ฑ๊ธ€ํ†ค ๋งŒ๋“œ๋Š” ๋ฐฉ์‹ 1 - public static final

public class Elvis {

    public static final Elvis INSTANCE = new Elvis();
    private Elvis(){}
}
class ElvisTest {

    @Test
    void singleToneTest() {
        Elvis elvis = Elvis.INSTANCE;
        Elvis elvis2 = Elvis.INSTANCE;

        assertEquals(elvis, elvis2);
    }
}
  • ์ฒซ ๋ฒˆ์งธ ๋ฐฉ๋ฒ•์€, ํด๋ž˜์Šค ๋‚ด๋ถ€์— public static ๋ฉค๋ฒ„๋ฅผ ํ•˜๋‚˜ ์ž‘์„ฑํ•ด ๋‘๊ณ  final๋กœ ์„ค์ •ํ•˜์—ฌ ์‹ฑ๊ธ€ํ†ค์œผ๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.
    • ์—ฌ๊ธฐ์„œ private ์ƒ์„ฑ์ž๋Š” public static final ํ•„๋“œ์ธ Elvis.INSTANCE๋ฅผ ์ดˆ๊ธฐํ™” ํ•  ๋•Œ ๋”ฑ ํ•œ ๋ฒˆ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.
    • public์ด๋‚˜ protected ์ƒ์„ฑ์ž๊ฐ€ ์—†์œผ๋ฏ€๋กœ ๋‹ค๋ฅธ ํŒจํ‚ค์ง€์—์„œ ์ƒ์„ฑํ•  ์ˆ˜ ์—†์Œ์„ ๋ณด์žฅํ•ด์ฃผ๋ฉฐ, ์ดˆ๊ธฐํ™” ํ•  ๋•Œ ๋”ฑ ํ•œ ๋ฒˆ ํ˜ธ์ถœํ•จ์œผ๋กœ์จ ์ธ์Šคํ„ด์Šค๊ฐ€ ์ „์ฒด ์‹œ์Šคํ…œ์—์„œ ํ•˜๋‚˜ ๋ฟ์ž„์ด ๋ณด์žฅ๋ฉ๋‹ˆ๋‹ค.
  • ์ด ๋ฐฉ์‹์€ ํ•ด๋‹น ํด๋ž˜์Šค๊ฐ€ ์‹ฑ๊ธ€ํ†ค์ž„์„ ํ™•์‹คํžˆ ๋“œ๋Ÿฌ๋‚ด๊ณ , ๊ฐ„๊ฒฐํ•˜๋‹ค๋Š” ๊ฒƒ์ด ์žฅ์ 

 

์˜ˆ์™ธ ์ผ€์ด์Šค : ์•„๋ž˜ ์ฝ”๋“œ์™€ ๊ฐ™์ด ๋ฆฌํ”Œ๋ ‰์…˜ API ( AccessibleObject.setAccessible)์„ ์‚ฌ์šฉํ•ด private ์ƒ์„ฑ์ž๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๋ฐฉ๋ฒ•
@Test
void reflectionBreakSingleton()
        throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
    Elvis elvis = Elvis.INSTANCE;
    Constructor<Elvis> constructor = (Constructor<Elvis>) elvis.getClass().getDeclaredConstructor();
    constructor.setAccessible(true);

    Elvis elvis2 = constructor.newInstance();
    assertNotSame(elvis, elvis2);
}
  • ์ด๋Ÿฐ ๊ณต๊ฒฉ์„ ๋ง‰๊ธฐ ์œ„ํ•ด, ์ƒ์„ฑ์ž๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ ๋‘ ๋ฒˆ์งธ ๊ฐ์ฒด๊ฐ€ ์ƒ์„ฑ๋˜๋ ค ํ•  ๋•Œ ์˜ˆ์™ธ๋ฅผ ๋˜์ง์œผ๋กœ์จ ๋ง‰์„ ์ˆ˜ ์žˆ๊ฒ ์Šต๋‹ˆ๋‹ค.
public class Presley {

    public static final Presley INSTANCE = new Presley();

    private Presley() {
        if (INSTANCE != null) {
            throw new RuntimeException("์ƒ์„ฑ์ž๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.");
        }
    }
}

 


์‹ฑ๊ธ€ํ†ค ๋งŒ๋“œ๋Š” ๋ฐฉ์‹ 2 - ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์†Œ๋“œ๋ฅผ public static ๋ฉค๋ฒ„๋กœ ์ œ๊ณตํ•˜๊ธฐ

public class Greenday {

    private static final Greenday INSTANCE = new Greenday();

    private Greenday() {}

    public static Greenday getInstance() {
        return INSTANCE;
    }
}
class GreendayTest {

    @Test
    void singletonTest() {
        Greenday greenday1 = Greenday.getInstance();
        Greenday greenday2 = Greenday.getInstance();

        assertEquals(greenday1, greenday2);
    }
}
  • ๋‘ ๋ฒˆ์งธ ๋ฐฉ๋ฒ•์€ ์ฒซ ๋ฒˆ์งธ ๋ฐฉ์‹์˜ ์‹ฑ๊ธ€ํ†ค ๊ฐ์ฒด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ์‹์„ ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์†Œ๋“œ ๋ฐฉ์‹์œผ๋กœ ์ •์˜ํ•œ ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.
  • ์ด ๋ฐฉ์‹์˜ ์žฅ์ ์€ ์‹ฑ๊ธ€ํ†ค ๋ฐฉ์‹์„ ํ’€๊ณ  ์‹ถ์„ ๋•Œ API๋ฅผ ๋ฐ”๊พธ์ง€ ์•Š๊ณ ๋„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค.
    • ์•„๋ž˜ ์ฝ”๋“œ์ฒ˜๋Ÿผ ๋‚ด๋ถ€์—์„œ INSTANCE๊ฐ€ ์•„๋‹Œ ์ƒˆ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•ด์ฃผ๋ฉด ๋˜๊ฒ ์Šต๋‹ˆ๋‹ค.
public class Greenday {

    private static final Greenday INSTANCE = new Greenday();

    private Greenday() {}

    public static Greenday getInstance() {
        return new Greenday();
    }
}
class GreendayTest {

    @Test
    void singletonTest() {
        Greenday greenday1 = Greenday.getInstance();
        Greenday greenday2 = Greenday.getInstance();

        assertNotEquals(greenday1, greenday2);
    }
}

 

  • ๋‘ ๋ฒˆ์งธ ์žฅ์ ์€ ์›ํ•œ๋‹ค๋ฉด ์ •์  ํŒฉํ† ๋ฆฌ๋ฅผ ์‹ฑ๊ธ€ํ†ค ํŒฉํ† ๋ฆฌ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. (Item 30 ์ฐธ๊ณ )
  • ์ •์  ํŒฉํ† ๋ฆฌ์˜ ๋ฉ”์†Œ๋“œ ์ฐธ์กฐ๋ฅผ ๊ณต๊ธ‰์ž๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (Item 43, Itme 44 ์ฐธ๊ณ )
    • Greenday::getInstance๋ฅผ Supplier<Greenday>๋กœ ์‚ฌ์šฉํ•ด์„œ ์•„๋ž˜์ฒ˜๋Ÿผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ
Supplier<Greenday> greendaySupplier = Greenday::getInstance;
Greenday greenday = greendaySupplier.get();

 


์œ„ ๋‘๊ฐ€์ง€ ๋ฐฉ์‹์˜ ๋ฌธ์ œ์  

https://data-flair.training/blogs/serialization-and-deserialization-in-java/

 

์œ„ ๋‘ ๊ฐ€์ง€ ๋ฐฉ์‹์˜ ๋ฌธ์ œ์ ์€ ๊ฐ ํด๋ž˜์Šค๋ฅผ ์ง๋ ฌํ™”(๊ฐ์ฒด๋ฅผ ์ €์žฅ, ์ „์†กํ•  ์ˆ˜ ์žˆ๋Š” ํŠน์ • ํฌ๋งท์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •)ํ•œ ํ›„ ์—ญ์ง๋ ฌํ™”(ํŠน์ • ํฌ๋งท ์ƒํƒœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ค์‹œ ๊ฐ์ฒด๋กœ ๋ณ€ํ™˜)ํ•  ๋•Œ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค.

  • ์—ญ์ง๋ ฌํ™”๋Š” ๊ธฐ๋ณธ ์ƒ์„ฑ์ž๋ฅผ ํ˜ธ์ถœํ•˜์ง€ ์•Š๊ณ  ์ธ์Šคํ„ด์Šค์˜ ๊ฐ’์„ ๋ณต์‚ฌํ•ด์„œ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์ด๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด readResolve ๋ฉ”์†Œ๋“œ๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด ์‹ฑ๊ธ€ํ†ค ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ณ , ๋ชจ๋“  ํ•„๋“œ์— transient ํ‚ค์›Œ๋“œ๋ฅผ ๋„ฃ์–ด์ฃผ๋Š” ๋ฐฉ์‹์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

transient ํ‚ค์›Œ๋“œ : ํ•„๋“œ์˜ ์ƒํƒœ๊ฐ’์„ ์ „์†กํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š” ํ‚ค์›Œ๋“œ
public class Greenday {

//    transient private static final Greenday INSTANCE = new Greenday();
    private static final Greenday INSTANCE = new Greenday();
    
    private Greenday() {}

    public static Greenday getInstance() {
        return INSTANCE;
    }
   
    private Greenday readResolve() {
        // '์ง„์งœ' Greenday๋ฅผ ๋ฆฌํ„ดํ•˜๊ณ , ๊ฐ€์งœ Greenday๋Š” ๊ฐ€๋น„์ง€ ์ปฌ๋ ‰ํ„ฐ์— ๋งก๊ธด๋‹ค.
        return INSTANCE;
    }
}
  • readResolve ๋ฉ”์†Œ๋“œ๋Š” ์—ญ์ง๋ ฌํ™” ๊ณผ์ •์—์„œ ๋ฐ˜๋“œ์‹œ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.
  • ์ด๋ ‡๊ฒŒ ์„ค์ •ํ•˜๋ฉด ์—ญ์ง๋ ฌํ™” ๊ณผ์ •์—์„œ ์‹ฑ๊ธ€ํ†ค์œผ๋กœ ๋งŒ๋“ค์–ด๋‘” ์ง„์งœ ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์„ค์ •๋˜์–ด, ๊ฐ’์„ ๋ณต์‚ฌํ•œ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค๋Š” ๊ฐ€๋น„์ง€ ์ปฌ๋ ‰ํ„ฐ๋กœ ๋„˜์–ด๊ฐ€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. 
  • ๋ฐฉ์–ด์ ์œผ๋กœ transient ํ‚ค์›Œ๋“œ๋ฅผ ๋„ฃ์–ด ์ง๋ ฌํ™” ๊ณผ์ •์—์„œ ํ•„๋“œ์˜ ์ƒํƒœ๊ฐ’ ์ „์†ก์„ ๋ง‰์•„ ์—ญ์ง๋ ฌํ™” ๊ณผ์ •์—์„œ ๋ณต์‚ฌํ•  ๊ฐ’ ์ž์ฒด๋ฅผ ์•„์˜ˆ ๋ณด๋‚ด์ง€ ์•Š๋„๋ก ์„ค์ •ํ•  ์ˆ˜๋„ ์žˆ๊ฒ ์Šต๋‹ˆ๋‹ค.

์‹ฑ๊ธ€ํ†ค ๋งŒ๋“œ๋Š” ๋ฐฉ์‹ 3 - enum ํƒ€์ž… 

public enum ColdBrew {
    
    INSTANCE;
}
  • ์„ธ ๋ฒˆ์งธ ๋ฐฉ๋ฒ•์€ enumํƒ€์ž…์œผ๋กœ ์‹ฑ๊ธ€ํ†ค์„ ์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ,public ํ•„๋“œ ๋ฐฉ์‹๊ณผ ๋น„์Šทํ•˜์ง€๋งŒ, ํ›จ์”ฌ ๊ฐ„๊ฒฐํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ์‹์œผ๋กœ, ๋ณต์žกํ•œ ์ง๋ ฌํ™” ์ƒํ™ฉ์ด๋‚˜ ๋ฆฌํ”Œ๋ ‰์…˜ ๊ณต๊ฒฉ์—์„œ๋„ ์ œ 2์˜ ์ธ์Šคํ„ด์Šค๊ฐ€ ์ƒ๊ธฐ๋Š” ์ผ์„ ์™„๋ฒฝํžˆ ๋ง‰์•„์ค๋‹ˆ๋‹ค.
    • ์—ด๊ฑฐํ˜• ํƒ€์ž…์œผ๋กœ ์‹ฑ๊ธ€ํ†ค์„ ์ ์šฉํ•˜๋Š” ๊ฒƒ์ด ์กฐ๊ธˆ ์–ด์ƒ‰ํ•  ์ˆœ ์žˆ์ง€๋งŒ, ๋Œ€๋ถ€๋ถ„ ์ƒํ™ฉ์—์„œ๋Š” ์›์†Œ๊ฐ€ ํ•˜๋‚˜๋ฟ์ธ ์—ด๊ฑฐ ํƒ•๋น„์ด ์‹ฑ๊ธ€ํ†ค์„ ๋งŒ๋“œ๋Š” ๊ฐ€์žฅ ์ข‹์€ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.
  • ๋งŒ๋“œ๋ ค๋Š” ์‹ฑ๊ธ€ํ†ค์ด enum์™ธ์˜ ํด๋ž˜์Šค๋ฅผ ์ƒ์†ํ•ด์•ผ ํ•œ๋‹ค๋ฉด ์ด ๋ฐฉ๋ฒ•์€ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. (์ธํ„ฐํŽ˜์ด์Šค๋Š” ๊ตฌํ˜„ํ•˜๋„๋ก ์„ ์–ธํ•  ์ˆ˜๋Š” ์žˆ์Œ)
    • public enum ColdBrew extends ~ (X), public enum ColdBrew implements ~ (O)

<์ฐธ๊ณ ์ž๋ฃŒ>

 

[์ดํŽ™ํ‹ฐ๋ธŒ ์ž๋ฐ”] ์•„์ดํ…œ 3. private ์ƒ์„ฑ์ž๋‚˜ ์—ด๊ฑฐ ํƒ€์ž…์œผ๋กœ ์‹ฑ๊ธ€ํ„ด์ž„์„ ๋ณด์ฆํ•˜๋ผ

์‹ฑ๊ธ€ํ„ด: ์ธ์Šคํ„ด์Šค๋ฅผ ์˜ค์ง ํ•˜๋‚˜๋งŒ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ํด๋ž˜์Šคex) ํ•จ์ˆ˜(๋ฌด์ƒํƒœ ๊ฐ์ฒด), ์„ค๊ณ„์ƒ ์œ ์ผํ•ด์•ผ ํ•˜๋Š” ์‹œ์Šคํ…œ ์ปดํฌ๋„ŒํŠธprivate ์ƒ์„ฑ์ž๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ƒ์†ํ•  ์ˆ˜ ์—†๋‹ค.private ์ƒ์„ฑ์ž๋Š” ์˜ค์ง ์‹ฑ

velog.io

 

 

[Java] ์ง๋ ฌํ™”(Serialization)์™€ ์—ญ์ง๋ ฌํ™”(Deserialization)๋ž€? transient ๋ณ€์ˆ˜๋ž€?

์ง๋ ฌํ™”(Serializaion)๋ž€? ์—ญ์ง๋ ฌํ™”(Deserialization)๋ž€? ์ง๋ ฌํ™”๋Š” ๊ฐ์ฒด๋ฅผ ์ €์žฅ ๊ฐ€๋Šฅํ•œ ์ƒํƒœ(์˜ˆ๋ฅผ ๋“ค์–ด ๋””์Šคํฌ์— ํŒŒ์ผ ํ˜•ํƒœ ๋“ฑ) ํ˜น์€ ์ „์†ก ๊ฐ€๋Šฅํ•œ ์ƒํƒœ(๋„คํŠธ์›Œํฌ ์ƒ์˜ ๋ฐ์ดํ„ฐ ์ŠคํŠธ๋ฆผ ํ˜•ํƒœ)๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ฒƒ์„

code-lab1.tistory.com

 

 

 

[์•„์ดํ…œ 3] transient๊ฐ€ ์—ญ์ง๋ ฌํ™”์‹œ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ์„ ๋ฐฉ์ง€ํ•˜๋Š” ์ด์œ  · Issue #4 · Java-Bom/ReadingR

24p ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋ฅผ transient๋กœ ์„ ์–ธํ•˜๊ณ  readResolve ๋ฉ”์„œ๋“œ๋ฅผ ์ œ๊ณตํ•ด์•ผ ํ•œ๋‹ค. transient๊ฐ€ ์ง๋ ฌํ™”์‹œ ์ œ์™ธ์‹œ์ผœ์ฃผ๋Š” ๊ฑด ์•Œ๊ฒ ๋Š”๋ฐ, ์ด๊ฒŒ ์™œ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒˆ๋กœ ์ƒ์„ฑํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š”๊ฑธ ๋ณด์žฅํ•˜๋Š”์ง€

github.com

 

๋ธ”๋กœ๊ทธ์˜ ์ •๋ณด

Study Repository

rlaehddnd0422

ํ™œ๋™ํ•˜๊ธฐ