public Class<?> defineClass(ClassLoader classLoader, String className, byte[] classbytes)
    {
        Method defineClassMethod = svDefineClassMethod;
        if (defineClassMethod == null)
        {
            Permissions perms = new Permissions();
            perms.add(new AllPermission());
            svAllPermissionProtectionDomain = new ProtectionDomain(null, perms);

            try
            {
                defineClassMethod = ClassLoader.class.getDeclaredMethod("defineClass",
                                                                        String.class,
                                                                        byte[].class,
                                                                        int.class,
                                                                        int.class,
                                                                        ProtectionDomain.class);
            } catch (NoSuchMethodException ex)
            {
                throw new IllegalStateException(ex);
            }

            defineClassMethod.setAccessible(true);
            svDefineClassMethod = defineClassMethod;
        }

        try
        {
            // We declare the class using a non-dynamic AllPermission
            // ProtectionDomain so that it will be ignored by Java 2 security.
            return (Class<?>) defineClassMethod.invoke(classLoader,
                                                       className,
                                                       classbytes,
                                                       0,
                                                       classbytes.length,
                                                       svAllPermissionProtectionDomain);
        } catch (IllegalAccessException ex)
        {
            throw new IllegalStateException(ex);
        } catch (InvocationTargetException ex)
        {
            Throwable cause = ex.getCause();
            if (cause instanceof Error)
            {
                throw (Error) cause;
            }
            if (cause instanceof RuntimeException)
            {
                throw (RuntimeException) cause;
            }

            throw new IllegalStateException(cause);
        }
    }
public Class < ? > defineClass ( ClassLoader classLoader , String className , byte [ ] classbytes ) { Method defineClassMethod = svDefineClassMethod ; if ( defineClassMethod == null ) { Permissions perms = new Permissions ( ) ; perms . add ( new AllPermission ( ) ) ; svAllPermissionProtectionDomain = new ProtectionDomain ( null , perms ) ; try { defineClassMethod = ClassLoader . class . getDeclaredMethod ( "defineClass" , String . class , byte [ ] . class , int . class , int . class , ProtectionDomain . class ) ; } catch ( NoSuchMethodException ex ) { throw new IllegalStateException ( ex ) ; } defineClassMethod . setAccessible ( true ) ; svDefineClassMethod = defineClassMethod ; } try { return ( Class < ? > ) defineClassMethod . invoke ( classLoader , className , classbytes , 0 , classbytes . length , svAllPermissionProtectionDomain ) ; } catch ( IllegalAccessException ex ) { throw new IllegalStateException ( ex ) ; } catch ( InvocationTargetException ex ) { Throwable cause = ex . getCause ( ) ; if ( cause instanceof Error ) { throw ( Error ) cause ; } if ( cause instanceof RuntimeException ) { throw ( RuntimeException ) cause ; } throw new IllegalStateException ( cause ) ; } }
Return {@link ClassLoader#defineClass} with a PermissionCollection containing AllPermission.

@param classLoader the class loader
@param className the class name
@param classbytes the class bytes
@return the class
@throws LinkageError if a class is defined twice within the given class loader
@throws ClassFormatError if the bytes passed in are invalid