Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Build failing with Hugo #4

Closed
vinc3m1 opened this issue Feb 19, 2014 · 7 comments
Closed

Android Build failing with Hugo #4

vinc3m1 opened this issue Feb 19, 2014 · 7 comments

Comments

@vinc3m1
Copy link

vinc3m1 commented Feb 19, 2014

here's the gradle stacktrace:

Saving lambda class: me/dashwith/ui/profile/login/LogInFragment$$Lambda$1
Saving lambda class: me/dashwith/ui/profile/login/LogInFragment$$Lambda$2
Saving lambda class: me/dashwith/ui/profile/login/LogInFragment$$Lambda$3
Saving lambda class: me/dashwith/ui/profile/login/LogInFragment$$Lambda$4
Saving lambda class: me/dashwith/ui/profile/ProfileFragment$$Lambda$1
Saving lambda class: me/dashwith/ui/profile/signup/SignUpFragment1NameEmail$$Lambda$1
Saving lambda class: me/dashwith/ui/profile/signup/SignUpFragment1NameEmail$$Lambda$2
Saving lambda class: me/dashwith/ui/profile/signup/SignUpFragment1NameEmail$$Lambda$3
Error! Failed to transform some classes
java.lang.RuntimeException: java.lang.IllegalAccessException: no such method: me.dashwith.ui.profile.signup.SignUpFragment2PasswordPhoneBday.lambda$onActivityCreated$8(Boolean)Boolean/invokeStatic
    at net.orfjackal.retrolambda.LambdaReifier.reifyLambdaClass(LambdaReifier.java:34)
    at net.orfjackal.retrolambda.LambdaUsageBackporter$InvokeDynamicInsnConvertingMethodVisitor.backportLambda(LambdaUsageBackporter.java:84)
    at net.orfjackal.retrolambda.LambdaUsageBackporter$InvokeDynamicInsnConvertingMethodVisitor.visitInvokeDynamicInsn(LambdaUsageBackporter.java:76)
    at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1438)
    at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1017)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:693)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
    at net.orfjackal.retrolambda.LambdaUsageBackporter.transform(LambdaUsageBackporter.java:19)
    at net.orfjackal.retrolambda.Main$1.transform(Main.java:40)
    at net.orfjackal.retrolambda.BytecodeTransformingFileVisitor.visitFile(BytecodeTransformingFileVisitor.java:25)
    at net.orfjackal.retrolambda.BytecodeTransformingFileVisitor.visitFile(BytecodeTransformingFileVisitor.java:11)
    at java.nio.file.Files.walkFileTree(Files.java:2667)
    at java.nio.file.Files.walkFileTree(Files.java:2739)
    at net.orfjackal.retrolambda.Main.main(Main.java:38)
Caused by: java.lang.IllegalAccessException: no such method: me.dashwith.ui.profile.signup.SignUpFragment2PasswordPhoneBday.lambda$onActivityCreated$8(Boolean)Boolean/invokeStatic
    at java.lang.invoke.MemberName.makeAccessException(MemberName.java:872)
    at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:993)
    at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1377)
    at java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:774)
    at net.orfjackal.retrolambda.LambdaReifier.toMethodHandle(LambdaReifier.java:107)
    at net.orfjackal.retrolambda.LambdaReifier.asmToJdkType(LambdaReifier.java:91)
    at net.orfjackal.retrolambda.LambdaReifier.callBootstrapMethod(LambdaReifier.java:74)
    at net.orfjackal.retrolambda.LambdaReifier.reifyLambdaClass(LambdaReifier.java:30)
    ... 13 more
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 12
Exception Details:
  Location:
    me/dashwith/ui/profile/signup/SignUpFragment2PasswordPhoneBday.onKey_aroundBody0(Lme/dashwith/ui/profile/signup/SignUpFragment2PasswordPhoneBday;Landroid/view/View;ILandroid/view/KeyEvent;Lorg/aspectj/lang/JoinPoint;)Z @3: if_icmpne
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0000000: 1c10 42a0 0009 2ab6 005c 04ac 03ac     

    at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
    at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:965)
    at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:990)
    ... 19 more
:compileRetrolambdaDebug FAILED
@vinc3m1
Copy link
Author

vinc3m1 commented Feb 19, 2014

Hm, nope reverted to b121 and I'm still getting the same error...

@vinc3m1
Copy link
Author

vinc3m1 commented Feb 19, 2014

oh woah just read into the stacktrace and noticed this only happens when used in conjunction with Hugo, maybe I should file this bug there? cc @JakeWharton

@JakeWharton
Copy link
Contributor

Both do bytecode weaving so it's unsurprising that they clash.

@vinc3m1
Copy link
Author

vinc3m1 commented Feb 19, 2014

Ah, that makes sense. I originally thought Hugo was just code gen.

@luontola
Copy link
Owner

The error message suggests that the SignUpFragment2PasswordPhoneBday.onKey_aroundBody0 method contains invalid bytecode - whoever generated or transformed that method forgot to generate the stackmap frames.

Is that a hand-written or generated method? If generated, what generates it? Does the method contain lambda expressions? Does the same error happen if you run the application with JDK 8, without Retrolambda, so that it loads the SignUpFragment2PasswordPhoneBday class.

Looking at the parameter list of the method, it looks like generated by AspectJ. Which version of AspectJ are you using? Is that version compatible with Java 8? (AspectJ 1.8.0.M1 mentions Java 8 compatibility.)

@vinc3m1
Copy link
Author

vinc3m1 commented Feb 19, 2014

That method is generated by Hugo so those would all be great questions for @JakeWharton 😃

I doubt Hugo is compatible with Java 8 at the moment, and if the fix takes some effort this might be worth postponing until Java 8 is formally released. Everything works fine if I don't use Hugo, so I'm alright for now.

@luontola
Copy link
Owner

OK, good to know. Maybe you can try to change the AspectJ version that Hugo uses to be AspectJ 1.8.0.M1.

I'll close this issue now since it seems to be unrelated to Retrolambda.

Arneball added a commit to Arneball/retrolambda that referenced this issue Aug 11, 2014
public interface MyInterface {
    default String def() {
        return "[" + toString() + ", " + "def]";
    }

    default String join(MyInterface other) {
        return def() + other.def();
    }
}

class C implements MyInterface{}  compiles to:

public class testpackage.MyClass implements testpackage.MyInterface {
  public testpackage.MyClass();
    Code:
       0: aload_0
       1: invokespecial luontola#16                 // Method java/lang/Object."<init>":()V
       4: return

  public java.lang.String join(testpackage.MyInterface);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  luontola#46                 // Method testpackage/MyInterfacehelper.join:(Ltestpackage/MyInterface;Ltestpackage/MyInterface;)Ljava/lang/String;
       5: areturn

  public java.lang.String def();
    Code:
       0: aload_0
       1: invokestatic  luontola#49                 // Method testpackage/MyInterfacehelper.def:(Ltestpackage/MyInterface;)Ljava/lang/String;
       4: areturn
}

Where testpackage.MyInterfacehelper is compiled to
public class testpackage.MyInterfacehelper {
  private testpackage.MyInterfacehelper();
    Code:
       0: aload_0
       1: invokespecial luontola#9                  // Method java/lang/Object."<init>":()V
       4: return

  public static java.lang.String def(testpackage.MyInterface);
    Code:
       0: new           luontola#13                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial luontola#14                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           luontola#16                 // String [
       9: invokevirtual luontola#20                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: invokevirtual luontola#24                 // Method java/lang/Object.toString:()Ljava/lang/String;
      16: invokevirtual luontola#20                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: ldc           luontola#26                 // String ,
      21: invokevirtual luontola#20                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: ldc           luontola#28                 // String def]
      26: invokevirtual luontola#20                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      29: invokevirtual luontola#29                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      32: areturn

  public static java.lang.String join(testpackage.MyInterface, testpackage.MyInterface);
    Code:
       0: new           luontola#13                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial luontola#14                 // Method java/lang/StringBuilder."<init>":()V
       7: aload_0
       8: invokeinterface luontola#35,  1           // InterfaceMethod testpackage/MyInterface.def:()Ljava/lang/String;
      13: invokevirtual luontola#20                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      16: aload_1
      17: invokeinterface luontola#35,  1           // InterfaceMethod testpackage/MyInterface.def:()Ljava/lang/String;
      22: invokevirtual luontola#20                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      25: invokevirtual luontola#29                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      28: areturn
}

==============
interface StaticTest {
    static <T> T staticMethod(T t) {
        return t;
    }
}
compiles to
public class testpackage.StaticTesthelper {
  private testpackage.StaticTesthelper();
    Code:
       0: aload_0
       1: invokespecial luontola#9                  // Method java/lang/Object."<init>":()V
       4: return

  public static <T> T staticMethod$static(T);
    Code:
       0: aload_0
       1: areturn
}

========

Brigde methods are generated properly in example:
public interface BridgeParent<T> {
    T get();
}
public interface StringBridges extends BridgeParent<String> {
    @OverRide
    default String get() {
        return "default method";
    }

    default String concrete() {
        return "concrete";
    }
}
public class testpackage.StringBridgeshelper
  SourceFile: "testpackage/StringBridges.java"
  minor version: 0
  major version: 50
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   luontola#1 = Utf8               testpackage/StringBridgeshelper
   luontola#2 = Class              luontola#1             //  testpackage/StringBridgeshelper
   luontola#3 = Utf8               java/lang/Object
   luontola#4 = Class              luontola#3             //  java/lang/Object
   luontola#5 = Utf8               testpackage/StringBridges.java
   luontola#6 = Utf8               <init>
   luontola#7 = Utf8               ()V
   luontola#8 = NameAndType        luontola#6:luontola#7          //  "<init>":()V
   luontola#9 = Methodref          luontola#4.luontola#8          //  java/lang/Object."<init>":()V
  luontola#10 = Utf8               get
  luontola#11 = Utf8               (Ltestpackage/StringBridges;)Ljava/lang/String;
  luontola#12 = Utf8               default method
  luontola#13 = String             luontola#12            //  default method
  luontola#14 = Utf8               concrete
  luontola#15 = String             luontola#14            //  concrete
  luontola#16 = Utf8               (Ltestpackage/StringBridges;)Ljava/lang/Object;
  luontola#17 = Utf8               testpackage/StringBridges
  luontola#18 = Class              luontola#17            //  testpackage/StringBridges
  luontola#19 = Utf8               ()Ljava/lang/String;
  luontola#20 = NameAndType        luontola#10:luontola#19        //  get:()Ljava/lang/String;
  luontola#21 = InterfaceMethodref luontola#18.luontola#20        //  testpackage/StringBridges.get:()Ljava/lang/String;
  luontola#22 = Utf8               Code
  luontola#23 = Utf8               LineNumberTable
  luontola#24 = Utf8               SourceFile
{
  private testpackage.StringBridgeshelper();
    descriptor: ()V
    flags: ACC_PRIVATE
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial luontola#9                  // Method java/lang/Object."<init>":()V
         4: return

  public static java.lang.String get(testpackage.StringBridges);
    descriptor: (Ltestpackage/StringBridges;)Ljava/lang/String;
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=1, locals=1, args_size=1
         0: ldc           luontola#13                 // String default method
         2: areturn
      LineNumberTable:
        line 9: 0

  public static java.lang.String concrete(testpackage.StringBridges);
    descriptor: (Ltestpackage/StringBridges;)Ljava/lang/String;
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=1, locals=1, args_size=1
         0: ldc           luontola#15                 // String concrete
         2: areturn
      LineNumberTable:
        line 13: 0

  public static java.lang.Object get(testpackage.StringBridges);
    descriptor: (Ltestpackage/StringBridges;)Ljava/lang/Object;
    flags: ACC_PUBLIC, ACC_STATIC, ACC_BRIDGE, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokeinterface luontola#21,  1           // InterfaceMethod testpackage/StringBridges.get:()Ljava/lang/String;
         6: areturn
      LineNumberTable:
        line 6: 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants