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

can not call overload method #440

Open
ywf4026 opened this issue Dec 8, 2022 · 0 comments
Open

can not call overload method #440

ywf4026 opened this issue Dec 8, 2022 · 0 comments

Comments

@ywf4026
Copy link

ywf4026 commented Dec 8, 2022

when using java.lang.Math.pow(2, 2.5) function, get a javassist.CannotCompileException: [source error] pow(int,double) not found in java.lang.Math

The Class Math doesn't contain function pow(int, double), but contains pow(double,double).
Does javassist not support reload method?

       ClassPool pool = ClassPool.getDefault();
        pool.insertClassPath(new ClassClassPath(JavaasistTest.class));

        CtClass formulaClass = pool.makeClass("A");
        CtClass mapClass;
        try {
            mapClass = pool.get("java.util.Map");
        } catch (NotFoundException e) {
            throw new RuntimeException("Map exception");
        }

        CtMethod runMethod = new CtMethod(CtClass.doubleType, "run", new CtClass[]{mapClass}, formulaClass);
        runMethod.setModifiers(Modifier.PUBLIC);
        try {
            String body = "{double s = Math.pow(2, 2.5);return s;}";
            runMethod.setBody(body);
        } catch (CannotCompileException e) {
            throw new RuntimeException("CannotCompileException1 exception");
        }

javassist.CannotCompileException: [source error] pow(int,double) not found in java.lang.Math

@ywf4026 ywf4026 changed the title can not call reload method can not call overload method Dec 8, 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

1 participant