Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!