diff --git a/compiler/preloader/instrumentation/src/org/jetbrains/jet/preloading/instrumentation/InterceptionInstrumenter.java b/compiler/preloader/instrumentation/src/org/jetbrains/jet/preloading/instrumentation/InterceptionInstrumenter.java index fd6e8acf178..3224ab4c8ac 100644 --- a/compiler/preloader/instrumentation/src/org/jetbrains/jet/preloading/instrumentation/InterceptionInstrumenter.java +++ b/compiler/preloader/instrumentation/src/org/jetbrains/jet/preloading/instrumentation/InterceptionInstrumenter.java @@ -175,25 +175,35 @@ public class InterceptionInstrumenter { } public byte[] instrument(String resourceName, byte[] data) { - List applicableInstrumenters = new ArrayList(); - String className = stripClassSuffix(resourceName); - for (Map.Entry classPatternEntry : classPatterns.entrySet()) { - String classPattern = classPatternEntry.getKey(); - ClassMatcher classMatcher = classPatternEntry.getValue(); - if (classMatcher.classPattern.matcher(className).matches()) { - neverMatchedClassPatterns.remove(classPattern); - applicableInstrumenters.addAll(classMatcher.instrumenters); + try { + String className = stripClassSuffix(resourceName); + if (className == null) { + // Not a .class file + return data; } + + List applicableInstrumenters = new ArrayList(); + for (Map.Entry classPatternEntry : classPatterns.entrySet()) { + String classPattern = classPatternEntry.getKey(); + ClassMatcher classMatcher = classPatternEntry.getValue(); + if (classMatcher.classPattern.matcher(className).matches()) { + neverMatchedClassPatterns.remove(classPattern); + applicableInstrumenters.addAll(classMatcher.instrumenters); + } + } + + if (applicableInstrumenters.isEmpty()) return data; + + return instrument(data, applicableInstrumenters); + } + catch (Throwable e) { + throw new IllegalStateException("Exception while instrumenting " + resourceName, e); } - - if (applicableInstrumenters.isEmpty()) return data; - - return instrument(data, applicableInstrumenters); } private static String stripClassSuffix(String name) { String suffix = ".class"; - if (!name.endsWith(suffix)) return name; + if (!name.endsWith(suffix)) return null; return name.substring(0, name.length() - suffix.length()); }