cglib - Byte Code Generation Library is high level API to generate and transform Java byte code. It is used by AOP, testing, data access frameworks to generate dynamic proxy objects and intercept field access.

Overview

cglib Build Status

Byte Code Generation Library is high level API to generate and transform JAVA byte code. It is used by AOP, testing, data access frameworks to generate dynamic proxy objects and intercept field access. https://github.com/cglib/cglib/wiki

How To: https://github.com/cglib/cglib/wiki/How-To

Latest Release: https://github.com/cglib/cglib/releases/latest

All Releases: https://github.com/cglib/cglib/releases

cglib-#.#_#.jar binary distribution, CGLIB classes only, it must be used to extend cglib classes dependant on ASM API

cglib-nodep-#.#_#.jar binary distribution, CGLIB and renamed ASM classes, not extendable

Comments
  • Cache related issue with class definitions

    Cache related issue with class definitions

    Hi,

    Since CGLIB 3.2.1+ (including 3.2.3) I experience the following error:

    net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
        at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332)
        at net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:445)
        at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:85)
        at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:83)
        at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
        at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
        at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:108)
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:282)
        at net.sf.cglib.proxy.Enhancer.nextInstance(Enhancer.java:643)
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:286)
        at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:433)
        at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:304)
        at org.apache.wicket.jmx.Initializer.createProxy(Initializer.java:295)
        at org.apache.wicket.jmx.Initializer.register(Initializer.java:249)
        at org.apache.wicket.jmx.Initializer.init(Initializer.java:192)
        at org.apache.wicket.Application.initInitializers(Application.java:568)
        at org.apache.wicket.Application.initApplication(Application.java:776)
        at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:431)
        at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:355)
        at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:137)
        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:856)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:346)
        at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1380)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)
        at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:518)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
        at org.eclipse.jetty.server.Server.start(Server.java:405)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
        at org.eclipse.jetty.server.Server.doStart(Server.java:372)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.apache.wicket.examples.StartExamples.main(StartExamples.java:110)
    Caused by: java.lang.reflect.InvocationTargetException
        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 net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:409)
        at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:323)
        ... 36 more
    Caused by: java.lang.LinkageError: loader (instance of  org/eclipse/jetty/webapp/WebAppClassLoader): attempted  duplicate class definition for name: "org/apache/wicket/jmx/Application"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        ... 42 more
    

    There is no such error with 3.2.0. The CGLIB related code that is involved is https://github.com/apache/wicket/blob/7973959f169a1c44c1de18a6acde21c8b926d64c/wicket-jmx/src/main/java/org/apache/wicket/jmx/Initializer.java#L256-L294

    Any idea what could be the reason ?

    opened by martin-g 59
  • Memory leak caused by identical classes being generated

    Memory leak caused by identical classes being generated

    We're having an issue where our spring-based JSF webapp throws an OOM after a few days (Spring 4.2.6 with cglib 3.2.2). I've tracked it down to the proxy classes that are generated for the Spring/JSF beans: instead of reusing the already generated cglib class definition, new ones are generated quite frequently. Since the classes themselves won't get garbage collected we run out of memory after a few days.

    I've created a small example (mirroring the way spring uses cglib internally) to reproduce the issue:

    while (true) {
                Enhancer enhancer = new Enhancer();
                enhancer.setSuperclass(SampleClass.class);
                enhancer.setCallbackFilter(new CallbackFilter() {
                    @Override
                    public int accept(Method method) {
                        return 0;
                    }
                    @Override
                    public boolean equals(Object obj) {
                        return true;
                    }
    
                    @Override
                    public int hashCode() {
                        return 0;
                    }
                });
                enhancer.setInterfaces(new Class[]{SampleI.class});
                enhancer.setCallback(new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        if (method.getDeclaringClass() != Object.class
                                && method.getReturnType() == String.class) {
                            System.out.println("Hello cglib!");
                            return null;
                        } else {
                            throw new RuntimeException("Do not know what to do.");
                        }
                    }});
                SampleClass proxy = (SampleClass) enhancer.create();
                proxy.test("2");
                Thread.sleep(30);
            }
    

    SampleClass is just:

    public class SampleClass implements SampleI {
    
        public String test(String s) {
            return s;
        }
    
    }
    

    After every GC run, the cached generated classes are no longer used, instead new ones are generated. See attached shot from memory profiler 2016-06-16 11_51_00-cg - yourkit java profiler 2016 02-b38 - 64-bit

    I've tracked this down to the LoadingCache and the use of a CallbackFilter on the Enhancer. The CallbackFilter is kept via WeakReference and used as part of the map key in the cache. If the filter is not referenced from outside it will be GC'd, so the entry in the cache won't be found any more.

    opened by asocaciu 34
  • ReflectUtils breaks with Java 9 build 148+

    ReflectUtils breaks with Java 9 build 148+

    Since Java 9 build 148, it is no longer possible to do setAccessible on any public Java runtime API class (except sun.misc.Unsafe as special case). This affects ClassLoader#defineClass (protected method).

    Because of this any mocking library (Mockito, EasyMock,...) that uses CGLIB breaks with ExceptionOnInitializer.

    Example in Apache Solr (Mockito/Easymock):

       [junit4] ERROR   0.38s J2 | TestManagedSchemaThreadSafety.testThreadSafety <<<
       [junit4]    > Throwable #1: java.lang.ExceptionInInitializerError
       [junit4]    >        at __randomizedtesting.SeedInfo.seed([8E654E5E1F32A757:142F5A06CCAD15A1]:0)
       [junit4]    >        at org.mockito.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:167)
       [junit4]    >        at org.mockito.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
       [junit4]    >        at org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:217)
       [junit4]    >        at org.mockito.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
       [junit4]    >        at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:117)
       [junit4]    >        at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:109)
       [junit4]    >        at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:105)
       [junit4]    >        at org.mockito.cglib.proxy.Enhancer.<clinit>(Enhancer.java:70)
       [junit4]    >        at org.mockito.internal.creation.jmock.ClassImposterizer.createProxyClass(ClassImposterizer.java:85)
       [junit4]    >        at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:62)
       [junit4]    >        at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:56)
       [junit4]    >        at org.mockito.internal.creation.CglibMockMaker.createMock(CglibMockMaker.java:23)
       [junit4]    >        at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
       [junit4]    >        at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)
       [junit4]    >        at org.mockito.Mockito.mock(Mockito.java:1243)
       [junit4]    >        at org.apache.solr.schema.TestManagedSchemaThreadSafety.createZkController(TestManagedSchemaThreadSafety.java:135)
       [junit4]    >        at org.apache.solr.schema.TestManagedSchemaThreadSafety.testThreadSafety(TestManagedSchemaThreadSafety.java:118)
       [junit4]    >        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [junit4]    >        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       [junit4]    >        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       [junit4]    >        at java.base/java.lang.reflect.Method.invoke(Method.java:538)
       [junit4]    >        at java.base/java.lang.Thread.run(Thread.java:844)
       [junit4]    > Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @4cbd6df7
       [junit4]    >        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:207)
       [junit4]    >        at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:192)
       [junit4]    >        at java.base/java.lang.reflect.Method.setAccessible(Method.java:186)
       [junit4]    >        at org.mockito.cglib.core.ReflectUtils$2.run(ReflectUtils.java:57)
       [junit4]    >        at java.base/java.security.AccessController.doPrivileged(Native Method)
       [junit4]    >        at org.mockito.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:47)
       [junit4]    >        ... 55 more
       [junit4]   2> 64469 INFO  (SUITE-TestManagedSchemaThreadSafety-seed#[8E654E5E1F32A757]-worker) [    ] o.a.s.c.ZkTestServer connecting to 127.0.0.1:51648 51648
       [junit4]   2> 64474 INFO  (Thread-158) [    ] o.a.s.c.ZkTestServer connecting to 127.0.0.1:51648 51648
       [junit4]   2> 64478 INFO  (SUITE-TestManagedSchemaThreadSafety-seed#[8E654E5E1F32A757]-worker) [    ] o.a.s.SolrTestCaseJ4 ###deleteCore
       [junit4]   2> NOTE: leaving temporary files on disk at: C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr1\solr\build\solr-core\test\J2\temp\solr.schema.TestManagedSchemaThreadSafety_8E654E5E1F32A757-001
       [junit4]   2> Dez. 26, 2016 8:47:14 NACHM. com.carrotsearch.randomizedtesting.ThreadLeakControl checkThreadLeaks
       [junit4]   2> WARNUNG: Will linger awaiting termination of 2 leaked thread(s).
       [junit4]   2> NOTE: test params are: codec=Lucene70, sim=RandomSimilarity(queryNorm=false): {}, locale=so-KE, timezone=Etc/GMT+4
       [junit4]   2> NOTE: Windows 10 10.0 amd64/Oracle Corporation 9-ea (64-bit)/cpus=4,threads=1,free=188820656,total=266338304
       [junit4]   2> NOTE: All tests run in this JVM: [TestRandomFaceting, TestCharFilters, BlockJoinFacetSimpleTest, SolrCmdDistributorTest, TestTolerantUpdateProcessorRandomCloud, TestManagedSchemaThreadSafety]
       [junit4] Completed [31/670 (1!)] on J2 in 0.83s, 1 test, 1 error <<< FAILURES!
    

    I have no idea why CGLib needs to do this (instead of just subclassing ClassLoader). I have the feeling that mocking libs need to "inject" classes into existing classloaders, so the workaround is needed.

    A trick to solve this might be using MethodHandles instead of Reflection using a "temporary" child class of ClassLoader (just to get a MethodHandle to the defineClass method). But this would require minimum Java 7. I may provide a PR to do this.

    opened by uschindler 29
  • Support ASM7_EXPERIMENTAL if system property is set

    Support ASM7_EXPERIMENTAL if system property is set

    Full support for Java 11 bytecode requires ASM7_EXPERIMENTAL. The approach used here is similar to byte-buddy's:

    https://github.com/raphw/byte-buddy/blob/30c31ab403eedce386e28acc3e6aee2a7e2e0752/byte-buddy-dep/src/main/java/net/bytebuddy/utility/OpenedClassReader.java#L42

    opened by ijuma 24
  • Convert cglib to be a maven project

    Convert cglib to be a maven project

    Initial basis to convert cglib to be a maven project, I suspect there would be further work needed to ensure this work correctly but hopefully helps.

    • Two tests were disabled for now since they relied on a signed jar file.
    • Maven needs to be updated to generate sources/javadoc jar files
    opened by ghost 23
  • BridgeMethodResolver resolveAll does not close InputStream

    BridgeMethodResolver resolveAll does not close InputStream

    I uncovered a problem in BridgeMethodResolver resolveAll: it opens an InputStream that is never closed.

    The problem is in cglib/cglib/src/main/java/net/sf/cglib/proxy/BridgeMethodResolver.java, in line 63 of resolveAll, which has this code:

            try {
                new ClassReader(classLoader.getResourceAsStream(owner.getName().replace('.', '/') + ".class"))
                  .accept(new BridgedFinder(bridges, resolved),
                          ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
            } catch(IOException ignored) {}
    

    The stream returned by classsLoader.getResourceAsStream is never closed. The ClassReader instance that it is passed to doesn't close it, and nothing else holds a reference to it that could be used to close it.

    The fix is simple, and I've attached a patch file for it. The heart of it is this change to the above code block:

            InputStream classStream = null;
            try {
                classStream = classLoader.getResourceAsStream(owner.getName().replace('.', '/') + ".class");
                new ClassReader(classStream)
                  .accept(new BridgedFinder(bridges, resolved),
                          ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
            } catch(IOException ignored) {}
            finally {
              try {
                if (classStream != null) {
                  classStream.close();
                }
              }
              catch (IOException ignoreMe) {}
            }
    

    Here is the patch file: BridgeMethodResolver.zip

    I noticed this when using cglib indirectly via the Spring framework. When my web application is deployed to Tomcat 8.5 on Windows, Tomcat refuses to undeploy the web application -- I have to shut down the entire Tomcat server. This happens because Tomcat's classloader keeps a Windows file lock on jar files when someone has an open input stream on one of the classes in the jar file (when opened by classLoader.getResourceAsStream). This is a substantial problem for users of my web application, since they cannot upgrade it without shutting down Tomcat, which often means that user get kicked out of all other web applications that Tomcat is hosting.

    The change above resolved the problem I was having in Spring with Tomcat 8.5.

    opened by yogregg 22
  • Switch to Opcodes.ASM5 for Java 8 support

    Switch to Opcodes.ASM5 for Java 8 support

    By default this doesn't change anything, but it allows you to pass args to the build to change the language level of the test classes. For example to run the tests in Java 8 mode you would run

    mvn clean test -Djava.test.version.source=1.8 -Djava.test.version.target=1.8
    

    (this produces 5 test failures)

    Or to see if the tests pass with the new Java 8 parameter name reflection flag you would run

    mvn clean test -Djava.test.version.source=1.8 -Djava.test.version.target=1.8 -Djava.test.compiler.argument=-parameters
    

    (this produces 15 test failures)

    Related to issue #33, I was going to write a small Java 8 test but I figured it would be much more robust to run the entire test suite against Java 8. Unfortunately this type of testing would have to be manual, I could try making it part of the build but the result would probably be pretty nasty.

    opened by jhaber 21
  • Release CGLIB 3.1.x?

    Release CGLIB 3.1.x?

    I'm interested in getting a new release of CGLIB up on Maven Central which can be consumed by downstream projects. I need pull request #15 for Mockito but they only consume official releases.

    Can I pretty please get a release?

    opened by guw 20
  • Avoid PermGen leak

    Avoid PermGen leak

    The key object put in the cache may be an instance of a dynamically generated class that references an application classloader. That reference causes said classloader to not be available for garbage collection, thus leaking the PermGen with old classes when that classloader is not needed anymore. This is mostly experienced in application restart scenarios, where each application has its own classloader managed in a long-lived container.

    Attached is an exceprt from a heap dump that shoes the reference to the classloader that causes the issue:

    screen shot 2015-11-10 at 11 00 50 am

    opened by elrodro83 19
  • Fix bridge type erasure

    Fix bridge type erasure

    Ok so this is a fun one

    Lets say you have a superclass, some subclass and an interface that are generically typed. The interface implicitly defines methods that are implemented in the superclass, but for some reason the interface is associated to the subclass.

    Now, just for extra fun, lets have the superclass implement some generic type but have it bounded. Lets have the interface also define some type, that is valid for the bound in the superclass, but have it lack the type bounding.

    This leads to something that looks a little like this.

    static abstract class Superclass<T extends ErasedType> {
        public T aMethod(T t) { return null; }
        public RetType widenReturn(T t) { return null; }
    }
    
    public interface ParameterisedInterfaceNotTypeBounded<T> {
        T aMethod(T obj);
        ErasedType widenReturn(T obj);
    }
    
    public static class OtherImpl extends Superclass<Refined> 
        implements ParameterisedInterfaceNotTypeBounded<Refined> {
            public String irrelvantMethod() { return "Not important"; }
    }
    

    Notice that the only thing not correctly tying the type hierarchies together is the lack of bound in the interface generics declaration.

    This has all the right ‟shape” for javac, and as such it complies this without error. In the bytecode that is generated, we wind up with a bridge targeted at tightening the type bound from OtherImplSuperclass such that, OtherImpl can satisfy type erasure from the interface, but still invoke the real implementation from the parent class Superclass.

    This bridge has one of the following forms in the wild (it seems to be arbitrary as to where javac places the checkcast).

      public java.lang.Object aMethod(java.lang.Object);
        descriptor: (Ljava/lang/Object;)Ljava/lang/Object;
        flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC
        Code:
          stack=2, locals=2, args_size=2
             0: aload_0
             1: aload_1
             2: checkcast     #3                  // class net/sf/cglib/proxy/TestEnhancer$Refined
             5: invokespecial #7                  // Method net/sf/cglib/proxy/TestEnhancer$Superclass.aMethod:(Lnet/sf/cglib/proxy/TestEnhancer$ErasedType;)Lnet/sf/cglib/proxy/TestEnhancer$ErasedType;
             8: areturn
          LocalVariableTable:
            Start  Length  Slot  Name   Signature
                0       9     0  this   Lnet/sf/cglib/proxy/TestEnhancer$OtherImpl;
        MethodParameters:
          Name                           Flags
          t                              synthetic
    

    Now, with the way cglib currently handles bridges that contain invokespecial we wind up basically invalidating this statement in Enhancer.java

    TODO: this assumes that the target has wider or the same type parameters than the current.
    In reality this should always be true because otherwise we wouldn't have had a bridge doing an invokespecial. If it isn't true, we would need to checkcast each argument against the target's argument types

    If we generate a proxy for this, and fail to correctly implement the Object aMethod(Object) bridge we get a VerifyError since we dont honor the superclass correctly.

    This pull request contains two things towards this. The first is a unit test testBridgedTypeErasure that tests this. The second is a (probably terrible) fast check to look for bridges that go Object<T>, and in the presence of such bridges emit a pure invokespecial call rather than having the proxy patch up the bridge with invokevirtual.


    This change is Reviewable

    opened by GregBowyer 15
  • Support Java 8

    Support Java 8

    cglib 3.1 doesn't seem to work under Java 8. In the best case, all that's required is to update to ASM 5 (see https://github.com/cglib/cglib/issues/7).

    opened by pniederw 14
  • BeanCopier slowly when project starts

    BeanCopier slowly when project starts

    when my project starts BeanCopier copier = BeanCopier.create(sourceClass, targetClass, useConverter); copier.copy(source, target, converter); is so slowly, almost 5000ms but i don't know what is the reason

    opened by zhangminxiaozhang 1
  • oss-fuzz integration

    oss-fuzz integration

    Hi all,

    we have prepared the Initial Integration of cglib into Google OSS-Fuzz which will provide more security for your project.

    Why do you need Fuzzing? The Code Intelligence JVM fuzzer Jazzer has already found hundreds of bugs in open source projects including for example OpenJDK, Protobuf or jsoup. Fuzzing proved to be very effective having no false positives. It provides a crashing input which helps you to reproduce and debug any finding easily. The integration of your project into the OSS-Fuzz platform will enable continuous fuzzing of your project by Jazzer.

    What do you need to do? The integration requires the maintainer or one established project commiter to deal with the bug reports.

    You need to create or provide one email address that is associated with a google account as per here. When a bug is found, you will receive an email that will provide you with access to ClusterFuzz, crash reports, code coverage reports and fuzzer statistics. More than 1 person can be included.

    How Code Intelligence can support? We will continue to add more fuzz targets to improve code coverage over time. Furthermore, we are permanently enhancing fuzzing technologies by developing new fuzzers and more bug detectors.

    Please let me know if you have any questions regarding fuzzing or the OSS-Fuzz integration.

    opened by aschaich 0
  • net.sf.cglib.core.ReflectUtils#OBJECT_METHODS  cause the upgrade of asm to fail

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

    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 b4cd1d6166781e466fe64f7730088dcafb11481c.

    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)
    
    opened by jesesun 0
  • Make hardcoded prefix

    Make hardcoded prefix "$cglib_prop_" configurable

    Add new system property -Dcglib.propFieldPrefix that allows for the previously hard coded $cglib_prop_ field name prefix to be configurable. Should resolve issues #180 and #162. Updated the TestTransformingLoader unit tests to include tests for empty property value, a specific prefix, and default behavior if the system property is not set.

    opened by natechadwick 0
Releases(RELEASE_3_3_0)
Owner
Code Generation Library
cglib is a powerful, high performance and quality Code Generation Library. It can extend JAVA classes and implement interfaces at runtime.
Code Generation Library
Mixin is a trait/mixin and bytecode weaving framework for Java using ASM

Mixin is a trait/mixin framework for Java using ASM and hooking into the runtime classloading process via a set of pluggable built-in or user-provided

SpongePowered 1.1k Jan 7, 2023
A Java 8+ Jar & Android APK Reverse Engineering Suite (Decompiler, Editor, Debugger & More)

Bytecode Viewer Bytecode Viewer - a lightweight user friendly Java Bytecode Viewer. New Features WAR & JSP Loading JADX-Core Decompiler Fixed APK & de

Kalen (Konloch) Kinloch 13.5k Jan 7, 2023
Java bytecode engineering toolkit

Java bytecode engineering toolkit Javassist version 3 Copyright (C) 1999-2020 by Shigeru Chiba, All rights reserved. Javassist (JAVA programming ASSIS

null 3.7k Dec 29, 2022
Chasm is a java bytecode transformer designed to handle collision between transformers wherever possible.

NOTE: This project is still in its early development. There's guaranteed bugs and missing functionality. Chasm - Collision Handling ASM What is Chasm?

null 51 Dec 30, 2022
The modern Java bytecode editor

Recaf An easy to use modern Java bytecode editor that abstracts away the complexities of Java programs. Recaf abstracts away: Constant pool Stack fram

Matt 4.5k Dec 31, 2022
Xerath - 🔪 AOP development framework implemented through *Annotation + ASM + Gradle Transform API* for Android🤖

简体中文 | English | Xerath Xerath 是一个通过 [自定义注解]+ASM + Gradle Transform API 实现的一套功能强大,方便开发,并且能够有效减少重复代码的Android Aop 框架。 旨在编译器进行全局性的修改,来完成一些诸如方法耗时统计,异常收集,拦

Pumpkin 325 Nov 22, 2022
Netflix, Inc. 809 Dec 28, 2022
Automatically discover and tag PII data across BigQuery tables and apply column-level access controls based on confidentiality level.

Automatically discover and tag PII data across BigQuery tables and apply column-level access controls based on confidentiality level.

Google Cloud Platform 18 Dec 29, 2022
Inria 1.4k Dec 29, 2022
Kryptonite is a turn-key ready transformation (SMT) for Apache Kafka® Connect to do field-level 🔒 encryption/decryption 🔓 of records. It's an UNOFFICIAL community project.

Kryptonite - An SMT for Kafka Connect Kryptonite is a turn-key ready transformation (SMT) for Apache Kafka® to do field-level encryption/decryption of

Hans-Peter Grahsl 53 Jan 3, 2023
Auto-Unit-Test-Case-Generator automatically generates high-level code-coverage JUnit test suites for Java, widely used within the ANT Group.

中文README传送门 What is Auto-Unit-Test-Case-Generator Auto-Unit-Test-Case-Generator generates JUnit test suites for Java class just as its name. During te

TRaaS 108 Dec 22, 2022
Generate a dynamic PAC script that will route traffic to your Burp proxy only if it matches the scope defined in your Burp target.

Burp PAC Server This Burp Extension generates a dynamic Proxy Auto-Configuration (PAC) script that will route traffic to your Burp proxy only if it ma

null 30 Jun 13, 2022
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

OpenAPI Generator Master (5.4.x): 6.0.x (6.0.x): ⭐ ⭐ ⭐ If you would like to contribute, please refer to guidelines and a list of open tasks. ⭐ ⭐ ⭐ ‼️

OpenAPI Tools 14.8k Dec 30, 2022
sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters.

sql2o Sql2o is a small java library, with the purpose of making database interaction easy. When fetching data from the database, the ResultSet will au

Lars Aaberg 1.1k Dec 28, 2022
Automon combines the power of AOP (AspectJ) with monitoring or logging tools you already use to declaratively monitor your Java code, the JDK, and 3rd party libraries.

Automon Automon combines the power of AOP (AspectJ) with monitoring tools or logging tools that you already use to declaratively monitor the following

Steve Souza 561 Nov 27, 2022
Dataflow template which read data from Kafka (Support SSL), transform, and outputs the resulting records to BigQuery

Kafka to BigQuery Dataflow Template The pipeline template read data from Kafka (Support SSL), transform the data and outputs the resulting records to

DoiT International 12 Jun 1, 2021
A Velocity proxy plugin for Minecraft server discovery in k8s. All discovered servers are automatically added to the Velocity proxy.

kryo-server-discovery This plugin connects minecraft servers to a velocity proxy within Kubernetes. The service account in the namespace which the pro

Kryonite 9 Sep 13, 2022
Winfoom is an HTTP(s) proxy server facade that allows applications to authenticate through the proxy without having to deal with the actual handshake.

winfoom Basic Proxy Facade for NTLM, Kerberos, SOCKS and Proxy Auto Config file proxies To help this project please give it a star ⭐ Overview Winfoom

Eugen Covaci 56 Dec 8, 2022
OBKV Table Client is Java Library that can be used to access table data from OceanBase storage layer.

OBKV Table Client OBKV Table Client is Java Library that can be used to access table data from OceanBase storage layer. Its access method is different

OceanBase 12 Dec 16, 2022