Encapsulation of sun.misc.Unsafe.defineClass
Christian Beikov
christian.beikov at gmail.com
Sat Sep 12 21:17:58 UTC 2015
Hello,
I am using Unsafe to define a class which normally wouldn't pass the
bytecode verification.
I do this because I want to initialize fields before invoking the super
constructor. That way I can use e.g. a getter in the super constructor.
I don't depend on this specific behavior but I guess there are valid use
cases which would actually benefit from something like that.
I mainly wanted my use case to be heard, because I couldn't find any
plans on encapsulating this part of sun.misc.Unsafe.
Allowing to skip the verifier completely might be too unsafe, but I
guess there are some edge cases for which an "extended mode" of the
verifier would make sense. This "extended mode" would allow e.g.
initializing fields before calling the super constructor and maybe some
other things.
Maybe there are some relaxations of the verifier rules that language
writers would like to see in such an "extended mode"?
Regards,
Christian
More information about the jigsaw-dev
mailing list