Home » Java » What to use instead of `defineClass` in Java10?

What to use instead of `defineClass` in Java10?

Posted by: admin June 30, 2018 Leave a comment

Questions:

I use method defineClass() from the ClassLoader to define a class from the byte array. I fetch this method using reflection:

ClassLoader.class.getDeclaredMethod(
    "defineClass", String.class, byte[].class, int.class, int.class);

Java10 complains about reflective usage of defineClass.

What should I use instead?

Answers: