Skip to content

Commit

Permalink
Improved error messages: report which class crashed Retrolambda
Browse files Browse the repository at this point in the history
Relates to #69
  • Loading branch information
luontola committed Dec 18, 2015
1 parent dbe9fa5 commit 60bcc67
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ Version History
methods which are placed in the interface's companion class, to avoid
them getting out of sync with their erased method descriptors
([Issue #48](https://github.com/orfjackal/retrolambda/issues/48))
- Improved error messages: report which class crashed Retrolambda

### Retrolambda 2.0.1 (2015-04-06)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,35 @@ private List<byte[]> extractInterfaceCompanion(ClassNode clazz) {
}

private byte[] transform(ClassNode node, ClassVisitorChain chain) {
return transform(node::accept, chain);
return transform(node.name, node::accept, chain);
}

private byte[] transform(ClassReader reader, ClassVisitorChain chain) {
return transform(cv -> reader.accept(cv, 0), chain);
return transform(reader.getClassName(), cv -> reader.accept(cv, 0), chain);
}

private byte[] transform(Consumer<ClassVisitor> reader, ClassVisitorChain chain) {
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
ClassVisitor next = writer;
private byte[] transform(String className, Consumer<ClassVisitor> reader, ClassVisitorChain chain) {
try {
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
ClassVisitor next = writer;

next = new LowerBytecodeVersion(next, targetVersion);
if (targetVersion < Opcodes.V1_7) {
next = new SwallowSuppressedExceptions(next);
next = new RemoveMethodHandlesLookupReferences(next);
}
next = new FixInvokeStaticOnInterfaceMethod(next);
next = chain.wrap(next);
next = new LowerBytecodeVersion(next, targetVersion);
if (targetVersion < Opcodes.V1_7) {
next = new SwallowSuppressedExceptions(next);
next = new RemoveMethodHandlesLookupReferences(next);
}
next = new FixInvokeStaticOnInterfaceMethod(next);
next = chain.wrap(next);

reader.accept(next);
return writer.toByteArray();

reader.accept(next);
return writer.toByteArray();
} catch (Throwable t) {
if (className != null) {
className = className.replace('/', '.');
}
throw new RuntimeException("Failed to transform class " + className, t);
}
}

private interface ClassVisitorChain {
Expand Down

0 comments on commit 60bcc67

Please sign in to comment.