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

net.sf.cglib.core.ReflectUtils#OBJECT_METHODS cause the upgrade of asm to fail #205

Open
jesesun opened this issue May 13, 2022 · 0 comments

Comments

@jesesun
Copy link

jesesun commented May 13, 2022

Background:

Since cglib versions lower than 3.1 are not compatible with asm 4.1+. So when upgrading asm version, you also need to upgrade cglib.

The latest cglib version contains a piece of code authored by @vlsi in the commit b4cd1d6.

Source code snippet:

    Method[] methods = Object.class.getDeclaredMethods();
    for (Method method : methods) {
        if ("finalize".equals(method.getName())
                || (method.getModifiers() & (Modifier.FINAL | Modifier.STATIC)) > 0) {
            continue;
        }
        OBJECT_METHODS.add(method);
    }

Issue:

The skip of finalize and final/static methods from the Object.class will cause an java.lang.IllegalArgumentException exception.

Test code snippet:

public void test_getMethod() throws IllegalArgumentException {
    Class<?> clazz = Assertions.class;
    FastClass fc = FastClass.create(clazz);
    Method[] methods = clazz.getMethods();
    for (Method m : methods) {
        // throws "java.lang.IllegalArgumentException: Cannot find method public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException"
        fc.getMethod(m);
    }
}

Exception stack:

java.lang.IllegalArgumentException: Cannot find method public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException

at net.sf.cglib.reflect.FastMethod.helper(FastMethod.java:39)
at net.sf.cglib.reflect.FastMethod.<init>(FastMethod.java:28)
at net.sf.cglib.reflect.FastClass.getMethod(FastClass.java:104)
at net.sf.cglib.reflect.TestFastClass.test_getMethod(TestFastClass.java:677)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at junit.framework.TestCase.runTest(TestCase.java:176)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:252)
at junit.framework.TestSuite.run(TestSuite.java:247)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
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