Skip to content

Commit

Permalink
Fixed the adapting from int to long
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Oct 28, 2017
1 parent 2031ef8 commit e2ddd0b
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,19 @@ public void inject(ClassVisitor cv) {
if ((access&ACC_ABSTRACT)==0) {
GeneratorAdapter ga = new GeneratorAdapter(mv, access, name, methodDescriptor);
mv.visitCode();

int sz = 0;

if (hasAdapterMethod()) {
// the LHS of the adapter method invocation
ga.loadThis();
sz++;
}

boolean isStatic = (access & ACC_STATIC) != 0;
if (!isStatic) {
mv.visitVarInsn(ALOAD,0);
sz++;
ga.loadThis();
sz++;
}

for (Type p : paramTypes) {
Expand All @@ -232,7 +240,7 @@ public void inject(ClassVisitor cv) {
}
mv.visitMethodInsn(
isStatic ? INVOKESTATIC : INVOKEVIRTUAL,internalClassName,name,desc);
if (adapterMethod!=null && adapterMethod.length()>0) {
if (hasAdapterMethod()) {
insertAdapterMethod(ga);
} else
if (castRequired) {
Expand All @@ -259,9 +267,11 @@ public void inject(ClassVisitor cv) {
mv.visitEnd();
}

private boolean hasAdapterMethod() {
return adapterMethod!=null && adapterMethod.length()>0;
}

private void insertAdapterMethod(GeneratorAdapter ga) {
ga.loadThis();
ga.swap();
ga.push(returnType);
ga.visitMethodInsn(INVOKEVIRTUAL, internalClassName, adapterMethod,
Type.getMethodDescriptor(
Expand Down

0 comments on commit e2ddd0b

Please sign in to comment.