Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.AbstractMethodError in com.sun.proxy.$Proxy117 #429

Closed
angryfang opened this issue Jul 1, 2022 · 5 comments
Closed

java.lang.AbstractMethodError in com.sun.proxy.$Proxy117 #429

angryfang opened this issue Jul 1, 2022 · 5 comments

Comments

@angryfang
Copy link

angryfang commented Jul 1, 2022

Use jdk proxy thrift iface Implement class,when add or sub filed in thrift method, sometimes hotswap failed。when client calls the server, I got the error in server

java.lang.AbstractMethodError: com.test.HelloThriftService.hello(Ljava/lang/String;)Ljava/lang/String;
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]

I found proxy class signatureMap equal judge sometimes are not right, and I made some fixed up as below

public class ReloadJavaProxyCommand extends MergeableCommand {
   //......

    public void executeSingleCommand() {
        try {
            Class<?> clazz = classLoader.loadClass(className);
            Map<String, String> signatureMap = ProxyClassSignatureHelper.getNonSyntheticSignatureMap(clazz);
            LOGGER.debug("executeSingleCommand class:{}, signature equals:{}", className, signatureMap.equals(signatureMapOrig));
            if (!signatureMap.equals(signatureMapOrig) || !isImplementInterface(signatureMap, clazz)) {
                byte[] generateProxyClass = ProxyGenerator.generateProxyClass(className, clazz.getInterfaces());
                Map<Class<?>, byte[]> reloadMap = new HashMap<>();
                reloadMap.put(clazz, generateProxyClass);
                PluginManager.getInstance().hotswap(reloadMap);
                LOGGER.reload("Class '{}' has been reloaded.", className);
            }
            ProxyPlugin.removeProxyDefiningClassName(className);
        } catch (ClassNotFoundException e) {
            LOGGER.error("Error redefining java proxy {}", e, className);
        }
    }

    // Whether all methods of the interface are implemented
    private boolean isImplementInterface(Map<String, String> signatureMap, Class<?> clazz) {
        String clazzSignature = "";
        try {
            clazzSignature = ProxyClassSignatureHelper.getJavaClassSignature(clazz).replaceAll("final ", "");
            LOGGER.debug("clazzSignature: {}", clazzSignature);
        } catch (Exception e) {
            LOGGER.error("Error getJavaClassSignature {}", clazz, e);
            return true;
        }
        for (Map.Entry<String, String> entry : signatureMap.entrySet()) {
            if(clazzSignature.contains(entry.getKey()) && entry.getValue().contains("public abstract")) {
                LOGGER.debug("{} Signature: {}", entry.getKey(), entry.getValue());
                String[] methodSigatures = entry.getValue().replaceAll("abstract ", "").split(";");
                for (String methodSigature : methodSigatures) {
                    if(!clazzSignature.contains(methodSigature)) {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}
@angryfang angryfang changed the title java.lang.AbstractMethodError java.lang.AbstractMethodError in com.sun.proxy.$Proxy117 Jul 1, 2022
@skybber
Copy link
Contributor

skybber commented Jul 1, 2022

Is it java17 related? Jdk proxy has changed on java17 , there is no fix for it in the HA yet. (I see 1.8.0_181 but not sure if you are really using java8)

@angryfang
Copy link
Author

Is it java17 related? Jdk proxy has changed on java17 , there is no fix for it in the HA yet. (I see 1.8.0_181 but not sure if you are really using java8)

I use java8 and java11

@skybber
Copy link
Contributor

skybber commented Jul 1, 2022

Could you please make PR?

angryfang pushed a commit to angryfang/HotswapAgent that referenced this issue Jul 1, 2022
@angryfang
Copy link
Author

Could you please make PR?

I have just submit my change to personal fork project, and create a pull request, is that PR meaning?

@skybber
Copy link
Contributor

skybber commented Jul 1, 2022

yes

skybber added a commit that referenced this issue Jul 1, 2022
fix java.lang.AbstractMethodError in com.sun.proxy.$Proxy117 #429
@skybber skybber closed this as completed Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants