Large arrays (~100+ elements) are not properly typed
@Jonathing がすでに取り組んでいます。
2025年1月14日 から。
評価
この issue はまだ評価されていません。
説明
This is actually a Nashorn bug, but I'd like to workaround it in CoreMods 5.3. Essentially, large arrays (either created with [] or with varargs) are not converted to the required type, but rather to Object[]. This is a problem particularly for ASMAPI.listOf(), which uses a varargs signature of ([Lorg/objectweb/asm/tree/AbstractInsnNode;). When the coremod script is evaluated by Nashorn, the script fails with a ClassCastException: cannot cast [Ljava/lang/Object;] to org/objectweb/asm/tree/AbstractInsnNode.
Workarounds
The easiest way to workaround this is to manually add each node to a list. For example:
const list = ASMAPI.listOf();
list.add(node1);
list.add(node2);
// ...
However, another workaround is to use Java.to() to convert the entire array into your desired type. For example:
method.instructions = ASMAPI.listOf(Java.to([
// ...
], Java.type('org.objectweb.asm.tree.AbstractInsnNode[]')));
Solution(?)
A solution to workaround this in CoreMods would be to create a sister method ASMAPI.listOf(Object... nodes) which accepts varargs object. Though, it might have a performance impact due to needing to cast each node to AbstractInsnNode. We can realistically skip the instanceof check since coremods should never attempt to add other objects that aren't nodes to an InsnList.
- 主要言語
- Java
- スター
- 39
- フォーク
- 23
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MinecraftForge/coremods のほかの issue
-
MinecraftForge/coremods#74 · 担当者 1 名 ·
-
MinecraftForge/coremods#72 · 担当者 1 名 ·
MinecraftForge/coremods の issue をすべて見る
似ている issue
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
inu-appcenter/memorIN-backend#288 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
frontend maui-pilot pilot-ask question
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
area/plugin
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
kestra-io/plugin-kestra#190 ·