intuit / QuickBooks-V3-Java-SDK

Java SDK for QuickBooks REST API v3 services
Apache License 2.0
60 stars 142 forks source link

SDK does not work on JVM 17 (caused by CGLIB Enhancer) #179

Closed ashirman closed 1 year ago

ashirman commented 2 years ago

due to CGLIB's enhancer usage in SDK as this

public static <T> T createQueryEntity(T entity) {
        Class<?> cl = entity.getClass();
        Enhancer enhancer = new Enhancer();
        if (cl.isInterface()) {
            LOG.debug("The given entity is interface");
            //enhancer.setInterfaces(new Class[] { cl });
            //enhancer.setCallback(new MyMethodInterceptor());
        } else {
            enhancer.setSuperclass(cl);
            enhancer.setCallbackFilter(CALLBACK_FILTER);
            enhancer.setCallbacks(new Callback[] {NoOp.INSTANCE, new MyMethodInterceptor()});
        }
        return (T) enhancer.create();
    }

attempts to use createQueryEntity(...) method cause runtime issue as this one

class java.lang.ExceptionInInitializerError
at com.intuit.ipp.query.GenerateQuery.createQueryEntity(GenerateQuery.java:75)

From what we were able to find most likely issue is caused by Enhancer enhancer = new Enhancer(); see issue on CGLIG side https://github.com/cglib/cglib/issues/191

Looks like SDK contains just couple of places where CGLIG enhancer is used so assume long term solution would be to migrate from CGLIG to bytebuddy or any other alternative solutions. Looks like similar issues were mentioned here https://help.developer.intuit.com/s/question/0D54R00008bAjQZSA0/java-quickbooks-online-sdk-is-incompatible-with-java-17

fjolin-intuit commented 2 years ago

Thanks @ashirman for reporting this. We are have added for for this internally but it will not be prioritized until early May. I realize there are not any good work arounds so we will not full support for Java 17+ until that time. That being said we do encourage contribution from developers for things of this nature.

sujitharamadass commented 1 year ago

Closing this as the PR to migrate CGLIB to ByteBuddy is merged