com.fasterxml.jackson.module.afterburner.util

## Class MyClassLoader

- java.lang.Object
- - java.lang.ClassLoader
  - - com.fasterxml.jackson.module.afterburner.util.MyClassLoader

-     public class MyClassLoader
      extends ClassLoader

  Class loader that is needed to load generated classes.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `_cfgUseParentLoader` Flag that determines if we should first try to load new class using parent class loader or not; this may be done to try to force access to protected/package-access properties.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MyClassLoader(ClassLoader parent, boolean tryToUseParent)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `canAddClassInPackageOf(Class<?> cls)` Helper method called to check whether it is acceptable to create a new class in package that given class is part of.
    `Class<?>` | `loadAndResolve(ClassName className, byte[] byteCode)`
    `static int` | `replaceName(byte[] byteCode, String from, String to)`

    - ### Methods inherited from class java.lang.ClassLoader

      `clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _cfgUseParentLoader

          protected final boolean _cfgUseParentLoader

      Flag that determines if we should first try to load new class using parent class loader or not; this may be done to try to force access to protected/package-access properties.

  - ### Constructor Detail

    - #### MyClassLoader

          public MyClassLoader(ClassLoader parent,
                       boolean tryToUseParent)

  - ### Method Detail

    - #### canAddClassInPackageOf

          public static boolean canAddClassInPackageOf(Class<?> cls)

      Helper method called to check whether it is acceptable to create a new class in package that given class is part of. This is used to prevent certain class of failures, related to access limitations: for example, we can not add classes in sealed packages, or core Java packages (java.*).
      Since:
        2.2.1

    - #### loadAndResolve

          public Class<?> loadAndResolve(ClassName className,
                                byte[] byteCode)
                                  throws IllegalArgumentException

      Parameters:
        `className` - Interface or abstract class that class to load should extend or implement
      Throws:
        `IllegalArgumentException`

    - #### replaceName

          public static int replaceName(byte[] byteCode,
                        String from,
                        String to)

Copyright © 2016 FasterXML. All rights reserved.