#StackBounty: #java #android #reflection #android-8.0-oreo How to create an Object with private creator under PIE?

Bounty: 200

This class is defined under Android:

public abstract class EGLObjectHandle {
    private final long mHandle;

    protected EGLObjectHandle(long handle) {
        mHandle = handle;

    public long getNativeHandle() {
        return mHandle;


and also

public class EGLContext extends EGLObjectHandle {
    private EGLContext(long handle) {


now my problem is that I want to create an EGLContext with my handle. How to do this? before I do it with the function below but it’s not working anymore under PIE

  private android.opengl.EGLContext createSharedEGLContextObj(long handle) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    Class<?> classType =Class.forName("android.opengl.EGLContext"); 
    Class<?>[] types = new Class[] { long.class };
    Constructor constructor=classType.getDeclaredConstructor(types);
    Object object=constructor.newInstance(handle);
    return (android.opengl.EGLContext) object;

I need an EGLContext because I need to pass it to a procedure who require an EGLContext parameter, IE: createEgl14( android.opengl.EGLContext sharedContext)

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.