-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow calls to methods on arrays
- Loading branch information
1 parent
332984a
commit 5d8f8ca
Showing
4 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
jasm-composition-jvm/src/test/java/me/darknet/assembler/Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package me.darknet.assembler; | ||
|
||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
exec(Test::example); | ||
} | ||
|
||
// the code we want to run | ||
static void example() { | ||
System.out.println("hi"); | ||
throw new RuntimeException(); | ||
} | ||
|
||
// runs a runnable | ||
static void exec(Runnable r) { | ||
r.run(); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
jasm-composition-jvm/src/test/resources/samples/jasm/Example-methods-on-arrays.jasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.super java/lang/Object | ||
.class public super Example { | ||
.method callArrayMethod ()V { | ||
parameters: { this }, | ||
code: { | ||
A: | ||
iconst_1 | ||
anewarray java/lang/String | ||
// as a edge case, arrays are allowed to access all methods from Object | ||
invokevirtual [Ljava/lang/String;.clone ()Ljava/lang/Object; | ||
pop | ||
return | ||
B: | ||
} | ||
} | ||
} |