代码
object ClassByte {
fun add(x: Int, y: Int): Int {
// Test 是个class
var a = object : Test() {
}
return x + y
}
}
反编译完的结果
package actionscopefirst;
@Metadata(mv = {1, 1, 16}, bv = {1, 0, 3}, k = 1, d1 = {"\000\024\n\002\030\002\n\002\020\000\n\002\b\002\n\002\020\b\n\002\b\003\b��\002\030\0002\0020\001B\007\b\002��\006\002\020\002J\026\020\003\032\0020\0042\006\020\005\032\0020\0042\006\020\006\032\0020\004��\006\007"}, d2 = {"Lactionscopefirst/ClassByte;", "", "()V", "add", "", "x", "y", "learn"})
public final class ClassByte {
static {
ClassByte classByte = new ClassByte();
INSTANCE = classByte;
}
public static final ClassByte INSTANCE;
public final int add(int x, int y) {
ClassByte$add$a$1 a = new ClassByte$add$a$1();
return x + y;
}
@Metadata(mv = {1, 1, 16}, bv = {1, 0, 3}, k = 1, d1 = {"\000\013\n\000\n\002\030\002\n\000*\001\000\b\n\030\0002\0020\001��\006\002"}, d2 = {"actionscopefirst/ClassByte$add$a$1", "Lactionscopefirst/Test;", "learn"})
public static final class ClassByte$add$a$1 extends Test {}
}
结论
- 生成一个static INSTANCE对象;
- 直接用static对象调用function;
网友评论