-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About instantiation. #110
Comments
@Littlenotch-Jacuzzi , I am getting
if I replace objenesis with Unsafe |
@kostaskougios private static Unsafe hackUnsafe() {
try {
Field field = Unsafe.class.getDeclaredField("theUnsafe");
field.setAccessible(true);
return (Unsafe) field.get(null);
} catch (Exception e) {
e.printStackTrace();
}
return null;
} Use this method to replace the Unsafe.getUnsafe() method. |
Note that the efficiency of the Unsafe.allocateInstance() method is about 2000 times that of Objenesis. But the instantiated objects has not gone any initialization, and the fields in these objects are all null(reference type) or default values(basic type). |
I recommend you to use sun.misc.Unsafe.allocateInstance(), the Objenesis will be not available when the class is dynamically generated(It causes NoClassDefFoundError like #100 and problems in #45).
The text was updated successfully, but these errors were encountered: