Skip to content

Commit

Permalink
[FLINK-3143] update Closure Cleaner's ASM references to ASM5
Browse files Browse the repository at this point in the history
- This solves errors with reflectasm using Scala 2.11 and Java 8

This closes apache#1445.
  • Loading branch information
mxm committed Dec 9, 2015
1 parent 3de49f5 commit e28b62e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class This0AccessFinder extends ClassVisitor {
private String this0Name;

public This0AccessFinder(String this0Name) {
super(Opcodes.ASM4);
super(Opcodes.ASM5);
this.this0Name = this0Name;
}

Expand All @@ -115,7 +115,7 @@ public boolean isThis0Accessed() {

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String sig, String[] exceptions) {
return new MethodVisitor(Opcodes.ASM4) {
return new MethodVisitor(Opcodes.ASM5) {

@Override
public void visitFieldInsn(int op, String owner, String name, String desc) {
Expand All @@ -125,4 +125,4 @@ public void visitFieldInsn(int op, String owner, String name, String desc) {
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,28 @@ object ClosureCleaner {
}

private[flink]
class ReturnStatementFinder extends ClassVisitor(ASM4) {
class ReturnStatementFinder extends ClassVisitor(ASM5) {
override def visitMethod(access: Int, name: String, desc: String,
sig: String, exceptions: Array[String]): MethodVisitor = {
if (name.contains("apply")) {
new MethodVisitor(ASM4) {
new MethodVisitor(ASM5) {
override def visitTypeInsn(op: Int, tp: String) {
if (op == NEW && tp.contains("scala/runtime/NonLocalReturnControl")) {
throw new InvalidProgramException("Return statements aren't allowed in Flink closures")
}
}
}
} else {
new MethodVisitor(ASM4) {}
new MethodVisitor(ASM5) {}
}
}
}

private[flink]
class FieldAccessFinder(output: Map[Class[_], Set[String]]) extends ClassVisitor(ASM4) {
class FieldAccessFinder(output: Map[Class[_], Set[String]]) extends ClassVisitor(ASM5) {
override def visitMethod(access: Int, name: String, desc: String,
sig: String, exceptions: Array[String]): MethodVisitor = {
new MethodVisitor(ASM4) {
new MethodVisitor(ASM5) {
override def visitFieldInsn(op: Int, owner: String, name: String, desc: String) {
if (op == GETFIELD) {
for (cl <- output.keys if cl.getName == owner.replace('/', '.')) {
Expand All @@ -297,7 +297,7 @@ class FieldAccessFinder(output: Map[Class[_], Set[String]]) extends ClassVisitor
}
}

private[flink] class InnerClosureFinder(output: Set[Class[_]]) extends ClassVisitor(ASM4) {
private[flink] class InnerClosureFinder(output: Set[Class[_]]) extends ClassVisitor(ASM5) {
var myName: String = null

override def visit(version: Int, access: Int, name: String, sig: String,
Expand All @@ -307,7 +307,7 @@ private[flink] class InnerClosureFinder(output: Set[Class[_]]) extends ClassVisi

override def visitMethod(access: Int, name: String, desc: String,
sig: String, exceptions: Array[String]): MethodVisitor = {
new MethodVisitor(ASM4) {
new MethodVisitor(ASM5) {
override def visitMethodInsn(op: Int, owner: String, name: String,
desc: String) {
val argTypes = Type.getArgumentTypes(desc)
Expand Down

0 comments on commit e28b62e

Please sign in to comment.