Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Large arrays (~100+ elements) are not properly typed

Aperta
#68 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@Jonathing ci sta già lavorando.

Dal 14/1/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
Java
Stelle
39
Fork
23
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MinecraftForge/coremods

Tutte le issue di MinecraftForge/coremods

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.