Class TestClassesGenerator


  • public final class TestClassesGenerator
    extends java.lang.Object
    A class generator used to create classes that can be used in tests.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] classWithEmptyMethods​(java.lang.String className, java.lang.String... namesAndDescriptors)
      Generates a class containing specified methods that contain empty bodies.
      static byte[] classWithFieldsAndMethods​(java.lang.String className, java.util.List<java.lang.String> fields, java.util.List<java.lang.String> methods)
      Generates a class containing specified fields and methods.
      static byte[] classWithStrings​(java.lang.String className, int cntStringsToGenerate)
      Generates a class containing specified fields and methods.
      static byte[] emptyClass​(java.lang.String pkg, java.lang.String name)
      Generates an empty class in the specified package.
      static byte[] emptyClass​(java.lang.String pkg, java.lang.String name, java.lang.String superName)  
      static byte[] rewriteToVersion​(int newVersion, java.io.InputStream current)
      Rewrites the version of the class file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TestClassesGenerator

        public TestClassesGenerator()
    • Method Detail

      • emptyClass

        public static byte[] emptyClass​(@NonNull
                                        java.lang.String pkg,
                                        @NonNull
                                        java.lang.String name)
                                 throws java.lang.Exception
        Generates an empty class in the specified package.
        Throws:
        java.lang.Exception
      • emptyClass

        public static byte[] emptyClass​(@NonNull
                                        java.lang.String pkg,
                                        @NonNull
                                        java.lang.String name,
                                        @NonNull
                                        java.lang.String superName)
      • classWithEmptyMethods

        public static byte[] classWithEmptyMethods​(java.lang.String className,
                                                   java.lang.String... namesAndDescriptors)
                                            throws java.lang.Exception
        Generates a class containing specified methods that contain empty bodies.
        Throws:
        java.lang.Exception
      • classWithFieldsAndMethods

        public static byte[] classWithFieldsAndMethods​(@NonNull
                                                       java.lang.String className,
                                                       @NonNull
                                                       java.util.List<java.lang.String> fields,
                                                       @NonNull
                                                       java.util.List<java.lang.String> methods)
                                                throws java.lang.Exception
        Generates a class containing specified fields and methods.
        Throws:
        java.lang.Exception
      • classWithStrings

        public static byte[] classWithStrings​(@NonNull
                                              java.lang.String className,
                                              int cntStringsToGenerate)
                                       throws java.lang.Exception
        Generates a class containing specified fields and methods.
        Throws:
        java.lang.Exception
      • rewriteToVersion

        @NonNull
        public static byte[] rewriteToVersion​(int newVersion,
                                              @NonNull
                                              java.io.InputStream current)
                                       throws java.io.IOException
        Rewrites the version of the class file.
        Throws:
        java.io.IOException