-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8827a4
commit 020c453
Showing
4 changed files
with
59 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,47 @@ If the invoked interface method has a return type but not a `void` type, its byt | |
- [x] void return type | ||
- [ ] other return type | ||
|
||
|
||
## Principle | ||
|
||
Before: | ||
|
||
|
||
|
||
``` | ||
invokeinterface #3, 2 // InterfaceMethod Callback.onProgress:(I)V | ||
``` | ||
|
||
|
||
After: | ||
|
||
|
||
``` | ||
invokestatic #23 // Method buoy$onProgress:(LCallback;I)V | ||
static void buoy$onProgress(JavaSample$Callback, int); | ||
Code: | ||
0: aload_0 | ||
1: ldc #25 // String Callback | ||
3: ldc #27 // String Callback.onProgress:(int)void | ||
5: invokestatic #33 // Method com/smartdengg/interfacebuoy/compiler/InterfaceBuoy.proxy:(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object; | ||
8: iload_1 | ||
9: invokeinterface #37, 2 // InterfaceMethod Callback.onProgress:(I)V | ||
14: return | ||
``` | ||
|
||
1. Replaces `invokeinterface ` with `invokestatic` at compile time. | ||
|
||
2. Generated `Buoy$onProgress` method at compile time to prevent calling interface methods on an null object. | ||
|
||
|
||
## About me | ||
|
||
email : [email protected] | ||
|
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
17 changes: 17 additions & 0 deletions
17
interface-buoy-app/src/main/java/com/smartdengg/interfacebuoy/sample/App.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,17 @@ | ||
package com.smartdengg.interfacebuoy.sample; | ||
|
||
import android.app.Application; | ||
import com.smartdengg.interfacebuoy.compiler.BuoySettings; | ||
|
||
/** | ||
* 创建时间: 2019/02/18 11:15 <br> | ||
* 作者: SmartDengg <br> | ||
* 描述: | ||
*/ | ||
public class App extends Application { | ||
|
||
@Override public void onCreate() { | ||
super.onCreate(); | ||
BuoySettings.loggable = true; | ||
} | ||
} |
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