Why I get this error
Exception in thread "main" java.lang.SecurityException: Unsafe
when I run my code
public class UnsafeString {
public static void main(String[] args) throws InstantiationException {
String obj = new UnsafeString().create();
System.out.println(obj);
}
public String create() throws InstantiationException {
return (String) sun.misc.Unsafe.getUnsafe().allocateInstance(String.class);
}
}