diff --git a/core/src/com/google/inject/internal/util/LineNumbers.java b/core/src/com/google/inject/internal/util/LineNumbers.java index 8c77f33514..d3120a8160 100644 --- a/core/src/com/google/inject/internal/util/LineNumbers.java +++ b/core/src/com/google/inject/internal/util/LineNumbers.java @@ -27,6 +27,8 @@ import java.lang.reflect.Member; import java.lang.reflect.Method; import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; @@ -42,6 +44,9 @@ */ final class LineNumbers { + private static final Logger logger = Logger.getLogger(LineNumbers.class.getName()); + private static volatile boolean alreadyLoggedReadingFailure; + private static final int ASM_API_LEVEL = Opcodes.ASM9; private final Class type; @@ -67,10 +72,20 @@ public LineNumbers(Class type) throws IOException { if (in != null) { try { new ClassReader(in).accept(new LineNumberReader(), ClassReader.SKIP_FRAMES); - } catch (UnsupportedOperationException ignored) { + } catch (Exception ignored) { // We may be trying to inspect classes that were compiled with a more recent version // of javac than our ASM supports. If that happens, just ignore the class and don't - // capture line numbers. + // capture line numbers. But log the failure so folks know something's off. + // (Only log it once, though, to avoid spam. It's OK if concurrent access makes this + // happen more than once.) + if (!alreadyLoggedReadingFailure) { + alreadyLoggedReadingFailure = true; + logger.log( + Level.WARNING, + "Failed loading line numbers. ASM is probably out of date. Further failures won't" + + " be logged.", + ignored); + } } finally { try { in.close();