mike-neckのブログ

Java or Groovy or Swift or Golang

雑学 - パラメーターの個数は254個まで

調べたら 254 個までだった。

パラメーター 254

jshell> interface StrFun254 { String apply(String arg1,String arg2,String arg3,String arg4,String arg5,String arg6,String arg7,String arg8,String arg9,String arg10,String arg11,String arg12,String arg13,String arg14,String arg15,String arg16,String arg17,String arg18,String arg19,String arg20,String arg21,String arg22,String arg23,String arg24,String arg25,String arg26,String arg27,String arg28,String arg29,String arg30,String arg31,String arg32,String arg33,String arg34,String arg35,String arg36,String arg37,String arg38,String arg39,String arg40,String arg41,String arg42,String arg43,String arg44,String arg45,String arg46,String arg47,String arg48,String arg49,String arg50,String arg51,String arg52,String arg53,String arg54,String arg55,String arg56,String arg57,String arg58,String arg59,String arg60,String arg61,String arg62,String arg63,String arg64,String arg65,String arg66,String arg67,String arg68,String arg69,String arg70,String arg71,String arg72,String arg73,String arg74,String arg75,String arg76,String arg77,String arg78,String arg79,String arg80,String arg81,String arg82,String arg83,String arg84,String arg85,String arg86,String arg87,String arg88,String arg89,String arg90,String arg91,String arg92,String arg93,String arg94,String arg95,String arg96,String arg97,String arg98,String arg99,String arg100,String arg101,String arg102,String arg103,String arg104,String arg105,String arg106,String arg107,String arg108,String arg109,String arg110,String arg111,String arg112,String arg113,String arg114,String arg115,String arg116,String arg117,String arg118,String arg119,String arg120,String arg121,String arg122,String arg123,String arg124,String arg125,String arg126,String arg127,String arg128,String arg129,String arg130,String arg131,String arg132,String arg133,String arg134,String arg135,String arg136,String arg137,String arg138,String arg139,String arg140,String arg141,String arg142,String arg143,String arg144,String arg145,String arg146,String arg147,String arg148,String arg149,String arg150,String arg151,String arg152,String arg153,String arg154,String arg155,String arg156,String arg157,String arg158,String arg159,String arg160,String arg161,String arg162,String arg163,String arg164,String arg165,String arg166,String arg167,String arg168,String arg169,String arg170,String arg171,String arg172,String arg173,String arg174,String arg175,String arg176,String arg177,String arg178,String arg179,String arg180,String arg181,String arg182,String arg183,String arg184,String arg185,String arg186,String arg187,String arg188,String arg189,String arg190,String arg191,String arg192,String arg193,String arg194,String arg195,String arg196,String arg197,String arg198,String arg199,String arg200,String arg201,String arg202,String arg203,String arg204,String arg205,String arg206,String arg207,String arg208,String arg209,String arg210,String arg211,String arg212,String arg213,String arg214,String arg215,String arg216,String arg217,String arg218,String arg219,String arg220,String arg221,String arg222,String arg223,String arg224,String arg225,String arg226,String arg227,String arg228,String arg229,String arg230,String arg231,String arg232,String arg233,String arg234,String arg235,String arg236,String arg237,String arg238,String arg239,String arg240,String arg241,String arg242,String arg243,String arg244,String arg245,String arg246,String arg247,String arg248,String arg249,String arg250,String arg251,String arg252,String arg253,String arg254); }
   ...> 
|  次を作成しました: インタフェース StrFun254

パラメーター 255

jshell> interface StrFun255 { String apply(String arg1,String arg2,String arg3,String arg4,String arg5,String arg6,String arg7,String arg8,String arg9,String arg10,String arg11,String arg12,String arg13,String arg14,String arg15,String arg16,String arg17,String arg18,String arg19,String arg20,String arg21,String arg22,String arg23,String arg24,String arg25,String arg26,String arg27,String arg28,String arg29,String arg30,String arg31,String arg32,String arg33,String arg34,String arg35,String arg36,String arg37,String arg38,String arg39,String arg40,String arg41,String arg42,String arg43,String arg44,String arg45,String arg46,String arg47,String arg48,String arg49,String arg50,String arg51,String arg52,String arg53,String arg54,String arg55,String arg56,String arg57,String arg58,String arg59,String arg60,String arg61,String arg62,String arg63,String arg64,String arg65,String arg66,String arg67,String arg68,String arg69,String arg70,String arg71,String arg72,String arg73,String arg74,String arg75,String arg76,String arg77,String arg78,String arg79,String arg80,String arg81,String arg82,String arg83,String arg84,String arg85,String arg86,String arg87,String arg88,String arg89,String arg90,String arg91,String arg92,String arg93,String arg94,String arg95,String arg96,String arg97,String arg98,String arg99,String arg100,String arg101,String arg102,String arg103,String arg104,String arg105,String arg106,String arg107,String arg108,String arg109,String arg110,String arg111,String arg112,String arg113,String arg114,String arg115,String arg116,String arg117,String arg118,String arg119,String arg120,String arg121,String arg122,String arg123,String arg124,String arg125,String arg126,String arg127,String arg128,String arg129,String arg130,String arg131,String arg132,String arg133,String arg134,String arg135,String arg136,String arg137,String arg138,String arg139,String arg140,String arg141,String arg142,String arg143,String arg144,String arg145,String arg146,String arg147,String arg148,String arg149,String arg150,String arg151,String arg152,String arg153,String arg154,String arg155,String arg156,String arg157,String arg158,String arg159,String arg160,String arg161,String arg162,String arg163,String arg164,String arg165,String arg166,String arg167,String arg168,String arg169,String arg170,String arg171,String arg172,String arg173,String arg174,String arg175,String arg176,String arg177,String arg178,String arg179,String arg180,String arg181,String arg182,String arg183,String arg184,String arg185,String arg186,String arg187,String arg188,String arg189,String arg190,String arg191,String arg192,String arg193,String arg194,String arg195,String arg196,String arg197,String arg198,String arg199,String arg200,String arg201,String arg202,String arg203,String arg204,String arg205,String arg206,String arg207,String arg208,String arg209,String arg210,String arg211,String arg212,String arg213,String arg214,String arg215,String arg216,String arg217,String arg218,String arg219,String arg220,String arg221,String arg222,String arg223,String arg224,String arg225,String arg226,String arg227,String arg228,String arg229,String arg230,String arg231,String arg232,String arg233,String arg234,String arg235,String arg236,String arg237,String arg238,String arg239,String arg240,String arg241,String arg242,String arg243,String arg244,String arg245,String arg246,String arg247,String arg248,String arg249,String arg250,String arg251,String arg252,String arg253,String arg254,String arg255); }
   ...> 
|  エラー:
|  パラメータが多すぎます
|  interface StrFun255 { String apply(String arg1,String arg2,String arg3,String arg4,String arg5,String arg6,String arg7,String arg8,String arg9,String arg10,String arg11,String arg12,String arg13,String arg14,String arg15,String arg16,String arg17,String arg18,String arg19,String arg20,String arg21,String arg22,String arg23,String arg24,String arg25,String arg26,String arg27,String arg28,String arg29,String arg30,String arg31,String arg32,String arg33,String arg34,String arg35,String arg36,String arg37,String arg38,String arg39,String arg40,String arg41,String arg42,String arg43,String arg44,String arg45,String arg46,String arg47,String arg48,String arg49,String arg50,String arg51,String arg52,String arg53,String arg54,String arg55,String arg56,String arg57,String arg58,String arg59,String arg60,String arg61,String arg62,String arg63,String arg64,String arg65,String arg66,String arg67,String arg68,String arg69,String arg70,String arg71,String arg72,String arg73,String arg74,String arg75,String arg76,String arg77,String arg78,String arg79,String arg80,String arg81,String arg82,String arg83,String arg84,String arg85,String arg86,String arg87,String arg88,String arg89,String arg90,String arg91,String arg92,String arg93,String arg94,String arg95,String arg96,String arg97,String arg98,String arg99,String arg100,String arg101,String arg102,String arg103,String arg104,String arg105,String arg106,String arg107,String arg108,String arg109,String arg110,String arg111,String arg112,String arg113,String arg114,String arg115,String arg116,String arg117,String arg118,String arg119,String arg120,String arg121,String arg122,String arg123,String arg124,String arg125,String arg126,String arg127,String arg128,String arg129,String arg130,String arg131,String arg132,String arg133,String arg134,String arg135,String arg136,String arg137,String arg138,String arg139,String arg140,String arg141,String arg142,String arg143,String arg144,String arg145,String arg146,String arg147,String arg148,String arg149,String arg150,String arg151,String arg152,String arg153,String arg154,String arg155,String arg156,String arg157,String arg158,String arg159,String arg160,String arg161,String arg162,String arg163,String arg164,String arg165,String arg166,String arg167,String arg168,String arg169,String arg170,String arg171,String arg172,String arg173,String arg174,String arg175,String arg176,String arg177,String arg178,String arg179,String arg180,String arg181,String arg182,String arg183,String arg184,String arg185,String arg186,String arg187,String arg188,String arg189,String arg190,String arg191,String arg192,String arg193,String arg194,String arg195,String arg196,String arg197,String arg198,String arg199,String arg200,String arg201,String arg202,String arg203,String arg204,String arg205,String arg206,String arg207,String arg208,String arg209,String arg210,String arg211,String arg212,String arg213,String arg214,String arg215,String arg216,String arg217,String arg218,String arg219,String arg220,String arg221,String arg222,String arg223,String arg224,String arg225,String arg226,String arg227,String arg228,String arg229,String arg230,String arg231,String arg232,String arg233,String arg234,String arg235,String arg236,String arg237,String arg238,String arg239,String arg240,String arg241,String arg242,String arg243,String arg244,String arg245,String arg246,String arg247,String arg248,String arg249,String arg250,String arg251,String arg252,String arg253,String arg254,String arg255); }
|                        ^------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^
|  次を作成しました: インタフェース StrFun255。しかし、このエラー(
|      パラメータが多すぎます
|      interface StrFun255 { String apply(String arg1,String arg2,String arg3,String arg4,String arg5,String arg6,String arg7,String arg8,String arg9,String arg10,String arg11,String arg12,String arg13,String arg14,String arg15,String arg16,String arg17,String arg18,String arg19,String arg20,String arg21,String arg22,String arg23,String arg24,String arg25,String arg26,String arg27,String arg28,String arg29,String arg30,String arg31,String arg32,String arg33,String arg34,String arg35,String arg36,String arg37,String arg38,String arg39,String arg40,String arg41,String arg42,String arg43,String arg44,String arg45,String arg46,String arg47,String arg48,String arg49,String arg50,String arg51,String arg52,String arg53,String arg54,String arg55,String arg56,String arg57,String arg58,String arg59,String arg60,String arg61,String arg62,String arg63,String arg64,String arg65,String arg66,String arg67,String arg68,String arg69,String arg70,String arg71,String arg72,String arg73,String arg74,String arg75,String arg76,String arg77,String arg78,String arg79,String arg80,String arg81,String arg82,String arg83,String arg84,String arg85,String arg86,String arg87,String arg88,String arg89,String arg90,String arg91,String arg92,String arg93,String arg94,String arg95,String arg96,String arg97,String arg98,String arg99,String arg100,String arg101,String arg102,String arg103,String arg104,String arg105,String arg106,String arg107,String arg108,String arg109,String arg110,String arg111,String arg112,String arg113,String arg114,String arg115,String arg116,String arg117,String arg118,String arg119,String arg120,String arg121,String arg122,String arg123,String arg124,String arg125,String arg126,String arg127,String arg128,String arg129,String arg130,String arg131,String arg132,String arg133,String arg134,String arg135,String arg136,String arg137,String arg138,String arg139,String arg140,String arg141,String arg142,String arg143,String arg144,String arg145,String arg146,String arg147,String arg148,String arg149,String arg150,String arg151,String arg152,String arg153,String arg154,String arg155,String arg156,String arg157,String arg158,String arg159,String arg160,String arg161,String arg162,String arg163,String arg164,String arg165,String arg166,String arg167,String arg168,String arg169,String arg170,String arg171,String arg172,String arg173,String arg174,String arg175,String arg176,String arg177,String arg178,String arg179,String arg180,String arg181,String arg182,String arg183,String arg184,String arg185,String arg186,String arg187,String arg188,String arg189,String arg190,String arg191,String arg192,String arg193,String arg194,String arg195,String arg196,String arg197,String arg198,String arg199,String arg200,String arg201,String arg202,String arg203,String arg204,String arg205,String arg206,String arg207,String arg208,String arg209,String arg210,String arg211,String arg212,String arg213,String arg214,String arg215,String arg216,String arg217,String arg218,String arg219,String arg220,String arg221,String arg222,String arg223,String arg224,String arg225,String arg226,String arg227,String arg228,String arg229,String arg230,String arg231,String arg232,String arg233,String arg234,String arg235,String arg236,String arg237,String arg238,String arg239,String arg240,String arg241,String arg242,String arg243,String arg244,String arg245,String arg246,String arg247,String arg248,String arg249,String arg250,String arg251,String arg252,String arg253,String arg254,String arg255); }
|                            ^------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^)が修正されるまで、参照できません

これは JVM 仕様により規定されているっぽい(https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-4.html#jvms-4.3.3)。また、 javac では、これをコンパイルエラーにしている。


なお、このエラーになるパラメーターの数を調べたあとに、 jshell を終了すると例外が発生した

jshell> /exit
|  終了します
Exception in thread "main" java.lang.IllegalArgumentException: Value too long: interface StrFun1024 { String apply(String arg1,String arg2,String arg3,String arg4,String arg5,String arg6,String arg7,String arg8,String arg9,String arg10,String arg11,String arg12,String arg13,String arg14,String arg15
…途中省略…
ring arg1007,String arg1008,String arg1009,String arg1010,String arg1011,String arg1012,String arg1013,String arg1014,String arg1015,String arg1016,String arg1017,String arg1018,String arg1019,String arg1020,String arg1021,String arg1022,String arg1023,String arg1024); }
    at java.prefs/java.util.prefs.AbstractPreferences.put(AbstractPreferences.java:253)
    at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder$PreferencesStorage.put(JShellToolBuilder.java:293)
    at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.close(ConsoleIOContext.java:240)
    at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:977)
    at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
    at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)

Gradle 5.5 で JUnit Jupiter が gradle init 時にテストフレームワークとして選べるようになっていた

表題の通りです

f:id:mike_neck:20190619163018p:plain

次のコマンドをターミナルで叩きます。

gradle init \
  --type java-library \
  --test-framework junit-jupiter \
  --dsl groovy \
  --package com.example \
  --project-name example-library

次のような build.gradle ファイルが生成されます

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java Library project to get you started.
 * For more details take a look at the Java Libraries chapter in the Gradle
 * User Manual available at https://docs.gradle.org/5.5/userguide/java_library_plugin.html
 */

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
}

repositories {
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:27.1-jre'

    // Use JUnit Jupiter API for testing.
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'

    // Use JUnit Jupiter Engine for testing.
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
}

test {
    // Use junit platform for unit tests
    useJUnitPlatform()
}