java.lang.ArrayIndexOutOfBoundsException: 42

JDK Bug System | Webbug Group | 1 year ago
  1. 0

    FULL PRODUCT VERSION : java version "1.8.0_65" Java(TM) SE Runtime Environment (build 1.8.0_65-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode) ADDITIONAL OS VERSION INFORMATION : Darwin ... 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64 A DESCRIPTION OF THE PROBLEM : javac produces a length attribute for RuntimeInvisibleTypeAnnotations that can be larger than the total length of the method bytecode. This trips up ASM bytecode parsing (see stack below), which in turn prevents tools such as FindBugs or JaCoCo from running on affected bytecode. The Eclipse Compiler for Java does not appear to suffer from this problem. ASM parsing exception stack trace (produced with asm-debug-all-5.0.2.jar): Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 42 at org.objectweb.asm.ClassReader.readLabel(ClassReader.java:2174) at org.objectweb.asm.ClassReader.readTypeAnnotations(ClassReader.java:1598) at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1184) at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1017) at org.objectweb.asm.ClassReader.accept(ClassReader.java:693) at org.objectweb.asm.ClassReader.accept(ClassReader.java:506) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Compile source code provided below. Check RuntimeInvisibleTypeAnnotations output provided by javap EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - RuntimeInvisibleTypeAnnotations: 0: #30(): LOCAL_VARIABLE, {start_pc=0, length=26, index=0}, location=[TYPE_ARGUMENT(0)] ACTUAL - RuntimeInvisibleTypeAnnotations: 0: #30(): LOCAL_VARIABLE, {start_pc=0, length=42, index=0}, location=[TYPE_ARGUMENT(0)] REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.lang.annotation.ElementType; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.Collection; public class ReproduceJavacBug { @Target(ElementType.TYPE_USE) public @interface Annotation {}; public static void main(String [] args) { final Collection<@Annotation Object> list = new ArrayList<>(); list.stream().forEach(r -> { int a = 0; System.out.println(a + ""); list.size(); throw new RuntimeException(); }); } } ---------- END SOURCE ----------

    JDK Bug System | 1 year ago | Webbug Group
    java.lang.ArrayIndexOutOfBoundsException: 42
  2. 0

    FULL PRODUCT VERSION : java version "1.8.0_65" Java(TM) SE Runtime Environment (build 1.8.0_65-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode) ADDITIONAL OS VERSION INFORMATION : Darwin ... 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64 A DESCRIPTION OF THE PROBLEM : javac produces a length attribute for RuntimeInvisibleTypeAnnotations that can be larger than the total length of the method bytecode. This trips up ASM bytecode parsing (see stack below), which in turn prevents tools such as FindBugs or JaCoCo from running on affected bytecode. The Eclipse Compiler for Java does not appear to suffer from this problem. ASM parsing exception stack trace (produced with asm-debug-all-5.0.2.jar): Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 42 at org.objectweb.asm.ClassReader.readLabel(ClassReader.java:2174) at org.objectweb.asm.ClassReader.readTypeAnnotations(ClassReader.java:1598) at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1184) at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1017) at org.objectweb.asm.ClassReader.accept(ClassReader.java:693) at org.objectweb.asm.ClassReader.accept(ClassReader.java:506) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Compile source code provided below. Check RuntimeInvisibleTypeAnnotations output provided by javap EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - RuntimeInvisibleTypeAnnotations: 0: #30(): LOCAL_VARIABLE, {start_pc=0, length=26, index=0}, location=[TYPE_ARGUMENT(0)] ACTUAL - RuntimeInvisibleTypeAnnotations: 0: #30(): LOCAL_VARIABLE, {start_pc=0, length=42, index=0}, location=[TYPE_ARGUMENT(0)] REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.lang.annotation.ElementType; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.Collection; public class ReproduceJavacBug { @Target(ElementType.TYPE_USE) public @interface Annotation {}; public static void main(String [] args) { final Collection<@Annotation Object> list = new ArrayList<>(); list.stream().forEach(r -> { int a = 0; System.out.println(a + ""); list.size(); throw new RuntimeException(); }); } } ---------- END SOURCE ----------

    JDK Bug System | 1 year ago | Webbug Group
    java.lang.ArrayIndexOutOfBoundsException: 42
  3. 0

    Remove spark.LambdaTest from JAR

    GitHub | 2 years ago | davsclaus
    java.lang.ArrayIndexOutOfBoundsException: 7786
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Jdk8 HikariCP issue

    GitHub | 2 years ago | zhuyuping
    java.lang.ArrayIndexOutOfBoundsException: 2925
  6. 0

    qulice-findbugs doesn't build with java 1.8

    GitHub | 3 years ago | krzyk
    java.lang.ArrayIndexOutOfBoundsException: 35328

    11 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ArrayIndexOutOfBoundsException

      42

      at org.objectweb.asm.ClassReader.readLabel()
    2. Felix iPOJO
      ClassReader.accept
      1. org.objectweb.asm.ClassReader.readLabel(ClassReader.java:2174)
      2. org.objectweb.asm.ClassReader.readTypeAnnotations(ClassReader.java:1598)
      3. org.objectweb.asm.ClassReader.readCode(ClassReader.java:1184)
      4. org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1017)
      5. org.objectweb.asm.ClassReader.accept(ClassReader.java:693)
      6. org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
      6 frames