Skip to content

Commit

Permalink
Test case to show a failure to bridge int to long
Browse files Browse the repository at this point in the history
long requires more bits in stack that breaks SWAP bytecode
  • Loading branch information
kohsuke committed Oct 28, 2017
1 parent 8fb551d commit 2031ef8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions injector/src/test/client/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public static void main(String[] args) throws Exception {
assertEquals("http://kohsuke.org/",a.o());

new Adapter.SomeClass().someMethod();

assertEquals(1,a.l());
}

private static void assertEquals(Object expected, Object actual) {
Expand Down
2 changes: 2 additions & 0 deletions injector/src/test/v1/Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public void someMethod() {
}
}

// we will evolve this from int -> long
public int l() { return 1; }
}
4 changes: 4 additions & 0 deletions injector/src/test/v2/Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ public void someMethod() {
}
}

@WithBridgeMethods(value=int.class, adapterMethod="l2i")
public long l() { return 1L; }

private Object l2i(long v, Class type) { return (int)v; }
}

0 comments on commit 2031ef8

Please sign in to comment.