https://github.com/xxdark/genesis
https://github.com/xxdark/genesis
constructor java
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/xxdark/genesis
- Owner: xxDark
- Created: 2024-04-06T15:17:05.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-09T15:37:34.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T09:41:35.670Z (11 months ago)
- Topics: constructor, java
- Language: Java
- Homepage:
- Size: 60.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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);
}
}
```