Upgrade to Pro — share decks privately, control downloads, hide ads and more …

J2Kコンバータをカスタマイズする ver: 5min

Paraya
July 26, 2018
1.6k

J2Kコンバータをカスタマイズする ver: 5min

Paraya

July 26, 2018
Tweet

Transcript

  1. +,ίϯόʔλΛΧελϚΠζ͢Δ
    QPUBUPUJQT
    QBSBZB
    ͠Ύͬͪΐ͏͹Μ

    View full-size slide

  2. ࣗݾ঺հ
    ɾ ࡾӜՂ༞QBSBZB
    ɾ גࣜձࣾΠάχεॴଐ
    ɾ XJUI"OESPJE୲౰
    ɾ ,PUMJO͸ͷࠒ͔Β ೥ఔ

    View full-size slide

  3. ςʔϚ
    ɾ +BWB͔Β,PUMJOʹม׵͢Δͷ͸ͱͯ΋େม
    ɾ ,PUMJOԽ͢Δ্Ͱ௨ৗͷํ๏Ҏ֎ʹ΋΍Γํ
    ͸͋Δ

    View full-size slide

  4. ΋͘͡
    ɾ +BWB͔Β,PUMJOʹม׵͢Δࡍʹۤ࿑͢Δ఺
    ɾ +,ίϯόʔλΛΧελϚΠζ

    View full-size slide

  5. +BWB͔Β,PUMJOʹม׵͢Δ
    ࡍʹۤ࿑͢Δ఺

    View full-size slide

  6. ௨ৗ+BWB͔Β,PUMJOʹม׵͢
    Δࡍ͸ɺ"OESPJE4UVEJP
    *OUFMMJK*%&"͔Βίϯόʔτ͢
    Δͱࢥ͍·͢

    View full-size slide

  7. "OESPJE4UVEJP*OUFMMJK*%&"
    Ͱͷ+,ίϯόʔτ
    ϝχϡʔ ➔ Code
    ➔ Convert Java File to Kotlin File

    View full-size slide

  8. ͨͩ͠ɺ͜ͷ௨ৗͷ+,ίϯ
    όʔλΛ༻͍ͨ,PUMJOԽͷํ
    ๏ʹ͸໰୊͕͋Γ·͢ɻ
    +,ίϯόʔλ͕ڧ੍తʹ
    /PO/VMMม׵ͯ͠͠·͏
    ໰୊

    View full-size slide

  9. ७ਖ਼+,ίϯόʔλ͕ڧ੍తʹ
    /PO/VMMม׵͢Δ໰୊
    public interface SampleInterface {
    String getText(Context context);
    int getValue(Context context);
    }
    interface SampleInterface {
    fun getText(context: Context): String
    fun getValue(context: Context): Int
    }
    /VMMBCMFͳ
    ίʔυͩͬͨͷ͕
    /PO/VMMίʔυʹ
    ม׵͞Εͯ͠·͏
    ʁ͕ͳ͍ʂ
    +BWB
    ,PUMJO

    View full-size slide

  10. ७ਖ਼+,ίϯόʔλ͕ڧ੍తʹ
    /PO/VMMม׵͢Δ໰୊
    +BWBίʔυଆ͔Β͸/PU/VMMΞϊςʔγϣϯ෇͍ͯ
    ΔͷʹOVMMΛ୅ೖͯ͠ΔΑXBSOJOH͕දࣔ͞Εͯ͠
    ·͏ʂʂ
    +BWB

    View full-size slide

  11. ७ਖ਼+,ίϯόʔλ͕ڧ੍తʹ
    /PO/VMMม׵͢Δ໰୊
    Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method
    kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter context
    at org.paradrops.sample.SampleClass.getText(SampleClass.kt)
    at org.paradrops.sample.Main2Activity.onCreate(Main2Activity.java:14)
    at android.app.Activity.performCreate(Activity.java:6664)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
    IllegalArgumentException: Parameter specified
    as non-null is null
    Ϋϥογϡͯ͠͠·͏ʂʂ

    View full-size slide

  12. ७ਖ਼+,ίϯόʔλ͕ڧ੍తʹ
    /PO/VMMม׵͢Δ
    ɾ ਌$MBTT*OUFSGBDFBCTUSBDUΫϥεͳͲϝιο
    υΛܧঝPS࣮૷ͨ͠৔߹ɺҾ਺ʹ/VMMBCMFΞ
    ϊςʔγϣϯ͕ͳ͍৔߹͸+,͕/PO/VMMม׵
    ͯ͠͠·͏
    ɾ ,PUMJO͸/PO/VMMɺ+BWB͸/VMMBCMF؀ڥʹͳͬ
    ͯ͠·͍ͱͯ΋Ϋϥογϡ͠΍͍͢

    View full-size slide

  13. Ͳ͏ղܾ͢Δ͔ʁ
    ղܾࡦ͸ͲΜͳ΋ͷ͕͋Δ͔ʁ

    View full-size slide

  14. ͺͬͱࢥ͍ͭ͘ղܾҊ
    ɾ ख௚͠Ҋɿ֤Ҿ਺໭Γ஋ͷܕͷ/VMMBCMF
    /PO/VMM͕ਖ਼͍͔͠ɺ໨ࢹͰνΣοΫͯ͠ख
    ௚͢͠Δ
    ɾ શಈ࡞νΣοΫҊɿͱΓ͋͑ͣ,PUMJOԽͯ͠
    ΞϓϦͷશಈ࡞νΣοΫͯ͠मਖ਼͢Δ

    View full-size slide

  15. ͲͪΒ΋͵͘΋ΓҲΕ͍ͯΔର
    ԠͰͱͯ΋΍Γͨ͘ͳ͍
    ,PUMJOԽ͢Δͱߦͷίʔυ
    ม׵ͱ͔ී௨ʹ͋Δɻ
    ͦΕΛख࡞ۀͰमਖ਼ͨ͠ίʔυ
    ͷϨϏϡʔ͢Δͷ͸ਏ͗͢Δ

    View full-size slide

  16. ͜͜·Ͱߟ͑ͯҰͭ
    ࢥ͍͖ͭ·ͨ͠

    View full-size slide

  17. ,PUMJOͬͯ044ͩ͠
    ίϯόʔλΛվ଄͢Ε͹Α͍
    ͷͰ͸ʜʁ

    View full-size slide

  18. +,ίϯόʔλΛ
    ΧελϚΠζ͢Δ

    View full-size slide

  19. +,ίϯόʔλΧελϚΠζ·
    Ͱͷεςοϓ
    ɾ ,PUMJOͷ։ൃ؀ڥΛ༻ҙ͢Δ
    ɾ ,PUMJOͷ5ZQF$POWFSUFSLUΛฤू͢Δ
    ɾ ,PUMJOΛνϟΠϧυ*%&"࣮ߦ͢Δ
    ɾ ίʔυΛίϯόʔτͯ͠ΈΔ

    View full-size slide

  20. ,PUMJOͷ։ൃ؀ڥΛ༻ҙ
    ɾ *OUFMMJ+*%&"
    ɾ +%,
    ɾ CSFXJOTUBMMBOU
    ɾ IUUQTHJUIVCDPN+FU#SBJOTLPUMJO
    ɾ ৄࡉ͸!TIJSBKJ͞ΜͷϒϩάهࣄͳͲͰIUUQT
    TIJSBKJHJUIVCJPCMPHIPXUPLPOUSJCVUF
    WTFUVQ

    View full-size slide

  21. ,PUMJOͷ5ZQF$POWFSUFSLUΛฤ
    ू͢Δ
    IUUQTHJUIVCDPN+FU#SBJOTLPUMJOCMPCNBTUFS
    KLTSDPSHKFUCSBJOTLPUMJOKL5ZQF$POWFSUFSLU
    fun variableNullability(variable: PsiVariable):
    Nullability = Nullability.Nullable
    fun methodNullability(method: PsiMethod):
    Nullability = Nullability.Nullable

    View full-size slide

  22. ,PUMJOΛνϟΠϧυ*%&"࣮ߦ͢
    Δ

    View full-size slide

  23. ࣮ࡍʹ,PUMJOίʔυίϯόʔτ
    ͯ͠ΈΔ
    public interface SampleInterface {
    String getText(Context context);
    int getValue(Context context);
    }
    interface SampleInterface {
    fun getText(context: Context?): String?
    fun getValue(context: Context?): Int
    }
    /VMMBCMFͳ
    +BWBίʔυ
    ͩͬͨͷ͕
    ͔ͬ͠Γͱ
    /VMMBCMFΛ
    อ࣋ͨ͠··
    ม׵͞Ε͍ͯΔ
    +BWB
    ,PUMJO

    View full-size slide

  24. ࣮ࡍʹΧελϜ+,Ͱίϯόʔ
    τͨ͠ίʔυΛ࢖ͬͯΈΔ
    /VMMBCMFʹOVMMΛ୅ೖ͢Δͷ͸ී௨ͷ͜ͱͳͷͰ
    XBSOJOH͸ग़ͣɺΫϥογϡ΋͠ͳ͍
    ར༻͢Δ+BWBίʔυଆʹมߋΛՃ͑Δඞཁͳ͠

    View full-size slide

  25. ͿͬͪΌ͚ΧελϜίϯόʔλ
    ͷ࢖༻ײͲ͏ʁ
    ɾ ࢖͍࢝Ίͨͷ͸ࠓ೥ͷࠒ
    ɾ ϦϦʔε➔Ϋϥογϡ➔IPUGJYͷܹݮ
    ɾ ίϯόʔλ͕ੜ੒͢Δίʔυʹ৴པײˠίʔ
    υϨϏϡʔͷ؆ૉԽ
    ɾ ,PUMJOԽ͕ؾܰʹͰ͖ΔΑ͏ʹ➔͜Εେࣄ

    View full-size slide

  26. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ
    ͓·͚ͷXJUI·Μ͕
    IUUQIFMQXJUIJT Q
    Α͔ͬͨΒಡΜͰΈͯͶʂ
    ͠Ύͬͪΐ͏͹Μ

    View full-size slide

  27. XJUI͸"OESPJEJ04ΤϯδχΞΛେઈࢍืूதʂ
    ϕςϥϯ,PUMJO4XJGUΤϯδχΞ͕αϙʔτ͢ΔͷͰ
    ॳ৺ऀͰ΋,PUMJO4XJGUʹڵຯ͕͋ΔͳΒ
    ؾܰʹԠืͯ͠ΈͯͶʂ
    IUUQTXXXXBOUFEMZDPNQSPKFDUT
    ͠Ύͬͪΐ͏͹Μ

    View full-size slide