An open API service indexing awesome lists of open source software.

https://github.com/xxdark/genesis


https://github.com/xxdark/genesis

constructor java

Last synced: 10 months ago
JSON representation

Awesome Lists containing this project

README

          

# genesis

Control when constructor is called.

```java
public class Test {

public Test() {
System.out.println(this);
}

public static void main(String[] args) throws Throwable {
Test test = Genesis.allocateInstance(Test.class);
MethodHandle ctor = MethodHandles.publicLookup().findConstructor(Test.class, MethodType.methodType(void.class));
MethodHandle constructorInvoker = Genesis.construtorAsInvoker(ctor);
constructorInvoker.invokeExact(test);
constructorInvoker.invokeExact(test);
}
}
```