Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
Iterating a List<String> using a forloop (Java)

Im trying to iterate a List. Im working with ASM, and usually I use

for(MethodNode methodNode:(List<MethodNode>) classNode.methods){
     //...
}

to iterate my Lists.

but when I try to iterate a List of String's

for(String interfaceName:(List<String>) classNode.interfaces){
     //...
}

my IDE gives me "Can only iterate over an array or an instance of java.lang.Iterable" error.

@Params classNode.interfaces returns a List <String>(http://asm.ow2.org/asm50/javadoc/user/org/objectweb/asm/tree/ClassNode.html#interfaces)

Edit: I figured it out! For those who were wondering what I did I figured Id post it!

for(Object strName: classNode.interfaces){
     //use String.valueOf(strName) to obtain type string
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This happens because for whatever reasons, the asm binary distribution comes with a jar stripped of generic signatures metadata. For development purposes, you should add asm-debug-all-5.2.jar to your classpath, then your IDE won't complain at you and you won't have to make strings out of things which are already strings. Here's the difference queried from each archive with javap

➤ javap -cp asm-all-5.2.jar org.objectweb.asm.tree.ClassNode | grep interfaces
  public java.util.List interfaces;
➤ javap -cp asm-debug-all-5.2.jar org.objectweb.asm.tree.ClassNode | grep interfaces
  public java.util.List<java.lang.String> interfaces;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda